//切换MainProcess
    private void SwitchMainProcess(ProcessID ID)
    {
        //获取当前主进程
        MainLoopProcess preMainLoop = this.currentMainLoop;

        if (this.currentMainLoop != null)
        {
            //关闭当前主进程
            this.currentMainLoop.ShutDownProcess();
            this.currentMainLoop.processActive = false;
            this.currentMainLoop = null;

            //GC
            GC.Collect();
            //释放资源引用
            Resources.UnloadUnusedAssets();
        }

        //根据枚举 实例化一个新的Process实例
        switch (ID)
        {
        case ProcessManager.ProcessID.Game:
            this.currentMainLoop = new Game(this);
            break;
        }
        //当前主进程与目标进程 通信
        preMainLoop?.CommunicateWithUpcomingProcess(this.currentMainLoop);
    }
Exemplo n.º 2
0
        public static void ImmediateSwitchCustom(ProcessManager self, MainLoopProcess newProcess)
        {
            MainLoopProcess mainLoopProcess = self.currentMainLoop;

            if (self.currentMainLoop != null)
            {
                self.currentMainLoop.ShutDownProcess();
                self.currentMainLoop.processActive = false;
                self.currentMainLoop = null;
                self.soundLoader.ReleaseAllUnityAudio();
                HeavyTexturesCache.ClearRegisteredFutileAtlases();
                GC.Collect();
                Resources.UnloadUnusedAssets();
            }
            self.rainWorld.progression.Revert();
            self.currentMainLoop = newProcess;
            if (mainLoopProcess != null)
            {
                mainLoopProcess.CommunicateWithUpcomingProcess(self.currentMainLoop);
            }
            self.blackFadeTime = self.currentMainLoop.FadeInTime;
            self.blackDelay    = self.currentMainLoop.InitialBlackSeconds;
            if (self.fadeSprite != null)
            {
                self.fadeSprite.RemoveFromContainer();
                Futile.stage.AddChild(self.fadeSprite);
            }
            if (self.loadingLabel != null)
            {
                self.loadingLabel.RemoveFromContainer();
                Futile.stage.AddChild(self.loadingLabel);
            }
            if (self.musicPlayer != null)
            {
                self.musicPlayer.UpdateMusicContext(self.currentMainLoop);
            }
            self.pauseFadeUpdate = true;
        }
Exemplo n.º 3
0
    private void SwitchMainProcess(ProcessManager.ProcessID ID)
    {
        this.shadersTime = 0f;
        if (ID == ProcessManager.ProcessID.Game && this.menuMic != null)
        {
            this.menuMic = null;
            this.sideProcesses.Remove(this.menuMic);
        }
        else if (ID != ProcessManager.ProcessID.Game && this.menuMic == null)
        {
            this.menuMic = new MenuMicrophone(this, this.soundLoader);
            this.sideProcesses.Add(this.menuMic);
        }
        MainLoopProcess mainLoopProcess = this.currentMainLoop;

        if (this.currentMainLoop != null)
        {
            this.currentMainLoop.ShutDownProcess();
            this.currentMainLoop.processActive = false;
            this.currentMainLoop = null;
            this.soundLoader.ReleaseAllUnityAudio();
            HeavyTexturesCache.ClearRegisteredFutileAtlases();
            System.GC.Collect();
            Resources.UnloadUnusedAssets();
        }
        if (ID != ProcessManager.ProcessID.SleepScreen && ID != ProcessManager.ProcessID.GhostScreen && ID != ProcessManager.ProcessID.DeathScreen && ID != ProcessManager.ProcessID.KarmaToMaxScreen)
        {
            this.rainWorld.progression.Revert();
        }
        switch (ID)
        {
        case ProcessManager.ProcessID.MainMenu:
            this.currentMainLoop = new MainMenu(this, mainLoopProcess != null && mainLoopProcess.ID == ProcessManager.ProcessID.IntroRoll);
            break;

        case ProcessManager.ProcessID.Game:
            this.currentMainLoop = new RainWorldGame(this);
            break;

        case ProcessManager.ProcessID.SleepScreen:
        case ProcessManager.ProcessID.DeathScreen:
        case ProcessManager.ProcessID.StarveScreen:
            this.currentMainLoop = new SleepAndDeathScreen(this, ID);
            break;

        case ProcessManager.ProcessID.RegionSelect:
            this.currentMainLoop = new Menu.RegionSelectMenu(this);
            break;

        case ProcessManager.ProcessID.OptionsMenu:
            this.currentMainLoop = new OptionsMenu(this);
            break;

        case ProcessManager.ProcessID.GhostScreen:
        case ProcessManager.ProcessID.KarmaToMaxScreen:
            this.currentMainLoop = new GhostEncounterScreen(this, ID);
            break;

        case ProcessManager.ProcessID.SlideShow:
            this.currentMainLoop = new SlideShow(this, this.nextSlideshow);
            break;

        case ProcessManager.ProcessID.FastTravelScreen:
        case ProcessManager.ProcessID.RegionsOverviewScreen:
            this.currentMainLoop = new FastTravelScreen(this, ID);
            break;

        case ProcessManager.ProcessID.CustomEndGameScreen:
            this.currentMainLoop = new CustomEndGameScreen(this);
            break;

        case ProcessManager.ProcessID.InputSelect:
            this.currentMainLoop = new InputSelectScreen(this);
            break;

        case ProcessManager.ProcessID.SlugcatSelect:
            this.currentMainLoop = new SlugcatSelectMenu(this);
            break;

        case ProcessManager.ProcessID.IntroRoll:
            this.currentMainLoop = new IntroRoll(this);
            break;

        case ProcessManager.ProcessID.Credits:
            this.currentMainLoop = new EndCredits(this);
            break;

        case ProcessManager.ProcessID.ConsoleOptionsMenu:
            this.currentMainLoop = new ConsoleOptionsMenu(this);
            break;

        case ProcessManager.ProcessID.Dream:
            this.currentMainLoop = new DreamScreen(this);
            break;

        case (ProcessManager.ProcessID)patch_ProcessManager.ProcessID.MessageScreen:
            this.currentMainLoop = new MessageScreen(this);
            break;

        case ProcessManager.ProcessID.MultiplayerMenu:
            this.currentMainLoop = new MultiplayerMenu(this);
            break;

        case ProcessManager.ProcessID.MultiplayerResults:
            this.currentMainLoop = new MultiplayerResults(this);
            break;

        case ProcessManager.ProcessID.InputOptions:
            this.currentMainLoop = new InputOptionsMenu(this);
            break;

        case ProcessManager.ProcessID.Statistics:
            this.currentMainLoop = new StoryGameStatisticsScreen(this);
            break;
        }
        if (mainLoopProcess != null)
        {
            mainLoopProcess.CommunicateWithUpcomingProcess(this.currentMainLoop);
        }
        this.blackFadeTime = this.currentMainLoop.FadeInTime;
        this.blackDelay    = this.currentMainLoop.InitialBlackSeconds;
        if (this.fadeSprite != null)
        {
            this.fadeSprite.RemoveFromContainer();
            Futile.stage.AddChild(this.fadeSprite);
        }
        if (this.loadingLabel != null)
        {
            this.loadingLabel.RemoveFromContainer();
            Futile.stage.AddChild(this.loadingLabel);
        }
        if (this.musicPlayer != null)
        {
            this.musicPlayer.UpdateMusicContext(this.currentMainLoop);
        }
        this.pauseFadeUpdate = true;
    }
