diff --git a/Core/Config.cs b/Core/Config.cs index 762b01a..ca9a050 100644 --- a/Core/Config.cs +++ b/Core/Config.cs @@ -778,12 +778,6 @@ public record class MitigationSettings /// public Optional RecursiveTileBreak = Optional.Default(false, true); - /// - /// TileFrame-ed tile will be tracked and TileFrame-ed again. - /// This will trigger recursive tile break. - /// - public Optional RecursiveTileFrame = Optional.Default(false, true); - public enum DisabledDamageAction { AsIs, diff --git a/Core/Mitigations.cs b/Core/Mitigations.cs index 8810b27..a4f0247 100644 --- a/Core/Mitigations.cs +++ b/Core/Mitigations.cs @@ -328,18 +328,17 @@ private void TAHook_Mitigation_GameUpdate(EventArgs _) if (mitigation.RecursiveTileBreak) { var kt = 0; - var count = this._pendingKilled.Count; - while (kt < this._pendingKilled.Count) + var count = this._pendingTileFrame.Count; + while (kt < this._pendingTileFrame.Count) { - var item = this._pendingKilled[kt]; + var item = this._pendingTileFrame[kt]; var ti = (int) (item >> 32); var tj = (int) item; Terraria.WorldGen.SquareTileFrame(ti, tj); kt++; } - this.Statistics.MitigationNewTileKillTriggered += this._pendingKilled.Count - count; - this._pendingKilled.Clear(); + this.Statistics.MitigationNewTileKillTriggered += this._pendingTileFrame.Count - count; this._pendingTileFrame.Clear(); } } diff --git a/Core/WorldGen.cs b/Core/WorldGen.cs index bb8a9a8..bf33f14 100644 --- a/Core/WorldGen.cs +++ b/Core/WorldGen.cs @@ -144,30 +144,25 @@ private void Detour_InspectTileFrame(Action orig, int i, i this._frameCount.Value -= 1; } - private readonly List _pendingKilled = new List(); + private readonly List _pendingTileFrame = new List(); private void MMHook_WorldGen_KillTile(On.Terraria.WorldGen.orig_KillTile orig, int i, int j, bool fail, bool effectOnly, bool noItem) { var pos = (((ulong) i) << 32) | ((uint) j); - if (this.config.Mitigation.Value.RecursiveTileBreak.Value && !this._pendingKilled.Contains(pos)) + if (this.config.Mitigation.Value.RecursiveTileBreak.Value && !this._pendingTileFrame.Contains(pos)) { - this._pendingKilled.Add(pos); + this. _pendingTileFrame.Add(pos); } orig(i, j, fail, effectOnly, noItem); } - private readonly Dictionary _pendingTileFrame = new Dictionary(); private void MMHook_WorldGen_TileFrame(On.Terraria.WorldGen.orig_TileFrame orig, int i, int j, bool resetFrame, bool noBreak) { var pos = (((ulong) i) << 32) | ((uint) j); - if (this.config.Mitigation.Value.RecursiveTileFrame.Value) + var type = Terraria.Main.tile[i, j].type; + orig.Invoke(i, j, resetFrame, noBreak); + if (type != Terraria.Main.tile[i, j].type && this.config.Mitigation.Value.RecursiveTileBreak.Value && !this._pendingTileFrame.Contains(pos)) { - if (this._pendingTileFrame.TryGetValue(pos, out var frames) && frames > 2) - { - return; - } - this._pendingTileFrame[pos] = frames + 1; - Terraria.WorldGen.destroyObject = false; - orig(i, j, resetFrame, noBreak); + this._pendingTileFrame.Add(pos); } } } \ No newline at end of file