Пример #1
0
        private async UniTask PerformPostEngineInitializationTasks()
        {
            await LoadSettingsAsync();

            if (!Engine.Initializing)
            {
                return;
            }
            await LoadGlobalAsync();

            if (!Engine.Initializing)
            {
                return;
            }

            if (Configuration.EnableStateRollback)
            {
                InitializeRollback();
            }

            async UniTask LoadSettingsAsync()
            {
                SettingsState = await SettingsSlotManager.LoadOrDefaultAsync(Configuration.DefaultSettingsSlotId);
                await LoadAllServicesFromStateAsync <IStatefulService <SettingsStateMap>, SettingsStateMap>(SettingsState);
            }

            async UniTask LoadGlobalAsync()
            {
                GlobalState = await GlobalSlotManager.LoadOrDefaultAsync(Configuration.DefaultGlobalSlotId);
                await LoadAllServicesFromStateAsync <IStatefulService <GlobalStateMap>, GlobalStateMap>(GlobalState);
            }

            void InitializeRollback()
            {
                scriptPlayer.AddPreExecutionTask(HandleCommandPreExecution);

                rollbackInput = Engine.GetService <IInputManager>().GetRollback();
                if (rollbackInput != null)
                {
                    rollbackInput.OnStart += HandleRollbackInputStart;
                }
            }
        }
Пример #2
0
        public virtual async UniTask InitializeServiceAsync()
        {
            scriptPlayer  = Engine.GetService <IScriptPlayer>();
            cameraManager = Engine.GetService <ICameraManager>();

            if (Configuration.EnableStateRollback)
            {
                scriptPlayer.AddPreExecutionTask(HandleCommandPreExecution);

                rollbackInput = Engine.GetService <IInputManager>().GetRollback();
                if (rollbackInput != null)
                {
                    rollbackInput.OnStart += HandleRollbackInputStart;
                }
            }

            SettingsState = await LoadSettingsAsync();

            GlobalState = await LoadGlobalStateAsync();
        }