Пример #1
0
        public void Recycle()
        {
            this.result       = PathCompleteState.NotCalculated;
            this.graph        = null;
            this.cacheEnabled = default;

            if (this.nodes != null)
            {
                PoolListCopyable <Node> .Recycle(ref this.nodes);
            }
            if (this.nodesModified != null)
            {
                PoolListCopyable <Node> .Recycle(ref this.nodesModified);
            }

            if (this.cacheEnabled == false && this.flowField.arr != null)
            {
                PoolArray <byte> .Recycle(ref this.flowField);
            }

            if (this.navMeshPoints != null)
            {
                PoolListCopyable <Vector3> .Recycle(ref this.navMeshPoints);
            }
        }
Пример #2
0
        public static bool Resize <T>(int index, ref T[] arr)
        {
            if (arr == null)
            {
                arr = PoolArray <T> .Spawn(index + 1);
            }
            if (index < arr.Length)
            {
                return(false);
            }

            var newLength = arr.Length * 2;

            if (newLength == 0 || newLength <= index)
            {
                newLength = index + 1;
            }

            var newArr = PoolArray <T> .Spawn(newLength);

            System.Array.Copy(arr, newArr, arr.Length);
            PoolArray <T> .Recycle(ref arr);

            arr = newArr;

            return(true);
        }
Пример #3
0
        public override void OnRecycle()
        {
            this.isTag = default;
            PoolArray <TComponent> .Recycle(ref this.components);

            PoolArray <byte> .Recycle(ref this.componentsStates);
        }
Пример #4
0
        private void SetCapacity(int capacity)
        {
            var newarray = PoolArray <T> .Spawn(capacity);

            if (this.size > 0)
            {
                if (this.head < this.tail)
                {
                    Array.Copy(this.array.arr, this.head, newarray.arr, 0, this.size);
                }
                else
                {
                    Array.Copy(this.array.arr, this.head, newarray.arr, 0, this.array.Length - this.head);
                    Array.Copy(this.array.arr, 0, newarray.arr, this.array.Length - this.head, this.tail);
                }
            }

            if (this.array.arr != null)
            {
                PoolArray <T> .Recycle(ref this.array);
            }

            this.array = newarray;
            this.head  = 0;
            this.tail  = this.size == capacity ? 0 : this.size;
            this.version++;
        }
Пример #5
0
        void IPoolableRecycle.OnRecycle()
        {
            this.result = default;
            PoolArray <UnityEngine.Vector3> .Recycle(ref this.path);

            PoolArray <ME.ECS.Pathfinding.Node> .Recycle(ref this.nodes);
        }
Пример #6
0
 public void Recycle(ref BufferArray <T> value)
 {
     if (value != null)
     {
         PoolArray <T> .Recycle(ref value);
     }
 }
Пример #7
0
        public void OnRecycle()
        {
            PoolArray <T> .Recycle(ref this.innerArray);

            this.Capacity = 0;
            this.Count    = 0;
        }
Пример #8
0
        private void Resize_INTERNAL(int newLength)
        {
            if (newLength > this.capacity)
            {
                var oldCapacity = this.capacity;
                if (this.capacity > 0)
                {
                    this.capacity *= 2;
                }
                else
                {
                    this.capacity = newLength;
                    oldCapacity   = 0;
                }

                var arr = PoolArray <T> .Spawn(this.capacity);

                if (this.arr != null)
                {
                    System.Array.Copy(this.arr, arr, this.arr.Length);
                    PoolArray <T> .Recycle(ref this.arr);
                }
                this.arr = arr;
            }
        }
Пример #9
0
        public BufferArray <T> Dispose()
        {
            T[] arr = this.arr;
            PoolArray <T> .Recycle(ref arr);

            return(new BufferArray <T>(null, 0));
        }
