Support for getting types on Pokemon.

This commit is contained in:
Deukhoofd 2020-10-23 18:59:38 +02:00
parent 06e252dbac
commit c34d7960ab
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
9 changed files with 36 additions and 10 deletions

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using PkmnLibSharp.Library; using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities; using PkmnLibSharp.Utilities;
using Item = PkmnLibSharp.Library.Items.Item; using Item = PkmnLibSharp.Library.Items.Item;
@ -192,6 +193,18 @@ namespace PkmnLibSharp.Battling
} }
} }
public byte[] Types
{
get
{
var typesLength = Creaturelib.Generated.Creature.GetTypeCount(Ptr);
var typePtr = Creaturelib.Generated.Creature.GetTypes(Ptr);
byte[] managedArray = new byte[typesLength];
Marshal.Copy(typePtr, managedArray, 0, (int) typesLength);
return managedArray;
}
}
public sbyte HpBoost => GetStatBoost(Statistic.Health); public sbyte HpBoost => GetStatBoost(Statistic.Health);
public sbyte AttackBoost => GetStatBoost(Statistic.Attack); public sbyte AttackBoost => GetStatBoost(Statistic.Attack);
public sbyte DefenseBoost => GetStatBoost(Statistic.Defense); public sbyte DefenseBoost => GetStatBoost(Statistic.Defense);
@ -317,6 +330,7 @@ namespace PkmnLibSharp.Battling
var typeByte = Library.StaticLibrary.TypeLibrary.GetTypeId(type); var typeByte = Library.StaticLibrary.TypeLibrary.GetTypeId(type);
return Creaturelib.Generated.Creature.HasType(Ptr, typeByte) == 1; return Creaturelib.Generated.Creature.HasType(Ptr, typeByte) == 1;
} }
public void ChangeLevelBy(sbyte amount) public void ChangeLevelBy(sbyte amount)
{ {
Creaturelib.Generated.Creature.ChangeLevelBy(Ptr, amount).Assert(); Creaturelib.Generated.Creature.ChangeLevelBy(Ptr, amount).Assert();

View File

@ -10,10 +10,10 @@ namespace Arbutils.Generated
[DllImport("libArbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_C_GetLastException")] [DllImport("libArbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_C_GetLastException")]
internal static extern IntPtr GetLastException(); internal static extern IntPtr GetLastException();
/// <param name="callback">Function *</param> /// <param name="">Function *</param>
/// <returns>void</returns> /// <returns>void</returns>
[DllImport("libArbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_C_SetSignalCallback")] [DllImport("libArbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_C_SetSignalCallback")]
internal static extern void SetSignalCallback(IntPtr callback); internal static extern void SetSignalCallback(IntPtr _);
} }
} }

View File

@ -155,6 +155,16 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_HasType")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_HasType")]
internal static extern byte HasType(IntPtr p, byte type); internal static extern byte HasType(IntPtr p, byte type);
/// <param name="p">Creature *</param>
/// <returns>long unsigned int</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetTypeCount")]
internal static extern ulong GetTypeCount(IntPtr p);
/// <param name="p">Creature *</param>
/// <returns>const unsigned char *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetTypes")]
internal static extern IntPtr GetTypes(IntPtr p);
/// <param name="p">const Creature *</param> /// <param name="p">const Creature *</param>
/// <returns>unsigned int</returns> /// <returns>unsigned int</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetMaxHealth")] [DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetMaxHealth")]

BIN
PkmnLibSharp/Native/libArbutils.so (Stored with Git LFS)

Binary file not shown.

BIN
PkmnLibSharp/Native/libCreatureLib.so (Stored with Git LFS)

Binary file not shown.

BIN
PkmnLibSharp/Native/libpkmnLib.so (Stored with Git LFS)

Binary file not shown.

View File

@ -1 +1 @@
{"enums":[{"byteSize":4,"filename":"libArbutils","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"libArbutils","name":"float_round_style","values":{"-1":"round_indeterminate","0":"round_toward_zero","1":"round_to_nearest","2":"round_toward_infinity","3":"round_toward_neg_infinity"}}],"functions":[{"filename":"libArbutils","name":"Arbutils_C_GetLastException","parameters":[],"returns":"const char *"},{"filename":"libArbutils","name":"Arbutils_C_SetSignalCallback","parameters":[{"name":"callback","type":"Function *"}],"returns":"void"},{"filename":"libArbutils","name":"Arbutils_Random_Construct","parameters":[],"returns":"Random *"},{"filename":"libArbutils","name":"Arbutils_Random_ConstructWithSeed","parameters":[{"name":"seed","type":"long unsigned int"}],"returns":"Random *"},{"filename":"libArbutils","name":"Arbutils_Random_Destruct","parameters":[{"name":"p","type":"Random *"}],"returns":"void"},{"filename":"libArbutils","name":"Arbutils_Random_GetFloat","parameters":[{"name":"p","type":"Random *"}],"returns":"float"},{"filename":"libArbutils","name":"Arbutils_Random_GetDouble","parameters":[{"name":"p","type":"Random *"}],"returns":"double"},{"filename":"libArbutils","name":"Arbutils_Random_Get","parameters":[{"name":"p","type":"Random *"}],"returns":"int"},{"filename":"libArbutils","name":"Arbutils_Random_GetWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"int"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsigned","parameters":[{"name":"p","type":"Random *"}],"returns":"unsigned int"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsignedWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsignedInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"unsigned int"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetSeed","parameters":[{"name":"p","type":"Random *"}],"returns":"long unsigned int"}]} {"enums":[{"byteSize":4,"filename":"libArbutils","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"libArbutils","name":"float_round_style","values":{"-1":"round_indeterminate","0":"round_toward_zero","1":"round_to_nearest","2":"round_toward_infinity","3":"round_toward_neg_infinity"}}],"functions":[{"filename":"libArbutils","name":"Arbutils_C_GetLastException","parameters":[],"returns":"const char *"},{"filename":"libArbutils","name":"Arbutils_C_SetSignalCallback","parameters":[{"name":"","type":"Function *"}],"returns":"void"},{"filename":"libArbutils","name":"Arbutils_Random_Construct","parameters":[],"returns":"Random *"},{"filename":"libArbutils","name":"Arbutils_Random_ConstructWithSeed","parameters":[{"name":"seed","type":"long unsigned int"}],"returns":"Random *"},{"filename":"libArbutils","name":"Arbutils_Random_Destruct","parameters":[{"name":"p","type":"Random *"}],"returns":"void"},{"filename":"libArbutils","name":"Arbutils_Random_GetFloat","parameters":[{"name":"p","type":"Random *"}],"returns":"float"},{"filename":"libArbutils","name":"Arbutils_Random_GetDouble","parameters":[{"name":"p","type":"Random *"}],"returns":"double"},{"filename":"libArbutils","name":"Arbutils_Random_Get","parameters":[{"name":"p","type":"Random *"}],"returns":"int"},{"filename":"libArbutils","name":"Arbutils_Random_GetWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"int"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsigned","parameters":[{"name":"p","type":"Random *"}],"returns":"unsigned int"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsignedWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsignedInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"unsigned int"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetSeed","parameters":[{"name":"p","type":"Random *"}],"returns":"long unsigned int"}]}

File diff suppressed because one or more lines are too long

View File

@ -94,6 +94,8 @@ def parse_type(type, enumSet):
def clean_name(name): def clean_name(name):
if (name == "out"): if (name == "out"):
return "@out" return "@out"
if (name == ""):
return "_"
return name return name
def write_class(c, enumSet): def write_class(c, enumSet):