public virtual void AddUpdateableComponent(EntityUpdateableComponent component) { if (component is Transform) { throw new Exception("Only one transform can be attached to entity"); } if (component.Parent != null) { throw new Exception("ParentComponent must be null"); } if (components.ContainsKey(component.Name)) { //TODO throw new Exception("Enity has component with same name"); } component.Parent = this; if (scene != null) { component.Initialize(); } component.UpdateOrderChanged += (s, e) => isUpdateDirty = true; components.Add(component.Name, component); updateableComponents.Add(component); isUpdateDirty = true; }
public virtual void RemoveUpdateableComponent(EntityUpdateableComponent component) { if (component is Transform) { throw new Exception("Trasnform could not be removed"); } component.Parent = null; components.Remove(component.Name); updateableComponents.Remove(component); }