diff --git a/PkmnLibSharp/Battling/PokemonParty.cs b/PkmnLibSharp/Battling/PokemonParty.cs index c62df75..c924ef4 100644 --- a/PkmnLibSharp/Battling/PokemonParty.cs +++ b/PkmnLibSharp/Battling/PokemonParty.cs @@ -8,6 +8,11 @@ namespace PkmnLibSharp.Battling { public class PokemonParty : PointerWrapper, IEnumerable { + public delegate void OnSwitchDelegate(ulong a, ulong b); + public event OnSwitchDelegate? OnSwitch; + public delegate void OnSwapIntoDelegate(ulong a); + public event OnSwapIntoDelegate? OnSwapInto; + private Pokemon?[]? _cache; private ReadOnlyNativePtrArray? _party; @@ -43,6 +48,7 @@ namespace PkmnLibSharp.Battling var temp = _cache![indexA]; _cache[indexA] = _cache[indexB]; _cache[indexB] = temp; + OnSwitch?.Invoke(indexA, indexB); } public Pokemon? SwapInto(ulong indexA, Pokemon? pokemon) @@ -52,6 +58,7 @@ namespace PkmnLibSharp.Battling if (pokemon != null) pkmnPtr = pokemon.Ptr; Creaturelib.Generated.CreatureParty.SwapInto(ref ptr, Ptr, indexA, pkmnPtr).Assert(); _cache![indexA] = pokemon; + OnSwapInto?.Invoke(indexA); if (TryResolvePointer(ptr, out Pokemon? newPokemon)) return newPokemon!; return Constructor.Active.ConstructPokemon(ptr)!;