Cleanup for EventData.
This commit is contained in:
parent
504bee3bda
commit
00cfd3c469
|
@ -20,14 +20,30 @@ namespace PkmnLibSharp.Battling.Events
|
|||
{
|
||||
_del = del;
|
||||
_innerDel = OnEventPtr;
|
||||
FunctionPtr = Marshal.GetFunctionPointerForDelegate<BattleEventPtrDelegate>(_innerDel);
|
||||
FunctionPtr = Marshal.GetFunctionPointerForDelegate(_innerDel);
|
||||
}
|
||||
|
||||
public void EnsureFinishedListening()
|
||||
{
|
||||
try
|
||||
{
|
||||
_currentTask?.Wait();
|
||||
}
|
||||
catch (AggregateException e)
|
||||
{
|
||||
LogHandler.Log(LogHandler.LogLevel.Error, e.GetBaseException().Message);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LogHandler.Log(LogHandler.LogLevel.Error, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEventPtr(IntPtr ptr)
|
||||
{
|
||||
// If we're still registering another event, wait until that's done. This ensures events always arrive in
|
||||
// the correct order.
|
||||
_currentTask?.Wait();
|
||||
EnsureFinishedListening();
|
||||
// We do however want to run the event handler async, so that the battle code can keep running up till its
|
||||
// next event.
|
||||
_currentTask = Task.Run(() => InternalRunner(ptr));
|
||||
|
@ -60,10 +76,21 @@ namespace PkmnLibSharp.Battling.Events
|
|||
return new ExperienceGainEvent(evtType, ptr);
|
||||
case EventDataKind.DisplayText:
|
||||
break;
|
||||
case EventDataKind.Miss:
|
||||
break;
|
||||
case EventDataKind.ChangeSpecies:
|
||||
break;
|
||||
case EventDataKind.ChangeVariant:
|
||||
break;
|
||||
case EventDataKind.AttackUse:
|
||||
break;
|
||||
case EventDataKind.WeatherChange:
|
||||
break;
|
||||
case EventDataKind.StatusChange:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
throw new ArgumentOutOfRangeException($"Unknown event kind: " + evtType);
|
||||
}
|
||||
Creaturelib.Generated.EventData.Destruct(ptr);
|
||||
throw new NotImplementedException($"Unhandled battle event: '{evtType}'");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
||||
namespace PkmnLibSharp.Battling.Events
|
||||
{
|
||||
public class DisplayTextEvent : EventData
|
||||
{
|
||||
internal DisplayTextEvent(EventDataKind kind, IntPtr ptr) : base(kind, ptr)
|
||||
{
|
||||
}
|
||||
|
||||
public string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_text != null) return _text;
|
||||
_text = Creaturelib.Generated.DisplayTextEvent.GetText(Ptr).PtrString();
|
||||
return _text!;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string? _text;
|
||||
protected override void DeletePtr()
|
||||
{
|
||||
Creaturelib.Generated.DisplayTextEvent.Destruct(Ptr);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,13 @@ namespace PkmnLibSharp.Battling.Events
|
|||
TurnStart = 4,
|
||||
TurnEnd = 5,
|
||||
ExperienceGain = 6,
|
||||
DisplayText = 7,
|
||||
Miss = 7,
|
||||
DisplayText = 8,
|
||||
ChangeSpecies = 9,
|
||||
ChangeVariant = 10,
|
||||
AttackUse = 11,
|
||||
|
||||
WeatherChange = 128,
|
||||
StatusChange = 129,
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace PkmnLibSharp.Battling
|
||||
{
|
||||
public static class LogHandler
|
||||
{
|
||||
private static readonly List<Action<LogLevel, string>> Listeners = new List<Action<LogLevel, string>>();
|
||||
|
||||
public enum LogLevel
|
||||
{
|
||||
Information,
|
||||
Warning,
|
||||
Error
|
||||
}
|
||||
|
||||
public static void RegisterListener(Action<LogLevel, string> listener)
|
||||
{
|
||||
Listeners.Add(listener);
|
||||
}
|
||||
|
||||
internal static void Log(LogLevel level, string message)
|
||||
{
|
||||
foreach (var listener in Listeners)
|
||||
{
|
||||
listener(level, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,5 +4,6 @@ namespace PkmnLibSharp.Battling
|
|||
{
|
||||
Unknown = 0,
|
||||
Level = 1,
|
||||
Tutor = 2,
|
||||
}
|
||||
}
|
|
@ -402,6 +402,26 @@ namespace PkmnLibSharp.Battling
|
|||
Pkmnlib.Generated.Pokemon.ChangeFriendship(Ptr, amount);
|
||||
}
|
||||
|
||||
public byte FirstAvailableMoveSlot()
|
||||
{
|
||||
return Creaturelib.Generated.Creature.GetAvailableAttackSlot(Ptr);
|
||||
}
|
||||
|
||||
public void AddMove(LearnedMove move)
|
||||
{
|
||||
Creaturelib.Generated.Creature.AddAttack(Ptr, move.Ptr).Assert();
|
||||
}
|
||||
public void ReplaceMove(byte index, LearnedMove move)
|
||||
{
|
||||
Creaturelib.Generated.Creature.ReplaceAttack(Ptr, index, move.Ptr).Assert();
|
||||
}
|
||||
|
||||
public void SwapMoves(byte a, byte b)
|
||||
{
|
||||
Creaturelib.Generated.Creature.SwapAttack(Ptr, a, b).Assert();
|
||||
}
|
||||
|
||||
|
||||
private Species? _displaySpecies;
|
||||
private Forme? _displayForme;
|
||||
private Species? _species;
|
||||
|
|
|
@ -8,8 +8,6 @@ namespace Creaturelib
|
|||
{
|
||||
Adjacent = 0,
|
||||
AdjacentAlly = 1,
|
||||
RandomOpponent = 10,
|
||||
Self = 11,
|
||||
AdjacentAllySelf = 2,
|
||||
AdjacentOpponent = 3,
|
||||
All = 4,
|
||||
|
@ -18,5 +16,7 @@ namespace Creaturelib
|
|||
AllAlly = 7,
|
||||
AllOpponent = 8,
|
||||
Any = 9,
|
||||
RandomOpponent = 10,
|
||||
Self = 11,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,13 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetVariant")]
|
||||
internal static extern IntPtr GetVariant(IntPtr p);
|
||||
|
||||
/// <param name="p">Creature *</param>
|
||||
/// <param name="species">const CreatureSpecies *</param>
|
||||
/// <param name="variant">const SpeciesVariant *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_ChangeSpecies")]
|
||||
internal static extern byte ChangeSpecies(IntPtr p, IntPtr species, IntPtr variant);
|
||||
|
||||
/// <param name="p">Creature *</param>
|
||||
/// <param name="variant">const SpeciesVariant *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
|
@ -295,5 +302,30 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetStatBoost")]
|
||||
internal static extern sbyte GetStatBoost(IntPtr p, Statistic stat);
|
||||
|
||||
/// <param name="p">const Creature *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_GetAvailableAttackSlot")]
|
||||
internal static extern byte GetAvailableAttackSlot(IntPtr p);
|
||||
|
||||
/// <param name="p">Creature *</param>
|
||||
/// <param name="attack">LearnedAttack *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_AddAttack")]
|
||||
internal static extern byte AddAttack(IntPtr p, IntPtr attack);
|
||||
|
||||
/// <param name="p">Creature *</param>
|
||||
/// <param name="index">long unsigned int</param>
|
||||
/// <param name="attack">LearnedAttack *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_ReplaceAttack")]
|
||||
internal static extern byte ReplaceAttack(IntPtr p, ulong index, IntPtr attack);
|
||||
|
||||
/// <param name="p">Creature *</param>
|
||||
/// <param name="a">long unsigned int</param>
|
||||
/// <param name="b">long unsigned int</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_SwapAttack")]
|
||||
internal static extern byte SwapAttack(IntPtr p, ulong a, ulong b);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ namespace Creaturelib
|
|||
TurnStart = 4,
|
||||
TurnEnd = 5,
|
||||
ExperienceGain = 6,
|
||||
DisplayText = 7,
|
||||
Miss = 7,
|
||||
DisplayText = 8,
|
||||
ChangeSpecies = 9,
|
||||
ChangeVariant = 10,
|
||||
AttackUse = 11,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace Creaturelib.Generated
|
|||
|
||||
/// <param name="p">const LibrarySettings *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_LibrarySettings_GetMaximalMoves")]
|
||||
internal static extern byte GetMaximalMoves(IntPtr p);
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_LibrarySettings_GetMaximalAttacks")]
|
||||
internal static extern byte GetMaximalAttacks(IntPtr p);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ namespace Pkmnlib
|
|||
{
|
||||
Adjacent = 0,
|
||||
AdjacentAlly = 1,
|
||||
RandomOpponent = 10,
|
||||
Self = 11,
|
||||
AdjacentAllySelf = 2,
|
||||
AdjacentOpponent = 3,
|
||||
All = 4,
|
||||
|
@ -18,5 +16,7 @@ namespace Pkmnlib
|
|||
AllAlly = 7,
|
||||
AllOpponent = 8,
|
||||
Any = 9,
|
||||
RandomOpponent = 10,
|
||||
Self = 11,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ namespace Pkmnlib
|
|||
TurnStart = 4,
|
||||
TurnEnd = 5,
|
||||
ExperienceGain = 6,
|
||||
DisplayText = 7,
|
||||
Miss = 7,
|
||||
DisplayText = 8,
|
||||
ChangeSpecies = 9,
|
||||
ChangeVariant = 10,
|
||||
AttackUse = 11,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,6 @@ namespace Pkmnlib
|
|||
{
|
||||
Level = 0,
|
||||
HighFriendship = 1,
|
||||
TradeWithHeldItem = 10,
|
||||
TradeWithSpecificPokemon = 11,
|
||||
Custom = 12,
|
||||
KnownMove = 2,
|
||||
LocationBased = 3,
|
||||
TimeBased = 4,
|
||||
|
@ -19,5 +16,8 @@ namespace Pkmnlib
|
|||
EvolutionItemUse = 7,
|
||||
EvolutionItemUseWithGender = 8,
|
||||
Trade = 9,
|
||||
TradeWithHeldItem = 10,
|
||||
TradeWithSpecificPokemon = 11,
|
||||
Custom = 12,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,6 @@ namespace Pkmnlib
|
|||
{
|
||||
asBEHAVE_CONSTRUCT = 0,
|
||||
asBEHAVE_LIST_CONSTRUCT = 1,
|
||||
asBEHAVE_SETGCFLAG = 10,
|
||||
asBEHAVE_GETGCFLAG = 11,
|
||||
asBEHAVE_ENUMREFS = 12,
|
||||
asBEHAVE_RELEASEREFS = 13,
|
||||
asBEHAVE_MAX = 14,
|
||||
asBEHAVE_DESTRUCT = 2,
|
||||
asBEHAVE_FACTORY = 3,
|
||||
asBEHAVE_LIST_FACTORY = 4,
|
||||
|
@ -21,5 +16,10 @@ namespace Pkmnlib
|
|||
asBEHAVE_GET_WEAKREF_FLAG = 7,
|
||||
asBEHAVE_TEMPLATE_CALLBACK = 8,
|
||||
asBEHAVE_FIRST_GC = 9,
|
||||
asBEHAVE_SETGCFLAG = 10,
|
||||
asBEHAVE_GETGCFLAG = 11,
|
||||
asBEHAVE_ENUMREFS = 12,
|
||||
asBEHAVE_RELEASEREFS = 13,
|
||||
asBEHAVE_MAX = 14,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,14 @@ namespace Pkmnlib
|
|||
internal enum asEEngineProp : int
|
||||
{
|
||||
asEP_ALLOW_UNSAFE_REFERENCES = 1,
|
||||
asEP_OPTIMIZE_BYTECODE = 2,
|
||||
asEP_COPY_SCRIPT_SECTIONS = 3,
|
||||
asEP_MAX_STACK_SIZE = 4,
|
||||
asEP_USE_CHARACTER_LITERALS = 5,
|
||||
asEP_ALLOW_MULTILINE_STRINGS = 6,
|
||||
asEP_ALLOW_IMPLICIT_HANDLE_TYPES = 7,
|
||||
asEP_BUILD_WITHOUT_LINE_CUES = 8,
|
||||
asEP_INIT_GLOBAL_VARS_AFTER_BUILD = 9,
|
||||
asEP_REQUIRE_ENUM_SCOPE = 10,
|
||||
asEP_SCRIPT_SCANNER = 11,
|
||||
asEP_INCLUDE_JIT_INSTRUCTIONS = 12,
|
||||
|
@ -17,7 +25,6 @@ namespace Pkmnlib
|
|||
asEP_DISALLOW_GLOBAL_VARS = 17,
|
||||
asEP_ALWAYS_IMPL_DEFAULT_CONSTRUCT = 18,
|
||||
asEP_COMPILER_WARNINGS = 19,
|
||||
asEP_OPTIMIZE_BYTECODE = 2,
|
||||
asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE = 20,
|
||||
asEP_ALTER_SYNTAX_NAMED_ARGS = 21,
|
||||
asEP_DISABLE_INTEGER_DIVISION = 22,
|
||||
|
@ -28,15 +35,8 @@ namespace Pkmnlib
|
|||
asEP_MAX_NESTED_CALLS = 27,
|
||||
asEP_GENERIC_CALL_MODE = 28,
|
||||
asEP_INIT_STACK_SIZE = 29,
|
||||
asEP_COPY_SCRIPT_SECTIONS = 3,
|
||||
asEP_INIT_CALL_STACK_SIZE = 30,
|
||||
asEP_MAX_CALL_STACK_SIZE = 31,
|
||||
asEP_LAST_PROPERTY = 32,
|
||||
asEP_MAX_STACK_SIZE = 4,
|
||||
asEP_USE_CHARACTER_LITERALS = 5,
|
||||
asEP_ALLOW_MULTILINE_STRINGS = 6,
|
||||
asEP_ALLOW_IMPLICIT_HANDLE_TYPES = 7,
|
||||
asEP_BUILD_WITHOUT_LINE_CUES = 8,
|
||||
asEP_INIT_GLOBAL_VARS_AFTER_BUILD = 9,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,51 +7,51 @@ namespace Pkmnlib
|
|||
internal enum asEObjTypeFlags : int
|
||||
{
|
||||
asOBJ_REF = 1,
|
||||
asOBJ_APP_CLASS_DESTRUCTOR = 1024,
|
||||
asOBJ_IMPLICIT_HANDLE = 1048576,
|
||||
asOBJ_APP_ALIGN16 = 1073741824,
|
||||
asOBJ_ASHANDLE = 128,
|
||||
asOBJ_APP_CLASS_D = 1280,
|
||||
asOBJ_APP_CLASS_ALLFLOATS = 131072,
|
||||
asOBJ_TEMPLATE_SUBTYPE = 134217728,
|
||||
asOBJ_NOHANDLE = 16,
|
||||
asOBJ_APP_FLOAT = 16384,
|
||||
asOBJ_FUNCDEF = 16777216,
|
||||
asOBJ_APP_CLASS_CD = 1792,
|
||||
asOBJ_VALUE = 2,
|
||||
asOBJ_APP_CLASS_ASSIGNMENT = 2048,
|
||||
asOBJ_MASK_VALID_FLAGS = 2097151,
|
||||
asOBJ_SCRIPT_OBJECT = 2097152,
|
||||
asOBJ_APP_CLASS_A = 2304,
|
||||
asOBJ_APP_CLASS = 256,
|
||||
asOBJ_NOCOUNT = 262144,
|
||||
asOBJ_TYPEDEF = 268435456,
|
||||
asOBJ_APP_CLASS_CA = 2816,
|
||||
asOBJ_SCOPED = 32,
|
||||
asOBJ_APP_ARRAY = 32768,
|
||||
asOBJ_APP_CLASS_DA = 3328,
|
||||
asOBJ_LIST_PATTERN = 33554432,
|
||||
asOBJ_APP_CLASS_CDA = 3840,
|
||||
asOBJ_GC = 4,
|
||||
asOBJ_POD = 8,
|
||||
asOBJ_NOHANDLE = 16,
|
||||
asOBJ_SCOPED = 32,
|
||||
asOBJ_TEMPLATE = 64,
|
||||
asOBJ_ASHANDLE = 128,
|
||||
asOBJ_APP_CLASS = 256,
|
||||
asOBJ_APP_CLASS_CONSTRUCTOR = 512,
|
||||
asOBJ_APP_CLASS_C = 768,
|
||||
asOBJ_APP_CLASS_DESTRUCTOR = 1024,
|
||||
asOBJ_APP_CLASS_D = 1280,
|
||||
asOBJ_APP_CLASS_CD = 1792,
|
||||
asOBJ_APP_CLASS_ASSIGNMENT = 2048,
|
||||
asOBJ_APP_CLASS_A = 2304,
|
||||
asOBJ_APP_CLASS_CA = 2816,
|
||||
asOBJ_APP_CLASS_DA = 3328,
|
||||
asOBJ_APP_CLASS_CDA = 3840,
|
||||
asOBJ_APP_CLASS_COPY_CONSTRUCTOR = 4096,
|
||||
asOBJ_SHARED = 4194304,
|
||||
asOBJ_APP_CLASS_K = 4352,
|
||||
asOBJ_APP_CLASS_CK = 4864,
|
||||
asOBJ_APP_CLASS_CONSTRUCTOR = 512,
|
||||
asOBJ_APP_CLASS_ALIGN8 = 524288,
|
||||
asOBJ_ABSTRACT = 536870912,
|
||||
asOBJ_APP_CLASS_DK = 5376,
|
||||
asOBJ_APP_CLASS_CDK = 5888,
|
||||
asOBJ_TEMPLATE = 64,
|
||||
asOBJ_APP_CLASS_AK = 6400,
|
||||
asOBJ_APP_CLASS_ALLINTS = 65536,
|
||||
asOBJ_ENUM = 67108864,
|
||||
asOBJ_APP_CLASS_CAK = 6912,
|
||||
asOBJ_APP_CLASS_DAK = 7424,
|
||||
asOBJ_APP_CLASS_C = 768,
|
||||
asOBJ_APP_CLASS_CDAK = 7936,
|
||||
asOBJ_POD = 8,
|
||||
asOBJ_APP_PRIMITIVE = 8192,
|
||||
asOBJ_APP_FLOAT = 16384,
|
||||
asOBJ_APP_ARRAY = 32768,
|
||||
asOBJ_APP_CLASS_ALLINTS = 65536,
|
||||
asOBJ_APP_CLASS_ALLFLOATS = 131072,
|
||||
asOBJ_NOCOUNT = 262144,
|
||||
asOBJ_APP_CLASS_ALIGN8 = 524288,
|
||||
asOBJ_IMPLICIT_HANDLE = 1048576,
|
||||
asOBJ_MASK_VALID_FLAGS = 2097151,
|
||||
asOBJ_SCRIPT_OBJECT = 2097152,
|
||||
asOBJ_SHARED = 4194304,
|
||||
asOBJ_NOINHERIT = 8388608,
|
||||
asOBJ_FUNCDEF = 16777216,
|
||||
asOBJ_LIST_PATTERN = 33554432,
|
||||
asOBJ_ENUM = 67108864,
|
||||
asOBJ_TEMPLATE_SUBTYPE = 134217728,
|
||||
asOBJ_TYPEDEF = 268435456,
|
||||
asOBJ_ABSTRACT = 536870912,
|
||||
asOBJ_APP_ALIGN16 = 1073741824,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,34 +6,34 @@ namespace Pkmnlib
|
|||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal enum asERetCodes : int
|
||||
{
|
||||
asERROR = -1,
|
||||
asINVALID_DECLARATION = -10,
|
||||
asINVALID_OBJECT = -11,
|
||||
asINVALID_TYPE = -12,
|
||||
asALREADY_REGISTERED = -13,
|
||||
asMULTIPLE_FUNCTIONS = -14,
|
||||
asNO_MODULE = -15,
|
||||
asNO_GLOBAL_VAR = -16,
|
||||
asINVALID_CONFIGURATION = -17,
|
||||
asINVALID_INTERFACE = -18,
|
||||
asCANT_BIND_ALL_FUNCTIONS = -19,
|
||||
asCONTEXT_ACTIVE = -2,
|
||||
asLOWER_ARRAY_DIMENSION_NOT_REGISTERED = -20,
|
||||
asWRONG_CONFIG_GROUP = -21,
|
||||
asCONFIG_GROUP_IS_IN_USE = -22,
|
||||
asILLEGAL_BEHAVIOUR_FOR_TYPE = -23,
|
||||
asWRONG_CALLING_CONV = -24,
|
||||
asBUILD_IN_PROGRESS = -25,
|
||||
asINIT_GLOBAL_VARS_FAILED = -26,
|
||||
asOUT_OF_MEMORY = -27,
|
||||
asMODULE_IS_IN_USE = -28,
|
||||
asCONTEXT_NOT_FINISHED = -3,
|
||||
asCONTEXT_NOT_PREPARED = -4,
|
||||
asINVALID_ARG = -5,
|
||||
asNO_FUNCTION = -6,
|
||||
asNOT_SUPPORTED = -7,
|
||||
asINVALID_NAME = -8,
|
||||
asOUT_OF_MEMORY = -27,
|
||||
asINIT_GLOBAL_VARS_FAILED = -26,
|
||||
asBUILD_IN_PROGRESS = -25,
|
||||
asWRONG_CALLING_CONV = -24,
|
||||
asILLEGAL_BEHAVIOUR_FOR_TYPE = -23,
|
||||
asCONFIG_GROUP_IS_IN_USE = -22,
|
||||
asWRONG_CONFIG_GROUP = -21,
|
||||
asLOWER_ARRAY_DIMENSION_NOT_REGISTERED = -20,
|
||||
asCANT_BIND_ALL_FUNCTIONS = -19,
|
||||
asINVALID_INTERFACE = -18,
|
||||
asINVALID_CONFIGURATION = -17,
|
||||
asNO_GLOBAL_VAR = -16,
|
||||
asNO_MODULE = -15,
|
||||
asMULTIPLE_FUNCTIONS = -14,
|
||||
asALREADY_REGISTERED = -13,
|
||||
asINVALID_TYPE = -12,
|
||||
asINVALID_OBJECT = -11,
|
||||
asINVALID_DECLARATION = -10,
|
||||
asNAME_TAKEN = -9,
|
||||
asINVALID_NAME = -8,
|
||||
asNOT_SUPPORTED = -7,
|
||||
asNO_FUNCTION = -6,
|
||||
asINVALID_ARG = -5,
|
||||
asCONTEXT_NOT_PREPARED = -4,
|
||||
asCONTEXT_NOT_FINISHED = -3,
|
||||
asCONTEXT_ACTIVE = -2,
|
||||
asERROR = -1,
|
||||
asSUCCESS = 0,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,22 +8,22 @@ namespace Pkmnlib
|
|||
{
|
||||
asTYPEID_VOID = 0,
|
||||
asTYPEID_BOOL = 1,
|
||||
asTYPEID_FLOAT = 10,
|
||||
asTYPEID_OBJHANDLE = 1073741824,
|
||||
asTYPEID_DOUBLE = 11,
|
||||
asTYPEID_SCRIPTOBJECT = 134217728,
|
||||
asTYPEID_INT8 = 2,
|
||||
asTYPEID_TEMPLATE = 268435456,
|
||||
asTYPEID_INT16 = 3,
|
||||
asTYPEID_INT32 = 4,
|
||||
asTYPEID_MASK_OBJECT = 469762048,
|
||||
asTYPEID_INT64 = 5,
|
||||
asTYPEID_HANDLETOCONST = 536870912,
|
||||
asTYPEID_UINT8 = 6,
|
||||
asTYPEID_MASK_SEQNBR = 67108863,
|
||||
asTYPEID_APPOBJECT = 67108864,
|
||||
asTYPEID_UINT16 = 7,
|
||||
asTYPEID_UINT32 = 8,
|
||||
asTYPEID_UINT64 = 9,
|
||||
asTYPEID_FLOAT = 10,
|
||||
asTYPEID_DOUBLE = 11,
|
||||
asTYPEID_MASK_SEQNBR = 67108863,
|
||||
asTYPEID_APPOBJECT = 67108864,
|
||||
asTYPEID_SCRIPTOBJECT = 134217728,
|
||||
asTYPEID_TEMPLATE = 268435456,
|
||||
asTYPEID_MASK_OBJECT = 469762048,
|
||||
asTYPEID_HANDLETOCONST = 536870912,
|
||||
asTYPEID_OBJHANDLE = 1073741824,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,6 @@ namespace Pkmnlib
|
|||
{
|
||||
_S_error_collate = 0,
|
||||
_S_error_ctype = 1,
|
||||
_S_error_badrepeat = 10,
|
||||
_S_error_complexity = 11,
|
||||
_S_error_stack = 12,
|
||||
_S_error_escape = 2,
|
||||
_S_error_backref = 3,
|
||||
_S_error_brack = 4,
|
||||
|
@ -19,5 +16,8 @@ namespace Pkmnlib
|
|||
_S_error_badbrace = 7,
|
||||
_S_error_range = 8,
|
||||
_S_error_space = 9,
|
||||
_S_error_badrepeat = 10,
|
||||
_S_error_complexity = 11,
|
||||
_S_error_stack = 12,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace PkmnLibSharp.Library
|
|||
public class LibrarySettings : PointerWrapper
|
||||
{
|
||||
public byte MaximalLevel => Creaturelib.Generated.LibrarySettings.GetMaximalLevel(Ptr);
|
||||
public byte MaximalMoves => Creaturelib.Generated.LibrarySettings.GetMaximalMoves(Ptr);
|
||||
public byte MaximalMoves => Creaturelib.Generated.LibrarySettings.GetMaximalAttacks(Ptr);
|
||||
public ushort ShinyRate => Pkmnlib.Generated.LibrarySettings.GetShinyRate(Ptr);
|
||||
|
||||
internal LibrarySettings(IntPtr ptr) : base(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.
|
@ -1,5 +1,6 @@
|
|||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=battling_005Cbattle/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=battling_005Cchoiceturn/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=battling_005Cevents_005Ceventdata/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=battling_005Clibrary/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=library_005Cspecies/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
|
@ -13,8 +13,7 @@ namespace PkmnLibSharp.Utilities
|
|||
|
||||
internal static string? PtrString(this IntPtr i)
|
||||
{
|
||||
if (i == IntPtr.Zero) return null;
|
||||
return Marshal.PtrToStringAnsi(i);
|
||||
return i == IntPtr.Zero ? null : Marshal.PtrToStringAnsi(i);
|
||||
}
|
||||
|
||||
internal static IntPtr ArrayPtr(this Array a)
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -18,7 +18,11 @@ def write_enum(enum, enumNames):
|
|||
f.write("namespace {}\n{{\n".format(namespace))
|
||||
f.write(" [SuppressMessage(\"ReSharper\", \"InconsistentNaming\")]\n")
|
||||
f.write(" internal enum {} : {}\n {{\n".format(enum["name"], resolve_enum_size(enum["byteSize"]) ))
|
||||
for k, v in enum["values"].items():
|
||||
vals = enum["values"].items();
|
||||
dict = {}
|
||||
for k, v in vals:
|
||||
dict[int(k)] = v;
|
||||
for k, v in sorted(dict.items(), key=lambda item: item[0]):
|
||||
f.write(" {} = {},\n".format(v, k))
|
||||
f.write(" }\n")
|
||||
f.write("}\n")
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using PkmnLibSharp.Battling;
|
||||
|
@ -92,11 +93,12 @@ namespace PkmnLibSharpTests.Battling.BattleTests
|
|||
.Build();
|
||||
|
||||
var evts = new List<EventData>();
|
||||
battle.RegisterEventListener(new BattleEventListener(evt =>
|
||||
var eventListener = new BattleEventListener(evt =>
|
||||
{
|
||||
evts.Add(evt);
|
||||
return Task.CompletedTask;
|
||||
}));
|
||||
});
|
||||
battle.RegisterEventListener(eventListener);
|
||||
|
||||
battle.SwitchPokemon(0, 0, p1.GetAtIndex(0));
|
||||
battle.SwitchPokemon(1, 0, p2.GetAtIndex(0));
|
||||
|
@ -108,6 +110,8 @@ namespace PkmnLibSharpTests.Battling.BattleTests
|
|||
Assert.That(battle.TrySetChoice(moveTurn1));
|
||||
Assert.That(battle.TrySetChoice(moveTurn2));
|
||||
Assert.AreEqual(1, battle.CurrentTurn);
|
||||
|
||||
eventListener.EnsureFinishedListening();
|
||||
|
||||
var damageEvents = evts.Where(x => x.Kind == EventDataKind.Damage).Cast<DamageEvent>().ToArray();
|
||||
Assert.AreEqual(2, damageEvents.Length);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using NUnit.Framework;
|
||||
using PkmnLibSharp.Battling;
|
||||
|
||||
namespace PkmnLibSharpTests
|
||||
{
|
||||
|
@ -13,6 +15,11 @@ namespace PkmnLibSharpTests
|
|||
NativeLibrary.Load("Arbutils", Assembly.GetCallingAssembly(), DllImportSearchPath.AssemblyDirectory);
|
||||
NativeLibrary.Load("CreatureLib", Assembly.GetCallingAssembly(), DllImportSearchPath.AssemblyDirectory);
|
||||
NativeLibrary.Load("pkmnLib", Assembly.GetCallingAssembly(), DllImportSearchPath.AssemblyDirectory);
|
||||
|
||||
LogHandler.RegisterListener((level, s) =>
|
||||
{
|
||||
Console.WriteLine($"[{level.ToString().ToUpperInvariant()}] {s}");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue