Пример #1
0
        public StateManager(StateConfiguration config, EngineConfiguration engineConfig)
        {
            Configuration = config;

            var rollbackCapacity = (config.EnableStateRollback || Application.isEditor || Debug.isDebugBuild) ? Mathf.Max(1, config.StateRollbackSteps) : 1; // One step is reserved for game save operations.

            rollbackStack = new StateRollbackStack(rollbackCapacity);

            var savesFolderPath = PathUtils.Combine(engineConfig.GeneratedDataPath, config.SaveFolderName);

            GameStateSlotManager   = (ISaveSlotManager <GameStateMap>)Activator.CreateInstance(Type.GetType(config.GameStateHandler), config, savesFolderPath);
            GlobalStateSlotManager = (ISaveSlotManager <GlobalStateMap>)Activator.CreateInstance(Type.GetType(config.GlobalStateHandler), config, savesFolderPath);
            SettingsSlotManager    = (ISaveSlotManager <SettingsStateMap>)Activator.CreateInstance(Type.GetType(config.SettingsStateHandler), config, savesFolderPath);

            Engine.AddPostInitializationTask(InitializeStateAsync);
        }
Пример #2
0
        public StateManager(StateConfiguration config, EngineConfiguration engineConfig, InputManager inputManager)
        {
            this.config       = config;
            this.inputManager = inputManager;

            var allowUserRollback = config.StateRollbackMode == StateRollbackMode.Full || (config.StateRollbackMode == StateRollbackMode.Debug && Debug.isDebugBuild);
            var rollbackCapacity  = allowUserRollback ? Mathf.Max(1, config.StateRollbackSteps) : 1; // One step is reserved for game save operations.

            rollbackStateStack = new StateRollbackStack(rollbackCapacity);

            var savesFolderPath = PathUtils.Combine(engineConfig.GeneratedDataPath, config.SaveFolderName);

            GameStateSlotManager   = new GameStateSlotManager(savesFolderPath, config.SaveSlotMask, config.QuickSaveSlotMask, config.SaveSlotLimit, config.QuickSaveSlotLimit, config.BinarySaveFiles);
            GlobalStateSlotManager = new GlobalStateSlotManager(savesFolderPath, config.DefaultGlobalSlotId, config.BinarySaveFiles);
            SettingsSlotManager    = new SettingsSlotManager(engineConfig.GeneratedDataPath, config.DefaultSettingsSlotId, false);
        }
Пример #3
0
        public StateManager(StateConfiguration config, EngineConfiguration engineConfig)
        {
            Configuration = config;

            if (config.EnableStateRollback)
            {
                var rollbackCapacity = Mathf.Max(1, config.StateRollbackSteps);
                RollbackStack = new StateRollbackStack(rollbackCapacity);
            }

            var savesFolderPath = PathUtils.Combine(engineConfig.GeneratedDataPath, config.SaveFolderName);

            GameStateSlotManager   = (ISaveSlotManager <GameStateMap>)Activator.CreateInstance(Type.GetType(config.GameStateHandler), config, savesFolderPath);
            GlobalStateSlotManager = (ISaveSlotManager <GlobalStateMap>)Activator.CreateInstance(Type.GetType(config.GlobalStateHandler), config, savesFolderPath);
            SettingsSlotManager    = (ISaveSlotManager <SettingsStateMap>)Activator.CreateInstance(Type.GetType(config.SettingsStateHandler), config, savesFolderPath);
        }