Example #1
0
        protected virtual async UniTask RollbackToStateAsync(GameStateMap state)
        {
            rollbackTaskQueue.Enqueue(state);
            OnRollbackStarted?.Invoke();

            while (rollbackTaskQueue.Peek() != state)
            {
                await AsyncUtils.WaitEndOfFrame;
            }

            await LoadAllServicesFromStateAsync <IStatefulService <GameStateMap>, GameStateMap>(state);

            await PerformOnGameDeserializeTasksAsync(state);

            rollbackTaskQueue.Dequeue();
            OnRollbackFinished?.Invoke();
        }
Example #2
0
        private async Task RollbackToStateAsync(GameStateMap state)
        {
            rollbackTaskQueue.Enqueue(state);
            OnRollbackStarted?.Invoke();

            while (rollbackTaskQueue.Peek() != state)
            {
                await waitForFrame;
            }

            await LoadAllServicesFromStateAsync <IStatefulService <GameStateMap>, GameStateMap>(state);

            foreach (var task in onGameDeserializeTasks)
            {
                await task(state);
            }

            rollbackTaskQueue.Dequeue();
            OnRollbackFinished?.Invoke();
        }
        private async UniTask RollbackToStateAsync(GameStateMap state)
        {
            rollbackTaskQueue.Enqueue(state);
            OnRollbackStarted?.Invoke();

            while (rollbackTaskQueue.Peek() != state)
            {
                await AsyncUtils.WaitEndOfFrame;
            }

            await LoadAllServicesFromStateAsync <IStatefulService <GameStateMap>, GameStateMap>(state);

            for (int i = onGameDeserializeTasks.Count - 1; i >= 0; i--)
            {
                await onGameDeserializeTasks[i](state);
            }

            rollbackTaskQueue.Dequeue();
            OnRollbackFinished?.Invoke();
        }