protected virtual void OnComponentAdded(GameComponentEventArgs <ComponentType> i_Args) { if (IsInitialized) { initializeComponent(i_Args.GameComponent); } else { m_UninitializedComponents.Add(i_Args.GameComponent); } IUpdateable updatable = i_Args.GameComponent as IUpdateable; if (updatable != null) { insertSorted(updatable); updatable.UpdateOrderChanged += new EventHandler <EventArgs>(childUpdateOrderChanged); } IDrawable drawable = i_Args.GameComponent as IDrawable; if (drawable != null) { insertSorted(drawable); drawable.DrawOrderChanged += new EventHandler <EventArgs>(childDrawOrderChanged); } if (ComponentAdded != null) { ComponentAdded(this, i_Args); } }
protected virtual void OnComponentRemoved(GameComponentEventArgs <ComponentType> i_Args) { if (!IsInitialized) { m_UninitializedComponents.Remove(i_Args.GameComponent); } IUpdateable updatable = i_Args.GameComponent as IUpdateable; if (updatable != null) { m_UpdateableComponents.Remove(updatable); updatable.UpdateOrderChanged -= childUpdateOrderChanged; } Sprite sprite = i_Args.GameComponent as Sprite; if (sprite != null) { m_Sprites.Remove(sprite); sprite.DrawOrderChanged -= childDrawOrderChanged; } else { IDrawable drawable = i_Args.GameComponent as IDrawable; if (drawable != null) { m_DrawableComponents.Remove(drawable); drawable.DrawOrderChanged -= childDrawOrderChanged; } } if (ComponentRemoved != null) { ComponentRemoved(this, i_Args); } }