From c9b33e527ad9e0ede1a6c11a7dc9aa7a51d19053 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sun, 1 Jan 2012 02:13:03 -0700 Subject: [PATCH] Add NPCSpecial hook --- TShockAPI/GetDataHandlers.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/TShockAPI/GetDataHandlers.cs b/TShockAPI/GetDataHandlers.cs index 76fe0b8d..ca4b4d3a 100644 --- a/TShockAPI/GetDataHandlers.cs +++ b/TShockAPI/GetDataHandlers.cs @@ -603,6 +603,27 @@ namespace TShockAPI return args.Handled; } + public class NPCSpecialEventArgs : HandledEventArgs + { + public byte ID { get; set; } + public byte Type { get; set; } + } + public static HandlerList NPCSpecial; + + private static bool OnNPCSpecial(byte id, byte type) + { + if (NPCSpecial == null) + return false; + + var args = new NPCSpecialEventArgs + { + ID = id, + Type = type, + }; + NPCSpecial.Invoke(null, args); + return args.Handled; + } + #endregion public static void InitGetDataHandler() { @@ -2067,6 +2088,9 @@ namespace TShockAPI var id = args.Data.ReadInt8(); var type = args.Data.ReadInt8(); + if (OnNPCSpecial(id, type)) + return true; + if (type == 1 && TShock.Config.DisableDungeonGuardian) { args.Player.SendMessage("The Dungeon Guardian returned you to your spawn point", Color.Purple);