Example #1
0
        public virtual void DestroyEntity(Entity entity)
        {
            var removed = _entities.Remove(entity);
            if (!removed) {
                throw new PoolDoesNotContainEntityException(entity,
                    "Could not destroy entity!");
            }
            _entitiesCache = null;

            updateGroupsEntityWillBeDestroyed(entity);
            if (OnEntityWillBeDestroyed != null) {
                OnEntityWillBeDestroyed(this, entity);
            }

            entity.OnComponentAdded -= updateGroupsComponentAddedOrRemoved;
            entity.OnComponentReplaced -= updateGroupsComponentReplaced;
            entity.OnComponentRemoved -= updateGroupsComponentAddedOrRemoved;
            entity.RemoveAllComponents();

            entity._isEnabled = false;
            _entityPool.Push(entity);

            if (OnEntityDestroyed != null) {
                OnEntityDestroyed(this, entity);
            }
        }
Example #2
0
        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);
        }