PkmnLibRSharp/PkmnLibRSharp/StaticData/Libraries/LibrarySettings.cs

40 lines
1.7 KiB
C#

using System.Diagnostics;
using PkmnLibSharp.FFI;
using PkmnLibSharp.Utils;
using Interface = PkmnLibSharp.FFI.StaticData.Libraries.LibrarySettings;
namespace PkmnLibSharp.StaticData.Libraries
{
/// <summary>
/// This library holds several misc settings for the library.
/// </summary>
public class LibrarySettings : HandleType
{
protected LibrarySettings(FFIHandle handle) : base(handle) {}
/// <inheritdoc cref="LibrarySettings"/>
/// <param name="maxLevel">The highest level a Pokemon can be.</param>
/// <param name="shinyRate">
/// The chance of a Pokemon being shiny, as the denominator of a fraction, where the nominator
/// is 1. For example, if this is 1000, then the chance of a Pokemon being shiny is 1/1000.
/// </param>
public static LibrarySettings Create(LevelInt maxLevel, uint shinyRate)
{
var handle = Interface.library_settings_new(maxLevel, shinyRate).Result();
return Resolver.Instance.ResolveLibrarySettings(handle.Resolve());
}
private LevelInt? _maxLevel;
/// <summary>
/// The highest level a Pokemon can be.
/// </summary>
public LevelInt MaxLevel => _maxLevel ??= Interface.library_settings_maximum_level(Handle);
private uint? _shinyRate;
/// <summary>
/// The chance of a Pokemon being shiny, as the denominator of a fraction, where the nominator
/// is 1. For example, if this is 1000, then the chance of a Pokemon being shiny is 1/1000.
/// </summary>
public uint ShinyRate => _shinyRate ??= Interface.library_settings_shiny_rate(Handle);
}
}