Adds interface for LearnableMoves

This commit is contained in:
Deukhoofd 2022-09-20 18:09:08 +02:00
parent 65d55a95fa
commit 8bb62aa260
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,20 @@
using System;
using System.Runtime.InteropServices;
using PkmnLibSharp.StaticData;
using LevelInt = System.Byte;
namespace PkmnLibSharp.FFI.StaticData
{
internal static class LearnableMoves
{
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr learnable_moves_new();
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl)]
internal static extern void learnable_moves_drop(IntPtr p);
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl)]
internal static extern void learnable_moves_add_level_move(IntPtr p, LevelInt level, IntPtr moveName);
}
}

View File

@ -0,0 +1,27 @@
using PkmnLibSharp.Utils;
using Interface = PkmnLibSharp.FFI.StaticData.LearnableMoves;
using LevelInt = System.Byte;
namespace PkmnLibSharp.StaticData
{
public class LearnableMoves : ExternPointer<object>
{
public LearnableMoves() : base(Interface.learnable_moves_new(), true)
{
}
public void AddLevelMove(LevelInt level, string moveName)
{
Interface.learnable_moves_add_level_move(Ptr, level, moveName.ToPtr());
}
public void AddLevelMove(LevelInt level, MoveData move)
{
Interface.learnable_moves_add_level_move(Ptr, level, move.Name.ToPtr());
}
protected override object CreateCache() => new object();
protected override void Destructor() => Interface.learnable_moves_drop(Ptr);
}
}