private static void MenuIllustration_LoadFile_1(On.Menu.MenuIllustration.orig_LoadFile_1 orig, Menu.MenuIllustration self, string folder) { if (folder.Contains("CustomResources")) { try { CustomWorldMod.Log($"Custom Regions: Loading custom resources at MenuIllustration. Folder [{folder}] and fileName [{self.fileName}]"); self.www = new WWW(string.Concat(new object[] { "file:///", Custom.RootFolderDirectory(), folder, Path.DirectorySeparatorChar, self.fileName, ".png" })); self.texture = new Texture2D(1, 1, TextureFormat.ARGB32, false); self.texture.wrapMode = TextureWrapMode.Clamp; if (self.crispPixels) { self.texture.anisoLevel = 0; self.texture.filterMode = FilterMode.Point; } self.www.LoadImageIntoTexture(self.texture); HeavyTexturesCache.LoadAndCacheAtlasFromTexture(self.fileName, self.texture); self.www = null; } catch (Exception e) { CustomWorldMod.Log($"Custom Regions: Failed loading textures for {folder} - {self.fileName} " + e); } } else { orig(self, folder); } }
public override void ShutDownProcess() { base.ShutDownProcess(); if (this.fadeSprite != null) { this.fadeSprite.RemoveFromContainer(); } this.manager.soundLoader.ReleaseAllUnityAudio(); this.processActive = false; this.manager.currentMainLoop = null; this.manager.soundLoader.ReleaseAllUnityAudio(); HeavyTexturesCache.ClearRegisteredFutileAtlases(); GC.Collect(); Resources.UnloadUnusedAssets(); this.manager.menuMic = new MenuMicrophone(this.manager, this.manager.soundLoader); this.manager.sideProcesses.Add(this.manager.menuMic); //base.PlaySound(SoundID.HUD_Exit_Game); OptionsMenuPatch.mod = true; if (this.manager.musicPlayer != null) { UnityEngine.GameObject.Destroy(this.manager.musicPlayer.gameObj); this.manager.musicPlayer.song?.StopAndDestroy(); this.manager.musicPlayer.ShutDownProcess(); this.manager.sideProcesses.Remove(this.manager.musicPlayer); } this.manager.musicPlayer = new Music.MusicPlayer(this.manager); this.manager.sideProcesses.Add(this.manager.musicPlayer); OptionsMenuPatch.modmenu = new ConfigMenu(this.manager); this.manager.currentMainLoop = OptionsMenuPatch.modmenu; OptionsMenuPatch.modmenu.OpenMenu(); }
// Add SlugBase character resources as a "virtual file" that illustrations may be read from // Folder: "SlugBase Resources" // File: "PlayerName\Dir1\Dir2\...\DirN\Image.png" private static void MenuIllustration_LoadFile_1(On.Menu.MenuIllustration.orig_LoadFile_1 orig, Menu.MenuIllustration self, string folder) { Texture2D customTex; if (folder == resourceFolderName && ((customTex = LoadTextureFromResources(self.fileName)) != null)) { self.texture = customTex; self.texture.wrapMode = TextureWrapMode.Clamp; if (self.crispPixels) { self.texture.anisoLevel = 0; self.texture.filterMode = FilterMode.Point; } HeavyTexturesCache.LoadAndCacheAtlasFromTexture(self.fileName, self.texture); return; } else { orig(self, folder); } }
private static void CustomIllustLoad(MenuIllustration self, string folder) { //Resource Assembly assembly = Assembly.GetExecutingAssembly(); string name = assembly.GetManifestResourceNames().Single(str => str.EndsWith(self.fileName + ".txt")); Debug.Log("LoadingCustomIllustration: " + name); string s; using (Stream manifestResourceStream = assembly.GetManifestResourceStream(name)) { using (StreamReader streamReader = new StreamReader(manifestResourceStream)) { s = streamReader.ReadToEnd(); } } byte[] data = Convert.FromBase64String(s); string text = Custom.RootFolderDirectory() + self.fileName + ".txt"; File.WriteAllBytes(text, data); self.www = new WWW("file:///" + text); //Apply self.texture = new Texture2D(1, 1, TextureFormat.ARGB32, false); self.texture.wrapMode = TextureWrapMode.Clamp; if (self.crispPixels) { self.texture.anisoLevel = 0; self.texture.filterMode = FilterMode.Point; } self.www.LoadImageIntoTexture(self.texture); HeavyTexturesCache.LoadAndCacheAtlasFromTexture(self.fileName, self.texture); self.www = null; File.Delete(text); }
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; }
// Token: 0x06000E40 RID: 3648 RVA: 0x00096624 File Offset: 0x00094824 public BattleRoomRain(Room rm) { if (rm.waterObject != null) { rm.waterObject.fWaterLevel = rm.waterObject.originalWaterLevel + this.flood; } this.dangerType = DangerType.FloodAndRain; if (rm.abstractRoom.shelter) { this.dangerType = BattleRoomRain.DangerType.Flood; } this.splashTiles = new List <IntVector2>(); this.rainReach = new int[rm.TileWidth]; this.shelterTex = new Texture2D(rm.TileWidth, rm.TileHeight); for (int i = 0; i < rm.TileWidth; i++) { bool flag = true; for (int j = rm.TileHeight - 1; j >= 0; j--) { if (flag && rm.GetTile(i, j).Solid) { flag = false; if (j < rm.TileHeight - 1) { this.splashTiles.Add(new IntVector2(i, j)); } this.rainReach[i] = j; } this.shelterTex.SetPixel(i, j, (!flag) ? new Color(0f, 0f, 0f) : new Color(1f, 0f, 0f)); } } if (rm.water) { for (int k = 0; k < rm.TileWidth; k++) { if (!rm.GetTile(k, rm.defaultWaterLevel).Solid) { this.shelterTex.SetPixel(k, rm.defaultWaterLevel, (this.shelterTex.GetPixel(k, rm.defaultWaterLevel).r <= 0.5f) ? new Color(0f, 0f, 1f) : new Color(1f, 0f, 1f)); int num = rm.defaultWaterLevel; while (num < rm.TileHeight && (float)num < (float)rm.defaultWaterLevel + 20f) { if (rm.GetTile(k, num).Solid) { break; } this.shelterTex.SetPixel(k, num + 1, (this.shelterTex.GetPixel(k, num + 1).r <= 0.5f) ? new Color(0f, 0f, 1f) : new Color(1f, 0f, 1f)); num++; } } } } else { bool flag2 = false; for (int l = 0; l < rm.TileWidth; l++) { if (!rm.GetTile(l, 0).Solid) { flag2 = true; this.shelterTex.SetPixel(l, 0, (this.shelterTex.GetPixel(l, 0).r <= 0.5f) ? new Color(0f, 0f, 1f) : new Color(1f, 0f, 1f)); } } if (flag2) { rm.deathFallGraphic = new DeathFallGraphic(); rm.AddObject(rm.deathFallGraphic); } } this.shelterTex.wrapMode = TextureWrapMode.Clamp; HeavyTexturesCache.LoadAndCacheAtlasFromTexture("RainMask_" + rm.abstractRoom.name, this.shelterTex); this.shelterTex.Apply(); this.splashes = this.splashTiles.Count * 2 / rm.cameraPositions.Length; if (this.intensity > 0f) { this.lastIntensity = 0f; } else { this.lastIntensity = 1f; } this.bulletDrips = new List <BulletDrip>(); if (this.dangerType != BattleRoomRain.DangerType.Flood) { this.normalRainSound = new DisembodiedDynamicSoundLoop(this); this.normalRainSound.sound = SoundID.Normal_Rain_LOOP; this.normalRainSound.VolumeGroup = 3; this.heavyRainSound = new DisembodiedDynamicSoundLoop(this); this.heavyRainSound.sound = SoundID.Heavy_Rain_LOOP; this.heavyRainSound.VolumeGroup = 3; } this.deathRainSound = new DisembodiedDynamicSoundLoop(this); this.deathRainSound.sound = ((this.dangerType == BattleRoomRain.DangerType.Flood) ? SoundID.Death_Rain_Heard_From_Underground_LOOP : SoundID.Death_Rain_LOOP); this.deathRainSound.VolumeGroup = 3; this.rumbleSound = new DisembodiedDynamicSoundLoop(this); this.rumbleSound.sound = SoundID.Death_Rain_Rumble_LOOP; this.rumbleSound.VolumeGroup = 3; if (this.dangerType != BattleRoomRain.DangerType.Rain) { this.floodingSound = new DisembodiedDynamicSoundLoop(this); this.floodingSound.sound = SoundID.Flash_Flood_LOOP; this.floodingSound.VolumeGroup = ((this.dangerType != BattleRoomRain.DangerType.Flood) ? 0 : 3); } this.distantDeathRainSound = new DisembodiedDynamicSoundLoop(this); this.distantDeathRainSound.sound = ((this.dangerType == BattleRoomRain.DangerType.Flood) ? SoundID.Death_Rain_Approaching_Heard_From_Underground_LOOP : SoundID.Death_Rain_Approaching_LOOP); this.SCREENSHAKESOUND = new DisembodiedDynamicSoundLoop(this); this.SCREENSHAKESOUND.sound = SoundID.Screen_Shake_LOOP; }
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; }