Support clearing a battle on demand

This commit is contained in:
Deukhoofd 2021-07-09 18:19:21 +02:00
parent dc79ed6e46
commit 6ecbae0370
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 11 additions and 1 deletions

View File

@ -59,6 +59,8 @@ namespace PkmnLibSharp.Battling
public ulong MonsPerSide => Creaturelib.Generated.Battle.GetCreaturesPerSide(Ptr); public ulong MonsPerSide => Creaturelib.Generated.Battle.GetCreaturesPerSide(Ptr);
public long LastTurnTimeMicroseconds => Creaturelib.Generated.Battle.GetLastTurnTimeMicroseconds(Ptr); public long LastTurnTimeMicroseconds => Creaturelib.Generated.Battle.GetLastTurnTimeMicroseconds(Ptr);
private bool _cleared;
public ReadOnlyNativePtrArray<BattleSide> Sides public ReadOnlyNativePtrArray<BattleSide> Sides
{ {
get get
@ -229,6 +231,14 @@ namespace PkmnLibSharp.Battling
private ReadOnlyNativePtrArray<BattleParty>? _parties; private ReadOnlyNativePtrArray<BattleParty>? _parties;
private HistoryHandler? _history; private HistoryHandler? _history;
public void ClearBattle()
{
if (_cleared)
return;
_cleared = true;
Creaturelib.Generated.Battle.ClearBattle(Ptr);
}
protected override void DeletePtr() protected override void DeletePtr()
{ {
Pkmnlib.Generated.Battle.Destruct(Ptr); Pkmnlib.Generated.Battle.Destruct(Ptr);
@ -238,7 +248,7 @@ namespace PkmnLibSharp.Battling
{ {
if (!IsDeleted) if (!IsDeleted)
{ {
Creaturelib.Generated.Battle.ClearBattle(Ptr); ClearBattle();
} }
base.Dispose(); base.Dispose();
} }