internal static void Break(On.Celeste.DashBlock.orig_Break_Vector2_Vector2_bool_bool orig, DashBlock self, Vector2 from, Vector2 direction, bool playSound, bool playDebrisSound) { if (self is FancyDashBlock) { FancyDashBlock block = (self as FancyDashBlock); if (playSound) { Audio.Play(SFX.game_gen_wallbreak_stone, block.Position); } for (int x = 0; x < block.Width / 8f; x++) { for (int y = 0; y < block.Height / 8f; y++) { if (block.tileMap.AnyInSegmentAtTile(x, y) && block.tileMap[x, y] != '0') { block.Scene.Add(Engine.Pooler.Create <Debris>().Init(block.Position + new Vector2(4 + x * 8, 4 + y * 8), block.tileMap[x, y], playDebrisSound).BlastFrom(from)); } } } block.Collidable = false; if (f_DashBlock_permanent[block]) { block.RemoveAndFlagAsGone(); } else { block.RemoveSelf(); } } else { orig(self, from, direction, playSound, playDebrisSound); } }
private static void DashBlockBreak(On.Celeste.DashBlock.orig_Break_Vector2_Vector2_bool_bool orig, Celeste.DashBlock self, Vector2 from, Vector2 direction, bool playSound, bool playDebrisSound) { orig(self, from, direction, playSound, playDebrisSound); if (self is FactoryActivatorDashBlock) { (self as FactoryActivatorDashBlock).OnBreak(); } }
private static void DashBlock_Break_Vector2_Vector2_bool_bool(On.Celeste.DashBlock.orig_Break_Vector2_Vector2_bool_bool orig, DashBlock self, Vector2 from, Vector2 direction, bool playSound, bool playDebrisSound) { // To `override` any method that isn't marked as `virtual` or `abstract`, use an On. hook and check if `self` (the current instance) is an instance of your subclass. if (self is ExtendedDashBlock extendedBlock) { Logger.Log("ExampleModule", "DashBlock.Break was called on an ExtendedDashBlock entity."); if (playSound) { Audio.Play(SFX.char_bad_disappear); } if (extendedBlock.removeOnBreak) { extendedBlock.Collidable = false; extendedBlock.RemoveSelf(); } } else { orig(self, from, direction, playSound, playDebrisSound); } }