Example #1
0
        void CleanUpEntityRecursively(IDCLEntity entity, bool removeImmediatelyFromEntitiesList)
        {
            // Iterate through all entity children
            using (var iterator = entity.children.GetEnumerator())
            {
                while (iterator.MoveNext())
                {
                    CleanUpEntityRecursively(iterator.Current.Value, removeImmediatelyFromEntitiesList);
                }
            }

            OnEntityRemoved?.Invoke(entity);

            if (Environment.i.world.sceneBoundsChecker.enabled)
            {
                entity.OnShapeUpdated -= Environment.i.world.sceneBoundsChecker.AddEntityToBeChecked;
                Environment.i.world.sceneBoundsChecker.RemoveEntityToBeChecked(entity);
            }

            if (removeImmediatelyFromEntitiesList)
            {
                // Every entity ends up being removed through here
                entity.Cleanup();
                entities.Remove(entity.entityId);
            }
            else
            {
                Environment.i.platform.parcelScenesCleaner.MarkForCleanup(entity);
            }
        }
Example #2
0
        void CleanUpEntityRecursively(DecentralandEntity entity, bool removeImmediatelyFromEntitiesList)
        {
            // Iterate through all entity children
            using (var iterator = entity.children.GetEnumerator())
            {
                while (iterator.MoveNext())
                {
                    CleanUpEntityRecursively(iterator.Current.Value, removeImmediatelyFromEntitiesList);
                }
            }

            OnEntityRemoved?.Invoke(entity);

            if (SceneController.i.useBoundariesChecker)
            {
                entity.OnShapeUpdated -= SceneController.i.boundariesChecker.AddEntityToBeChecked;
                SceneController.i.boundariesChecker.RemoveEntityToBeChecked(entity);
            }

            if (removeImmediatelyFromEntitiesList)
            {
                // Every entity ends up being removed through here
                entity.Cleanup();
                entities.Remove(entity.entityId);
            }
            else
            {
                parcelScenesCleaner.MarkForCleanup(entity);
            }
        }
        public void DestroyEntity(Entity entity)
        {
            OnEntityRemoved?.Invoke(entity);

            foreach (var comp in entity.Components)
            {
                var upf = comp as UnityPrefabComp;
                if (upf != null)
                {
                    var go = upf.Owner.Wrapper.gameObject;
                    if (upf.IsPooled)
                    {
                        go.Release();
                    }
                    else
                    {
                        UnityEngine.Object.Destroy(go);
                    }
                }
                //if (entity.IsPooled)
                //{
                //    comp.Enabled = false;
                //}
                DestroyComponent(comp);
            }
            EntityList.Remove(entity);
            if (entity.IsPooled)
            {
                EntityPool.Instance.ReleaseToPool(entity);
            }
        }
Example #4
0
        internal void RemoveEntity(string name)
        {
            Entity e = entities[name];

            entities.Remove(name);
            OnEntityRemoved?.Invoke(e);
        }
 /// This is used by the pool to manage the group.
 public void UpdateEntity(Entity <T> entity, Type type, T previousComponent, T newComponent)
 {
     if (_entities.Contains(entity))
     {
         OnEntityRemoved?.Invoke(this, entity, type, previousComponent);
         OnEntityAdded?.Invoke(this, entity, type, newComponent);
         OnEntityUpdated?.Invoke(this, entity, type, previousComponent, newComponent);
     }
 }
Example #6
0
 /// This is used by the context to manage the group.
 public void UpdateEntity(TEntity entity, int index, IComponent previousComponent, IComponent newComponent)
 {
     if (_entities.Contains(entity))
     {
         OnEntityRemoved?.Invoke(this, entity, index, previousComponent);
         OnEntityAdded?.Invoke(this, entity, index, newComponent);
         OnEntityUpdated?.Invoke(this, entity, index, previousComponent, newComponent);
     }
 }
Example #7
0
        public void RemoveEntity(ECSEntity entity)
        {
            bool removed = entities.Remove(entity);

            if (removed)
            {
                OnEntityRemoved?.Invoke(entity);
            }
        }
Example #8
0
        public void RemoveEntity(int ent)
        {
            if (!entities.HasValue(ent))
            {
                return;
            }

            entities.RemoveValue(ent);
            gaps.AddFirst(ent);
            OnEntityRemoved?.Invoke(ent);
        }
