Lots of work

This commit is contained in:
Deukhoofd 2020-05-02 22:58:08 +02:00
parent 25d72e14f9
commit 6b6ba9a031
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
41 changed files with 649 additions and 111 deletions

View File

@ -132,13 +132,13 @@ namespace Creaturelibbattling.Generated
/// <param name="key">const char *</param>
/// <returns>Script *</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_GetVolatileScript")]
internal static extern IntPtr GetVolatileScript(IntPtr p, string key);
internal static extern IntPtr GetVolatileScript(IntPtr p, IntPtr key);
/// <param name="p">Battle *</param>
/// <param name="key">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_AddVolatileScriptByName")]
internal static extern byte AddVolatileScriptByName(IntPtr p, string key);
internal static extern byte AddVolatileScriptByName(IntPtr p, IntPtr key);
/// <param name="p">Battle *</param>
/// <param name="script">Script *</param>
@ -150,7 +150,7 @@ namespace Creaturelibbattling.Generated
/// <param name="key">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_RemoveVolatileScript")]
internal static extern byte RemoveVolatileScript(IntPtr p, string key);
internal static extern byte RemoveVolatileScript(IntPtr p, IntPtr key);
/// <param name="p">Battle *</param>
/// <param name="script">Script *</param>
@ -162,7 +162,7 @@ namespace Creaturelibbattling.Generated
/// <param name="key">const char *</param>
/// <returns>bool</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_HasVolatileScript")]
internal static extern bool HasVolatileScript(IntPtr p, string key);
internal static extern bool HasVolatileScript(IntPtr p, IntPtr key);
/// <param name="p">Battle *</param>
/// <param name="func">Function *</param>

View File

@ -7,7 +7,7 @@ namespace Creaturelibbattling.Generated
{
/// <returns>const char *</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_C_GetLastException")]
internal static extern string GetLastException();
internal static extern IntPtr GetLastException();
}
}

View File

@ -22,7 +22,7 @@ namespace Creaturelibbattling.Generated
/// <param name="attacksNum">long unsigned int</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_Construct")]
internal static extern byte Construct(ref IntPtr @out, IntPtr library, IntPtr species, IntPtr variant, byte level, uint experience, uint uid, Gender gender, byte coloring, IntPtr heldItem, string nickname, bool secretTalent, byte talent, IntPtr attacks, ulong attacksNum);
internal static extern byte Construct(ref IntPtr @out, IntPtr library, IntPtr species, IntPtr variant, byte level, uint experience, uint uid, Gender gender, byte coloring, IntPtr heldItem, IntPtr nickname, bool secretTalent, byte talent, IntPtr attacks, ulong attacksNum);
/// <param name="p">const Creature *</param>
/// <returns>void</returns>
@ -63,7 +63,7 @@ namespace Creaturelibbattling.Generated
/// <param name="name">const char *</param>
/// <returns>bool</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_HasHeldItem")]
internal static extern bool HasHeldItem(IntPtr p, string name);
internal static extern bool HasHeldItem(IntPtr p, IntPtr name);
/// <param name="p">const Creature *</param>
/// <param name="hash">unsigned int</param>
@ -80,7 +80,7 @@ namespace Creaturelibbattling.Generated
/// <param name="name">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_SetHeldItem")]
internal static extern byte SetHeldItem(IntPtr p, string name);
internal static extern byte SetHeldItem(IntPtr p, IntPtr name);
/// <param name="p">Creature *</param>
/// <param name="hash">unsigned int</param>
@ -117,7 +117,7 @@ namespace Creaturelibbattling.Generated
/// <param name="p">Creature *</param>
/// <returns>const char *</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetNickname")]
internal static extern string GetNickname(IntPtr p);
internal static extern IntPtr GetNickname(IntPtr p);
/// <param name="p">Creature *</param>
/// <returns>long unsigned int</returns>
@ -164,7 +164,7 @@ namespace Creaturelibbattling.Generated
/// <param name="talent">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_OverrideActiveTalent")]
internal static extern byte OverrideActiveTalent(IntPtr p, string talent);
internal static extern byte OverrideActiveTalent(IntPtr p, IntPtr talent);
/// <param name="p">Creature *</param>
/// <param name="experience">unsigned int</param>
@ -181,7 +181,7 @@ namespace Creaturelibbattling.Generated
/// <param name="scriptName">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_AddVolatileScriptByName")]
internal static extern byte AddVolatileScriptByName(IntPtr p, string scriptName);
internal static extern byte AddVolatileScriptByName(IntPtr p, IntPtr scriptName);
/// <param name="p">Creature *</param>
/// <param name="script">Script *</param>
@ -193,7 +193,7 @@ namespace Creaturelibbattling.Generated
/// <param name="scriptName">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_RemoveVolatileScriptByName")]
internal static extern byte RemoveVolatileScriptByName(IntPtr p, string scriptName);
internal static extern byte RemoveVolatileScriptByName(IntPtr p, IntPtr scriptName);
/// <param name="p">Creature *</param>
/// <param name="script">Script *</param>
@ -205,7 +205,7 @@ namespace Creaturelibbattling.Generated
/// <param name="scriptName">const char *</param>
/// <returns>bool</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_HasVolatileScript")]
internal static extern bool HasVolatileScript(IntPtr p, string scriptName);
internal static extern bool HasVolatileScript(IntPtr p, IntPtr scriptName);
/// <param name="p">Creature *</param>
/// <returns>long unsigned int</returns>

View File

@ -8,7 +8,7 @@ namespace Creaturelibbattling.Generated
/// <param name="p">const DisplayTextEvent *</param>
/// <returns>const char *</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_DisplayTextEvent_GetText")]
internal static extern string GetText(IntPtr p);
internal static extern IntPtr GetText(IntPtr p);
}
}

View File

@ -23,7 +23,7 @@ namespace Creaturelibbattling.Generated
/// <param name="p">Script *</param>
/// <returns>const char *</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Script_GetName")]
internal static extern string GetName(IntPtr p);
internal static extern IntPtr GetName(IntPtr p);
/// <param name="p">Script *</param>
/// <param name="choice">const BaseTurnChoice *</param>

View File

@ -26,7 +26,7 @@ namespace Creaturelibbattling.Generated
/// <param name="scriptName">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibBattling", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ScriptResolver_LoadScript")]
internal static extern byte LoadScript(ref IntPtr @out, IntPtr p, ScriptCategory category, string scriptName);
internal static extern byte LoadScript(ref IntPtr @out, IntPtr p, ScriptCategory category, IntPtr scriptName);
}
}

