Cache created wrappers for pointers, so we can resolve them later.

This commit is contained in:
2020-05-03 17:14:07 +02:00
parent 1bf2f0ad09
commit 42ec208425
6 changed files with 41 additions and 10 deletions

View File

@@ -54,8 +54,7 @@ namespace PkmnLibSharp.Library
}
internal override void DeletePtr()
protected override void DeletePtr()
{
Creatureliblibrary.Generated.EffectParameter.Destruct(Ptr);
}

View File

@@ -67,7 +67,6 @@ namespace PkmnLibSharp.Library
return _abilities;
}
}
public ImmutableArray<string> HiddenAbilities
{
get
@@ -89,13 +88,25 @@ namespace PkmnLibSharp.Library
}
}
public LearnableMoves Moves
{
get
{
if (_moves != null) return _moves;
var movesPtr = SpeciesVariant.GetLearnableAttacks(Ptr);
if (!TryResolvePointer(movesPtr, out _moves))
{
_moves = new LearnableMoves(movesPtr);
}
return _moves;
}
}
public int GetPkmnType(int index)
{
return Types[index];
}
public static unsafe Forme Create(string name, float height, float weight, uint baseExperience, byte[] types,
ushort baseHealth, ushort baseAttack, ushort baseDefense, ushort baseSpecialAttack,
ushort baseSpecialDefense, ushort baseSpeed, string[] abilities, string[] hiddenAbilities,
@@ -125,7 +136,7 @@ namespace PkmnLibSharp.Library
{
}
internal override void DeletePtr()
protected override void DeletePtr()
{
SpeciesVariant.Destruct(Ptr);
}

View File

@@ -5,7 +5,7 @@ namespace PkmnLibSharp.Library
{
public class LearnableMoves : PointerWrapper
{
private LearnableMoves(IntPtr ptr) : base(ptr)
internal LearnableMoves(IntPtr ptr) : base(ptr)
{
}
@@ -21,7 +21,7 @@ namespace PkmnLibSharp.Library
LearnableAttacks.AddLevelAttack(Ptr, level, move.Ptr);
}
internal override void DeletePtr()
protected override void DeletePtr()
{
LearnableAttacks.Destruct(Ptr);
}

View File

@@ -50,7 +50,7 @@ namespace PkmnLibSharp.Library
{
}
internal override void DeletePtr()
protected override void DeletePtr()
{
AttackData.Destruct(Ptr);
}

View File

@@ -20,7 +20,7 @@ namespace PkmnLibSharp.Library
return new Species(ptr);
}
internal override void DeletePtr()
protected override void DeletePtr()
{
PokemonSpecies.Destruct(Ptr);
}