/// <summary> /// Called when a component is removed from the world /// </summary> /// <param name="compo">Component</param> /// <returns>Returns true if successfully removed otherwise false</returns> public override bool Unregister(Component compo) { if (compo == null) return false; Type componentType = compo.GetType(); if (componentType == typeof(HealthComponent)) RemoveHealth(compo as HealthComponent); else if (componentType == typeof(ShieldComponent)) RemoveShield(compo as ShieldComponent); return true; }
/// <summary> /// Called when a new component is added to the world /// </summary> /// <param name="compo">Component</param> public override void Register(Component compo) { if(compo == null) throw new ArgumentNullException("compo"); Type componentType = compo.GetType(); if (componentType == typeof (HealthComponent)) ActivateHealth(compo as HealthComponent); else if (componentType == typeof (ShieldComponent)) ActivateShield(compo as ShieldComponent); }