34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using PkmnLibSharp.Utils;
|
|
using Interface = PkmnLibSharp.FFI.StaticData.Libraries.SpeciesLibrary;
|
|
|
|
namespace PkmnLibSharp.StaticData.Libraries
|
|
{
|
|
/// <summary>
|
|
/// A library to store all data for Pokemon species.
|
|
/// </summary>
|
|
public class SpeciesLibrary : DataLibrary<Species>
|
|
{
|
|
/// <inheritdoc cref="SpeciesLibrary"/>
|
|
protected SpeciesLibrary(FFIHandle handle) : base(handle)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Instantiates a new Species Library.
|
|
/// </summary>
|
|
public static SpeciesLibrary Create(ulong capacity)
|
|
{
|
|
var handle = Interface.species_library_new(capacity);
|
|
var lib = Resolver.Instance.ResolveSpeciesLibrary(handle.Resolve());
|
|
if (capacity > 0)
|
|
lib.ReserveCapacity(capacity);
|
|
return lib;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void AddNative(string key, Species value)
|
|
{
|
|
Interface.species_library_add(Handle, key.ToPtr(), value.Handle);
|
|
}
|
|
}
|
|
} |