Support getting a nature iterator.

This commit is contained in:
Deukhoofd 2020-08-09 11:39:41 +02:00
parent cae763fdc0
commit a9b0ec0e98
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
7 changed files with 35 additions and 6 deletions

View File

@ -231,6 +231,12 @@ namespace Creaturelib.Generated
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetAttacks")]
internal static extern IntPtr GetAttacks(IntPtr p);
/// <param name="p">Creature *</param>
/// <param name="scriptName">const char *</param>
/// <returns>bool</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_HasAttack")]
internal static extern byte HasAttack(IntPtr p, IntPtr scriptName);
/// <param name="p">const Creature *</param>
/// <returns>const CreatureSpecies *</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetDisplaySpecies")]

View File

@ -44,5 +44,17 @@ namespace Pkmnlib.Generated
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_NatureLibrary_GetNatureName")]
internal static extern byte GetNatureName(IntPtr p, IntPtr nature, ref IntPtr @out);
/// <param name="p">const NatureLibrary *</param>
/// <returns>long unsigned int</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_NatureLibrary_GetNatureCount")]
internal static extern ulong GetNatureCount(IntPtr p);
/// <param name="p">NatureLibrary *</param>
/// <param name="index">long unsigned int</param>
/// <param name="out">const char * &</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_NatureLibrary_GetNatureByIndex")]
internal static extern byte GetNatureByIndex(IntPtr p, ulong index, ref IntPtr @out);
}
}

View File

@ -62,6 +62,17 @@ namespace PkmnLibSharp.Library
return val.PtrString()!;
}
public IEnumerable<string> GetNatures()
{
var count = Pkmnlib.Generated.NatureLibrary.GetNatureCount(Ptr);
var ptr = IntPtr.Zero;
for (ulong i = 0; i < count; i++)
{
Pkmnlib.Generated.NatureLibrary.GetNatureByIndex(Ptr, i, ref ptr).Assert();
yield return ptr.PtrString()!;
}
}
protected override void DeletePtr()
{
Pkmnlib.Generated.NatureLibrary.Destruct(Ptr);

BIN
PkmnLibSharp/Native/libCreatureLib.so (Stored with Git LFS)

Binary file not shown.

BIN
PkmnLibSharp/Native/libpkmnLib.so (Stored with Git LFS)

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long