//public struct SpringJob : IJobProcessComponentData<Position, Body> //{ // public void Execute(ref Position pos, ref Body body) // { // } //} protected override JobHandle OnUpdate(JobHandle handle) { ForceJob fJob = new ForceJob { objectBody = forceGroup.objectBody, objectVel = forceGroup.objectVel, objectPos = forceGroup.objectPos, objectNeigh = forceGroup.objectNeigh, objectFixedNeigh = forceGroup.objectFixedNeigh, objectID = forceGroup.objectID, }; return(fJob.Schedule(forceGroup.Length, 1, handle)); //throw new System.NotImplementedException(); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { // 计算准备 double deltaTime = math.min(0.05, Time.DeltaTime);; // 计算受力 var forceJob = new ForceJob(); forceJob.deltaTime = deltaTime; inputDeps = forceJob.Schedule(forceQuery, inputDeps); inputDeps.Complete(); //返回句柄 return(inputDeps); }
protected override void OnUpdate() { var deltaTime = math.min(Time.DeltaTime, 0.05f); var forceJob = new ForceJob() { deltaTime = deltaTime }; var forceHandle = forceJob.Schedule(this); var walkerJob = new WalkerJob() { deltaTime = deltaTime, maxWidth = Map.MaxWidth, maxHeight = Map.MaxHeight }; var walkerHandle = walkerJob.Schedule(this, forceHandle); walkerHandle.Complete(); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var entities = EntityManager.GetAllEntities(Allocator.Temp); var translations = new NativeArray <Translation>(entities.Length, Allocator.TempJob); var types = new NativeArray <int>(entities.Length, Allocator.TempJob); var stats = GameManagerScript.GetInstance().stats; var attract = new NativeArray <float>(stats.attract, Allocator.TempJob); var minr = new NativeArray <float>(stats.minR, Allocator.TempJob); var maxr = new NativeArray <float>(stats.maxR, Allocator.TempJob); //? Might be a bottle neck for (int i = 0; i < entities.Length; i++) { translations[i] = EntityManager.GetComponentData <Translation>(entities[i]); types[i] = EntityManager.GetComponentData <Particle>(entities[i]).type; } entities.Dispose(); var job = new ForceJob() { types = types, entity_positions = translations, width = GameManagerScript.Width * 2, height = GameManagerScript.Height * 2, wrap = false, attract = attract, minR = minr, maxR = maxr, length = stats.Count, }; var handle = job.Schedule(this, inputDeps); return(handle); }