public GameEntityComponentLine(GameEntityComponent.UpdateLines updateLine) { m_updteLine = updateLine; m_head = new GameEntityComponent(updateLine); m_tail = new GameEntityComponent(updateLine); m_head.Next = m_tail; m_tail.Previous = m_head; }
/// <summary> /// Update all component of line /// </summary> /// <param name="dT">spend time [sec]</param> public void Update(double dT) { GameEntityComponent component = m_head.Next; while (component != m_tail) { component.Update(dT); component = component.Next; } }
/// <summary> /// Add component to the tail of this line /// </summary> /// <param name="component">component (same UpdateLine)</param> /// <remarks> /// This method is called by GameEntityComponent only. /// </remarks> public void AddComponent(GameEntityComponent component) { Debug.Assert(component.UpdateLine == m_updteLine, "defferent update line"); GameEntityComponent position = m_tail.Previous; position.Next = component; component.Previous = position; component.Next = m_tail; m_tail.Previous = component; m_count++; }
/// <summary> /// Remove component from this line /// </summary> /// <param name="component">component (same UpdateLine)</param> /// <remarks> /// This method is called by GameEntityComponent only. /// </remarks> public void RemoveComponent(GameEntityComponent component) { Debug.Assert(component.UpdateLine == m_updteLine, "defferent update line"); Debug.Assert(component.Next != null, "next component is null"); Debug.Assert(component.Previous != null, "previous component is null"); GameEntityComponent prev = component.Previous; GameEntityComponent next = component.Next; prev.Next = next; next.Previous = prev; component.Previous = null; component.Next = null; m_count--; }
public GameEntityComponent(UpdateLines updateLine) { m_updateLine = updateLine; Previous = Next = null; }
/// <summary> /// Add new component to entity /// </summary> /// <param name="component">new component</param> public void AddComponent(GameEntityComponent component) { m_components.Add(component); component.OnAddToEntity(this); }