View File

@ -22,7 +22,7 @@ namespace Creatureliblibrary.Generated
/// <param name="flagsCount">long unsigned int</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackData_Construct")]
internal static extern byte Construct(ref IntPtr @out, string name, byte type, AttackCategory category, byte power, byte accuracy, byte baseUsage, AttackTarget target, sbyte priority, float effectChance, string effectName, IntPtr effectParameters, ulong effectParameterCount, IntPtr flags, ulong flagsCount);
internal static extern byte Construct(ref IntPtr @out, IntPtr name, byte type, AttackCategory category, byte power, byte accuracy, byte baseUsage, AttackTarget target, sbyte priority, float effectChance, IntPtr effectName, IntPtr effectParameters, ulong effectParameterCount, IntPtr flags, ulong flagsCount);
/// <param name="p">const AttackData *</param>
/// <returns>void</returns>
@ -32,7 +32,7 @@ namespace Creatureliblibrary.Generated
/// <param name="p">const AttackData *</param>
/// <returns>const char *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackData_GetName")]
internal static extern string GetName(IntPtr p);
internal static extern IntPtr GetName(IntPtr p);
/// <param name="p">const AttackData *</param>
/// <returns>unsigned char</returns>
@ -62,7 +62,7 @@ namespace Creatureliblibrary.Generated
/// <param name="p">const AttackData *</param>
/// <returns>AttackTarget</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackData_GetTarget")]
internal static extern AttackTarget GetTarget(IntPtr p);
internal static extern Pkmnlib.AttackTarget GetTarget(IntPtr p);
/// <param name="p">const AttackData *</param>
/// <returns>signed char</returns>
@ -82,13 +82,13 @@ namespace Creatureliblibrary.Generated
/// <param name="p">const AttackData *</param>
/// <returns>const char *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackData_GetSecondaryEffectName")]
internal static extern string GetSecondaryEffectName(IntPtr p);
internal static extern IntPtr GetSecondaryEffectName(IntPtr p);
/// <param name="p">const AttackData *</param>
/// <param name="key">const char *</param>
/// <returns>bool</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackData_HasFlag")]
internal static extern bool HasFlag(IntPtr p, string key);
internal static extern bool HasFlag(IntPtr p, IntPtr key);
}
}

View File

@ -21,7 +21,7 @@ namespace Creatureliblibrary.Generated
/// <param name="t">AttackData *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackLibrary_Insert")]
internal static extern byte Insert(IntPtr p, string name, IntPtr t);
internal static extern byte Insert(IntPtr p, IntPtr name, IntPtr t);
/// <param name="p">AttackLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
@ -34,7 +34,7 @@ namespace Creatureliblibrary.Generated
/// <param name="name">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackLibrary_Delete")]
internal static extern byte Delete(IntPtr p, string name);
internal static extern byte Delete(IntPtr p, IntPtr name);
/// <param name="p">AttackLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
@ -47,7 +47,7 @@ namespace Creatureliblibrary.Generated
/// <param name="out">const AttackData *&</param>
/// <returns>bool</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackLibrary_TryGet")]
internal static extern bool TryGet(IntPtr p, string name, ref IntPtr @out);
internal static extern bool TryGet(IntPtr p, IntPtr name, ref IntPtr @out);
/// <param name="p">AttackLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
@ -61,7 +61,7 @@ namespace Creatureliblibrary.Generated
/// <param name="out">const AttackData *&</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackLibrary_Get")]
internal static extern byte Get(IntPtr p, string name, ref IntPtr @out);
internal static extern byte Get(IntPtr p, IntPtr name, ref IntPtr @out);
/// <param name="p">AttackLibrary *</param>
/// <param name="hashedKey">unsigned int</param>

View File

@ -7,7 +7,7 @@ namespace Creatureliblibrary.Generated
{
/// <returns>const char *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_C_GetLastException")]
internal static extern string GetLastException();
internal static extern IntPtr GetLastException();
}
}

View File

@ -14,7 +14,7 @@ namespace Creatureliblibrary.Generated
/// <param name="captureRate">unsigned char</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureSpecies_Construct")]
internal static extern byte Construct(ref IntPtr @out, ushort id, string name, IntPtr defaultVariant, float genderRatio, string growthRate, byte captureRate);
internal static extern byte Construct(ref IntPtr @out, ushort id, IntPtr name, IntPtr defaultVariant, float genderRatio, IntPtr growthRate, byte captureRate);
/// <param name="p">const CreatureSpecies *</param>
/// <returns>void</returns>
@ -39,18 +39,18 @@ namespace Creatureliblibrary.Generated
/// <param name="p">const CreatureSpecies *</param>
/// <returns>const char *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureSpecies_GetName")]
internal static extern string GetName(IntPtr p);
internal static extern IntPtr GetName(IntPtr p);
/// <param name="p">const CreatureSpecies *</param>
/// <returns>const char *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureSpecies_GetGrowthRate")]
internal static extern string GetGrowthRate(IntPtr p);
internal static extern IntPtr GetGrowthRate(IntPtr p);
/// <param name="p">const CreatureSpecies *</param>
/// <param name="name">const char *</param>
/// <returns>bool</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureSpecies_HasVariant")]
internal static extern bool HasVariant(IntPtr p, string name);
internal static extern bool HasVariant(IntPtr p, IntPtr name);
/// <param name="p">const CreatureSpecies *</param>
/// <param name="hash">unsigned int</param>
@ -63,7 +63,7 @@ namespace Creatureliblibrary.Generated
/// <param name="out">const SpeciesVariant *&</param>
/// <returns>bool</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureSpecies_TryGetVariant")]
internal static extern bool TryGetVariant(IntPtr p, string name, ref IntPtr @out);
internal static extern bool TryGetVariant(IntPtr p, IntPtr name, ref IntPtr @out);
/// <param name="p">const CreatureSpecies *</param>
/// <param name="hash">unsigned int</param>
@ -77,7 +77,7 @@ namespace Creatureliblibrary.Generated
/// <param name="name">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_CreatureSpecies_GetVariant")]
internal static extern byte GetVariant(ref IntPtr @out, IntPtr p, string name);
internal static extern byte GetVariant(ref IntPtr @out, IntPtr p, IntPtr name);
/// <param name="out">const SpeciesVariant *</param>
/// <param name="p">const CreatureSpecies *</param>

