コード例 #1
0
 private void SetCrystalHeartSprite(On.Celeste.HeartGem.orig_Awake orig, HeartGem self, Scene scene)
 {
     orig(self, scene);
     if (!self.IsGhost && !self.IsFake)
     {
         var meta = GetModeMetaForAltSide(AreaData.Get((scene as Level).Session.Area));
         if (meta != null)
         {
             var selfdata = new DynData <HeartGem>(self);
             var sprite   = new Sprite(GFX.Game, meta.InWorldHeartIcon);
             sprite.CenterOrigin();
             sprite.AddLoop("idle", "", 0, new int[] { 0 });
             sprite.AddLoop("spin", "", 0.1f, new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
             sprite.AddLoop("fastspin", "", 0.1f);
             sprite.CenterOrigin();
             sprite.OnLoop = delegate(string anim) {
                 if (self.Visible && anim == "spin" && (bool)selfdata["autoPulse"])
                 {
                     Audio.Play("event:/game/general/crystalheart_pulse", self.Position);
                     self.ScaleWiggler.Start();
                     (scene as Level).Displacement.AddBurst(self.Position, 0.35f, 8f, 48f, 0.25f);
                 }
             };
             sprite.Play("spin");
             self.ScaleWiggler.RemoveSelf();
             self.ScaleWiggler = Wiggler.Create(0.5f, 4f, delegate(float f) {
                 sprite.Scale = Vector2.One * (1f + f * 0.25f);
             });
             self.Add(self.ScaleWiggler);
             ((Component)selfdata["sprite"]).RemoveSelf();
             selfdata["sprite"] = sprite;
             self.Add(sprite);
         }
     }
 }
コード例 #2
0
        private void SetCrystalHeartSprite(On.Celeste.HeartGem.orig_Awake orig, HeartGem self, Scene scene)
        {
            orig(self, scene);
            if (!self.IsFake)
            {
                var data = AreaData.Get((scene as Level).Session.Area);
                var meta = GetModeMetaForAltSide(data);
                if (meta != null)
                {
                    Logger.Log("AltSidesHelper", $"In-world heart customisation: found metadata for \"{data.SID}\".");
                    if (meta.OverrideHeartTextures)
                    {
                        Logger.Log("AltSidesHelper", $"Replacing crystal heart texture for \"{data.SID}\".");
                        var selfdata = new DynData <HeartGem>(self);
                        if (!self.IsGhost)
                        {
                            var sprite = new Sprite(GFX.Game, meta.InWorldHeartIcon);
                            sprite.CenterOrigin();
                            sprite.AddLoop("idle", "", 0, new int[] { 0 });
                            sprite.AddLoop("spin", "", 0.1f, new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 });
                            sprite.AddLoop("fastspin", "", 0.1f);
                            sprite.CenterOrigin();
                            sprite.OnLoop = delegate(string anim) {
                                if (self.Visible && anim == "spin" && (bool)selfdata["autoPulse"])
                                {
                                    Audio.Play("event:/game/general/crystalheart_pulse", self.Position);
                                    self.ScaleWiggler.Start();
                                    (scene as Level).Displacement.AddBurst(self.Position, 0.35f, 8f, 48f, 0.25f);
                                }
                            };
                            sprite.Play("spin");
                            self.ScaleWiggler.RemoveSelf();
                            self.ScaleWiggler = Wiggler.Create(0.5f, 4f, delegate(float f) {
                                sprite.Scale = Vector2.One * (1f + f * 0.25f);
                            });
                            self.Add(self.ScaleWiggler);
                            ((Component)selfdata["sprite"]).RemoveSelf();
                            selfdata["sprite"] = sprite;
                            self.Add(sprite);
                        }

                        var colour = Calc.HexToColor(meta.HeartColour);
                        selfdata["shineParticle"] = new ParticleType(HeartGem.P_BlueShine)
                        {
                            Color = colour
                        };

                        selfdata.Get <VertexLight>("light").RemoveSelf();
                        var newLight = new VertexLight(Color.Lerp(colour, Color.White, 0.5f), 1f, 32, 64);
                        self.Add(newLight);
                        selfdata["light"] = newLight;
                    }
                }
            }
        }