/// <summary> /// Removes a component from the entity. /// </summary> /// <param name="name">Name of the component which is to be removed from the entity.</param> public void RemoveComponent(string name) { if (name == null || name.Length == 0) { throw new ArgumentNullException("Entity.RemoveComponent(): null name."); } IEntityComponent component = mComponents.Find(c => c.Name == name); if (component == null) { throw new ArgumentException("Entity.RemoveComponent(): component not found."); } else { component.Owner = null; component.OnRemove(); ResetComponents(); if (ComponentRemoved != null) { ComponentRemoved(this, component); } } mComponents.Remove(component); }
/// <summary> /// Removes a component from the entity. /// </summary> /// <param name="component">Component which is to be removed from the entity.</param> public void RemoveComponent(IEntityComponent component) { if (component == null) { throw new ArgumentNullException("Entity.RemoveComponent(): null component."); } if (mComponents.Remove(component)) { component.Owner = null; component.OnRemove(); ResetComponents(); if (ComponentRemoved != null) { ComponentRemoved(this, component); } } else { throw new ArgumentException("Entity.RemoveComponent(): component not found."); } }