Support getting type name.
This commit is contained in:
parent
26f8722fee
commit
1b025ea3cf
|
@ -23,13 +23,6 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TypeLibrary_GetTypeId")]
|
||||
internal static extern byte GetTypeId(ref byte @out, IntPtr p, IntPtr type);
|
||||
|
||||
/// <param name="out">unsigned char &</param>
|
||||
/// <param name="p">const TypeLibrary *</param>
|
||||
/// <param name="type">unsigned int</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TypeLibrary_GetTypeIdWithHash")]
|
||||
internal static extern byte GetTypeIdWithHash(ref byte @out, IntPtr p, uint type);
|
||||
|
||||
/// <param name="out">unsigned char &</param>
|
||||
/// <param name="p">TypeLibrary *</param>
|
||||
/// <param name="type">const char *</param>
|
||||
|
@ -37,13 +30,6 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TypeLibrary_RegisterType")]
|
||||
internal static extern byte RegisterType(ref byte @out, IntPtr p, IntPtr type);
|
||||
|
||||
/// <param name="out">unsigned char &</param>
|
||||
/// <param name="p">TypeLibrary *</param>
|
||||
/// <param name="type">unsigned int</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TypeLibrary_RegisterTypeWithHash")]
|
||||
internal static extern byte RegisterTypeWithHash(ref byte @out, IntPtr p, uint type);
|
||||
|
||||
/// <param name="p">TypeLibrary *</param>
|
||||
/// <param name="attacking">unsigned char</param>
|
||||
/// <param name="defensive">unsigned char</param>
|
||||
|
@ -69,5 +55,12 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TypeLibrary_GetEffectiveness")]
|
||||
internal static extern byte GetEffectiveness(ref float @out, IntPtr p, byte attacking, IntPtr defensive, ulong defensiveCount);
|
||||
|
||||
/// <param name="out">const char * &</param>
|
||||
/// <param name="p">TypeLibrary *</param>
|
||||
/// <param name="type">unsigned char</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TypeLibrary_GetTypeName")]
|
||||
internal static extern byte GetTypeName(ref IntPtr @out, IntPtr p, byte type);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
BIN
PkmnLibSharp/Native/libCreatureLib.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libCreatureLib.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/libpkmnLib.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libpkmnLib.so (Stored with Git LFS)
Binary file not shown.
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue