PkmnLibRSharp/PkmnLibRSharp/StaticData/Libraries/GrowthRateLibrary.cs

43 lines
1.4 KiB
C#
Raw Normal View History

2022-10-01 13:39:33 +00:00
using System;
2023-04-15 07:58:21 +00:00
using System.Diagnostics;
2022-10-01 13:39:33 +00:00
using JetBrains.Annotations;
2022-10-08 11:42:30 +00:00
using PkmnLibSharp.FFI;
2022-10-01 13:39:33 +00:00
using PkmnLibSharp.Utils;
using Interface = PkmnLibSharp.FFI.StaticData.Libraries.GrowthRateLibrary;
namespace PkmnLibSharp.StaticData.Libraries
{
public class GrowthRateLibrary : ExternPointer<object>
{
public GrowthRateLibrary(ulong capacity) : base(Interface.growth_rate_library_new(capacity), true)
{
}
2022-10-08 11:42:30 +00:00
internal GrowthRateLibrary(IdentifiablePointer ptr, bool isOwner) : base(ptr, isOwner)
2022-10-01 13:39:33 +00:00
{
}
[MustUseReturnValue]
public LevelInt CalculateLevel(string growthRate, uint experience) =>
Interface.growth_rate_library_calculate_level(Ptr, growthRate.ToPtr(), experience);
[MustUseReturnValue]
2023-04-15 07:58:21 +00:00
public uint CalculateExperience(string growthRate, LevelInt level)
{
Debug.Assert(level >= 1);
return Interface.growth_rate_library_calculate_experience(Ptr, growthRate.ToPtr(), level);
}
2022-10-01 13:39:33 +00:00
public void AddGrowthRate(string name, GrowthRate growthRate) =>
Interface.growth_rate_library_add_growth_rate(Ptr, name.ToPtr(), growthRate.TakeOwnershipAndInvalidate());
protected override object CreateCache() => new();
protected override void Destructor() => Interface.growth_rate_library_drop(Ptr);
2022-10-08 11:42:30 +00:00
~GrowthRateLibrary()
{
Dispose();
}
2022-10-01 13:39:33 +00:00
}
}