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()); } }
private static void Execute() { while (running) { TaskNode node = taskList.Pop(); node.task.Invoke(); } }
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); }