View File

@ -0,0 +1,63 @@
using System;
using System.Runtime.InteropServices;
namespace Creatureliblibrary.Generated
{
internal static class EffectParameter
{
/// <param name="b">bool</param>
/// <returns>EffectParameter *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_EffectParameter_FromBool")]
internal static extern IntPtr FromBool(bool b);
/// <param name="i">long int</param>
/// <returns>EffectParameter *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_EffectParameter_FromInt")]
internal static extern IntPtr FromInt(long i);
/// <param name="f">float</param>
/// <returns>EffectParameter *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_EffectParameter_FromFloat")]
internal static extern IntPtr FromFloat(float f);
/// <param name="c">const char *</param>
/// <returns>EffectParameter *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_EffectParameter_FromString")]
internal static extern IntPtr FromString(IntPtr c);
/// <param name="p">const EffectParameter *</param>
/// <returns>void</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_EffectParameter_Destruct")]
internal static extern void Destruct(IntPtr p);
/// <param name="p">const EffectParameter *</param>
/// <returns>EffectParameterType</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_EffectParameter_GetType")]
internal static extern EffectParameterType GetType(IntPtr p);
/// <param name="p">const EffectParameter *</param>
/// <param name="out">bool&</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_EffectParameter_AsBool")]
internal static extern byte AsBool(IntPtr p, ref bool @out);
/// <param name="p">const EffectParameter *</param>
/// <param name="out">long int&</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_EffectParameter_AsInt")]
internal static extern byte AsInt(IntPtr p, ref long @out);
/// <param name="p">const EffectParameter *</param>
/// <param name="out">float&</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_EffectParameter_AsFloat")]
internal static extern byte AsFloat(IntPtr p, ref float @out);
/// <param name="p">const EffectParameter *</param>
/// <param name="out">const char *&</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_EffectParameter_AsString")]
internal static extern byte AsString(IntPtr p, ref IntPtr @out);
}
}

View File

@ -21,7 +21,7 @@ namespace Creatureliblibrary.Generated
/// <param name="experience">unsigned int</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_GrowthRateLibrary_CalculateLevel")]
internal static extern byte CalculateLevel(ref byte @out, IntPtr library, string growthRate, uint experience);
internal static extern byte CalculateLevel(ref byte @out, IntPtr library, IntPtr growthRate, uint experience);
/// <param name="out">unsigned char&</param>
/// <param name="library">GrowthRateLibrary *</param>
@ -37,7 +37,7 @@ namespace Creatureliblibrary.Generated
/// <param name="level">unsigned char</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_GrowthRateLibrary_CalculateExperience")]
internal static extern byte CalculateExperience(ref uint @out, IntPtr library, string growthRate, byte level);
internal static extern byte CalculateExperience(ref uint @out, IntPtr library, IntPtr growthRate, byte level);
/// <param name="out">unsigned int&</param>
/// <param name="library">GrowthRateLibrary *</param>
@ -52,7 +52,7 @@ namespace Creatureliblibrary.Generated
/// <param name="growthRate">GrowthRate *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_GrowthRateLibrary_AddGrowthRate")]
internal static extern byte AddGrowthRate(IntPtr library, string growthRateName, IntPtr growthRate);
internal static extern byte AddGrowthRate(IntPtr library, IntPtr growthRateName, IntPtr growthRate);
/// <param name="library">GrowthRateLibrary *</param>
/// <param name="growthRateHash">unsigned int</param>

View File

@ -13,7 +13,7 @@ namespace Creatureliblibrary.Generated
/// <param name="flagsCount">long unsigned int</param>
/// <returns>Item *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Item_Construct")]
internal static extern IntPtr Construct(string name, ItemCategory category, BattleItemCategory battleCategory, int price, IntPtr flags, ulong flagsCount);
internal static extern IntPtr Construct(IntPtr name, ItemCategory category, BattleItemCategory battleCategory, int price, IntPtr flags, ulong flagsCount);
/// <param name="p">const Item *</param>
/// <returns>void</returns>
@ -23,7 +23,7 @@ namespace Creatureliblibrary.Generated
/// <param name="p">const Item *</param>
/// <returns>const char *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Item_GetName")]
internal static extern string GetName(IntPtr p);
internal static extern IntPtr GetName(IntPtr p);
/// <param name="p">const Item *</param>
/// <returns>ItemCategory</returns>
@ -44,7 +44,7 @@ namespace Creatureliblibrary.Generated
/// <param name="key">const char *</param>
/// <returns>bool</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Item_HasFlag")]
internal static extern bool HasFlag(IntPtr p, string key);
internal static extern bool HasFlag(IntPtr p, IntPtr key);
}
}

View File

@ -20,7 +20,7 @@ namespace Creatureliblibrary.Generated
/// <param name="t">Item *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemLibrary_Insert")]
internal static extern byte Insert(IntPtr p, string name, IntPtr t);
internal static extern byte Insert(IntPtr p, IntPtr name, IntPtr t);
/// <param name="p">ItemLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
@ -33,7 +33,7 @@ namespace Creatureliblibrary.Generated
/// <param name="name">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemLibrary_Delete")]
internal static extern byte Delete(IntPtr p, string name);
internal static extern byte Delete(IntPtr p, IntPtr name);
/// <param name="p">ItemLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
@ -46,7 +46,7 @@ namespace Creatureliblibrary.Generated
/// <param name="out">const Item *&</param>
/// <returns>bool</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemLibrary_TryGet")]
internal static extern bool TryGet(IntPtr p, string name, ref IntPtr @out);
internal static extern bool TryGet(IntPtr p, IntPtr name, ref IntPtr @out);
/// <param name="p">ItemLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
@ -60,7 +60,7 @@ namespace Creatureliblibrary.Generated
/// <param name="out">const Item *&</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemLibrary_Get")]
internal static extern byte Get(IntPtr p, string name, ref IntPtr @out);
internal static extern byte Get(IntPtr p, IntPtr name, ref IntPtr @out);
/// <param name="p">ItemLibrary *</param>
/// <param name="hashedKey">unsigned int</param>

View File

