public bool UnRegisterGroup(int groupId) { var foundAny = false; var newObjectToKey = PoolDictionary <object, Key> .Spawn(100); foreach (var item in this.objectToKey) { if (item.Value.groupId == groupId) { var keyData = item.Value; var key = MathUtils.GetKey(keyData.groupId, keyData.objId); var foundInside = false; object obj; if (this.keyToObjects.TryGetValue(key, out obj) == true) { var found = this.keyToObjects.Remove(key); if (found == true) { foundInside = true; foundAny = true; } } if (foundInside == false) { newObjectToKey.Add(item.Key, item.Value); } } } PoolDictionary <object, Key> .Recycle(ref this.objectToKey); this.objectToKey = newObjectToKey; return(foundAny); }
void IModuleBase.OnDeconstruct() { this.OnDeInitialize(); this.replayMode = default; this.asyncMode = default; this.localOrderIndex = default; this.rpcId = default; this.ping = default; this.pingTime = default; this.syncTime = default; this.syncedTick = default; this.syncHash = default; this.syncTickSent = default; this.revertingTo = default; this.isReverting = default; this.currentObjectRegistryId = default; this.world.SetNetworkModule(null); this.statesHistoryModule = null; this.UnRegisterObject(this, -1); this.currentObjectRegistryId = 1000; PoolHashSet <int> .Recycle(ref this.runLocalOnly); PoolDictionary <long, object> .Recycle(ref this.keyToObjects); PoolDictionary <object, Key> .Recycle(ref this.objectToKey); PoolDictionary <int, System.Reflection.MethodInfo> .Recycle(ref this.registry); }
void IModule <TState> .OnDeconstruct() { PoolDictionary <long, object> .Recycle(ref this.keyToObjects); PoolDictionary <object, Key> .Recycle(ref this.objectToKey); PoolDictionary <int, System.Reflection.MethodInfo> .Recycle(ref this.registry); }
void IModuleBase.OnDeconstruct() { this.UnRegisterObject(this, -1); PoolDictionary <long, object> .Recycle(ref this.keyToObjects); PoolDictionary <object, Key> .Recycle(ref this.objectToKey); PoolDictionary <int, System.Reflection.MethodInfo> .Recycle(ref this.registry); }
void IModuleBase.OnDeconstruct() { this.OnDeInitialize(); this.UnRegisterObject(this, -1); this.currentObjectRegistryId = 1000; PoolHashSet <int> .Recycle(ref this.runLocalOnly); PoolDictionary <long, object> .Recycle(ref this.keyToObjects); PoolDictionary <object, Key> .Recycle(ref this.objectToKey); PoolDictionary <int, System.Reflection.MethodInfo> .Recycle(ref this.registry); }
public override void CopyFrom(State other) { base.CopyFrom(other); var _other = (ExampleState)other; if (this.playerEntities != null) { PoolDictionary <int, Entity> .Recycle(ref this.playerEntities); } this.playerEntities = PoolDictionary <int, Entity> .Spawn(_other.playerEntities.Count); foreach (var item in _other.playerEntities) { this.playerEntities.Add(item.Key, item.Value); } }
public void Reset() { this.oldestTick = Tick.Invalid; this.lastSavedStateTick = Tick.Invalid; foreach (var item in this.syncHashTable) { PoolDictionary <int, int> .Recycle(item.Value); } this.syncHashTable.Clear(); this.statesHistory.DiscardAll(); this.statesHistory.Clear(); foreach (var item in this.events) { PoolSortedList <long, HistoryEvent> .Recycle(item.Value); } this.events.Clear(); }
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; }
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); }
public void Dispose() { if (Serializers.initialized.TryGetValue(this.id, out var state) == false || state == false) { return; } if (this.serializers != null) { PoolDictionary <System.Type, Item> .Recycle(ref this.serializers); } if (this.serializersBaseType != null) { PoolDictionary <System.Type, Item> .Recycle(ref this.serializersBaseType); } if (this.serializersByTypeValue != null) { PoolDictionary <byte, Item> .Recycle(ref this.serializersByTypeValue); } Serializers.initialized.Remove(this.id); }
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; }
private void CleanUpHashTable(Tick beforeTick) { var list = PoolList <Tick> .Spawn(this.syncHashTable.Count); foreach (var kv in this.syncHashTable) { if (kv.Key <= beforeTick) { list.Add(kv.Key); } } for (int i = 0; i < list.Count; ++i) { var key = list[i]; var arr = this.syncHashTable[key]; PoolDictionary <int, int> .Recycle(arr); this.syncHashTable.Remove(key); } PoolList <Tick> .Recycle(ref list); }
public override void OnRecycle() { base.OnRecycle(); PoolDictionary <int, Entity> .Recycle(ref this.playerEntities); }
public override void ApplyBeforeConnections(Graph graph) { var navMeshGraph = graph as NavMeshGraph; var graphBounds = new Bounds(navMeshGraph.graphCenter, navMeshGraph.size); var graphHeightMin = navMeshGraph.minHeight; var graphHeightMax = navMeshGraph.maxHeight; var cache = PoolDictionary <int, Item> .Spawn(100); var obstacles = PoolDictionary <int, System.Collections.Generic.List <Bounds> > .Spawn(3); foreach (var item in this.items) { cache.Add(item.requiredTile == null ? 0 : item.requiredTile.GetInstanceID(), item); } foreach (var pos in this.bounds.allPositionsWithin) { var worldPosition = this.tilemap.GetCellCenterWorld(pos) - this.tilemap.layoutGrid.cellGap; if (graphBounds.Contains(worldPosition) == false) { continue; } var tile = this.tilemap.GetTile(pos); var id = tile == null ? 0 : tile.GetInstanceID(); if (cache.TryGetValue(id, out var item) == true) { if (obstacles.TryGetValue(item.tag, out var list) == false) { list = new System.Collections.Generic.List <Bounds>(); obstacles[item.tag] = PoolList <Bounds> .Spawn(100); } list.Add(new Bounds(worldPosition, new Vector3(item.customSize == true ? item.size.x : this.tilemap.layoutGrid.cellSize.x, item.customSize == true ? item.size.y : this.tilemap.layoutGrid.cellSize.y, item.height))); if (item.height < graphHeightMin) { graphHeightMin = item.height; } if (item.height > graphHeightMax) { graphHeightMax = item.height; } } } foreach (var kv in obstacles) { var count = kv.Value.Count; BoundsCompressor.CompressBounds(kv.Value, 0.05f); UnityEngine.Debug.Log($"Obstacles bounds compress from {count} to {kv.Value.Count}"); foreach (var obstacle in kv.Value) { var source = new UnityEngine.AI.NavMeshBuildSource { area = kv.Key, shape = UnityEngine.AI.NavMeshBuildSourceShape.Box, transform = Matrix4x4.TRS(obstacle.center, this.tilemap.transform.rotation, this.tilemap.transform.lossyScale) * this.tilemap.orientationMatrix * this.tilemap.GetTransformMatrix(this.tilemap.WorldToCell(obstacle.center)), size = obstacle.size, }; navMeshGraph.AddBuildSource(source); } PoolList <Bounds> .Recycle(kv.Value); } navMeshGraph.SetMinMaxHeight(graphHeightMin, graphHeightMax); PoolDictionary <int, Item> .Recycle(ref cache); PoolDictionary <int, System.Collections.Generic.List <Bounds> > .Recycle(ref obstacles); }
public void Dispose() { PoolDictionary <int, System.Type> .Recycle(ref this.typeById); PoolDictionary <System.Type, MetaType> .Recycle(ref this.meta); }