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);
        }
Beispiel #2
0
        // Remember to not reference any other engine services to make sure this service is always initialized first.
        // This is required for the post engine initialization tasks to be performed before any others.
        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);

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

            Engine.AddPostInitializationTask(PerformPostEngineInitializationTasks);
        }