@ -20,7 +20,7 @@ namespace Creatureliblibrary.Generated
/// <param name="t">CreatureSpecies *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesLibrary_Insert")]
internal static extern byte Insert(IntPtr p, string name, IntPtr t);
internal static extern byte Insert(IntPtr p, IntPtr name, IntPtr t);
/// <param name="p">SpeciesLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
@ -33,7 +33,7 @@ namespace Creatureliblibrary.Generated
/// <param name="name">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesLibrary_Delete")]
internal static extern byte Delete(IntPtr p, string name);
internal static extern byte Delete(IntPtr p, IntPtr name);
/// <param name="p">SpeciesLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
@ -46,7 +46,7 @@ namespace Creatureliblibrary.Generated
/// <param name="out">const CreatureSpecies *&</param>
/// <returns>bool</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesLibrary_TryGet")]
internal static extern bool TryGet(IntPtr p, string name, ref IntPtr @out);
internal static extern bool TryGet(IntPtr p, IntPtr name, ref IntPtr @out);
/// <param name="p">SpeciesLibrary *</param>
/// <param name="hashedKey">unsigned int</param>
@ -60,7 +60,7 @@ namespace Creatureliblibrary.Generated
/// <param name="out">const CreatureSpecies *&</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesLibrary_Get")]
internal static extern byte Get(IntPtr p, string name, ref IntPtr @out);
internal static extern byte Get(IntPtr p, IntPtr name, ref IntPtr @out);
/// <param name="p">SpeciesLibrary *</param>
/// <param name="hashedKey">unsigned int</param>

View File

@ -24,7 +24,7 @@ namespace Creatureliblibrary.Generated
/// <param name="attacks">const LearnableAttacks *</param>
/// <returns>SpeciesVariant *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesVariant_Construct")]
internal static extern IntPtr Construct(string name, float height, float weight, uint baseExperience, IntPtr types, ulong typeLength, ushort baseHealth, ushort baseAttack, ushort baseDefense, ushort baseMagicalAttack, ushort baseMagicalDefense, ushort baseSpeed, IntPtr talents, ulong talentsLength, IntPtr secretTalents, ulong secretTalentsLength, IntPtr attacks);
internal static extern IntPtr Construct(IntPtr name, float height, float weight, uint baseExperience, IntPtr types, ulong typeLength, ushort baseHealth, ushort baseAttack, ushort baseDefense, ushort baseMagicalAttack, ushort baseMagicalDefense, ushort baseSpeed, IntPtr talents, ulong talentsLength, IntPtr secretTalents, ulong secretTalentsLength, IntPtr attacks);
/// <param name="p">SpeciesVariant *</param>
/// <returns>void</returns>
@ -34,7 +34,7 @@ namespace Creatureliblibrary.Generated
/// <param name="p">SpeciesVariant *</param>
/// <returns>const char *</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesVariant_GetName")]
internal static extern string GetName(IntPtr p);
internal static extern IntPtr GetName(IntPtr p);
/// <param name="p">const SpeciesVariant *</param>
/// <returns>float</returns>
@ -64,9 +64,9 @@ namespace Creatureliblibrary.Generated
/// <param name="p">SpeciesVariant *</param>
/// <param name="stat">Statistic</param>
/// <returns>unsigned int</returns>
/// <returns>unsigned short</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesVariant_GetStatistic")]
internal static extern uint GetStatistic(IntPtr p, Statistic stat);
internal static extern ushort GetStatistic(IntPtr p, Statistic stat);
/// <param name="p">const SpeciesVariant *</param>
/// <returns>long unsigned int</returns>
@ -81,9 +81,10 @@ namespace Creatureliblibrary.Generated
/// <param name="p">SpeciesVariant *</param>
/// <param name="secret">bool</param>
/// <param name="index">unsigned char</param>
/// <param name="out">const char *&</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SpeciesVariant_GetTalent")]
internal static extern byte GetTalent(IntPtr p, bool secret, byte index);
internal static extern byte GetTalent(IntPtr p, bool secret, byte index, ref IntPtr @out);
/// <param name="p">SpeciesVariant *</param>
/// <returns>const LearnableAttacks *</returns>

View File

@ -20,7 +20,7 @@ namespace Creatureliblibrary.Generated
/// <param name="type">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TypeLibrary_GetTypeId")]
internal static extern byte GetTypeId(ref byte @out, IntPtr p, string type);
internal static extern byte GetTypeId(ref byte @out, IntPtr p, IntPtr type);
/// <param name="out">unsigned char&</param>
/// <param name="p">const TypeLibrary *</param>
@ -34,7 +34,7 @@ namespace Creatureliblibrary.Generated
/// <param name="type">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("CreatureLibLibrary", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_TypeLibrary_RegisterType")]
internal static extern byte RegisterType(ref byte @out, IntPtr p, string type);
internal static extern byte RegisterType(ref byte @out, IntPtr p, IntPtr type);
/// <param name="out">unsigned char&</param>
/// <param name="p">TypeLibrary *</param>

View File

@ -25,7 +25,7 @@ namespace Pkmnlib.Generated
/// <param name="script">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_AngelScriptResolver_CreateScript")]
internal static extern byte CreateScript(IntPtr p, string name, string script);
internal static extern byte CreateScript(IntPtr p, IntPtr name, IntPtr script);
/// <param name="p">AngelScriptResolver *</param>
/// <returns>unsigned char</returns>
@ -38,20 +38,20 @@ namespace Pkmnlib.Generated
/// <param name="scriptName">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_AngelScriptResolver_LoadScript")]
internal static extern byte LoadScript(ref IntPtr @out, IntPtr p, ScriptCategory category, string scriptName);
internal static extern byte LoadScript(ref IntPtr @out, IntPtr p, ScriptCategory category, IntPtr scriptName);
/// <param name="p">AngelScriptResolver *</param>
/// <param name="file">const char *</param>
/// <param name="stripDebugInfo">bool</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_AngelScriptResolver_WriteByteCodeToFile")]
internal static extern byte WriteByteCodeToFile(IntPtr p, string file, bool stripDebugInfo);
internal static extern byte WriteByteCodeToFile(IntPtr p, IntPtr file, bool stripDebugInfo);
/// <param name="p">AngelScriptResolver *</param>
/// <param name="file">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_AngelScriptResolver_LoadByteCodeFromFile")]
internal static extern byte LoadByteCodeFromFile(IntPtr p, string file);
internal static extern byte LoadByteCodeFromFile(IntPtr p, IntPtr file);
/// <param name="p">AngelScriptResolver *</param>
/// <param name="stripDebugInfo">bool</param>
@ -72,7 +72,7 @@ namespace Pkmnlib.Generated
/// <param name="typeName">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_AngelScriptResolver_RegisterType")]
internal static extern byte RegisterType(IntPtr p, string typeName);
internal static extern byte RegisterType(IntPtr p, IntPtr typeName);
/// <param name="p">AngelScriptResolver *</param>
/// <param name="typeName">const char *</param>
@ -80,14 +80,14 @@ namespace Pkmnlib.Generated
/// <param name="func">Function *</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_AngelScriptResolver_RegisterTypeMethod")]
internal static extern byte RegisterTypeMethod(IntPtr p, string typeName, string decl, IntPtr func);
internal static extern byte RegisterTypeMethod(IntPtr p, IntPtr typeName, IntPtr decl, IntPtr func);
/// <param name="p">AngelScriptResolver *</param>
/// <param name="decl">const char *</param>
/// <param name="func">Function *</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_AngelScriptResolver_RegisterGlobalMethod")]
internal static extern byte RegisterGlobalMethod(IntPtr p, string decl, IntPtr func);
internal static extern byte RegisterGlobalMethod(IntPtr p, IntPtr decl, IntPtr func);
}
}

