Beispiel #1
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;
        }
Beispiel #2
0
        public void HookPageGrafUpdate(On.Menu.SlugcatSelectMenu.SlugcatPage.orig_GrafUpdate orig, SlugcatSelectMenu.SlugcatPage instance, float timeStacker)
        {
            float num   = instance.Scroll(timeStacker);
            float num2  = instance.UseAlpha(timeStacker);
            float depth = instance.slugcatDepth;

            if (instance.HasMark)
            {
                float num3 = Mathf.Lerp(instance.lastMarkAlpha, instance.markAlpha, timeStacker) * num2;
                if (instance.slugcatNumber == 2)
                {
                    num3 *= ((!(instance is SlugcatSelectMenu.SlugcatPageContinue)) ? 0f : Mathf.Pow(Mathf.InverseLerp(4f, 14f, (float)(instance as SlugcatSelectMenu.SlugcatPageContinue).saveGameData.cycle), 3.5f));
                }
                Vector2 a = new Vector2(instance.MidXpos + num * instance.ScrollMagnitude, instance.imagePos.y + 150f) + instance.markOffset;
                a -= instance.slugcatImage.CamPos(timeStacker) * 80f / depth;
                a -= new Vector2(0, artOffset);
                instance.markSquare.x     = a.x;
                instance.markSquare.y     = a.y;
                instance.markSquare.alpha = Mathf.Pow(num3, 0.75f);
                instance.markGlow.x       = a.x;
                instance.markGlow.y       = a.y;
                instance.markGlow.scale   = Mathf.Lerp(3f, 3.3f, Mathf.Pow(num3, 0.2f)) + ((!instance.HasGlow) ? 0f : -0.5f) + Mathf.Lerp(-0.1f, 0.1f, UnityEngine.Random.value) * instance.markFlicker;
                instance.markGlow.alpha   = ((instance.slugcatNumber != 0) ? 0.6f : 0.4f) * Mathf.Pow(num3, 0.75f);
            }
            if (instance.HasGlow)
            {
                float   num4 = Mathf.Lerp(0.8f, 1f, Mathf.Lerp(instance.lastGlowAlpha, instance.glowAlpha, timeStacker)) * num2 * Mathf.Lerp(instance.lastInposition, instance.inPosition, timeStacker);
                Vector2 a2   = new Vector2(instance.MidXpos + num * instance.ScrollMagnitude, instance.imagePos.y) + instance.glowOffset;
                a2 -= instance.slugcatImage.CamPos(timeStacker) * 80f / depth;
                a2 -= new Vector2(0, artOffset);
                instance.glowSpriteB.color = Color.Lerp(instance.effectColor, new Color(1f, 1f, 1f), 0.3f * num4);
                instance.glowSpriteB.x     = a2.x;
                instance.glowSpriteB.y     = a2.y;
                instance.glowSpriteB.scale = Mathf.Lerp(20f, 38f, Mathf.Pow(num4, 0.75f));
                instance.glowSpriteB.alpha = Mathf.Pow(num4, 0.25f) * Mathf.Lerp(0.394f, 0.406f, UnityEngine.Random.value * (1f - Mathf.Lerp(instance.lastGlowAlpha, instance.glowAlpha, timeStacker)));
                instance.glowSpriteA.color = Color.Lerp(instance.effectColor, new Color(1f, 1f, 1f), 0.9f * num4);
                instance.glowSpriteA.x     = a2.x;
                instance.glowSpriteA.y     = a2.y;
                instance.glowSpriteA.scale = Mathf.Lerp(10f, 17f, Mathf.Pow(num4, 1.2f));
                instance.glowSpriteA.alpha = num4 * 0.6f;
            }
            for (int i = 0; i < instance.slugcatImage.depthIllustrations.Count; i++)
            {
                Vector2 a3 = instance.slugcatImage.depthIllustrations[i].pos;
                a3   -= new Vector2(0, artOffset);
                a3   -= instance.slugcatImage.CamPos(timeStacker) * 80f / instance.slugcatImage.depthIllustrations[i].depth;
                a3   += instance.sceneOffset;
                a3.x += num * instance.ScrollMagnitude;
                instance.slugcatImage.depthIllustrations[i].sprite.x     = a3.x;
                instance.slugcatImage.depthIllustrations[i].sprite.y     = a3.y;
                instance.slugcatImage.depthIllustrations[i].sprite.alpha = instance.slugcatImage.depthIllustrations[i].alpha * num2;
            }
            for (int j = 0; j < instance.slugcatImage.flatIllustrations.Count; j++)
            {
                Vector2 a4 = instance.slugcatImage.flatIllustrations[j].pos;
                a4   -= new Vector2(0, artOffset);
                a4   += instance.sceneOffset;
                a4.x += num * instance.ScrollMagnitude;
                instance.slugcatImage.flatIllustrations[j].sprite.x     = a4.x;
                instance.slugcatImage.flatIllustrations[j].sprite.y     = a4.y;
                instance.slugcatImage.flatIllustrations[j].sprite.alpha = instance.slugcatImage.flatIllustrations[j].alpha * num2;
            }

            if (instance.slugcatImage.depthIllustrations.Count > 0)
            {
                int lastIndex = instance.slugcatImage.depthIllustrations.Count - 1;

                if (customArtSprite != null)
                {
                    customArtSprite.RemoveFromContainer();
                    Vector2 a3 = new Vector2(Futile.screen.width / 2, Futile.screen.height / 2);
                    a3 += new Vector2(0, (Futile.screen.height * 2) - artOffset);
                    customArtSprite.x      = a3.x;
                    customArtSprite.y      = a3.y;
                    customArtSprite.width  = 400f;
                    customArtSprite.height = 400f;
                    customArtSprite.y     += customArtSprite.height / 6;
                    instance.slugcatImage.depthIllustrations[lastIndex].sprite.container.AddChild(customArtSprite);
                    customArtSprite.MoveToBack();
                    customArtSprite.MoveInFrontOfOtherNode(instance.slugcatImage.depthIllustrations[lastIndex].sprite);
                }
            }
        }
Beispiel #3
0
        // Change some data associated with custom slugcat pages
        private static void SlugcatPage_ctor(On.Menu.SlugcatSelectMenu.SlugcatPage.orig_ctor orig, SlugcatSelectMenu.SlugcatPage self, Menu.Menu menu, MenuObject owner, int pageIndex, int slugcatNumber)
        {
            orig(self, menu, owner, pageIndex, slugcatNumber);
            SlugBaseCharacter ply = PlayerManager.GetCustomPlayer(pageIndex);

            if (ply != null)
            {
                self.colorName   = ply.Name;
                self.effectColor = ply.SlugcatColor() ?? Color.white;
            }
        }