43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using JetBrains.Annotations;
|
|
using PkmnLibSharp.Utils;
|
|
using Interface = PkmnLibSharp.FFI.StaticData.Libraries.GrowthRateLibrary;
|
|
|
|
namespace PkmnLibSharp.StaticData.Libraries
|
|
{
|
|
public class GrowthRateLibrary : HandleType
|
|
{
|
|
// ReSharper disable once CollectionNeverQueried.Local
|
|
private Dictionary<string, GrowthRate> _growthRates = new();
|
|
|
|
protected GrowthRateLibrary(FFIHandle handle) : base(handle)
|
|
{
|
|
}
|
|
|
|
public static GrowthRateLibrary Create(ulong capacity)
|
|
{
|
|
var handle = Interface.growth_rate_library_new(capacity);
|
|
var lib = Resolver.Instance.ResolveGrowthRateLibrary(handle.Resolve());
|
|
if (capacity > 0)
|
|
lib._growthRates = new Dictionary<string, GrowthRate>((int)capacity, StringComparer.InvariantCultureIgnoreCase);
|
|
return lib;
|
|
}
|
|
|
|
[MustUseReturnValue]
|
|
public LevelInt CalculateLevel(string name, uint experience) =>
|
|
Interface.growth_rate_library_calculate_level(Handle, name.ToPtr(), experience).Result();
|
|
|
|
[MustUseReturnValue]
|
|
public uint CalculateExperience(string name, LevelInt level)
|
|
{
|
|
return Interface.growth_rate_library_calculate_experience(Handle, name.ToPtr(), level).Result();
|
|
}
|
|
|
|
public void AddGrowthRate(string name, GrowthRate growthRate)
|
|
{
|
|
Interface.growth_rate_library_add_growth_rate(Handle, name.ToPtr(), growthRate.Handle);
|
|
_growthRates.Add(name, growthRate);
|
|
}
|
|
}
|
|
} |