Code: Select all
public enum MeleeAction { Attack1, Attack2, Attack3 }
public struct PlayerMeleeHitArg
{
public readonly int ObjectID;
public readonly IObject HitObject;
public readonly Vector2 HitPosition;
public readonly bool IsPlayer;
public readonly float HitDamage;
// new property
public readonly MeleeAction MeleeAction;
public PlayerMeleeHitArg(int objectID, IObject hitObject, Vector2 hitPosition, bool isPlayer, float hitDamage, MeleeAction meleeAction);
}
Code: Select all
Events.PlayerMeleeActionCallback.Start(OnPlayerMeleeAction);
// ...
private static void OnPlayerMeleeAction(IPlayer attacker, PlayerMeleeHitArg[] args)
{
foreach (var arg in args)
{
if (arg.MeleeAction == MeleeAction.Attack1) { /* ... */ }
if (arg.MeleeAction == MeleeAction.Attack2) { /* ... */ }
if (arg.MeleeAction == MeleeAction.Attack3) { /* Activate powerup... */ }
}
}