Implements growth rates
This commit is contained in:
22
PkmnLibRSharp/FFI/StaticData/GrowthRate.cs
Normal file
22
PkmnLibRSharp/FFI/StaticData/GrowthRate.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using LevelInt = System.Byte;
|
||||
|
||||
namespace PkmnLibSharp.FFI.StaticData
|
||||
{
|
||||
internal static class GrowthRate
|
||||
{
|
||||
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
internal static extern IntPtr growth_rate_lookup_new(IntPtr array, ulong length);
|
||||
|
||||
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
internal static extern void growth_rate_lookup_drop(IntPtr p);
|
||||
|
||||
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
internal static extern LevelInt growth_rate_calculate_level(IntPtr p, uint experience);
|
||||
|
||||
[DllImport(Data.DllName, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
|
||||
internal static extern uint growth_rate_calculate_experience(IntPtr p, LevelInt level);
|
||||
}
|
||||
}
|
||||
49
PkmnLibRSharp/StaticData/GrowthRate.cs
Normal file
49
PkmnLibRSharp/StaticData/GrowthRate.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PkmnLibSharp.Utils;
|
||||
using Interface = PkmnLibSharp.FFI.StaticData.GrowthRate;
|
||||
using LevelInt = System.Byte;
|
||||
|
||||
namespace PkmnLibSharp.StaticData
|
||||
{
|
||||
public abstract class GrowthRate : ExternPointer<object>
|
||||
{
|
||||
protected internal GrowthRate()
|
||||
{
|
||||
}
|
||||
|
||||
protected internal GrowthRate(IntPtr ptr, bool isOwner) : base(ptr, isOwner)
|
||||
{
|
||||
}
|
||||
|
||||
public LevelInt CalculateLevel(uint experience)
|
||||
{
|
||||
return Interface.growth_rate_calculate_level(Ptr, experience);
|
||||
}
|
||||
|
||||
public uint CalculateExperience(LevelInt level)
|
||||
{
|
||||
return Interface.growth_rate_calculate_experience(Ptr, level);
|
||||
}
|
||||
|
||||
protected override void Destructor()
|
||||
{
|
||||
Interface.growth_rate_lookup_drop(Ptr);
|
||||
}
|
||||
}
|
||||
|
||||
public class LookupGrowthRate : GrowthRate
|
||||
{
|
||||
public LookupGrowthRate(uint[] experienceArray)
|
||||
{
|
||||
var arrayPtr = experienceArray.ArrayPtr();
|
||||
var ptr = Interface.growth_rate_lookup_new(arrayPtr, (ulong)experienceArray.Length);
|
||||
InitializePointer(ptr, true);
|
||||
}
|
||||
|
||||
protected override object CreateCache()
|
||||
{
|
||||
return new object();
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
PkmnLibRSharp/libpkmn_lib.so
(Stored with Git LFS)
BIN
PkmnLibRSharp/libpkmn_lib.so
(Stored with Git LFS)
Binary file not shown.
Reference in New Issue
Block a user