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.destroy(); if (OnEntityDestroyed != null) { OnEntityDestroyed(this, entity); } if (entity._refCount == 1) { entity.OnEntityReleased -= _cachedOnEntityReleased; _reusableEntities.Push(entity); } else { _retainedEntities.Add(entity); } entity.Release(); }
/// Destroys the entity, removes all its components and pushs it back to the internal ObjectPool for entities. public virtual void DestroyEntity(Entity entity) { var removed = _entities.Remove(entity); if (!removed) { throw new PoolDoesNotContainEntityException("'" + this + "' cannot destroy " + entity + "!", "Did you call pool.DestroyEntity() on a wrong pool?"); } _entitiesCache = null; if (OnEntityWillBeDestroyed != null) { OnEntityWillBeDestroyed(this, entity); } entity.destroy(); if (OnEntityDestroyed != null) { OnEntityDestroyed(this, entity); } if (entity.retainCount == 1) { entity.OnEntityReleased -= _cachedOnEntityReleased; _reusableEntities.Push(entity); } else { _retainedEntities.Add(entity); } entity.Release(this); }
protected override void removeEntity(TKey key, Entity entity) { _index.Remove(key); var safeAerc = entity.aerc as SafeAERC; if (safeAerc != null) { if (safeAerc.owners.Contains(this)) { entity.Release(this); } } else { entity.Release(this); } }
void removeEntitySilently(Entity entity) { var removed = _entities.Remove(entity); if (removed) { _entitiesCache = null; _singleEntityCache = null; entity.Release(); } }
/// Destroys the entity, removes all its components and pushs it back /// to the internal ObjectPool for entities. private void DestroyEntity(Entity entity) { var removed = _entities.Remove(entity); if (!removed) { throw new ContextDoesNotContainEntityException( "'" + this + "' cannot destroy " + entity + "!", "This cannot happen!?!" ); } _entitiesCache = null; if (OnEntityWillBeDestroyed != null) { OnEntityWillBeDestroyed(this, entity); } entity.InternalDestroy(); if (OnEntityDestroyed != null) { OnEntityDestroyed(this, entity); } if (entity.retainCount == 1) { // Can be released immediately without // adding to _retainedEntities entity.OnEntityReleased -= _cachedEntityReleased; _reusableEntities.Push(entity); entity.Release(this); entity.RemoveAllOnEntityReleasedHandlers(); } else { _retainedEntities.Add(entity); entity.Release(this); } }
bool removeEntitySilently(Entity entity) { var removed = _entities.Remove(entity); if (removed) { _entitiesCache = null; _singleEntityCache = null; entity.Release(this); } return(removed); }
void removeEntity(Entity entity, int index, IComponent component) { var removed = _entities.Remove(entity); if (removed) { _entitiesCache = null; _singleEntityCache = null; if (OnEntityRemoved != null) { OnEntityRemoved(this, entity, index, component); } entity.Release(this); } }
protected override void removeEntity( Entity entity, IComponent component) { _index.Remove(_getKey(entity, component)); entity.Release(this); }
protected override void removeEntity(Entity entity, IComponent component) { GetEntities(_getKey(entity, component)).Remove(entity); entity.Release(this); }
bool removeEntitySilently(Entity entity) { var removed = _entities.Remove(entity); if(removed) { _entitiesCache = null; _singleEntityCache = null; entity.Release(this); } return removed; }
void removeEntity(Entity entity, int index, IComponent component) { var removed = _entities.Remove(entity); if(removed) { _entitiesCache = null; _singleEntityCache = null; if(OnEntityRemoved != null) { OnEntityRemoved(this, entity, index, component); } entity.Release(this); } }