From bada3f4c24e8e1a0c03738f554f5f7347b4436c3 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 31 Dec 2011 18:59:39 -0700 Subject: [PATCH] Add TileKill hook --- TShockAPI/GetDataHandlers.cs | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 5be65744..c6d01190 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -70,7 +70,7 @@ namespace TShockAPI /// [Description("Called when a tile is placed or destroyed")] public static HandlerList TileEdit; - public static bool OnTileEdit(int x, int y, byte type, byte editType) + private static bool OnTileEdit(int x, int y, byte type, byte editType) { if (TileEdit == null) return false; @@ -95,7 +95,7 @@ namespace TShockAPI /// TogglePvp - called when a player toggles pvp /// public static HandlerList TogglePvp; - public static bool OnPvpToggled(byte _id, bool _pvp) + private static bool OnPvpToggled(byte _id, bool _pvp) { if (TogglePvp == null) return false; @@ -122,7 +122,7 @@ namespace TShockAPI /// PlayerSlot - called at a PlayerSlot event /// public static HandlerList PlayerSlot; - public static bool OnPlayerSlot(byte _plr, byte _slot, byte _stack, byte _prefix, short _type) + private static bool OnPlayerSlot(byte _plr, byte _slot, byte _stack, byte _prefix, short _type) { if (PlayerSlot == null) return false; @@ -151,7 +151,7 @@ namespace TShockAPI /// public static HandlerList PlayerHP; - public static bool OnPlayerHP(int _plr, short _cur, short _max) + private static bool OnPlayerHP(int _plr, short _cur, short _max) { if (PlayerHP == null) return false; @@ -178,7 +178,7 @@ namespace TShockAPI /// public static HandlerList PlayerMana; - public static bool OnPlayerMana(int _plr, short _cur, short _max) + private static bool OnPlayerMana(int _plr, short _cur, short _max) { if (PlayerMana == null) return false; @@ -207,7 +207,7 @@ namespace TShockAPI /// public static HandlerList PlayerInfo; - public static bool OnPlayerInfo(byte _plrid, byte _hair, bool _male, byte _difficulty, string _name) + private static bool OnPlayerInfo(byte _plrid, byte _hair, bool _male, byte _difficulty, string _name) { if (PlayerInfo == null) return false; @@ -223,6 +223,27 @@ namespace TShockAPI PlayerInfo.Invoke(null, args); return args.Handled; } + + public class TileKillEventArgs : HandledEventArgs + { + public int TileX { get; set; } + public int TileY { get; set; } + } + public static HandlerList TileKill; + + private static bool OnTileKill(int tilex, int tiley) + { + if (TileKill == null) + return false; + + var args = new TileKillEventArgs + { + TileX = tilex, + TileY = tiley, + }; + TileKill.Invoke(null, args); + return args.Handled; + } #endregion public static void InitGetDataHandler() { @@ -1284,7 +1305,8 @@ namespace TShockAPI { var tileX = args.Data.ReadInt32(); var tileY = args.Data.ReadInt32(); - + if (OnTileKill(tileX, tileY)) + return true; if (tileX < 0 || tileX >= Main.maxTilesX || tileY < 0 || tileY >= Main.maxTilesY) return false;