public virtual void DestroyEntity(Entity entity) { var removed = _entities.Remove(entity); if (!removed) { throw new PoolDoesNotContainEntityException(entity, "Could not destroy entity!"); } _entitiesCache = null; if (OnEntityWillBeDestroyed != null) { OnEntityWillBeDestroyed(this, entity); } entity.RemoveAllComponents(); entity.OnComponentAdded -= onComponentAddedOrRemoved; entity.OnComponentReplaced -= onComponentReplaced; entity.OnComponentRemoved -= onComponentAddedOrRemoved; entity._isEnabled = false; _entityPool.Push(entity); if (OnEntityDestroyed != null) { OnEntityDestroyed(this, entity); } }
public void DestroyEntity(Entity entity) { entity.RemoveAllComponents(); entity.OnComponentAdded -= onComponentAdded; entity.OnComponentReplaced -= onComponentReplaced; entity.OnComponentWillBeRemoved -= onComponentWillBeRemoved; entity.OnComponentRemoved -= onComponentRemoved; _entities.Remove(entity); _entitiesCache = null; _entityPool.Push(entity); }
public virtual void DestroyEntity(Entity entity) { var removed = _entities.Remove(entity); if (!removed) { throw new PoolDoesNotContainEntityException(entity, "Could not destroy entity!"); } entity.RemoveAllComponents(); entity.OnComponentAdded -= onComponentAddedOrRemoved; entity.OnComponentReplaced -= onComponentReplaced; entity.OnComponentWillBeRemoved -= onComponentWillBeRemoved; entity.OnComponentRemoved -= onComponentAddedOrRemoved; _entitiesCache = null; _entityPool.Push(entity); }