void IModuleBase.OnConstruct() { this.registry = PoolDictionary <int, System.Reflection.MethodInfo> .Spawn(100); this.objectToKey = PoolDictionary <object, Key> .Spawn(100); this.keyToObjects = PoolDictionary <long, object> .Spawn(100); this.runLocalOnly = PoolHashSet <int> .Spawn(100); this.statesHistoryModule = this.world.GetModule <StatesHistory.IStatesHistoryModule <TState> >(); this.statesHistoryModule.SetEventRunner(this); this.world.SetNetworkModule(this); this.RegisterRPC(NetworkModule <TState> .PING_RPC_ID, new System.Action <double, bool>(this.Ping_RPC).Method); this.RegisterRPC(NetworkModule <TState> .SYNC_RPC_ID, new System.Action <Tick, int>(this.Sync_RPC).Method); this.RegisterObject(this, -1, -1); this.OnInitialize(); }
public virtual void OnDeconstruct() { this.eventRunner = default; this.prewarmed = false; 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.statesHistory = null; 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); }
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); }
void IModuleBase.OnConstruct() { this.replayMode = false; this.asyncMode = false; this.localOrderIndex = 0; this.rpcId = 0; this.ping = 0d; this.pingTime = 0f; this.syncTime = 0f; this.syncedTick = 0; this.syncHash = 0; this.syncTickSent = 0; this.revertingTo = 0; this.isReverting = false; this.registry = PoolDictionary <int, System.Reflection.MethodInfo> .Spawn(100); this.objectToKey = PoolDictionary <object, Key> .Spawn(100); this.keyToObjects = PoolDictionary <long, object> .Spawn(100); this.runLocalOnly = PoolHashSet <int> .Spawn(100); this.currentObjectRegistryId = 1000; this.statesHistoryModule = this.world.GetModule <StatesHistory.IStatesHistoryModule <TState> >(); this.statesHistoryModule.SetEventRunner(this); this.world.SetNetworkModule(this); this.RegisterRPC(NetworkModule <TState> .CANCEL_EVENT_RPC_ID, new System.Action <byte[]>(this.CancelEvent_RPC).Method); this.RegisterRPC(NetworkModule <TState> .PING_RPC_ID, new System.Action <double, bool>(this.Ping_RPC).Method); this.RegisterRPC(NetworkModule <TState> .SYNC_RPC_ID, new System.Action <Tick, int>(this.Sync_RPC).Method); this.RegisterObject(this, -1, -1); this.OnInitialize(); }
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 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.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.Zero; this.lastSavedStateTick = Tick.Zero; 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(); } PoolDictionary <Tick, ME.ECS.Collections.SortedList <long, HistoryEvent> > .Recycle(ref this.events); PoolDictionary <Tick, int> .Recycle(ref this.syncHash); //this.states.Recycle(); //this.states = null; }
private void Init(int capacity) { if (this.id == 0) { this.id = ++Serializers.idIncrement; } if (this.serializers == null) { this.serializers = PoolDictionary <System.Type, Item> .Spawn(capacity); } if (this.serializersBaseType == null) { this.serializersBaseType = PoolDictionary <System.Type, Item> .Spawn(capacity); } if (this.serializersByTypeValue == null) { this.serializersByTypeValue = PoolDictionary <byte, Item> .Spawn(capacity); } if (Serializers.initialized.ContainsKey(this.id) == false) { Serializers.initialized.Add(this.id, true); } }
private void Start() { PoolDictionary.AddPool(minionToSpawn.name, () => SpawnMethod(), 25); }
public override void OnRecycle() { base.OnRecycle(); PoolDictionary <int, Entity> .Recycle(ref this.playerEntities); }
private void Awake() { instance = this; }
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); }