Exemple #1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            int currentTime = Mathf.FloorToInt(DayNightSystem.worldTime);

            if (currentTime != savedTime)
            {
                var newPositions = new NativeArray <float3>(m_WandererData.Instances.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
                for (int i = 0; i < newPositions.Length; ++i)
                {
                    newPositions[i] = new float3(Random.Range(minX, maxX), ECSBootstrapper.humanPositionY, Random.Range(minZ, maxZ));
                }
                var SetTargetJob = new setTargetJob
                {
                    Instance        = m_WandererData.Instances,
                    target          = m_WandererData.Targets,
                    homePosition    = m_WandererData.homePositions,
                    randomPositions = newPositions,
                    currTime        = currentTime,
                    commandBuffer   = addBoidBuffer.CreateCommandBuffer()
                }.Schedule(m_WandererData.Targets.Length, 64, inputDeps);

                savedTime = currentTime;
                newPositions.Dispose();
                return(SetTargetJob);
            }
            else
            {
                return(inputDeps);
            }
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var SetTargetJob = new setTargetJob
            {
                Instance     = m_HumanData.Instances,
                target       = m_HumanData.Targets,
                homePosition = m_HumanData.homePositions,
                workPosition = m_HumanData.workPositions,
                //workerSchedules = m_HumanData.workerSchedules,
                currentTime   = Mathf.FloorToInt(DayNightSystem.worldTime),
                commandBuffer = addBoidBuffer.CreateCommandBuffer()
            }.Schedule(m_HumanData.Targets.Length, 64, inputDeps);


            return(SetTargetJob);
        }