void HookOnDifficultySelectedMethod()
        {
            originalOnDifficultyChosenMethod = Dynamic._onDifficultyChosen;

            void NewOnDifficultySelectedMethod(GameSave.EGameDifficultyType difficulty)
            {
                if (!seed.HasValue)
                {
                    return;
                }

                originalOnDifficultyChosenMethod(difficulty);

                var loadingScreen = ScreenManager
                                    .GetScreens()
                                    .First(s => s.GetType() == LoadingScreenType)
                                    .AsDynamic();

                var gameplayScreen = ((GameScreen[])loadingScreen._screensToLoad)[0];
                var saveGame       = (GameSave)gameplayScreen.AsDynamic().SaveFile;

                AddSeedAndFillingMethodToSelectedSave(saveGame);

                onDifficultSelected?.Invoke(saveGame);
            }

            Dynamic._onDifficultyChosen = (Action <GameSave.EGameDifficultyType>)NewOnDifficultySelectedMethod;
        }
예제 #2
0
        void AddSeedToSelectedSave()
        {
            var loadingScreen = ScreenManager
                                .GetScreens()
                                .First(s => s.GetType() == LoadingScreenType)
                                .AsDynamic();

            var gameplayScreen = ((GameScreen[])loadingScreen._screensToLoad)[0];
            var saveGame       = (GameSave)gameplayScreen.AsDynamic().SaveFile;

            saveGame.SetSeed(seed.Value);
            saveGame.SetFillingMethod(FillingMethod.Random);
            saveGame.DataKeyStrings["TsRandomizerVersion"] = Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }