Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        // Override select scenes for SlugBase characters
        private static void SlugcatPage_AddImage(On.Menu.SlugcatSelectMenu.SlugcatPage.orig_AddImage orig, SlugcatSelectMenu.SlugcatPage self, bool ascended)
        {
            SlugBaseCharacter ply = PlayerManager.GetCustomPlayer(self.slugcatNumber);

            // Do not modify scenes for any non-SlugBase slugcats
            if (ply == null)
            {
                orig(self, ascended);
                return;
            }

            // Use Survivor's default scenes on the select menu
            string sceneName = ascended ? "SelectMenuAscended" : "SelectMenu";

            if (!ply.HasScene(sceneName))
            {
                orig(self, ascended);

                // Fix the scene position being off
                if (self.sceneOffset == default(Vector2))
                {
                    self.sceneOffset = new Vector2(-10f, 100f);
                }

                // Fix the wrong scene loading in when ascended
                if (ascended && self.slugcatImage.sceneID == MenuScene.SceneID.Slugcat_White)
                {
                    self.slugcatImage.RemoveSprites();
                    self.RemoveSubObject(self.slugcatImage);

                    self.slugcatImage = new InteractiveMenuScene(self.menu, self, MenuScene.SceneID.Ghost_White);
                    self.subObjects.Add(self.slugcatImage);
                }

                return;
            }

            // Make sure it doesn't crash if the mark or glow is missing
            self.markSquare = new FSprite("pixel")
            {
                isVisible = false
            };
            self.markGlow = new FSprite("pixel")
            {
                isVisible = false
            };
            self.glowSpriteA = new FSprite("pixel")
            {
                isVisible = false
            };
            self.glowSpriteB = new FSprite("pixel")
            {
                isVisible = false
            };


            // This function intentionally does not call the original
            // If this mod has claimed a slot, it seems best to not let other mods try to change this screen

            // Taken from SlugcatPage.AddImage
            self.imagePos    = new Vector2(683f, 484f);
            self.sceneOffset = new Vector2(0f, 0f);


            // Load a custom character's select screen from resources
            CustomScene scene = OverrideNextScene(ply, sceneName, img =>
            {
                if (img.HasTag("MARK") && !self.HasMark)
                {
                    return(false);
                }
                if (img.HasTag("GLOW") && !self.HasGlow)
                {
                    return(false);
                }
                return(true);
            });

            // Parse selectmenux and selectmenuy
            self.sceneOffset.x = scene.GetProperty <float?>("selectmenux") ?? 0f;
            self.sceneOffset.y = scene.GetProperty <float?>("selectmenuy") ?? 0f;
            Debug.Log($"Scene offset for {ply.Name}: {self.sceneOffset}");

            // Slugcat depth, used for positioning the glow and mark
            self.slugcatDepth = scene.GetProperty <float?>("slugcatdepth") ?? 3f;

            // Add mark
            MarkImage mark = new MarkImage(scene, self.slugcatDepth + 0.1f);

            scene.InsertImage(mark);

            // Add glow
            GlowImage glow = new GlowImage(scene, self.slugcatDepth + 0.1f);

            scene.InsertImage(glow);

            try
            {
                self.slugcatImage = new InteractiveMenuScene(self.menu, self, MenuScene.SceneID.Slugcat_White); // This scene will be immediately overwritten
            } finally { ClearSceneOverride(); }
            self.subObjects.Add(self.slugcatImage);

            // Find the relative mark and glow positions
            self.markOffset = mark.Pos - new Vector2(self.MidXpos, self.imagePos.y + 150f) + self.sceneOffset;
            self.glowOffset = glow.Pos - new Vector2(self.MidXpos, self.imagePos.y) + self.sceneOffset;
        }