26 lines
897 B
C#
26 lines
897 B
C#
using System;
|
|
using PkmnLibSharp.Utils;
|
|
using Interface = PkmnLibSharp.FFI.StaticData.Libraries.SpeciesLibrary;
|
|
|
|
namespace PkmnLibSharp.StaticData.Libraries
|
|
{
|
|
public class SpeciesLibrary : DataLibrary<Species>
|
|
{
|
|
public SpeciesLibrary(ulong capacity) : base(Interface.species_library_new(capacity), true)
|
|
{
|
|
}
|
|
|
|
protected override void Destructor() => Interface.species_library_drop(Ptr);
|
|
|
|
public override void Add(string key, Species value) =>
|
|
Interface.species_library_add(Ptr, key.ToPtr(), value.TakeOwnershipAndInvalidate());
|
|
|
|
public override ulong Length => Interface.species_library_len(Ptr);
|
|
|
|
protected override Species? GetValueByKey(string key)
|
|
{
|
|
var ptr = Interface.species_library_get(Ptr, key.ToPtr());
|
|
return ptr == IntPtr.Zero ? null : new Species(ptr, false);
|
|
}
|
|
}
|
|
} |