예제 #1
0
        public IEnumerator ExecutePhysicsTask()
        {
            while (running)
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                stopwatch.Start();
                while (stopwatch.ElapsedMilliseconds < allocatedPhysicsTime)
                {
                    Stopwatch taskTime = Stopwatch.StartNew();

                    TaskNode node = physicsTaskList.CheckPop();
                    if (node == null)
                    {
                        break;
                    }
                    node.task.Invoke();

                    if (taskHeuristics.ContainsKey(node.name))
                    {
                        taskHeuristics[node.name].AddTime(taskTime.ElapsedMilliseconds);
                    }
                    else
                    {
                        taskHeuristics.Add(node.name, new TaskHeuristic(taskTime.ElapsedMilliseconds));
                    }
                    taskTime.Stop();
                }
                stopwatch.Stop();
                yield return(new WaitForFixedUpdate());
            }
        }
예제 #2
0
 private static void Execute()
 {
     while (running)
     {
         TaskNode node = taskList.Pop();
         node.task.Invoke();
     }
 }
예제 #3
0
 public void QueueTask(TaskNode t, float priority)
 {
     if (taskHeuristics.ContainsKey(t.name))
     {
         priority += taskHeuristics[t.name].averageTime * 0.01f;
     }
     t.Priority = priority;
     taskList.Add(t);
 }