Esempio n. 1
0
        void IModuleBase.OnConstruct()
        {
            this.statesHistory = new ME.ECS.Network.StatesHistory <TState>(this.world, this.GetQueueCapacity());
            //this.states = new StatesCircularQueue<TState>(this.GetTicksPerState(), this.GetQueueCapacity());
            this.events = PoolDictionary <Tick, ME.ECS.Collections.SortedList <long, HistoryEvent> > .Spawn(StatesHistoryModule <TState> .POOL_EVENTS_CAPACITY);

            this.syncHash = PoolDictionary <Tick, int> .Spawn(StatesHistoryModule <TState> .POOL_SYNCHASH_CAPACITY);

            PoolSortedList <int, HistoryEvent> .Prewarm(StatesHistoryModule <TState> .POOL_HISTORY_SIZE, StatesHistoryModule <TState> .POOL_HISTORY_CAPACITY);

            this.world.SetStatesHistoryModule(this);
        }
Esempio n. 2
0
        public virtual void OnConstruct()
        {
            this.oldestTick               = Tick.Invalid;
            this.lastSavedStateTick       = Tick.Invalid;
            this.pauseStoreStateSinceTick = Tick.Invalid;

            this.prewarmed           = false;
            this.beginAddEventsCount = 0;
            this.beginAddEvents      = false;
            this.statEventsAdded     = 0;
            this.statPlayedEvents    = 0;

            this.statesHistory = new ME.ECS.Network.StatesHistory <TState>(this.world, this.GetQueueCapacity());
            this.events        = PoolDictionary <Tick, ME.ECS.Collections.SortedList <long, HistoryEvent> > .Spawn(StatesHistoryModule <TState> .POOL_EVENTS_CAPACITY);

            this.syncHashTable = PoolDictionary <Tick, Dictionary <int, int> > .Spawn(StatesHistoryModule <TState> .POOL_SYNCHASH_CAPACITY);

            this.world.SetStatesHistoryModule(this);
        }
Esempio n. 3
0
        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);
        }