Exemplo n.º 4
0
        private static void SwitchMainProcessHK(On.ProcessManager.orig_SwitchMainProcess orig, ProcessManager self, ProcessManager.ProcessID ID)
        {
            if (self.currentMainLoop?.ID == ProcessManager.ProcessID.Game && ID != ProcessManager.ProcessID.Game)
            {
                InGameClear();
            }
            if (!MonklandSteamManager.isInGame)
            {
                orig(self, ID);
                return;
            }

            ProcessManager.ProcessID newID = ID;

            switch (ID)
            {
            case ProcessManager.ProcessID.SleepScreen:
            case ProcessManager.ProcessID.DeathScreen:
            case ProcessManager.ProcessID.StarveScreen:
                break;

            case ProcessManager.ProcessID.GhostScreen:
            case ProcessManager.ProcessID.KarmaToMaxScreen:
            case ProcessManager.ProcessID.SlideShow:
            case ProcessManager.ProcessID.FastTravelScreen:
            case ProcessManager.ProcessID.RegionsOverviewScreen:
            case ProcessManager.ProcessID.Credits:
            case ProcessManager.ProcessID.Statistics:
                newID = ProcessManager.ProcessID.SleepScreen;
                break;

            default: orig(self, ID); return;
            }

            MainLoopProcess mainLoopProcess = self.currentMainLoop;

            self.shadersTime = 0f;
            if (ID == ProcessManager.ProcessID.Game && self.menuMic != null)
            {
                self.menuMic = null;
                self.sideProcesses.Remove(self.menuMic);
            }
            else if (ID != ProcessManager.ProcessID.Game && self.menuMic == null)
            {
                self.menuMic = new MenuMicrophone(self, self.soundLoader);
                self.sideProcesses.Add(self.menuMic);
            }
            if (self.currentMainLoop != null)
            {
                self.currentMainLoop.ShutDownProcess();
                self.currentMainLoop.processActive = false;
                self.currentMainLoop = null;
                self.soundLoader.ReleaseAllUnityAudio();
                HeavyTexturesCache.ClearRegisteredFutileAtlases();
                GC.Collect();
                Resources.UnloadUnusedAssets();
            }
            if (ID != ProcessManager.ProcessID.SleepScreen && ID != ProcessManager.ProcessID.GhostScreen &&
                ID != ProcessManager.ProcessID.DeathScreen && ID != ProcessManager.ProcessID.KarmaToMaxScreen)
            {
                self.rainWorld.progression.Revert();
            }

            self.currentMainLoop = new MultiplayerSleepAndDeathScreen(self, newID);

            if (mainLoopProcess != null)
            {
                mainLoopProcess.CommunicateWithUpcomingProcess(self.currentMainLoop);
            }
            self.blackFadeTime = self.currentMainLoop.FadeInTime;
            self.blackDelay    = self.currentMainLoop.InitialBlackSeconds;
            if (self.fadeSprite != null)
            {
                self.fadeSprite.RemoveFromContainer();
                Futile.stage.AddChild(self.fadeSprite);
            }
            if (self.loadingLabel != null)
            {
                self.loadingLabel.RemoveFromContainer();
                Futile.stage.AddChild(self.loadingLabel);
            }
            if (self.musicPlayer != null)
            {
                self.musicPlayer.UpdateMusicContext(self.currentMainLoop);
            }
            self.pauseFadeUpdate = true;
        }