// The components are stored in their draw order, so it is easy to loop // through them and draw them in the correct order without having to sort // them every time they are drawn public void PutComponentInOrder(Component component) { if (components.Contains(component)) { components.Remove(component); int i = 0; // Iterate through the components in order until we find one with // a higher or equal draw order, and insert the component at that // position. for (i = 0; i < components.Count; i++) if (components[i].DrawOrder >= component.DrawOrder) break; components.Insert(i, component); } }
public void RemoveComponent(Component Component) { if (Component != null && components.Contains(Component)) { if (Updating) { componentsToBeRemoved.Add(Component); } else { components.Remove(Component); } } }
public void AddComponent(Component Component) { if (Updating) { componentsToBeAdded.Add(Component); return; } if (!components.Contains(Component)) { components.Add(Component); Component.Initialize(); Component.LoadContent(); PutComponentInOrder(Component); } }