internal void RemoveAll() { while (Head != null) { var system = Head; Head = Head.Next; system.Previous = null; system.Next = null; } Tail = null; }
internal void Add(SystemBase system) { if (Head == null) { Head = Tail = system; system.Next = system.Previous = null; } else { var node = Tail; for (; node != null; node = node.Previous) { if (node.Priority <= system.Priority) { break; } } if (node == Tail) { Tail.Next = system; system.Previous = Tail; system.Next = null; Tail = system; } else if (node == null) { system.Next = Head; system.Previous = null; Head.Previous = system; Head = system; } else { system.Next = node.Next; system.Previous = node; node.Next.Previous = system; } } }
internal void Add(T system) { if (this.Head == null) { this.Tail = system; this.Head = system; SystemBase <T> arg_38_0 = system; SystemBase <T> arg_32_0 = system; T t = default(T); arg_32_0.Previous = t; arg_38_0.Next = t; return; } T t2 = this.Tail; while (t2 != null && t2.Priority > system.Priority) { t2 = t2.Previous; } if (t2 == this.Tail) { this.Tail.Next = system; system.Previous = this.Tail; system.Next = default(T); this.Tail = system; return; } if (t2 == null) { system.Next = this.Head; system.Previous = default(T); this.Head.Previous = system; this.Head = system; return; } system.Next = t2.Next; system.Previous = t2; t2.Next.Previous = system; t2.Next = system; }
internal void Add(SystemBase system) { if (Head == null) { Head = Tail = system; system.Next = system.Previous = null; } else { var node = Tail; for (; node != null; node = node.Previous) { if (node.Priority <= system.Priority) { break; } } if (node == Tail) { Tail.Next = system; system.Previous = Tail; system.Next = null; Tail = system; } else if (node == null) { system.Next = Head; system.Previous = null; Head.Previous = system; Head = system; } else { system.Next = node.Next; system.Previous = node; node.Next.Previous = system; } } }
internal void Remove(SystemBase system) { if (Head == system) { Head = Head.Next; } if (Tail == system) { Tail = Tail.Previous; } if (system.Previous != null) { system.Previous.Next = system.Next; } if (system.Next != null) { system.Next.Previous = system.Previous; } // N.B. Don't set system.next and system.previous to null because that will break the list iteration if node is the current node in the iteration. }
internal void Remove(SystemBase system) { if (Head == system) { Head = Head.Next; } if (Tail == system) { Tail = Tail.Previous; } if (system.Previous != null) { system.Previous.Next = system.Next; } if (system.Next != null) { system.Next.Previous = system.Previous; } // N.B. Don't set system.next and system.previous to null because that will break the list iteration if node is the current node in the iteration. }
public void SystemsUpdatedInPriorityOrderIfSameAsAddOrder() { var result = new List<SystemBase>(); _system1 = new MockSystem((sys, action, time) => result.Add(sys)); _system2 = new MockSystem((sys, action, time) => result.Add(sys)); _game.AddSystem(_system1, 10); _game.AddSystem(_system2, 20); result = new List<SystemBase>(); _game.Update(0.1); var expected = new List<SystemBase> {_system1, _system2}; Assert.AreEqual(expected, result); }
public void RemoveSystemAndAddItAgainDontCauseInvalidLinkedList() { _system1 = new DummySystem(); _system2 = new DummySystem(); _game.AddSystem(_system1, 0); _game.AddSystem(_system2, 0); _game.RemoveSystem(_system1); _game.AddSystem(_system1, 0); _game.Update(0.1); var expected = new Tuple<SystemBase, SystemBase>(null, null); var results = new Tuple<SystemBase, SystemBase>(_system2.Previous, _system1.Next); Assert.AreEqual(expected, results); }
/** * Remove a system from the game. * * @param system The system to remove from the game. */ public void RemoveSystem(SystemBase system) { _systems.Remove(system); system.RemoveFromGame(this); }
/** * Add a system to the game, and set its priority for the order in which the * systems are updated by the game loop. * * <p>The priority dictates the order in which the systems are updated by the game * loop. Lower numbers for priority are updated first. i.e. a priority of 1 is * updated before a priority of 2.</p> * * @param system The system to add to the game. * @param priority The priority for updating the systems during the game loop. A * lower number means the system is updated sooner. */ public void AddSystem(SystemBase system, int priority) { system.Priority = priority; system.AddToGame(this); _systems.Add(system); }
private void AddSystemToGame <T>(SystemBase <T> system, int priority, ushort schedulingPattern) { system.Priority = priority; system.SchedulingPattern = schedulingPattern; system.AddToGame(this); }
internal void RemoveAll() { while (Head != null) { var system = Head; Head = Head.Next; system.Previous = null; system.Next = null; } Tail = null; }