protected override JobHandle OnUpdate(JobHandle inputDeps) { if (m_Ships.Length == 0) { return(inputDeps); } var handle = new CalculatePositionsJob { Ships = m_Ships.Data, Planets = m_Planets.Data, TargetPlanet = GetComponentDataFromEntity <PlanetData>(), DeltaTime = Time.deltaTime, Entities = m_Ships.Entities, Positions = m_Ships.Positions, Rotations = m_Ships.Rotations, ShipArrivedQueue = m_ShipArrivedQueue.ToConcurrent() }.Schedule(m_Ships.Length, 32, inputDeps); handle = new ShipArrivedTagJob { EntityCommandBuffer = m_EndFrameBarrier.CreateCommandBuffer(), ShipArrivedQueue = m_ShipArrivedQueue }.Schedule(handle); return(handle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var jobHandle = inputDeps; var dt = Time.deltaTime; for (int i = 0; i < emitterGroup.Length; i++) { var emitter = emitterGroup.emitters[i]; var position = emitterGroup.emitters[i].emitterPosition; emitter.emissionTimer += dt; if (emitter.emissionTimer >= emitter.emissionRate) { emitter.emissionTimer = 0; var emissionJob = new EmissionJob() { commandBuffer = endFrameBarrier.CreateCommandBuffer(), particleArchetype = BootstrapperParticles.particleArchetype, randomDirections = randomEmissionDirections, randomRotators = randomRotatorComponents, emitter = emitter, emitterPosition = new Position() { Value = position }, offset = UnityEngine.Random.Range(0, emitter.maxParticles / (int)emitter.particlesPerEmission) }; jobHandle = emissionJob.Schedule((int)emitter.particlesPerEmission, 1, inputDeps); } emitterGroup.emitters[i] = emitter; } return(jobHandle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var transforms = m_InitialTransformGroup.GetTransformAccessArray(); var entities = m_InitialTransformGroup.GetEntityArray(); var transformStashes = new NativeArray <TransformStash>(transforms.length, Allocator.TempJob); var stashTransformsJob = new StashTransforms { transformStashes = transformStashes }; var stashTransformsJobHandle = stashTransformsJob.Schedule(transforms, inputDeps); var copyTransformsJob = new CopyTransforms { positions = m_Positions, rotations = m_Rotations, localPositions = m_LocalPositions, localRotations = m_LocalRotations, transformStashes = transformStashes, entities = entities }; var copyTransformsJobHandle = copyTransformsJob.Schedule(transformStashes.Length, 64, stashTransformsJobHandle); var removeComponentsJob = new RemoveCopyInitialTransformFromGameObjectComponent { entities = entities, entityCommandBuffer = m_EndFrameBarrier.CreateCommandBuffer() }; var removeComponentsJobHandle = removeComponentsJob.Schedule(copyTransformsJobHandle); return(removeComponentsJobHandle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { int numCameras = Camera.allCamerasCount; #if UNITY_EDITOR if (EditorApplication.isPlayingOrWillChangePlaymode) { numCameras += SceneView.GetAllSceneCameras().Length; } else { numCameras = SceneView.GetAllSceneCameras().Length; } #endif if (numCameras == 0) { return(inputDeps); } var cameras = new NativeArray <float4>(numCameras, Allocator.TempJob); #if UNITY_EDITOR for (int cam = 0; cam < SceneView.GetAllSceneCameras().Length; ++cam) { var curCamera = SceneView.GetAllSceneCameras()[cam]; float halfAngle = math.tan(math.radians(curCamera.fieldOfView) * 0.5F); cameras[cam] = new float4(curCamera.transform.position, halfAngle); } if (EditorApplication.isPlayingOrWillChangePlaymode) #endif { for (int i = 0; i < Camera.allCamerasCount; ++i) { // FIXME: assums perspective projection float halfAngle = math.tan(math.radians(Camera.allCameras[i].fieldOfView) * 0.5F); cameras[numCameras - Camera.allCamerasCount + i] = new float4(Camera.allCameras[i].transform.position, halfAngle); } } var groupJob = new LodGroupJob { lod = lodGroups.lod, transform = lodGroups.transform, cameras = cameras }; var groupHandle = groupJob.Schedule(lodGroups.Length, 1, inputDeps); var meshJob = new LodMeshJob { lod = lodMeshes.lod, entities = lodMeshes.entities, allGroups = allGroups, commandBuffer = barrier.CreateCommandBuffer() }; return(meshJob.Schedule(groupHandle)); }
#pragma warning restore 649 protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new EnemyHealthJob { Ecb = endFrameBarrier.CreateCommandBuffer().ToConcurrent(), Dead = GetComponentDataFromEntity <DeadData>() }; return(job.Schedule(this, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new DeathJob() { objects = objects, commandBuffer = endFrameBarrier.CreateCommandBuffer() }; return(job.Schedule(objects.Length, 64, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new TaskJob() { aiUnits = aiUnits, commandBuffer = endFrameBarrier.CreateCommandBuffer() }; return(job.Schedule(aiUnits.Length, 1000, inputDeps));///TODO: fix inner loop batch count }
#pragma warning restore 649 protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new EnemyAttackJob { Ecb = endFrameBarrier.CreateCommandBuffer().ToConcurrent(), DeltaTime = Time.deltaTime, Health = GetComponentDataFromEntity <HealthData>(), Damaged = GetComponentDataFromEntity <DamagedData>() }; return(job.Schedule(this, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var lifeTimeJob = new LifetimeJob() { dt = Time.deltaTime, commandBuffer = endFrameBarrier.CreateCommandBuffer(), particles = particleGroup.particles, entities = particleGroup.entities }; return(lifeTimeJob.Schedule(particleGroup.Length, 1, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { // TODO: Would be to have individual colours per cube to correspond pixel colours, but MeshInstanceRenderer seems to be a bit limited in regards to per instance data so far. var positionSetterJob = new PixelCubePlacerJob { positions = pixelCubes.positions, entities = pixelCubes.entities, width = pixelCubes.imageColours[0].width, height = pixelCubes.imageColours[0].height, commandBuffer = endFrameBarrier.CreateCommandBuffer() }; var handle = positionSetterJob.Schedule(pixelCubes.Length, 64, inputDeps); handle.Complete(); return(handle); }
private JobHandle ScheduleStateUpdate(JobHandle inputDeps) { switch (_config.Method) { case TestMethod.InstancedByteComponent: return(new UpdateInstancedByteStateJob { Components = _groupWithInstancedByteComponent.Components, States = _statesToWrite }.Schedule(_config.ChangesPerFrame, 64, inputDeps)); case TestMethod.AddRemoveInstancedComponent: var instancedAdds = Mathf.Min(_groupWithoutInstancedBinaryComponent.Length, _config.ChangesPerFrame - (_config.ChangesPerFrame / 2)); var instancedRemoves = Mathf.Min(_groupWithInstancedBinaryComponent.Length, _config.ChangesPerFrame - instancedAdds); if (instancedAdds > 0 && instancedRemoves > 0) { return(JobHandle.CombineDependencies( ScheduleAddingInstancedBinaryComponents(instancedAdds, inputDeps), ScheduleRemovingInstancedBinaryComponents(instancedRemoves, inputDeps))); } else if (instancedAdds > 0) { return(ScheduleAddingInstancedBinaryComponents(instancedAdds, inputDeps)); } else if (instancedRemoves > 0) { return(ScheduleRemovingInstancedBinaryComponents(instancedRemoves, inputDeps)); } return(inputDeps); case TestMethod.AddRemoveSharedComponent: var sharedAdds = Mathf.Min(_groupWithoutSharedBinaryComponent.Length, _config.ChangesPerFrame - (_config.ChangesPerFrame / 2)); var sharedRemoves = Mathf.Min(_groupWithSharedBinaryComponent.Length, _config.ChangesPerFrame - sharedAdds); if (sharedAdds > 0 && sharedRemoves > 0) { return(JobHandle.CombineDependencies( ScheduleAddingSharedBinaryComponents(sharedAdds, inputDeps), ScheduleRemovingSharedBinaryComponents(sharedRemoves, inputDeps))); } else if (sharedAdds > 0) { return(ScheduleAddingSharedBinaryComponents(sharedAdds, inputDeps)); } else if (sharedRemoves > 0) { return(ScheduleRemovingSharedBinaryComponents(sharedRemoves, inputDeps)); } return(inputDeps); case TestMethod.SetValueSharedComponentForEachFilter: case TestMethod.SetValueSharedComponentSetFilter: case TestMethod.SetValueSharedComponentNoFilter: return(new UpdateSharedByteStateJob { Entities = _byteStateGroup.GetEntityArray(), States = _statesToWrite, CommandBuffer = _endFrameBarrier.CreateCommandBuffer() }.Schedule(_config.ChangesPerFrame, 64, inputDeps)); default: return(inputDeps); } }