public void Move(EiLLNode <T> node, EiLinkedList <T> otherList) { if (node.List != this) { throw new Exception("You are not allowed to move nodes from other list without going through its own list"); } if (count == 1) { this.node = null; } node.Prev.Next = node.Next; node.Next.Prev = node.Prev; node.List = otherList; if (otherList.Count() == 0) { node.Next = node; node.Prev = node; otherList.node = node; } else { otherList.node.Prev.Next = node; node.Prev = otherList.node.Prev; node.Next = otherList.node; otherList.node.Prev = node; } count--; otherList.count++; }
void Update() { while (isRunning) { #region start sw.Start(); var time = DeltaTime; updates++; #endregion #region EiComponent Update try { EiLLNode <EiUpdateInterface> component; var iterator = components.GetIterator(); while (iterator.Next(out component)) { try { if (component.Value == null) { components.Remove(component); } else { component.Value.ThreadedUpdateComponent(time); } } catch (Exception e) { if (component != null) { components.Remove(component); } LogException(() => e); } } } catch (Exception e) { LogException(() => e); } #endregion #region FPS Counter if (DateTime.UtcNow.Ticks > lastFpsUpdate + TimeSpan.TicksPerSecond) { lastFpsUpdate = DateTime.UtcNow.Ticks; framesPerSecond = updates; updates = 0; } #endregion #region End and sleep Thread.Sleep(new TimeSpan(Math.Max(1000, targetFpsInTicks - ticks))); ticks = sw.ElapsedTicks; if (components.Count() > 10) { if (node.Next.Value.ticks < ticks - 5000) { components.LastNode().MoveTo(node.Next.Value.components); } } sw.Reset(); #endregion } }