Support clearing a battle on demand
This commit is contained in:
parent
dc79ed6e46
commit
6ecbae0370
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue