private static void MenuScene_AddIllustration(On.Menu.MenuScene.orig_AddIllustration orig, MenuScene self, MenuIllustration newIllu) { SlugBaseCharacter chara = PlayerManager.GetCustomPlayer(self.menu.manager.rainWorld.progression.miscProgressionData.currentlySelectedSinglePlayerSlugcat); if (newIllu.fileName == "Sleep - 2 - Red" && chara != null && !chara.HasScene("SleepScreen") && ((self.menu as SleepAndDeathScreen)?.IsSleepScreen ?? false) && newIllu is MenuDepthIllustration mdi) { string folder = string.Concat(new object[] { "Scenes", Path.DirectorySeparatorChar, "Sleep Screen - White", }); newIllu.RemoveSprites(); newIllu = new MenuDepthIllustration(newIllu.menu, newIllu.owner, folder, "Sleep - 2 - White", new Vector2(677f, 63f), mdi.depth, mdi.shader); moveImages.Add(new KeyValuePair <MenuDepthIllustration, Vector2>((MenuDepthIllustration)newIllu, new Vector2(677f, 63f))); } orig(self, newIllu); }
private static void MenuScene_BuildScene(On.Menu.MenuScene.orig_BuildScene orig, MenuScene self) { // Automatically override scenes if the current character has a scene by the same name SlugBaseCharacter currentPlayer; if (PlayerManager.UsingCustomCharacter) { currentPlayer = PlayerManager.CurrentCharacter; } else { int index; if (self.menu.manager.currentMainLoop is RainWorldGame rwg) { index = rwg.StoryCharacter; } else { index = self.menu.manager.rainWorld.progression.PlayingAsSlugcat; } currentPlayer = PlayerManager.GetCustomPlayer(index); } if (currentPlayer != null) { string sceneName = self.sceneID.ToString(); if (sceneOverride == null && currentPlayer.HasScene(sceneName)) { OverrideNextScene(currentPlayer, sceneName); } } if (sceneOverride != null) { try { self.sceneFolder = resourceFolderName; // Check for flatmode support bool hasFlatmode = false; foreach (var img in sceneOverride.Images) { if (img.HasTag("FLATMODE")) { hasFlatmode = true; break; } } // Load all images into the scene for (int imgIndex = 0; imgIndex < sceneOverride.Images.Count; imgIndex++) { var img = sceneOverride.Images[imgIndex]; // Hide disabled images if (!img.Enabled) { continue; } // Allow images to use their own sprites if (!img.OnBuild(self)) { continue; } // Skip this image if it is flatmode only and flatmode is disabled, and vice versa bool flat = img.depth < 0f; bool flatmodeOnly = hasFlatmode && img.HasTag("flatmode"); if (hasFlatmode && (self.flatMode != flatmodeOnly)) { continue; } // Parse alpha float alpha = img.GetProperty <float?>("alpha") ?? 1f; string assetPath = $"{sceneOverride.Owner.Name}\\Scenes\\{sceneOverride.Name}\\{img.assetName}"; Vector2 pos = img.Pos; bool crisp = img.HasTag("CRISP"); string shaderName = img.GetProperty <string>("shader"); FShader shader = null; MenuIllustration illust; if (flat) { // It's Friday // Parse shader if (shaderName != null) { if (!self.menu.manager.rainWorld.Shaders.TryGetValue(shaderName, out shader)) { shader = null; } } // Add a flat illustration illust = new MenuIllustration(self.menu, self, self.sceneFolder, assetPath, pos, crisp, false); if (shader != null) { illust.sprite.shader = shader; } } else { // Parse shader MenuDepthIllustration.MenuShader menuShader = MenuDepthIllustration.MenuShader.Normal; if (shaderName != null) { try { menuShader = Custom.ParseEnum <MenuDepthIllustration.MenuShader>(shaderName); shader = null; } catch { if (!self.menu.manager.rainWorld.Shaders.TryGetValue(shaderName, out shader)) { shader = null; } menuShader = MenuDepthIllustration.MenuShader.Normal; } } // Add an illustration with depth illust = new MenuDepthIllustration(self.menu, self, self.sceneFolder, assetPath, pos, img.Depth, menuShader); // Apply crisp pixels if (crisp) { illust.sprite.element.atlas.texture.filterMode = FilterMode.Point; } } // Add idle depths if (self is InteractiveMenuScene ims) { ims.idleDepths = new List <float>(); List <object> depths = sceneOverride.GetProperty <List <object> >("idledepths"); if (depths != null) { for (int i = 0; i < depths.Count; i++) { if (depths[i] is double depth) { ims.idleDepths.Add((float)depth); } } } } // Apply tags if (shader != null) { illust.sprite.shader = shader; } illust.setAlpha = alpha; self.AddIllustration(illust); // Link back to the custom scene image customRep[illust] = img; } } finally { ClearSceneOverride(); } } else { orig(self); } }