public Entity AddComponent(BaseComponent c, bool overwriteIfExists = false) { var componentType = c.GetType().Name; if (this.HasComponent(componentType) && !overwriteIfExists) { throw new ApplicationException("Component already exists on this entity"); } this.Components[componentType] = c; this.OnComponentAdded(c); return this; }
protected void OnComponentRemoved(BaseComponent c) { if (this.ComponentRemoved != null) ComponentRemoved(this, new ComponentChangedEventArgs() { Component = c }); }