Add LandGolfBallInCup event handler.
This commit is contained in:
parent
20620f2b47
commit
26773f61a2
1 changed files with 65 additions and 0 deletions
|
|
@ -152,6 +152,7 @@ namespace TShockAPI
|
|||
{ PacketTypes.PlayerHurtV2, HandlePlayerDamageV2 },
|
||||
{ PacketTypes.PlayerDeathV2, HandlePlayerKillMeV2 },
|
||||
{ PacketTypes.SyncRevengeMarker, HandleSyncRevengeMarker },
|
||||
{ PacketTypes.LandGolfBallInCup, HandleLandGolfBallInCup },
|
||||
{ PacketTypes.FishOutNPC, HandleFishOutNPC },
|
||||
{ PacketTypes.FoodPlatterTryPlacing, HandleFoodPlatterTryPlacing }
|
||||
};
|
||||
|
|
@ -1866,6 +1867,56 @@ namespace TShockAPI
|
|||
return args.Handled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For use in a LandGolfBallInCup event.
|
||||
/// </summary>
|
||||
public class LandGolfBallInCupEventArgs : GetDataHandledEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The player index in the packet, who puts the ball in the cup.
|
||||
/// </summary>
|
||||
public byte PlayerIndex { get; set; }
|
||||
/// <summary>
|
||||
/// The X tile position of where the ball lands in a cup.
|
||||
/// </summary>
|
||||
public ushort TileX { get; set; }
|
||||
/// <summary>
|
||||
/// The Y tile position of where the ball lands in a cup.
|
||||
/// </summary>
|
||||
public ushort TileY { get; set; }
|
||||
/// <summary>
|
||||
/// The amount of hits it took for the player to land the ball in the cup.
|
||||
/// </summary>
|
||||
public ushort Hits { get; set; }
|
||||
/// <summary>
|
||||
/// The type of the projectile that was landed in the cup. A golfball in legit cases.
|
||||
/// </summary>
|
||||
public ushort ProjectileType { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when a player lands a golf ball in a cup.
|
||||
/// </summary>
|
||||
public static HandlerList<LandGolfBallInCupEventArgs> LandGolfBallInCup = new HandlerList<LandGolfBallInCupEventArgs>();
|
||||
private static bool OnLandGolfBallInCup(TSPlayer player, MemoryStream data, byte playerIndex, ushort tileX, ushort tileY, ushort hits, ushort projectileType )
|
||||
{
|
||||
if (LandGolfBallInCup == null)
|
||||
return false;
|
||||
|
||||
var args = new LandGolfBallInCupEventArgs
|
||||
{
|
||||
Player = player,
|
||||
Data = data,
|
||||
PlayerIndex = playerIndex,
|
||||
TileX = tileX,
|
||||
TileY = tileY,
|
||||
Hits = hits,
|
||||
ProjectileType = projectileType
|
||||
};
|
||||
LandGolfBallInCup.Invoke(null, args);
|
||||
return args.Handled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For use in a FishOutNPC event.
|
||||
/// </summary>
|
||||
|
|
@ -3686,6 +3737,20 @@ namespace TShockAPI
|
|||
return false;
|
||||
}
|
||||
|
||||
private static bool HandleLandGolfBallInCup(GetDataHandlerArgs args)
|
||||
{
|
||||
byte playerIndex = args.Data.ReadInt8();
|
||||
ushort tileX = args.Data.ReadUInt16();
|
||||
ushort tileY = args.Data.ReadUInt16();
|
||||
ushort hits = args.Data.ReadUInt16();
|
||||
ushort projectileType = args.Data.ReadUInt16();
|
||||
|
||||
if (OnLandGolfBallInCup(args.Player, args.Data, playerIndex, tileX, tileY, hits, projectileType))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool HandleFishOutNPC(GetDataHandlerArgs args)
|
||||
{
|
||||
ushort tileX = args.Data.ReadUInt16();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue