public Entity(string name) { this.name = name; Components = new EntityComponentCollection(this); Children.CollectionChanged += Children_CollectionChanged; Components.CollectionChanged += Components_CollectionChanged; Components.Add(Transform); }
private void OnComponentsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { EntityComponentCollection entityComponentCollection = (EntityComponentCollection)sender; Entity entity = entityComponentCollection.Entity; switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (EntityComponent component in e.NewItems.Cast <EntityComponent>()) { Add(component, entity); UpdateDependentSystems(entity, component); } break; case NotifyCollectionChangedAction.Remove: foreach (EntityComponent component in e.OldItems.Cast <EntityComponent>()) { Remove(component, entity); UpdateDependentSystems(entity, component); } break; } }