Exemplo n.º 1
0
        public void RunTasks(Unity.Collections.NativeArray <PathTask> tasks, ref BufferArray <Path> results)
        {
            ArrayUtils.Resize(tasks.Length, ref Pathfinding.results);

            Pathfinding.pathfinding = this;

            var job = new RunTasksJob()
            {
                arr = tasks,
            };
            var jobHandle = job.Schedule(tasks.Length, 64);

            jobHandle.Complete();

            results = Pathfinding.results;

            /*
             * for (int i = 0; i < tasks.Count; ++i) {
             *
             *  var task = tasks[i];
             *  task.result = this.CalculatePath(task.@from, task.to, task.constraint, task.pathCornersModifier);
             *  tasks[i] = task;
             *
             * }*/
        }
Exemplo n.º 2
0
        public void RunTasks <TMod, TProcessor>(Unity.Collections.NativeArray <PathTask> tasks, ref BufferArray <Path> results) where TMod : struct, IPathModifier where TProcessor : struct, IPathfindingProcessor
        {
            ArrayUtils.Resize(tasks.Length, ref Pathfinding.results);

            Pathfinding.pathfinding = this;

            var job = new RunTasksJob <TMod, TProcessor>()
            {
                arr = tasks,
            };

            for (int i = 0; i < tasks.Length; ++i)
            {
                var item = tasks[i];
                if (item.burstEnabled == true)
                {
                    job.Execute(i);
                    item.isValid = false;
                    tasks[i]     = item;
                }
            }

            var jobHandle = job.Schedule(tasks.Length, 64);

            jobHandle.Complete();

            for (int i = 0; i < tasks.Length; ++i)
            {
                var item = tasks[i];
                if (item.burstEnabled == true)
                {
                    item.isValid = true;
                    tasks[i]     = item;
                }
            }

            results = Pathfinding.results;

            /*
             * for (int i = 0; i < tasks.Count; ++i) {
             *
             *  var task = tasks[i];
             *  task.result = this.CalculatePath(task.@from, task.to, task.constraint, task.pathCornersModifier);
             *  tasks[i] = task;
             *
             * }*/
        }