Пример #10
0
        public void SetCapacity(int min)
        {
            if (this.Capacity < min)
            {
                var prevLength = this.Capacity;
                this.Capacity *= 2;
                if (this.Capacity < min)
                {
                    this.Capacity = min;
                }

                var newArray = PoolArray <T> .Spawn(this.Capacity);

                if (this.tail > this.head)                                                               // If we are not wrapped around...
                {
                    Array.Copy(this.innerArray.arr, this.head, newArray.arr, 0, this.Count);             // ...take from head to head+Count and copy to beginning of new array
                }
                else if (this.Count > 0)                                                                 // Else if we are wrapped around... (tail == head is ambiguous - could be an empty buffer or a full one)
                {
                    Array.Copy(this.innerArray.arr, this.head, newArray.arr, 0, prevLength - this.head); // ...take head to end and copy to beginning of new array
                    Array.Copy(this.innerArray.arr, 0, newArray.arr, prevLength - this.head, this.tail); // ...take beginning to tail and copy after previously copied elements
                }

                this.head = 0;
                this.tail = this.Count;
                if (this.innerArray.isNotEmpty == true)
                {
                    PoolArray <T> .Recycle(ref this.innerArray);
                }

                this.innerArray = newArray;
            }
        }
Пример #11
0
        public void OnRecycle()
        {
            PoolArray <T> .Recycle(ref this.innerArray);

            this.head  = 0;
            this.tail  = 0;
            this.Count = 0;
        }
Пример #12
0
        public void RPC <T1>(object instance, RPCId rpcId, T1 p1) where T1 : struct
        {
            var arr = PoolArray <object> .Spawn(1);

            arr[0] = p1;
            this.CallRPC(instance, rpcId, arr);
            PoolArray <object> .Recycle(ref arr);
        }
Пример #13
0
        public void RPC <T1, T2>(object instance, RPCId rpcId, T1 p1, T2 p2) where T1 : struct where T2 : struct
        {
            var arr = PoolArray <object> .Spawn(2);

            arr[0] = p1;
            arr[1] = p2;
            this.CallRPC(instance, rpcId, arr);
            PoolArray <object> .Recycle(ref arr);
        }
 public static void ClearCache()
 {
     foreach (var item in PathfindingFlowFieldProcessor.pathCache)
     {
         PoolArray <byte> .Recycle(item.Value);
     }
     PathfindingFlowFieldProcessor.pathCache.Clear();
     PathfindingFlowFieldProcessor.pathCacheQueue.Clear();
 }
Пример #15
0
        void IPoolableRecycle.OnRecycle()
        {
            PoolArray <T> .Recycle(ref this.arr);

            PoolQueueCopyable <int> .Recycle(ref this.freePeek);

            PoolHashSetCopyable <int> .Recycle(ref this.free);

            PoolHashSetCopyable <int> .Recycle(ref this.freePrepared);
        }
Пример #16
0
        public void RPC <T1, T2, T3, T4>(object instance, RPCId rpcId, T1 p1, T2 p2, T3 p3, T4 p4) where T1 : struct where T2 : struct where T3 : struct where T4 : struct
        {
            var arr = PoolArray <object> .Spawn(4);

            arr[0] = p1;
            arr[1] = p2;
            arr[2] = p3;
            arr[3] = p4;
            this.CallRPC(instance, rpcId, arr);
            PoolArray <object> .Recycle(ref arr);
        }
Пример #17
0
        public override void OnRecycle()
        {
            this.isTag = default;
            PoolArray <TComponent> .Recycle(ref this.components);

            PoolArray <byte> .Recycle(ref this.componentsStates);

            if (this.lifetimeIndexes != null)
            {
                PoolList <int> .Recycle(ref this.lifetimeIndexes);
            }
        }
Пример #18
0
        public void Recycle()
        {
            foreach (var item in this.data)
            {
                var st = item;
                WorldUtilities.ReleaseState(ref st);
            }

            PoolArray <TState> .Recycle(ref this.data);

            PoolArray <Tick> .Recycle(ref this.dataTicks);
        }
Пример #19
0
        public void CopyFrom(EntitiesList <T> other)
        {
            if (this.arr != null)
            {
                PoolArray <T> .Recycle(ref this.arr);
            }
            this.arr = PoolArray <T> .Spawn(other.arr.Length);

            System.Array.Copy(other.arr, this.arr, other.arr.Length);

            this.capacity = other.capacity;
            this.count    = other.count;
        }
