Exemple #1
0
        void IPoolableRecycle.OnRecycle()
        {
            this.ReleaseState(ref this.resetState);
            this.ReleaseState(ref this.currentState);

            for (int i = 0; i < this.systems.Count; ++i)
            {
                this.systems[i].OnDeconstruct();
                PoolSystems.Recycle(this.systems[i]);
            }
            PoolList <ISystem <TState> > .Recycle(ref this.systems);

            for (int i = 0; i < this.modules.Count; ++i)
            {
                this.modules[i].OnDeconstruct();
                PoolModules.Recycle(this.modules[i]);
            }
            PoolList <IModule <TState> > .Recycle(ref this.modules);

            PoolDictionary <int, IList> .Recycle(ref this.entitiesCache);

            //PoolDictionary<EntityId, IEntity>.Recycle(ref this.entitiesDirectCache);
            PoolDictionary <int, IList> .Recycle(ref this.filtersCache);

            PoolDictionary <int, IComponents> .Recycle(ref this.componentsCache);

            PoolDictionary <int, int> .Recycle(ref this.capacityCache);
        }
Exemple #2
0
        public void CopyFrom(Filter <T> other)
        {
            if (this.list != null)
            {
                PoolList <T> .Recycle(ref this.list);
            }
            this.list = PoolList <T> .Spawn(other.list.Capacity);

            this.list.AddRange(other.list);
        }
Exemple #3
0
 public void SetData(List <T> data)
 {
     if (this.freeze == false && data != null && this.list != data)
     {
         if (this.list != null)
         {
             PoolList <T> .Recycle(ref this.list);
         }
         this.list = data;
     }
 }
Exemple #4
0
        public static void Recycle <T, TCopy>(ref ListCopyable <T> item, TCopy copy) where TCopy : IArrayElementCopy <T>
        {
            if (item != null)
            {
                for (int i = 0; i < item.Count; ++i)
                {
                    copy.Recycle(item[i]);
                }

                PoolList <T> .Recycle(ref item);
            }
        }
Exemple #5
0
        void IPoolableRecycle.OnRecycle()
        {
            foreach (var item in this.dic)
            {
                PoolComponents.Recycle(item.Value);
                PoolList <IComponent <TState, TEntity> > .Recycle(item.Value);
            }
            PoolDictionary <EntityId, List <IComponent <TState, TEntity> > > .Recycle(ref this.dic);

            this.freeze   = false;
            this.capacity = 0;
        }
Exemple #6
0
        void IPoolableRecycle.OnRecycle()
        {
            this.freeze = default;

            if (this.filters != null)
            {
                for (int i = 0, count = this.filters.Count; i < count; ++i)
                {
                    this.filters[i].Recycle();
                }

                PoolList <IFilterBase> .Recycle(ref this.filters);
            }
        }
Exemple #7
0
        public static void Copy <T, TCopy>(System.Collections.Generic.List <T> fromArr, ref System.Collections.Generic.List <T> arr, TCopy copy) where TCopy : IArrayElementCopy <T>
        {
            if (fromArr == null)
            {
                if (arr != null)
                {
                    for (int i = 0; i < arr.Count; ++i)
                    {
                        copy.Recycle(arr[i]);
                    }

                    PoolList <T> .Recycle(ref arr);
                }

                arr = null;
                return;
            }

            if (arr == null || fromArr.Count != arr.Count)
            {
                if (arr != null)
                {
                    ArrayUtils.Recycle(ref arr, copy);
                }
                arr = PoolList <T> .Spawn(fromArr.Count);
            }

            var cnt = arr.Count;

            for (int i = 0; i < fromArr.Count; ++i)
            {
                var isDefault = i >= cnt;

                T item = (isDefault ? default : arr[i]);
                copy.Copy(fromArr[i], ref item);
                if (isDefault == true)
                {
                    arr.Add(item);
                }
                else
                {
                    arr[i] = item;
                }
            }
        }
Exemple #8
0
        public static void Copy <T>(ListCopyable <T> fromArr, ref ListCopyable <T> arr) where T : struct
        {
            if (fromArr == null)
            {
                if (arr != null)
                {
                    PoolList <T> .Recycle(ref arr);
                }

                arr = null;
                return;
            }

            if (arr == null)
            {
                arr = PoolList <T> .Spawn(fromArr.Count);
            }

            arr.CopyFrom(fromArr);
        }
Exemple #9
0
        public void CopyFrom(Components <TEntity, TState> other)
        {
            if (this.dic != null)
            {
                foreach (var item in this.dic)
                {
                    //PoolComponents.Recycle(item.Value);
                    PoolList <IComponent <TState, TEntity> > .Recycle(item.Value);
                }
                PoolDictionary <EntityId, List <IComponent <TState, TEntity> > > .Recycle(ref this.dic);
            }
            this.dic = PoolDictionary <EntityId, List <IComponent <TState, TEntity> > > .Spawn(this.capacity);

            foreach (var item in other.dic)
            {
                var newList = PoolList <IComponent <TState, TEntity> > .Spawn(item.Value.Capacity);

                newList.AddRange(item.Value);
                this.dic.Add(item.Key, newList);
            }
        }
Exemple #10
0
        public static void Copy <T>(System.Collections.Generic.List <T> fromArr, ref System.Collections.Generic.List <T> arr) where T : struct
        {
            if (fromArr == null)
            {
                if (arr != null)
                {
                    PoolList <T> .Recycle(ref arr);
                }

                arr = null;
                return;
            }

            if (arr == null || fromArr.Count != arr.Count)
            {
                if (arr != null)
                {
                    PoolList <T> .Recycle(ref arr);
                }
                arr = PoolList <T> .Spawn(fromArr.Count);
            }

            var cnt = arr.Count;

            for (int i = 0; i < fromArr.Count; ++i)
            {
                var isDefault = i >= cnt;
                var item      = fromArr[i];
                if (isDefault == true)
                {
                    arr.Add(item);
                }
                else
                {
                    arr[i] = item;
                }
            }
        }
Exemple #11
0
        void IPoolableRecycle.OnRecycle()
        {
            PoolList <T> .Recycle(ref this.list);

            this.freeze = false;
        }