//切换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); }
public override void CommunicateWithUpcomingProcess(MainLoopProcess nextProcess) { if (nextProcess.ID == ProcessManager.ProcessID.CustomEndGameScreen) { (nextProcess as CustomEndGameScreen).GetDataFromSleepScreen(this.proceedWithEndgameID.Value); } if (this.IsDeathScreen && nextProcess is RainWorldGame && (nextProcess as RainWorldGame).world != null && (nextProcess as RainWorldGame).world.rainCycle != null) { (nextProcess as RainWorldGame).world.rainCycle.timer = 340; } }
//停止指定辅助Process public void StopSideProcess(MainLoopProcess process) { //移除引用 for (int i = this.sideProcesses.Count - 1; i >= 0; --i) { if (this.sideProcesses[i] == process) { this.sideProcesses.RemoveAt(i); } } //关闭Process process.ShutDownProcess(); }
public override void CommunicateWithUpcomingProcess(MainLoopProcess nextProcess) { orig_CommunicateWithUpcomingProcess(nextProcess); if (nextProcess is MessageScreen) { int karma = this.GetStorySession.saveState.deathPersistentSaveData.karma; Debug.Log("savKarma: " + karma); if (this.sawAGhost > -1) { Debug.Log("Ghost end of process stuff"); this.manager.CueAchievement(GhostWorldPresence.PassageAchievementID((GhostWorldPresence.GhostID) this.sawAGhost), 2f); if (this.GetStorySession.saveState.deathPersistentSaveData.karmaCap == 8) { this.manager.CueAchievement(RainWorld.AchievementID.AllGhostsEncountered, 10f); } this.GetStorySession.saveState.GhostEncounter(this.sawAGhost, this.rainWorld); } int num = karma; if (nextProcess.ID == ProcessManager.ProcessID.DeathScreen && !this.GetStorySession.saveState.deathPersistentSaveData.reinforcedKarma) { num = Custom.IntClamp(num - 1, 0, this.GetStorySession.saveState.deathPersistentSaveData.karmaCap); } Debug.Log("next screen MAP KARMA: " + num); this.cameras[0].hud.map.mapData.UpdateData(this.world, 1 + this.GetStorySession.saveState.deathPersistentSaveData.foodReplenishBonus, num, this.GetStorySession.saveState.deathPersistentSaveData.karmaFlowerPosition, true); int num2 = this.Players[0].pos.room; Vector2 vector = this.Players[0].pos.Tile.ToVector2() * 20f; if (nextProcess.ID == ProcessManager.ProcessID.DeathScreen && this.cameras[0].hud != null && this.cameras[0].hud.textPrompt != null) { num2 = this.cameras[0].hud.textPrompt.deathRoom; vector = this.cameras[0].hud.textPrompt.deathPos; } else if (this.Players[0].realizedCreature != null) { vector = this.Players[0].realizedCreature.mainBodyChunk.pos; } if (this.Players[0].realizedCreature != null && this.Players[0].realizedCreature.room != null && num2 == this.Players[0].realizedCreature.room.abstractRoom.index) { vector = Custom.RestrictInRect(vector, this.Players[0].realizedCreature.room.RoomRect.Grow(50f)); } KarmaLadderScreen.SleepDeathScreenDataPackage package = new KarmaLadderScreen.SleepDeathScreenDataPackage((nextProcess.ID != ProcessManager.ProcessID.SleepScreen && nextProcess.ID != ProcessManager.ProcessID.Dream) ? this.cameras[0].hud.textPrompt.foodInStomach : this.GetStorySession.saveState.food, new IntVector2(karma, this.GetStorySession.saveState.deathPersistentSaveData.karmaCap), this.GetStorySession.saveState.deathPersistentSaveData.reinforcedKarma, num2, vector, this.cameras[0].hud.map.mapData, this.GetStorySession.saveState, this.GetStorySession.characterStats, this.GetStorySession.playerSessionRecords[0], this.GetStorySession.saveState.lastMalnourished, this.GetStorySession.saveState.malnourished); (nextProcess as MessageScreen).GetDataFromGame(((this.GetStorySession.saveState.dreamsState as patch_DreamsState).everSeenMissonComplete), ((this.GetStorySession.saveState.dreamsState as patch_DreamsState).everSeenTraitor), this.GetStorySession.saveState.dreamsState.UpcomingDreamID, package); } }
// Use this for initialization void Start() { FutileParams futileParams = new FutileParams(true, true, true, true); futileParams.AddResolutionLevel(windowRes.x, 1f, 1f, string.Empty); futileParams.origin = new Vector2(0f, 0f); Futile.instance.Init(futileParams); Futile.displayScale = 1f; // Load Resources Futile.atlasManager.LoadAtlas("Atlases/mainAtlas"); Futile.atlasManager.LoadAtlas("Atlases/fontAtlas"); Futile.atlasManager.LoadFont("Raleway32", "Raleway32", "Atlases/Raleway32", 0f, 0f); Futile.atlasManager.LoadFont("Raleway24", "Raleway24", "Atlases/Raleway24", 0f, 0f); Futile.atlasManager.LoadFont("Raleway16", "Raleway16", "Atlases/Raleway16", 0f, 0f); LoadConfigFile(); projectScrollOff = ProjectIcon.size * 0.5f; ProjectMigrator migrate = new ProjectMigrator(); activeProcess = new ProjectsProcess(); }
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; }
public new void UpdateMusicContext(MainLoopProcess currentProcess) { this.musicContext = MusicPlayer.MusicContext.Menu; }
private static void MainLoopProcess_Update(On.MainLoopProcess.orig_Update orig, MainLoopProcess self) { orig(self); CustomWorldMod.scripts.RemoveAll(x => x == null); for (int i = CustomWorldMod.scripts.Count - 1; i >= 0; i--) { CustomWorldScript script = CustomWorldMod.scripts[i]; { if (script != null) { if (script.readyToDelete) { script.Clear(); CustomWorldMod.scripts.Remove(script); script = null; CustomWorldMod.Log($"Scripts count [{CustomWorldMod.scripts.Count}]"); } else { script.Update(); } } } } }
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; }
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; }
public virtual void CommunicateWithUpcomingProcess(MainLoopProcess nextProcess) { }
private static void MainLoopProcess_Update(On.MainLoopProcess.orig_Update orig, MainLoopProcess self) { CustomWorldMod.scripts.RemoveAll(x => x == null); //foreach(CustomRegionScript script in CustomWorldMod.scripts) for (int i = CustomWorldMod.scripts.Count - 1; i >= 0; i--) { CustomWorldScript script = CustomWorldMod.scripts[i]; { if (script != null) { if (script.readyToDelete) { script.Clear(); //CustomWorldMod.Log($"Destroying script [{script.name}]"); //UnityEngine.Object.Destroy(script); CustomWorldMod.scripts.Remove(script); script = null; CustomWorldMod.Log($"Scripts count [{CustomWorldMod.scripts.Count}]"); } else { script.Update(); } } } } }
public extern void orig_CommunicateWithUpcomingProcess(MainLoopProcess nextProcess);
// Plug a memory leak private static void MainLoopProcess_ShutDownProcess(On.MainLoopProcess.orig_ShutDownProcess orig, MainLoopProcess self) { orig(self); updateDelegates.Clear(); }