Пример #20
0
        public void Recycle()
        {
            if (this.nodes != null)
            {
                PoolListCopyable <Node> .Recycle(ref this.nodes);
            }
            if (this.nodesModified != null)
            {
                PoolListCopyable <Node> .Recycle(ref this.nodesModified);
            }

            if (this.cacheEnabled == false && this.flowField.arr != null)
            {
                PoolArray <byte> .Recycle(ref this.flowField);
            }
        }
Пример #21
0
        public void CopyFrom(QueueCopyable <T> other)
        {
            if (this.array.arr != null)
            {
                PoolArray <T> .Recycle(ref this.array);
            }
            this.array = PoolArray <T> .Spawn(other.array.Length);

            System.Array.Copy(other.array.arr, this.array.arr, other.array.Length);

            this.head     = other.head;
            this.tail     = other.tail;
            this.size     = other.size;
            this.version  = other.version;
            this.capacity = other.capacity;
        }
Пример #22
0
        private void CallRPC(object instance, RPCId rpcId, bool storeInHistory, params object[] parameters)
        {
            Key key;

            if (this.objectToKey.TryGetValue(instance, out key) == true)
            {
                if (this.transporter.IsConnected() == false)
                {
                    return;
                }

                var evt = new ME.ECS.StatesHistory.HistoryEvent();
                evt.tick           = this.world.GetStateTick() + Tick.One; // Call RPC on next tick
                evt.order          = this.GetRPCOrder();
                evt.localOrder     = ++this.localOrderIndex;
                evt.parameters     = parameters;
                evt.rpcId          = rpcId;
                evt.objId          = key.objId;
                evt.groupId        = key.groupId;
                evt.storeInHistory = storeInHistory;

                var storedInHistory = false;
                if (storeInHistory == true && (this.GetNetworkType() & NetworkType.RunLocal) != 0)
                {
                    this.statesHistoryModule.AddEvent(evt);
                    storedInHistory = true;
                }

                if ((this.GetNetworkType() & NetworkType.SendToNet) != 0)
                {
                    if (this.transporter != null && this.serializer != null)
                    {
                        this.transporter.Send(this.serializer.Serialize(evt));
                    }
                }

                if (storedInHistory == false && parameters != null)
                {
                    // Return parameters into pool if we are not storing them locally
                    PoolArray <object> .Recycle(ref parameters);
                }
            }
            else
            {
                throw new RegisterObjectMissingException(instance, rpcId);
            }
        }
Пример #23
0
        void IModuleBase.OnDeconstruct()
        {
            //this.maxTick = Tick.Zero;
            this.prewarmed = false;
            //this.beginAddEventsTick = Tick.Zero;
            this.beginAddEventsCount      = 0;
            this.beginAddEvents           = false;
            this.statEventsAdded          = 0;
            this.statPlayedEvents         = 0;
            this.oldestTick               = Tick.Invalid;
            this.lastSavedStateTick       = Tick.Invalid;
            this.pauseStoreStateSinceTick = Tick.Invalid;

            this.statesHistory.DiscardAll();

            this.world.SetStatesHistoryModule(null);

            foreach (var item in this.events)
            {
                var values = item.Value.Values;
                for (int i = 0, cnt = values.Count; i < cnt; ++i)
                {
                    var val = values[i];
                    if (val.parameters != null)
                    {
                        PoolArray <object> .Recycle(ref val.parameters);
                    }
                }
                item.Value.Clear();
                PoolSortedList <long, HistoryEvent> .Recycle(item.Value);
            }
            PoolDictionary <Tick, ME.ECS.Collections.SortedList <long, HistoryEvent> > .Recycle(ref this.events);

            foreach (var kv in this.syncHashTable)
            {
                PoolDictionary <int, int> .Recycle(kv.Value);
            }
            PoolDictionary <Tick, Dictionary <int, int> > .Recycle(ref this.syncHashTable);

            //this.states.Recycle();
            //this.states = null;
        }
