public void RemoveComponentImmediate <TComponent>(Entity entity) where TComponent : IComponent { if (typeof(TComponent) == _iComponentType) { throw new InvalidTComponentException(); } Type componentType = typeof(TComponent); ComponentArray <TComponent> entityComponentMap = GetComponentMap <TComponent>(false); if (entityComponentMap != null && entityComponentMap.Contains(entity)) { _entityComponents[entity].Remove(componentType); entityComponentMap.Remove(entity); InspectComponentGroups(entity); } }
public void RemoveComponent <TComponent>(Entity entity, TComponent component) where TComponent : IComponent { if (typeof(TComponent) == _iComponentType) { throw new InvalidTComponentException(); } Type componentType = typeof(TComponent); ComponentArray <TComponent> entityComponentMap = GetComponentMap <TComponent>(false); if (entityComponentMap != null) { entityComponentMap.Remove(entity); _entityComponents[entity].Remove(componentType); InspectComponentGroups(entity); _componentRemovedFromEntityEvent.CallEvent(this, ref entity, componentType); } //_compoentRemovedList.Add(new KeyValuePair<Entity, Type>(entity, componentType)); }
internal void HandleDeletion() { foreach (DeletionPair item in _deletableComponents) { Entity entity = item.entity; ComponentArray entityComponentMap = item.componentArray; if (entityComponentMap != null && entityComponentMap.Contains(entity)) { entityComponentMap.Remove(entity); _entityComponents[entity].Remove(entityComponentMap.ComponentType); InspectComponentGroups(entity); } } _deletableComponents.Clear(); foreach (Entity entity in _destroyableEntities) { DestroyEntityImmediate(entity); } _destroyableEntities.Clear(); }