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); } } }
private static void customizeParticles(On.Celeste.HeartGem.orig_Awake orig, HeartGem self, Scene scene) { orig(self, scene); if (!self.IsGhost && LobbyHelper.IsHeartSide(self.SceneAs <Level>().Session.Area.GetSID())) { // we are in a heartside: make the heart particles match the heart sprite. DynData <HeartGem> selfData = new DynData <HeartGem>(self); switch (selfData.Get <Sprite>("sprite").Texture.AtlasPath) { case "collectables/heartGem/1/00": selfData["shineParticle"] = HeartGem.P_RedShine; break; case "collectables/heartGem/2/00": selfData["shineParticle"] = HeartGem.P_GoldShine; break; case "CollabUtils2/crystalHeart/expert/00": selfData["shineParticle"] = new ParticleType(HeartGem.P_BlueShine) { Color = Color.Orange }; break; case "CollabUtils2/crystalHeart/grandmaster/00": selfData["shineParticle"] = new ParticleType(HeartGem.P_BlueShine) { Color = Color.DarkViolet }; break; } } }
public HeartGemShard(HeartGem heart, Vector2 position, int index) : base(position) { Heart = heart; heartData = new DynData <HeartGem>(Heart); this.index = index; Depth = Depths.Pickups; Collider = new Hitbox(12f, 12f, -6f, -6f); Add(holdableCollider = new HoldableCollider(OnHoldable)); Add(new PlayerCollider(OnPlayer)); moveWiggler = Wiggler.Create(0.8f, 2f); moveWiggler.StartZero = true; Add(moveWiggler); Add(collectSfx = new SoundSource()); Add(shaker = new Shaker(on: false)); shaker.Interval = 0.1f; // index % 3 determines which third of the heart this piece looks like Add(sprite = new Image(GFX.Game.GetAtlasSubtexturesAt("collectables/CommunalHelper/heartGemShard/shard", index % 3)).CenterOrigin()); Add(outline = new Image(GFX.Game.GetAtlasSubtexturesAt("collectables/CommunalHelper/heartGemShard/shard_outline", index % 3)).CenterOrigin()); Add(scaleWiggler = Wiggler.Create(0.5f, 4f, f => sprite.Scale = Vector2.One * (1f + f * 0.25f))); Add(new BloomPoint(Heart.IsFake ? 0f : 0.75f, 16f)); Add(new MirrorReflection()); }
private void onHeartGemCollect(On.Celeste.HeartGem.orig_Collect orig, HeartGem self, Player player) { orig(self, player); // prevent seekers from slowing down time! if (self.Scene.Entities.OfType <AutoDestroyingSeeker>().Count() != 0) { killSeekerSlowdownToFixHeart = true; } }
private void tellReverseOshirosToStopControllingTime(HeartGem self) { foreach (AngryOshiroRight oshiro in self.Scene.Entities.OfType <AngryOshiroRight>()) { if (oshiro.Any(component => component.GetType() == typeof(AutoDestroyingReverseOshiroModder))) { oshiro.StopControllingTime(); } } }
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; } } } }
private void modHeartGemCollect(On.Celeste.HeartGem.orig_Collect orig, HeartGem self, Player player) { // tell all extended variant Oshiros to stop controlling time foreach (AutoDestroyingAngryOshiro oshiro in self.Scene.Entities.OfType <AutoDestroyingAngryOshiro>()) { oshiro.StopControllingTime(); } // tell all reverse Oshiros spawned by Extended Variants to do the same if (ExtendedVariantsModule.Instance.DJMapHelperInstalled) { tellReverseOshirosToStopControllingTime(self); } orig(self, player); }
private void HeartGem_Collect(On.Celeste.HeartGem.orig_Collect orig, HeartGem self, Player player) { if (Scene == null) { On.Celeste.Player.UseRefill -= Player_UseRefill; On.Celeste.HeartGem.Collect -= HeartGem_Collect; orig(self, player); return; } orig(self, player); RemoveSelf(); ChronosDisplay display; if ((display = player.Scene.Tracker.GetEntity <ChronosDisplay>()) != null) { display.RemoveSelf(); } }
private static void HeartGem_Awake(On.Celeste.HeartGem.orig_Awake orig, HeartGem self, Scene scene) { orig(self, scene); DynData <HeartGem> heartData = new DynData <HeartGem>(self); if (heartData.Data.TryGetValue(HeartGem_HeartGemPieces, out object result)) { if (result is List <HeartGemShard> pieces && pieces.Count > 0 && !(scene as Level).Session.GetFlag(GotShardFlag(heartData))) { foreach (HeartGemShard piece in pieces) { scene.Add(piece); } self.Visible = false; self.Active = false; self.Collidable = false; heartData.Get <BloomPoint>("bloom").Visible = heartData.Get <VertexLight>("light").Visible = false; } } }
public CSGEN_HeartGemShards(HeartGem heart) : base(true, false) { this.heart = heart; heartData = new DynData <HeartGem>(heart); }
private static void HeartGem_OnPlayer(On.Celeste.HeartGem.orig_OnPlayer orig, HeartGem self, Player player) { if (self is MultiDashHeartGem gem) { Console.WriteLine("IsMultiDashHeartGem"); if (player.DashAttacking) { if (!gem.baseData.Get <bool>("collected") && !gem.SceneAs <Level>().Frozen) { if (gem.health > 1) { if (gem.baseData.Get <float>("bounceSfxDelay") <= 0f) { Audio.Play(SFX.game_gen_crystalheart_bounce, gem.Position); gem.baseData["bounceSfxDelay"] = 0.1f; } player.PointBounce(self.Center); gem.baseData.Get <Wiggler>("moveWiggler").Start(); gem.ScaleWiggler.Start(); gem.baseData["moveWiggleDir"] = (gem.Center - player.Center).SafeNormalize(Vector2.UnitY); Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium); } Console.WriteLine(gem.health); TryStartCutscene(gem.cutscenes[3 - gem.health], player); gem.Crack(player); } return; } } orig(self, player); }
private static void HeartGem_OnHoldable(On.Celeste.HeartGem.orig_OnHoldable orig, HeartGem self, Holdable h) { if (self is MultiDashHeartGem gem) { if (h.Dangerous(gem.baseData.Get <HoldableCollider>("holdableCollider"))) { Player player = gem.Scene.Tracker.GetEntity <Player>(); if (!gem.baseData.Get <bool>("collected") && player != null && gem.health > 1) { // Basically just HeartGem.OnPlayer if (gem.baseData.Get <float>("bounceSfxDelay") <= 0f) { Audio.Play(SFX.game_gen_crystalheart_bounce, gem.Position); gem.baseData["bounceSfxDelay"] = 0.1f; } h.PointBounce(self.Center); gem.baseData.Get <Wiggler>("moveWiggler").Start(); gem.ScaleWiggler.Start(); gem.baseData["moveWiggleDir"] = (gem.Center - player.Center).SafeNormalize(Vector2.UnitY); Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium); } else { // Collect normally orig(self, h); } Console.WriteLine(gem.health); TryStartCutscene(gem.cutscenes[3 - gem.health], player); gem.Crack(player); } } else { orig(self, h); } }
private static void HeartGem_ctor_EntityData_Vector2(On.Celeste.HeartGem.orig_ctor_EntityData_Vector2 orig, HeartGem self, EntityData data, Vector2 offset) { orig(self, data, offset); // If it hasn't been loaded by our mod, don't even bother with it if (data.Has(HeartGem_HeartGemID)) { DynData <HeartGem> heartData = new DynData <HeartGem>(self); if (data.Nodes != null && data.Nodes.Length != 0) { List <HeartGemShard> pieces = new List <HeartGemShard>(); for (int i = 0; i < data.Nodes.Length; i++) { HeartGemShard shard = new HeartGemShard(self, offset + data.Nodes[i], i); // Just blindly use any color attribute, if available if (data.Has("color")) { shard.Color = Calc.HexToColor(data.Attr("color", "00a81f")); } pieces.Add(shard); } heartData[HeartGem_HeartGemPieces] = pieces; } else { heartData[HeartGem_HeartGemPieces] = null; } heartData[HeartGem_HeartGemID] = data.Values[HeartGem_HeartGemID]; } }
private void OverlayEntities(MapElement entities, Bitmap map, VirtualMap <char> solids, bool background) { CassetteBlock.Blocks.Clear(); using (Graphics g = Graphics.FromImage(map)) { List <Entity> ents = new List <Entity>(); for (int i = entities.Children.Count - 1; i >= 0; i--) { MapElement child = entities.Children[i]; Entity entity = null; if (child.Name.IndexOf("spikes", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? Spikes.FromElement(child) : null; } else if (child.Name.IndexOf("triggerSpikes", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? TriggerSpikes.FromElement(child) : null; } else if (child.Name.IndexOf("strawberry", StringComparison.OrdinalIgnoreCase) == 0) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("goldenBerry", StringComparison.OrdinalIgnoreCase)) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("redBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("greenBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("yellowBlocks", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterBlock.FromElement(child) : null; } else if (child.Name.Equals("clutterCabinet", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterCabinet.FromElement(child) : null; } else if (child.Name.Equals("introCar", StringComparison.OrdinalIgnoreCase)) { entity = background ? IntroCar.FromElement(child) : null; } else if (child.Name.Equals("clothesLine", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClothesLine.FromElement(child) : null; } else if (child.Name.Equals("colorSwitch", StringComparison.OrdinalIgnoreCase)) { entity = background ? ColorSwitch.FromElement(child) : null; } else if (child.Name.Equals("memorialTextController", StringComparison.OrdinalIgnoreCase)) { entity = background ? Strawberry.FromElement(child) : null; } else if (child.Name.Equals("bonfire", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bonfire.FromElement(child) : null; } else if (child.Name.Equals("trapDoor", StringComparison.OrdinalIgnoreCase)) { entity = background ? TrapDoor.FromElement(child) : null; } else if (child.Name.Equals("movingPlatform", StringComparison.OrdinalIgnoreCase)) { entity = background ? MovingPlatform.FromElement(child) : null; } else if (child.Name.Equals("sinkingPlatform", StringComparison.OrdinalIgnoreCase)) { entity = background ? SinkingPlatform.FromElement(child) : null; } else if (child.Name.Equals("clutterDoor", StringComparison.OrdinalIgnoreCase)) { entity = background ? ClutterDoor.FromElement(child) : null; } else if (child.Name.Equals("bridge", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bridge.FromElement(child) : null; } else if (child.Name.Equals("bridgeFixed", StringComparison.OrdinalIgnoreCase)) { entity = background ? BridgeFixed.FromElement(child) : null; } else if (child.Name.Equals("jumpThru", StringComparison.OrdinalIgnoreCase)) { entity = background ? JumpThru.FromElement(child) : null; } else if (child.Name.Equals("door", StringComparison.OrdinalIgnoreCase)) { entity = background ? Door.FromElement(child) : null; } else if (child.Name.Equals("blockField", StringComparison.OrdinalIgnoreCase)) { entity = background ? BlockField.FromElement(child) : null; } else if (child.Name.Equals("lamp", StringComparison.OrdinalIgnoreCase)) { entity = background ? Lamp.FromElement(child) : null; } else if (child.Name.Equals("hahaha", StringComparison.OrdinalIgnoreCase)) { entity = background ? Haha.FromElement(child) : null; } else if (child.Name.Equals("waterFall", StringComparison.OrdinalIgnoreCase)) { entity = background ? WaterFall.FromElement(child) : null; } else if (child.Name.Equals("water", StringComparison.OrdinalIgnoreCase)) { entity = background ? Water.FromElement(child) : null; } else if (child.Name.Equals("key", StringComparison.OrdinalIgnoreCase)) { entity = background ? Key.FromElement(child) : null; } else if (child.Name.Equals("resortLantern", StringComparison.OrdinalIgnoreCase)) { entity = background ? ResortLantern.FromElement(child) : null; } else if (child.Name.Equals("bird", StringComparison.OrdinalIgnoreCase)) { entity = background ? Bird.FromElement(child) : null; } else if (child.Name.Equals("memorial", StringComparison.OrdinalIgnoreCase)) { entity = background ? Memorial.FromElement(child) : null; } else if (child.Name.Equals("player", StringComparison.OrdinalIgnoreCase)) { entity = background ? PlayerSpawn.FromElement(child) : null; } else if (child.Name.Equals("zipMover", StringComparison.OrdinalIgnoreCase)) { entity = background ? ZipMover.FromElement(child) : null; } else if (child.Name.Equals("wire", StringComparison.OrdinalIgnoreCase)) { entity = background ? Wire.FromElement(child) : null; } else if (child.Name.Equals("crumbleBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? CrumbleBlock.FromElement(child) : null; } else if (child.Name.Equals("refill", StringComparison.OrdinalIgnoreCase)) { entity = background ? Refill.FromElement(child) : null; } else if (child.Name.Equals("spring", StringComparison.OrdinalIgnoreCase)) { entity = background ? Spring.FromElement(child) : null; } else if (child.Name.Equals("fakeWall", StringComparison.OrdinalIgnoreCase)) { entity = background ? FakeWall.FromElement(child) : null; } else if (child.Name.Equals("exitBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? FakeWall.FromElement(child) : null; } else if (child.Name.Equals("lightBeam", StringComparison.OrdinalIgnoreCase)) { entity = background ? LightBeam.FromElement(child) : null; } else if (child.Name.Equals("cobweb", StringComparison.OrdinalIgnoreCase)) { entity = background ? Cobweb.FromElement(child) : null; } else if (child.Name.Equals("cassette", StringComparison.OrdinalIgnoreCase)) { entity = background ? Cassette.FromElement(child) : null; } else if (child.Name.Equals("flutterBird", StringComparison.OrdinalIgnoreCase)) { entity = background ? FlutterBird.FromElement(child) : null; } else if (child.Name.Equals("checkpoint", StringComparison.OrdinalIgnoreCase)) { entity = background ? Checkpoint.FromElement(child) : null; } else if (child.Name.Equals("fallingBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? FallingBlock.FromElement(child) : null; } else if (child.Name.Equals("introCrusher", StringComparison.OrdinalIgnoreCase)) { entity = background ? FallingBlock.FromElement(child) : null; } else if (child.Name.Equals("cassetteBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? CassetteBlock.FromElement(child) : null; } else if (child.Name.Equals("dashBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? DashBlock.FromElement(child) : null; } else if (child.Name.Equals("coverupWall", StringComparison.OrdinalIgnoreCase)) { entity = background ? CoverupWall.FromElement(child) : null; } else if (child.Name.Equals("npc", StringComparison.OrdinalIgnoreCase)) { entity = background ? NPC.FromElement(child) : null; } else if (child.Name.Equals("birdForsakenCityGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? ForsakenCityGem.FromElement(child) : null; } else if (child.Name.Equals("soundSource", StringComparison.OrdinalIgnoreCase)) { entity = background ? SoundSource.FromElement(child) : null; } else if (child.Name.Equals("friendlyGhost", StringComparison.OrdinalIgnoreCase)) { entity = background ? FriendlyGhost.FromElement(child) : null; } else if (child.Name.Equals("floatingDebris", StringComparison.OrdinalIgnoreCase)) { entity = background ? FloatingDebris.FromElement(child) : null; } else if (child.Name.Equals("hangingLamp", StringComparison.OrdinalIgnoreCase)) { entity = background ? HangingLamp.FromElement(child) : null; } else if (child.Name.Equals("lockBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? LockBlock.FromElement(child) : null; } else if (child.Name.Equals("heartGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? HeartGem.FromElement(child) : null; } else if (child.Name.Equals("blackGem", StringComparison.OrdinalIgnoreCase)) { entity = background ? HeartGem.FromElement(child) : null; } else if (child.Name.Equals("dreamMirror", StringComparison.OrdinalIgnoreCase)) { entity = background ? DreamMirror.FromElement(child) : null; } else if (child.Name.Equals("darkChaser", StringComparison.OrdinalIgnoreCase)) { entity = background ? DarkChaser.FromElement(child) : null; } else if (child.Name.Equals("dreamBlock", StringComparison.OrdinalIgnoreCase)) { entity = background ? DreamBlock.FromElement(child) : null; } else if (child.Name.Equals("touchSwitch", StringComparison.OrdinalIgnoreCase)) { entity = background ? TouchSwitch.FromElement(child) : null; } else if (child.Name.Equals("switchGate", StringComparison.OrdinalIgnoreCase)) { entity = background ? SwitchGate.FromElement(child) : null; } else if (child.Name.Equals("invisibleBarrier", StringComparison.OrdinalIgnoreCase)) { entity = background ? InvisibleBarrier.FromElement(child) : null; } else if (child.Name.Equals("payphone", StringComparison.OrdinalIgnoreCase)) { entity = background ? Payphone.FromElement(child) : null; } else if (child.Name.Equals("spinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? Spinner.FromElement(child) : null; } else if (child.Name.Equals("rotateSpinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? RotateSpinner.FromElement(child) : null; } else if (child.Name.Equals("trackSpinner", StringComparison.OrdinalIgnoreCase)) { entity = background ? TrackSpinner.FromElement(child) : null; } else if (child.Name.Equals("towerViewer", StringComparison.OrdinalIgnoreCase)) { entity = background ? TowerViewer.FromElement(child) : null; } else if (child.Name.Equals("foregroundDebris", StringComparison.OrdinalIgnoreCase)) { entity = !background?ForegroundDebris.FromElement(child) : null; } else if (background) { Console.WriteLine(child.Name); } if (entity != null) { ents.Add(entity); } } ents.Sort(delegate(Entity one, Entity two) { int comp = two.Depth.CompareTo(one.Depth); return(comp == 0 ? one.ID.CompareTo(two.ID) : comp); }); for (int i = 0; i < ents.Count; i++) { Entity entity = ents[i]; entity.Render(g, solids); } } }