View File

@ -25,7 +25,7 @@ namespace Pkmnlib.Generated
/// <param name="name">const char *</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_Battle_SetWeather")]
internal static extern byte SetWeather(IntPtr p, string name);
internal static extern byte SetWeather(IntPtr p, IntPtr name);
/// <param name="p">Battle *</param>
/// <returns>unsigned char</returns>
@ -35,7 +35,7 @@ namespace Pkmnlib.Generated
/// <param name="p">Battle *</param>
/// <returns>const char *</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_Battle_GetWeatherName")]
internal static extern string GetWeatherName(IntPtr p);
internal static extern IntPtr GetWeatherName(IntPtr p);
}
}

View File

@ -7,7 +7,7 @@ namespace Pkmnlib.Generated
{
/// <returns>const char *</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_C_GetLastException")]
internal static extern string GetLastException();
internal static extern IntPtr GetLastException();
}
}

View File

@ -27,7 +27,7 @@ namespace Pkmnlib.Generated
/// <param name="into">const PokemonSpecies *</param>
/// <returns>const EvolutionData *</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_EvolutionData_CreateLocationEvolution")]
internal static extern IntPtr CreateLocationEvolution(string location, IntPtr into);
internal static extern IntPtr CreateLocationEvolution(IntPtr location, IntPtr into);
}
}

View File

@ -14,7 +14,7 @@ namespace Pkmnlib.Generated
/// <param name="flingPower">unsigned char</param>
/// <returns>Item *</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_Item_Construct")]
internal static extern IntPtr Construct(string name, ItemCategory category, BattleItemCategory battleCategory, int price, IntPtr flags, ulong flagsCount, byte flingPower);
internal static extern IntPtr Construct(IntPtr name, ItemCategory category, BattleItemCategory battleCategory, int price, IntPtr flags, ulong flagsCount, byte flingPower);
/// <param name="p">const Item *</param>
/// <returns>void</returns>

View File

@ -20,27 +20,27 @@ namespace Pkmnlib.Generated
/// <param name="nature">const Nature *</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_NatureLibrary_LoadNature")]
internal static extern byte LoadNature(IntPtr p, string name, IntPtr nature);
internal static extern byte LoadNature(IntPtr p, IntPtr name, IntPtr nature);
/// <param name="p">NatureLibrary *</param>
/// <param name="name">const char *</param>
/// <param name="out">const Nature *&</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_NatureLibrary_GetNatureByName")]
internal static extern byte GetNatureByName(IntPtr p, string name, ref IntPtr @out);
internal static extern byte GetNatureByName(IntPtr p, IntPtr name, ref IntPtr @out);
/// <param name="p">NatureLibrary *</param>
/// <param name="rand">Random *</param>
/// <returns>const char *</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_NatureLibrary_GetRandomNatureName")]
internal static extern string GetRandomNatureName(IntPtr p, IntPtr rand);
internal static extern IntPtr GetRandomNatureName(IntPtr p, IntPtr rand);
/// <param name="p">NatureLibrary *</param>
/// <param name="nature">const Nature *</param>
/// <param name="out">const char *&</param>
/// <returns>unsigned char</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_NatureLibrary_GetNatureName")]
internal static extern byte GetNatureName(IntPtr p, IntPtr nature, ref string @out);
internal static extern byte GetNatureName(IntPtr p, IntPtr nature, ref IntPtr @out);
}
}

View File

@ -34,7 +34,7 @@ namespace Pkmnlib.Generated
/// <param name="nature">const Nature *</param>
/// <returns>Pokemon *</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_Pokemon_Construct")]
internal static extern IntPtr Construct(IntPtr library, IntPtr species, IntPtr forme, byte level, uint experience, uint uid, Gender gender, byte coloring, IntPtr heldItem, string nickname, bool hiddenAbility, byte abilityIndex, IntPtr moves, ulong moveCount, byte hpIv, byte attIv, byte defIv, byte sAtIv, byte sDeIv, byte spIv, byte hpEv, byte attEv, byte defEv, byte sAtEv, byte sDeEv, byte spEv, IntPtr nature);
internal static extern IntPtr Construct(IntPtr library, IntPtr species, IntPtr forme, byte level, uint experience, uint uid, Gender gender, byte coloring, IntPtr heldItem, IntPtr nickname, bool hiddenAbility, byte abilityIndex, IntPtr moves, ulong moveCount, byte hpIv, byte attIv, byte defIv, byte sAtIv, byte sDeIv, byte spIv, byte hpEv, byte attEv, byte defEv, byte sAtEv, byte sDeEv, byte spEv, IntPtr nature);
/// <param name="p">const Pokemon *</param>
/// <returns>void</returns>

View File

@ -14,7 +14,7 @@ namespace Pkmnlib.Generated
/// <param name="baseHappiness">unsigned char</param>
/// <returns>const PokemonSpecies *</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_PokemonSpecies_Construct")]
internal static extern IntPtr Construct(ushort id, string name, IntPtr defaultForme, float genderRatio, string growthRate, byte captureRate, byte baseHappiness);
internal static extern IntPtr Construct(ushort id, IntPtr name, IntPtr defaultForme, float genderRatio, IntPtr growthRate, byte captureRate, byte baseHappiness);
/// <param name="p">const PokemonSpecies *</param>
/// <returns>void</returns>

