Пример #1
0
 public void AddComponent(Component component)
 {
     if (!components.Contains(component))
     {
         components.Add(component);
         component.Parent = this;
         component.LoadComponent();
         PutComponentInOrder(component);
     }
 }
Пример #2
0
 public void RemoveComponent(Component component)
 {
     if (component != null && components.Contains(component))
     {
         components.Remove(component);
         component.Parent = null;
     }
 }
Пример #3
0
        // 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++)
                    //TODO Check this
                    if (component is DrawableComponent)
                    {
                        if (((DrawableComponent)components[i]).DrawOrder >= ((DrawableComponent)component).DrawOrder)
                            break;
                    }

                components.Insert(i, component);
            }
        }