Example #9
0
        private void removeEntity(TEntity entity, int index, IComponent component)
        {
            var removed = _entities.Remove(entity);

            if (removed)
            {
                _entitiesCache     = null;
                _singleEntityCache = null;
                OnEntityRemoved?.Invoke(this, entity, index, component);
                entity.Release(this);
            }
        }
        void RemoveEntity(Entity <T> entity, Type type, T component)
        {
            var removed = _entities.Remove(entity);

            if (removed)
            {
                _entitiesCache     = null;
                _singleEntityCache = null;
                OnEntityRemoved?.Invoke(this, entity, type, component);
                entity.Release(this);
            }
        }
Example #11
0
        /// <summary>
        /// Dispatches entity removing logic
        /// </summary>
        internal void ProcessEntitiesForRemoving()
        {
            while (EntitiesForRemoving.Count != 0)
            {
                Entity entity = EntitiesForRemoving.Dequeue();

                entity.AttachedComponents.Clear();
                _freeIds.Enqueue(entity.Id);

                Entities.Remove(entity.Id);

                OnEntityRemoved?.Invoke(entity);
                entity.MarkedToBeRemoved = false;
                entity.Service           = null;
            }
        }
Example #12
0
        void CleanUpEntityRecursively(DecentralandEntity entity, bool removeImmediatelyFromEntitiesList)
        {
            // Iterate through all entity children
            using (var iterator = entity.children.GetEnumerator())
            {
                while (iterator.MoveNext())
                {
                    CleanUpEntityRecursively(iterator.Current.Value, removeImmediatelyFromEntitiesList);
                }
            }

            OnEntityRemoved?.Invoke(entity);

            if (removeImmediatelyFromEntitiesList)
            {
                // Every entity ends up being removed through here
                entity.Cleanup();
                entities.Remove(entity.entityId);
            }
            else
            {
                parcelScenesCleaner.MarkForCleanup(entity);
            }
        }
Example #13
0
 public void RemoveRange(IEnumerable <T> entities)
 {
     Context.Set <T>().RemoveRange(entities);
     OnEntityRemoved?.Invoke(this, new EntityRemovedEventArgs <T>(entities));
 }
Example #14
0
 public void Remove(T entity)
 {
     Context.Set <T>().Remove(entity);
     OnEntityRemoved?.Invoke(this, new EntityRemovedEventArgs <T>(entity));
 }
Example #15
0
 internal static void RaiseEntityRemoved(Entity entity)
 {
     OnEntityRemoved?.Invoke(entity);
 }
Example #16
0
        /// <summary>
        /// Remove entity from Db
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        public void Remove <T>(T t) where T : IDbEntity
        {
            AddType <T>();
            Type type = typeof(T);

            Database[type].Remove(t);

            // check entity references
            foreach (KeyValuePair <Type, HashSet <IDbEntity> > kv in Database)
            {
                Type entityType = kv.Key;

                EntityInfo infos = GetEntityInfo(entityType);

                foreach (IDbEntity entity in kv.Value)
                {
                    bool changed = false;

                    // single refs
                    foreach (SingleReferenceProperty referenceProperty in infos.SingleReferenceInjectors)
                    {
                        IDbReference dbReference = (IDbReference)referenceProperty.PropertyAccessor.GetValue(entity);

                        if (dbReference.ReferenceId == t.EntityId && dbReference.EntityType == type)
                        {
                            dbReference.ReferenceId = null;
                            dbReference.Entity      = null;

                            changed = true;
                        }
                    }

                    // multiple refs
                    foreach (MultipleReferenceProperty referenceProperty in infos.MultipleReferenceInjectors)
                    {
                        IList dbReference = (IList)referenceProperty.PropertyAccessor.GetValue(entity);

                        if (dbReference == null)
                        {
                            continue;
                        }


                        for (int i = dbReference.Count - 1; i >= 0; i--)
                        {
                            IDbReference reference = (IDbReference)dbReference[i];

                            if (reference.ReferenceId == t.EntityId && reference.EntityType == type)
                            {
                                dbReference.RemoveAt(i);
                                changed = true;
                            }
                        }
                    }

                    if (changed)
                    {
                        OnEntityChanged?.Invoke(entity);
                    }
                }
            }

            OnDatabaseChanged?.Invoke(this);

            OnEntityRemoved?.Invoke(t);
        }
Example #17
0
 public void Remove(Entity entity)
 {
     entities.Remove(entity);
     OnEntityRemoved?.Invoke(this, null);
 }
Example #18
0
 public void TriggerEntityRemoved(Entity entity)
 {
     OnEntityRemoved?.Invoke(entity);
 }