Support getting type name.

This commit is contained in:
2020-08-08 13:15:17 +02:00
parent 26f8722fee
commit 1b025ea3cf
5 changed files with 26 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Library
@@ -56,6 +57,20 @@ namespace PkmnLibSharp.Library
return f;
}
public string GetTypeName(byte typeId)
{
foreach (var kv in _cache.Where(kv => kv.Value == typeId))
{
return kv.Key;
}
var ptr = IntPtr.Zero;
Creaturelib.Generated.TypeLibrary.GetTypeName(ref ptr, Ptr, typeId).Assert();
var s = ptr.PtrString();
_cache[s] = typeId;
return s;
}
protected override void DeletePtr()
{
Creaturelib.Generated.TypeLibrary.Destruct(Ptr);