protected override JobHandle OnUpdate(JobHandle inputDeps) { this.DisposeBuffers(); var handle = inputDeps; var playerGroupLength = this._playerGroup.CalculateLength(); // Allocate Memory this._playerColliders = new NativeArray <SphereCollider>( playerGroupLength, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); // ComponentDataArray handle = new CopyComponentData <SphereCollider> { Source = this._playerGroup.GetComponentDataArray <SphereCollider>(), Results = this._playerColliders, }.Schedule(playerGroupLength, 32, handle);; // Check Hit handle = new CheckHitJob { PlayerColliders = this._playerColliders }.Schedule(this, handle); return(handle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { this.DisposeBuffers(); var handle = inputDeps; var playerGroupLength = this._playerGroup.CalculateLength(); // --------------------- // Allocate Memory this._playerColliders = new NativeArray <SphereCollider>( playerGroupLength, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); this._playerHashmap = new NativeMultiHashMap <int, int>( playerGroupLength * MaxGridNum, Allocator.TempJob); // --------------------- // ComponentDataArray var copyPlayerColliderJobHandle = new CopyComponentData <SphereCollider> { Source = this._playerGroup.GetComponentDataArray <SphereCollider>(), Results = this._playerColliders, }.Schedule(playerGroupLength, 32, handle); // Hashmap Settings var playerHashmapJobHandle = new HashPositions { CellRadius = CellRadius, Offsets = this._offsets, SphereColliders = this._playerGroup.GetComponentDataArray <SphereCollider>(), Hashmap = this._playerHashmap.ToConcurrent(), }.Schedule(playerGroupLength, 32, handle); // ※Jobの依存関係の結合 var handles = new NativeArray <JobHandle>(2, Allocator.Temp); handles[0] = copyPlayerColliderJobHandle; handles[1] = playerHashmapJobHandle; handle = JobHandle.CombineDependencies(handles); handles.Dispose(); // --------------------- // Check Hit handle = new CheckHitJob { CellRadius = CellRadius, PlayerColliders = this._playerColliders, PlayerHashmap = this._playerHashmap, }.Schedule(this, handle); return(handle); }