Adds switch and swap into event to party.
This commit is contained in:
parent
813cf65331
commit
506f10b085
|
@ -8,6 +8,11 @@ namespace PkmnLibSharp.Battling
|
|||
{
|
||||
public class PokemonParty : PointerWrapper, IEnumerable<Pokemon?>
|
||||
{
|
||||
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<Pokemon>? _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)!;
|
||||
|
|
Loading…
Reference in New Issue