public void AddTask(ITickable task) { Assert.That(!_queuedTasks.Contains(task), "Duplicate task added to kernel with name '" + task.GetType().FullName + "'"); Assert.That(!_tasks.Any(t => ReferenceEquals(t.Tickable, task)), "Duplicate task added to kernel with name '" + task.GetType().FullName + "'"); // Wait until next frame to add the task, otherwise whether it gets updated // on the current frame depends on where in the update order it was added // from, so you might get off by one frame issues _queuedTasks.Add(task); }
public void RemoveTask(ITickable task) { var info = _sortedTasks.Concat(_unsortedTasks).Where(x => x.Tickable == task).Single(); Assert.That(!info.IsRemoved, "Tried to remove task twice, task = " + task.GetType().Name); info.IsRemoved = true; }
void UpdateTickable(ITickable tickable) { using (ProfileBlock.Start("{0}.Tick()".Fmt(tickable.GetType().Name()))) { tickable.Tick(); } }
public void RemoveTask(ITickable task) { var info = _tasks.Where(i => ReferenceEquals(i.Tickable, task)).Single(); Assert.That(!info.IsRemoved, "Tried to remove task twice, task = " + task.GetType().Name); info.IsRemoved = true; }
void UpdateTickable(ITickable tickable) { #if PROFILING_ENABLED using (ProfileBlock.Start("{0}.Tick()".Fmt(tickable.GetType().Name()))) #endif { tickable.Tick(); } }
void AddTaskInternal(ITickable task, int?priority) { Assert.That(!AllTasks.Select(x => x.Tickable).Contains(task), "Duplicate task added to kernel with name '" + task.GetType().FullName + "'"); // Wait until next frame to add the task, otherwise whether it gets updated // on the current frame depends on where in the update order it was added // from, so you might get off by one frame issues _queuedTasks.Add( new TickableInfo(task, priority)); }
void AddTaskInternal(ITickable task, int? priority) { Assert.That(!AllTasks.Select(x => x.Tickable).Contains(task), "Duplicate task added to kernel with name '" + task.GetType().FullName + "'"); // Wait until next frame to add the task, otherwise whether it gets updated // on the current frame depends on where in the update order it was added // from, so you might get off by one frame issues _queuedTasks.Add( new TickableInfo(task, priority)); }