Пример #24
0
        void IModuleBase.OnDeconstruct()
        {
            this.statesHistory.DiscardAll();

            this.world.SetStatesHistoryModule(null);

            foreach (var item in this.events)
            {
                foreach (var hItem in item.Value)
                {
                    var val = hItem.Value;
                    PoolArray <object> .Recycle(ref val.parameters);
                }
                item.Value.Clear();
            }
            PoolDictionary <Tick, SortedList <long, HistoryEvent> > .Recycle(ref this.events);

            PoolDictionary <Tick, int> .Recycle(ref this.syncHash);

            //this.states.Recycle();
            //this.states = null;
        }
Пример #25
0
        void IModuleBase.OnDeconstruct()
        {
            this.isRequestsDirty = true;
            this.UpdateRequests();

            var temp = PoolList <IView> .Spawn(this.registryPrefabToId.Count);

            foreach (var prefab in this.registryIdToPrefab)
            {
                temp.Add(prefab.Value);
            }

            foreach (var prefab in temp)
            {
                this.UnRegisterViewSource(prefab);
            }
            PoolList <IView> .Recycle(ref temp);

            PoolDictionary <ViewId, IViewsProvider> .Recycle(ref this.registryPrefabToProvider);

            PoolDictionary <ViewId, IViewsProviderInitializerBase> .Recycle(ref this.registryPrefabToProviderInitializer);

            PoolDictionary <ViewId, IView> .Recycle(ref this.registryIdToPrefab);

            PoolDictionary <IView, ViewId> .Recycle(ref this.registryPrefabToId);

            PoolHashSet <ViewInfo> .Recycle(ref this.rendering);

            for (int i = 0; i < this.list.Length; ++i)
            {
                var views = this.list.arr[i];
                if (views.otherViews != null)
                {
                    PoolList <IView> .Recycle(views.otherViews);
                }
            }
            //PoolDictionary<int, List<IView<TEntity>>>.Recycle(ref this.list);
            PoolArray <Views> .Recycle(ref this.list);
        }
Пример #26
0
        public static void Copy <T>(T[] fromArr, ref T[] arr)
        {
            if (fromArr == null)
            {
                if (arr != null)
                {
                    PoolArray <T> .Recycle(ref arr);
                }
                arr = null;
                return;
            }

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

            System.Array.Copy(fromArr, arr, fromArr.Length);
        }
Пример #27
0
        public void CopyFrom(HashSetCopyable <T> other)
        {
            if (this.m_buckets != null)
            {
                PoolArray <int> .Recycle(ref this.m_buckets);
            }
            if (other.m_buckets != null)
            {
                this.m_buckets = PoolArray <int> .Spawn(other.m_buckets.Length);

                for (int i = 0; i < this.m_buckets.Length; ++i)
                {
                    this.m_buckets[i] = other.m_buckets[i];
                }
            }

            if (this.m_slots != null)
            {
                PoolArray <Slot> .Recycle(ref this.m_slots);
            }
            if (other.m_slots != null)
            {
                this.m_slots = PoolArray <Slot> .Spawn(other.m_slots.Length);

                for (int i = 0; i < this.m_slots.Length; ++i)
                {
                    this.m_slots[i] = other.m_slots[i];
                }
            }

            this.m_count     = other.m_count;
            this.m_lastIndex = other.m_lastIndex;
            this.m_freeList  = other.m_freeList;
            this.m_comparer  = other.m_comparer;
            this.m_version   = other.m_version;
        }
Пример #28
0
 void IPoolableRecycle.OnRecycle()
 {
     PoolArray <DrawMeshViewBase.Item> .Recycle(ref this.items);
 }
Пример #29
0
        public BufferArray <T> Clear()
        {
            PoolArray <T> .Recycle(this);

            return(new BufferArray <T>(null, 0));
        }
Пример #30
0
 void IPoolableRecycle.OnRecycle()
 {
     PoolArray <ParticleViewBase.Item> .Recycle(ref this.items);
 }