2023-04-15 07:58:21 +00:00
|
|
|
using System.Diagnostics;
|
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.LibrarySettings;
|
|
|
|
|
|
|
|
namespace PkmnLibSharp.StaticData.Libraries
|
|
|
|
{
|
2023-04-15 07:58:21 +00:00
|
|
|
/// <summary>
|
|
|
|
/// This library holds several misc settings for the library.
|
|
|
|
/// </summary>
|
2022-10-01 13:39:33 +00:00
|
|
|
public class LibrarySettings : ExternPointer<LibrarySettings.CacheData>
|
|
|
|
{
|
|
|
|
public class CacheData
|
|
|
|
{
|
|
|
|
public LevelInt? MaxLevel { get; internal set; }
|
2023-04-15 07:58:21 +00:00
|
|
|
public uint? ShinyRate { get; internal set; }
|
2022-10-01 13:39:33 +00:00
|
|
|
}
|
|
|
|
|
2023-04-15 07:58:21 +00:00
|
|
|
/// <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 LibrarySettings(LevelInt maxLevel, uint shinyRate)
|
2022-10-01 13:39:33 +00:00
|
|
|
{
|
2023-04-15 07:58:21 +00:00
|
|
|
Debug.Assert(maxLevel >= 1);
|
|
|
|
Debug.Assert(shinyRate >= 1);
|
|
|
|
InitializePointer(Interface.library_settings_new(maxLevel, shinyRate), true);
|
2022-10-01 13:39:33 +00:00
|
|
|
}
|
|
|
|
|
2022-10-08 11:42:30 +00:00
|
|
|
internal LibrarySettings(IdentifiablePointer ptr, bool isOwner) : base(ptr, isOwner)
|
2022-10-01 13:39:33 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-04-15 07:58:21 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The highest level a Pokemon can be.
|
|
|
|
/// </summary>
|
2022-10-01 13:39:33 +00:00
|
|
|
public LevelInt MaxLevel => Cache.MaxLevel ??= Interface.library_settings_maximum_level(Ptr);
|
|
|
|
|
2023-04-15 07:58:21 +00:00
|
|
|
/// <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 => Cache.ShinyRate ??= Interface.library_settings_shiny_rate(Ptr);
|
|
|
|
|
2022-10-01 13:39:33 +00:00
|
|
|
protected override CacheData CreateCache() => new();
|
|
|
|
|
|
|
|
protected override void Destructor() => Interface.library_settings_drop(Ptr);
|
2023-04-15 07:58:21 +00:00
|
|
|
|
2022-10-08 11:42:30 +00:00
|
|
|
~LibrarySettings()
|
|
|
|
{
|
|
|
|
Dispose();
|
|
|
|
}
|
2022-10-01 13:39:33 +00:00
|
|
|
}
|
|
|
|
}
|