View File

@ -13,7 +13,7 @@ namespace Pkmnlib.Generated
/// <param name="p">WeatherChangeEvent *</param>
/// <returns>const char *</returns>
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_WeatherChangeEvent_GetWeatherName")]
internal static extern string GetWeatherName(IntPtr p);
internal static extern IntPtr GetWeatherName(IntPtr p);
}
}

View File

@ -0,0 +1,63 @@
using System;
using Pkmnlib;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Library
{
public class EffectParameter : PointerWrapper
{
public EffectParameter(string s) : base(Creatureliblibrary.Generated.EffectParameter.FromString(s.ToPtr()))
{
}
public EffectParameter(bool b) : base(Creatureliblibrary.Generated.EffectParameter.FromBool(b))
{
}
public EffectParameter(long l) : base(Creatureliblibrary.Generated.EffectParameter.FromInt(l))
{
}
public EffectParameter(float f) : base(Creatureliblibrary.Generated.EffectParameter.FromFloat(f))
{
}
public EffectParameterType ParameterType =>
(EffectParameterType) Creatureliblibrary.Generated.EffectParameter.GetType(Ptr);
public bool AsBool()
{
bool b = false;
Creatureliblibrary.Generated.EffectParameter.AsBool(Ptr, ref b).Assert();
return b;
}
public long AsInt()
{
long i = 0;
Creatureliblibrary.Generated.EffectParameter.AsInt(Ptr, ref i).Assert();
return i;
}
public float AsFloat()
{
float f = 0;
Creatureliblibrary.Generated.EffectParameter.AsFloat(Ptr, ref f).Assert();
return f;
}
public string AsString()
{
IntPtr p = IntPtr.Zero;
Creatureliblibrary.Generated.EffectParameter.AsString(Ptr, ref p).Assert();
return p.PtrString();
}
internal override void DeletePtr()
{
Creatureliblibrary.Generated.EffectParameter.Destruct(Ptr);
}
}
}

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Runtime.InteropServices;
using Creatureliblibrary;
using Creatureliblibrary.Generated;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Library
{
@ -11,8 +12,11 @@ namespace PkmnLibSharp.Library
{
private string _name;
private ImmutableArray<byte> _types;
private ImmutableArray<string> _abilities;
private ImmutableArray<string> _hiddenAbilities;
private LearnableMoves _moves;
public string Name => _name ??= SpeciesVariant.GetName(Ptr);
public string Name => _name ??= SpeciesVariant.GetName(Ptr).PtrString();
public float Height => SpeciesVariant.GetHeight(Ptr);
public float Weight => SpeciesVariant.GetWeight(Ptr);
public float BaseExperience => SpeciesVariant.GetBaseExperience(Ptr);
@ -43,6 +47,48 @@ namespace PkmnLibSharp.Library
public uint BaseSpecialDefense => SpeciesVariant.GetStatistic(Ptr, Statistic.MagicalDefense);
public uint BaseSpeed => SpeciesVariant.GetStatistic(Ptr, Statistic.Speed);
public ImmutableArray<string> Abilities
{
get
{
if (_abilities != null)
return _abilities;
var abilityCount = SpeciesVariant.GetTalentCount(Ptr);
var abilities = new string[abilityCount];
for (byte i = 0; i < abilityCount; i++)
{
IntPtr s = IntPtr.Zero;
SpeciesVariant.GetTalent(Ptr, false, i, ref s).Assert();
abilities[i] = s.PtrString();
}
_abilities = abilities.ToImmutableArray();
return _abilities;
}
}
public ImmutableArray<string> HiddenAbilities
{
get
{
if (_hiddenAbilities != null)
return _hiddenAbilities;
var abilityCount = SpeciesVariant.GetSecretTalentCount(Ptr);
var abilities = new string[abilityCount];
for (byte i = 0; i < abilityCount; i++)
{
IntPtr s = IntPtr.Zero;
SpeciesVariant.GetTalent(Ptr, true, i, ref s).Assert();
abilities[i] = s.PtrString();
}
_hiddenAbilities = abilities.ToImmutableArray();
return _hiddenAbilities;
}
}
public int GetPkmnType(int index)
{
@ -52,28 +98,25 @@ namespace PkmnLibSharp.Library
public static unsafe Forme Create(string name, float height, float weight, uint baseExperience, byte[] types,
ushort baseHealth, ushort baseAttack, ushort baseDefense, ushort baseSpecialAttack,
ushort baseSpecialDefense, ushort baseSpeed, string[] abilities, string[] hiddenAbilities)
ushort baseSpecialDefense, ushort baseSpeed, string[] abilities, string[] hiddenAbilities,
LearnableMoves moves)
{
var abilitiesConverted = abilities.Select(Marshal.StringToHGlobalUni).ToArray();
var hiddenAbilitiesConverted = hiddenAbilities.Select(Marshal.StringToHGlobalUni).ToArray();
fixed (byte* t = types)
var abilitiesConverted = abilities.Select(x => x.ToPtr()).ToArray();
var hiddenAbilitiesConverted = hiddenAbilities.Select(x => x.ToPtr()).ToArray();
fixed (IntPtr* ab = abilitiesConverted)
{
fixed (IntPtr* ab = abilitiesConverted)
fixed (IntPtr* hab = hiddenAbilitiesConverted)
{
fixed (IntPtr* hab = hiddenAbilitiesConverted)
{
var ptr = SpeciesVariant.Construct(name, height, weight, baseExperience, (IntPtr) t,
(ulong) types.Length,
baseHealth, baseAttack, baseDefense, baseSpecialAttack, baseSpecialDefense,
baseSpeed, (IntPtr) ab, (ulong) abilities.Length, (IntPtr) hab,
(ulong) hiddenAbilities.Length, IntPtr.Zero);
var f = new Forme(ptr);
foreach (var intPtr in abilitiesConverted)
Marshal.FreeHGlobal(intPtr);
foreach (var intPtr in hiddenAbilitiesConverted)
Marshal.FreeHGlobal(intPtr);
return f;
}
var ptr = SpeciesVariant.Construct(name.ToPtr(), height, weight, baseExperience, types.ArrayPtr(),
(ulong) types.Length, baseHealth, baseAttack, baseDefense, baseSpecialAttack,
baseSpecialDefense, baseSpeed, (IntPtr) ab, (ulong) abilities.Length, (IntPtr) hab,
(ulong) hiddenAbilities.Length, moves.Ptr);
var f = new Forme(ptr);
foreach (var intPtr in abilitiesConverted)
Marshal.FreeHGlobal(intPtr);
foreach (var intPtr in hiddenAbilitiesConverted)
Marshal.FreeHGlobal(intPtr);
return f;
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using Creatureliblibrary.Generated;
namespace PkmnLibSharp.Library
{
public class LearnableMoves : PointerWrapper
{
private LearnableMoves(IntPtr ptr) : base(ptr)
{
}
public static LearnableMoves Create(byte maxLevel)
{
var ptr = IntPtr.Zero;
LearnableAttacks.Construct(ref ptr, maxLevel);
return new LearnableMoves(ptr);
}
public void AddLevelAttack(byte level, MoveData move)
{
LearnableAttacks.AddLevelAttack(Ptr, level, move.Ptr);
}
internal override void DeletePtr()
{
LearnableAttacks.Destruct(Ptr);
}
}
}

View File

@ -0,0 +1,58 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;
using Creatureliblibrary.Generated;
using Pkmnlib;
using PkmnLibSharp.Utilities;
using AttackCategory = Creatureliblibrary.AttackCategory;
namespace PkmnLibSharp.Library
{
public class MoveData : PointerWrapper
{
private string _name;
private string _secondaryEffectName;
public string Name => _name ??= AttackData.GetName(Ptr).PtrString();
public byte Type => AttackData.GetType(Ptr);
public MoveCategory Category => (MoveCategory) AttackData.GetCategory(Ptr);
public byte BasePower => AttackData.GetBasePower(Ptr);
public byte Accuracy => AttackData.GetAccuracy(Ptr);
public byte BaseUsages => AttackData.GetBaseUsages(Ptr);
public AttackTarget Target => AttackData.GetTarget(Ptr);
public sbyte Priority => AttackData.GetPriority(Ptr);
public bool HasSecondaryEffect => AttackData.HasSecondaryEffect(Ptr);
public float SecondaryEffectChance => AttackData.GetSecondaryEffectChance(Ptr);
public string SecondaryEffectName =>
_secondaryEffectName ??= AttackData.GetSecondaryEffectName(Ptr).PtrString();
public bool HasFlag(string s)
{
return AttackData.HasFlag(Ptr, s.ToPtr());
}
public static MoveData Create(string name, byte type, MoveCategory category, byte power, byte accuracy,
byte baseUsage, AttackTarget target, sbyte priority, float effectChance, string effectName,
EffectParameter[] parameters, string[] flags)
{
var ptr = IntPtr.Zero;
var pars = parameters.Select(x => x.Ptr).ToArray().ArrayPtr();
var f = flags.Select(x => x.ToPtr()).ToArray().ArrayPtr();
AttackData.Construct(ref ptr, name.ToPtr(), type, (AttackCategory) category, power, accuracy, baseUsage,
(Creatureliblibrary.AttackTarget) target, priority, effectChance, effectName.ToPtr(), pars,
(ulong) parameters.Length, f, (ulong) flags.Length).Assert();
return new MoveData(ptr);
}
private MoveData(IntPtr ptr) : base(ptr)
{
}
internal override void DeletePtr()
{
AttackData.Destruct(Ptr);
}
}
}

View File

@ -1,13 +1,17 @@
using System;
using System.Runtime.InteropServices;
using Pkmnlib.Generated;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Library
{
public class Species : PointerWrapper
{
// ReSharper disable once SuggestBaseTypeForParameter
public Species(ushort id, string name, Forme defaultForme, float genderRatio, string growthRate, byte captureRate,
byte baseHappiness) : base(PokemonSpecies.Construct(id, name, defaultForme.Ptr, genderRatio, growthRate, captureRate, baseHappiness))
public Species(ushort id, string name, Forme defaultForme, float genderRatio, string growthRate,
byte captureRate,
byte baseHappiness) : base(PokemonSpecies.Construct(id, name.ToPtr(), defaultForme.Ptr, genderRatio,
growthRate.ToPtr(), captureRate, baseHappiness))
{
}

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,11 @@
using System;
namespace PkmnLibSharp
{
public class NativeException : Exception
{
public NativeException(string library, string message) : base($"[{library}] - '{message}'")
{
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections;
using System.Runtime.InteropServices;
namespace PkmnLibSharp.Utilities
{
internal static class MarshalHelper
{
internal static IntPtr ToPtr(this string s)
{
return Marshal.StringToHGlobalAuto(s);
}
internal static string PtrString(this IntPtr i)
{
return Marshal.PtrToStringAuto(i);
}
internal static IntPtr ArrayPtr(this Array a)
{
return Marshal.UnsafeAddrOfPinnedArrayElement(a, 0);
}
}
}

View File

@ -0,0 +1,20 @@
using System;
namespace PkmnLibSharp.Utilities
{
internal static class ResultChecker
{
internal static void Assert(this byte result)
{
if (result == 0) return;
if (result == 1)
{
throw new NativeException("CreatureLib", Creatureliblibrary.Generated.C.GetLastException().PtrString());
}
if (result == 2)
{
throw new NativeException("PkmnLib", Pkmnlib.Generated.C.GetLastException().PtrString());
}
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -62,13 +62,12 @@ def parse_type(type, enumSet):
return "float"
if (type == "long unsigned int"):
return "ulong"
if (type == "long int"):
return "long"
if (type == "unsigned int"):
return "uint"
if (type == "int"):
return "int"
if (type == "const char *"):
return "string"
if (type.endswith("*")):
return "IntPtr"
if (type.endswith("&")):

View File

@ -0,0 +1,60 @@
using System;
using NUnit.Framework;
using Pkmnlib;
using PkmnLibSharp;
using PkmnLibSharp.Library;
namespace PkmnLibSharpTests.Library
{
public class EffectParameterTests
{
[Test]
public void CreateInt([Range(-10000000, 10000000, 1000000)] long value)
{
var p = new EffectParameter(value);
Assert.AreEqual(EffectParameterType.Int, p.ParameterType);
Assert.AreEqual(value, p.AsInt());
p.Dispose();
}
[Test]
public void CreateBool()
{
var p = new EffectParameter(true);
Assert.AreEqual(EffectParameterType.Bool, p.ParameterType);
Assert.AreEqual(true, p.AsBool());
p.Dispose();
p = new EffectParameter(false);
Assert.AreEqual(EffectParameterType.Bool, p.ParameterType);
Assert.AreEqual(false, p.AsBool());
p.Dispose();
}
[Test]
public void CreateFloat([Range(-5, 5, 0.25f)] float value)
{
var p = new EffectParameter(value);
Assert.AreEqual(EffectParameterType.Float, p.ParameterType);
Assert.AreEqual(value, p.AsFloat());
p.Dispose();
}
[Test]
public void CreateString()
{
var p = new EffectParameter("foobar");
Assert.AreEqual(EffectParameterType.String, p.ParameterType);
Assert.AreEqual("foobar", p.AsString());
p.Dispose();
}
[Test]
public void ThrowOnWrongType()
{
var p = new EffectParameter(10);
var ex = Assert.Throws<NativeException>(() => { p.AsString(); });
Assert.AreEqual("[CreatureLib] - 'Cast effect parameter to string, but was Int'", ex.Message);
p.Dispose();
}
}
}

View File

@ -1,8 +1,7 @@
using NUnit.Framework;
using PkmnLibSharp.Library;
namespace PkmnLibSharpTests
namespace PkmnLibSharpTests.Library
{
public class FormeTests
{
@ -10,7 +9,7 @@ namespace PkmnLibSharpTests
public void ConstructDestruct()
{
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"});
new[] {"bar"}, LearnableMoves.Create(100));
forme.Dispose();
}
@ -18,7 +17,7 @@ namespace PkmnLibSharpTests
public void GetName()
{
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"});
new[] {"bar"}, LearnableMoves.Create(100));
Assert.AreEqual("foo", forme.Name);
forme.Dispose();
}
@ -27,7 +26,7 @@ namespace PkmnLibSharpTests
public void GetHeight()
{
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"});
new[] {"bar"}, LearnableMoves.Create(100));
Assert.AreEqual(1f, forme.Height);
forme.Dispose();
}
@ -36,7 +35,7 @@ namespace PkmnLibSharpTests
public void GetWeight()
{
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"});
new[] {"bar"}, LearnableMoves.Create(100));
Assert.AreEqual(2f, forme.Weight);
forme.Dispose();
}
@ -45,7 +44,7 @@ namespace PkmnLibSharpTests
public void GetBaseExperience()
{
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"});
new[] {"bar"}, LearnableMoves.Create(100));
Assert.AreEqual(100, forme.BaseExperience);
forme.Dispose();
}
@ -54,16 +53,48 @@ namespace PkmnLibSharpTests
public void GetTypes()
{
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"});
new[] {"bar"}, LearnableMoves.Create(100));
Assert.AreEqual(0, forme.GetPkmnType(0));
forme.Dispose();
forme = Forme.Create("foo", 1, 2, 100, new byte[] {0, 1}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"});
new[] {"bar"}, LearnableMoves.Create(100));
Assert.AreEqual(0, forme.GetPkmnType(0));
Assert.AreEqual(1, forme.GetPkmnType(1));
forme.Dispose();
}
[Test]
public void GetStats()
{
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 20, 30, 40, 50, 60, new[] {"foo"},
new[] {"bar"}, LearnableMoves.Create(100));
Assert.AreEqual(10, forme.BaseHealth);
Assert.AreEqual(20, forme.BaseAttack);
Assert.AreEqual(30, forme.BaseDefense);
Assert.AreEqual(40, forme.BaseSpecialAttack);
Assert.AreEqual(50, forme.BaseSpecialDefense);
Assert.AreEqual(60, forme.BaseSpeed);
forme.Dispose();
}
[Test]
public void GetAbilities()
{
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, LearnableMoves.Create(100));
Assert.AreEqual("foo", forme.Abilities[0]);
forme.Dispose();
}
[Test]
public void GetHiddenAbilities()
{
var forme = Forme.Create("foo", 1, 2, 100, new byte[] {0}, 10, 10, 10, 10, 10, 10, new[] {"foo"},
new[] {"bar"}, LearnableMoves.Create(100));
Assert.AreEqual("bar", forme.HiddenAbilities[0]);
forme.Dispose();
}
}
}

View File

@ -0,0 +1,132 @@
using NUnit.Framework;
using Pkmnlib;
using PkmnLibSharp.Library;
namespace PkmnLibSharpTests.Library
{
public class MoveDataTests
{
[Test]
public void ConstructDestruct()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
move.Dispose();
}
[Test]
public void GetName()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual("foobar", move.Name);
move.Dispose();
}
[Test]
public void GetType()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(0, move.Type);
move.Dispose();
}
[Test]
public void GetCategory()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(MoveCategory.Physical, move.Category);
move.Dispose();
}
[Test]
public void GetBasePower()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(60, move.BasePower);
move.Dispose();
}
[Test]
public void GetAccuracy()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(100, move.Accuracy);
move.Dispose();
}
[Test]
public void GetBaseUsages()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(20, move.BaseUsages);
move.Dispose();
}
[Test]
public void GetTarget()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(AttackTarget.Adjacent, move.Target);
move.Dispose();
}
[Test]
public void GetPriority()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(1, move.Priority);
move.Dispose();
}
[Test]
public void GetEffectChance()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0.5f, "", new EffectParameter[0], new string[0]);
Assert.AreEqual(0.5f, move.SecondaryEffectChance);
move.Dispose();
}
[Test]
public void GetEffectChanceName()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0.5f, "test", new EffectParameter[0], new string[0]);
Assert.AreEqual("test", move.SecondaryEffectName);
move.Dispose();
}
[Test]
public void HasSecondaryEffect()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0.5f, "test", new EffectParameter[0], new string[0]);
Assert.True(move.HasSecondaryEffect);
move.Dispose();
move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0.5f, "", new EffectParameter[0], new string[0]);
Assert.False(move.HasSecondaryEffect);
move.Dispose();
}
[Test]
public void HasFlag()
{
var move = MoveData.Create("foobar", 0, MoveCategory.Physical, 60, 100, 20, AttackTarget.Adjacent, 1,
0.5f, "test", new EffectParameter[0], new []{"flag1"});
Assert.True(move.HasFlag("flag1"));
Assert.False(move.HasFlag("flag2"));
move.Dispose();
}
}
}