Update GetDataHandlers.cs
This commit is contained in:
parent
c6b870a480
commit
bd7b1c1460
1 changed files with 74 additions and 0 deletions
|
|
@ -135,6 +135,7 @@ namespace TShockAPI
|
||||||
{ PacketTypes.Teleport, HandleTeleport },
|
{ PacketTypes.Teleport, HandleTeleport },
|
||||||
{ PacketTypes.PlayerHealOther, HandleHealOther },
|
{ PacketTypes.PlayerHealOther, HandleHealOther },
|
||||||
{ PacketTypes.CatchNPC, HandleCatchNpc },
|
{ PacketTypes.CatchNPC, HandleCatchNpc },
|
||||||
|
{ PacketTypes.ReleaseNPC, HandleReleaseNpc },
|
||||||
{ PacketTypes.TeleportationPotion, HandleTeleportationPotion },
|
{ PacketTypes.TeleportationPotion, HandleTeleportationPotion },
|
||||||
{ PacketTypes.CompleteAnglerQuest, HandleCompleteAnglerQuest },
|
{ PacketTypes.CompleteAnglerQuest, HandleCompleteAnglerQuest },
|
||||||
{ PacketTypes.NumberOfAnglerQuestsCompleted, HandleNumberOfAnglerQuestsCompleted },
|
{ PacketTypes.NumberOfAnglerQuestsCompleted, HandleNumberOfAnglerQuestsCompleted },
|
||||||
|
|
@ -1638,6 +1639,56 @@ namespace TShockAPI
|
||||||
return args.Handled;
|
return args.Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The ReleaseNPC event arguments
|
||||||
|
/// </summary>
|
||||||
|
public class ReleaseNpcEventArgs : GetDataHandledEventArgs
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The X value of where NPC released
|
||||||
|
/// </summary>
|
||||||
|
public int X { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Y value of where NPC released
|
||||||
|
/// </summary>
|
||||||
|
public int Y { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The NPC Type that player release
|
||||||
|
/// </summary>
|
||||||
|
public short Type { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The NPC release style
|
||||||
|
/// </summary>
|
||||||
|
public byte Style { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when player release a NPC, for checking critter released from item.
|
||||||
|
/// </summary>
|
||||||
|
public static HandlerList<ReleaseNpcEventArgs> ReleaseNPC = new HandlerList<ReleaseNpcEventArgs>();
|
||||||
|
private static bool OnReleaseNpc(TSPlayer player, MemoryStream data, int _x, int _y, short _type, byte _style)
|
||||||
|
{
|
||||||
|
if (ReleaseNPC == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var args = new ReleaseNpcEventArgs
|
||||||
|
{
|
||||||
|
Player = player,
|
||||||
|
Data = data,
|
||||||
|
X = _x,
|
||||||
|
Y = _y,
|
||||||
|
Type = _type,
|
||||||
|
Style = _style
|
||||||
|
};
|
||||||
|
ReleaseNPC.Invoke(null, args);
|
||||||
|
return args.Handled;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>The arguments to the PlaceObject hook.</summary>
|
/// <summary>The arguments to the PlaceObject hook.</summary>
|
||||||
public class PlaceObjectEventArgs : GetDataHandledEventArgs
|
public class PlaceObjectEventArgs : GetDataHandledEventArgs
|
||||||
{
|
{
|
||||||
|
|
@ -3658,10 +3709,33 @@ namespace TShockAPI
|
||||||
NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcID);
|
NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(args.Player.IsBeingDisabled())
|
||||||
|
{
|
||||||
|
TShock.Log.ConsoleDebug("GetDataHandlers / HandleCatchNpc rejected catch npc {0}", args.Player.Name);
|
||||||
|
Main.npc[npcID].active = true;
|
||||||
|
NetMessage.SendData((int)PacketTypes.NpcUpdate, -1, -1, NetworkText.Empty, npcID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool HandleReleaseNpc(GetDataHandlerArgs args)
|
||||||
|
{
|
||||||
|
var x = args.Data.ReadInt32();
|
||||||
|
var y = args.Data.ReadInt32();
|
||||||
|
var type = args.Data.ReadInt16();
|
||||||
|
var style = args.Data.ReadInt8();
|
||||||
|
|
||||||
|
if (OnReleaseNpc(args.Player, args.Data, x, y, type, style))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static bool HandleTeleportationPotion(GetDataHandlerArgs args)
|
private static bool HandleTeleportationPotion(GetDataHandlerArgs args)
|
||||||
{
|
{
|
||||||
var type = args.Data.ReadByte();
|
var type = args.Data.ReadByte();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue