Beispiel #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;

            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();
        }
Beispiel #2
0
        /// 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);
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        void removeEntitySilently(Entity entity)
        {
            var removed = _entities.Remove(entity);

            if (removed)
            {
                _entitiesCache     = null;
                _singleEntityCache = null;
                entity.Release();
            }
        }
Beispiel #5
0
        /// 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);
            }
        }
Beispiel #6
0
        bool removeEntitySilently(Entity entity)
        {
            var removed = _entities.Remove(entity);

            if (removed)
            {
                _entitiesCache     = null;
                _singleEntityCache = null;
                entity.Release(this);
            }

            return(removed);
        }
Beispiel #7
0
        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);
            }
        }
Beispiel #8
0
 protected override void removeEntity(
     Entity entity, IComponent component)
 {
     _index.Remove(_getKey(entity, component));
     entity.Release(this);
 }
Beispiel #9
0
 protected override void removeEntity(Entity entity, IComponent component)
 {
     GetEntities(_getKey(entity, component)).Remove(entity);
     entity.Release(this);
 }
Beispiel #10
0
        bool removeEntitySilently(Entity entity)
        {
            var removed = _entities.Remove(entity);
            if(removed) {
                _entitiesCache = null;
                _singleEntityCache = null;
                entity.Release(this);
            }

            return removed;
        }
Beispiel #11
0
 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);
     }
 }