Adds more events.

This commit is contained in:
Deukhoofd 2020-08-25 19:13:15 +02:00
parent 2ded1d3ceb
commit ea4c9c6877
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
12 changed files with 255 additions and 9 deletions

View File

@ -75,15 +75,15 @@ namespace PkmnLibSharp.Battling.Events
case EventDataKind.ExperienceGain:
return new ExperienceGainEvent(evtType, ptr);
case EventDataKind.DisplayText:
break;
return new DisplayTextEvent(evtType, ptr);
case EventDataKind.Miss:
break;
return new MissEvent(evtType, ptr);
case EventDataKind.ChangeSpecies:
break;
return new ChangeSpeciesEvent(evtType, ptr);
case EventDataKind.ChangeVariant:
break;
return new ChangeFormeEvent(evtType, ptr);
case EventDataKind.AttackUse:
break;
return new MoveUseEvent(evtType, ptr);
case EventDataKind.WeatherChange:
break;
case EventDataKind.StatusChange:

View File

@ -0,0 +1,47 @@
using System;
using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling.Events
{
public class ChangeFormeEvent : EventData
{
internal ChangeFormeEvent(EventDataKind kind, IntPtr ptr) : base(kind, ptr)
{
}
public Pokemon Pokemon
{
get
{
if (_pokemon != null) return _pokemon;
var ptr = Creaturelib.Generated.ChangeVariantEvent.GetCreature(Ptr);
if (TryResolvePointer(ptr, out _pokemon))
return _pokemon!;
_pokemon = Constructor.Active.ConstructPokemon(ptr)!;
return _pokemon;
}
}
public Forme NewForme
{
get
{
if (_newForme != null) return _newForme;
var ptr = Creaturelib.Generated.ChangeVariantEvent.GetNewVariant(Ptr);
if (TryResolvePointer(ptr, out _newForme))
return _newForme!;
_newForme = Constructor.Active.ConstructForme(ptr)!;
return _newForme;
}
}
private Pokemon? _pokemon;
private Forme? _newForme;
protected override void DeletePtr()
{
Creaturelib.Generated.ChangeVariantEvent.Destruct(Ptr);
}
}
}

View File

@ -0,0 +1,47 @@
using System;
using PkmnLibSharp.Library;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling.Events
{
public class ChangeSpeciesEvent : EventData
{
internal ChangeSpeciesEvent(EventDataKind kind, IntPtr ptr) : base(kind, ptr)
{
}
public Pokemon Pokemon
{
get
{
if (_pokemon != null) return _pokemon;
var ptr = Creaturelib.Generated.ChangeSpeciesEvent.GetCreature(Ptr);
if (TryResolvePointer(ptr, out _pokemon))
return _pokemon!;
_pokemon = Constructor.Active.ConstructPokemon(ptr)!;
return _pokemon;
}
}
public Species NewSpecies
{
get
{
if (_newSpecies != null) return _newSpecies;
var ptr = Creaturelib.Generated.ChangeSpeciesEvent.GetNewSpecies(Ptr);
if (TryResolvePointer(ptr, out _newSpecies))
return _newSpecies!;
_newSpecies = Constructor.Active.ConstructSpecies(ptr)!;
return _newSpecies;
}
}
private Pokemon? _pokemon;
private Species? _newSpecies;
protected override void DeletePtr()
{
Creaturelib.Generated.ChangeSpeciesEvent.Destruct(Ptr);
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling.Events
{
public class MissEvent : EventData
{
internal MissEvent(EventDataKind kind, IntPtr ptr) : base(kind, ptr)
{
}
public Pokemon Pokemon
{
get
{
if (_pokemon != null) return _pokemon;
var ptr = Creaturelib.Generated.MissEvent.GetCreature(Ptr);
if (TryResolvePointer(ptr, out _pokemon))
return _pokemon!;
_pokemon = Constructor.Active.ConstructPokemon(ptr)!;
return _pokemon;
}
}
private Pokemon? _pokemon;
protected override void DeletePtr()
{
Creaturelib.Generated.MissEvent.Destruct(Ptr);
}
}
}

View File

@ -0,0 +1,31 @@
using System;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling.Events
{
public class MoveUseEvent : EventData
{
internal MoveUseEvent(EventDataKind kind, IntPtr ptr) : base(kind, ptr)
{
}
public ExecutingMove Move
{
get
{
if (_move != null) return _move;
var ptr = Creaturelib.Generated.AttackUseEvent.GetAttack(Ptr);
if (TryResolvePointer(ptr, out _move))
return _move!;
_move = new ExecutingMove(ptr);
return _move;
}
}
private ExecutingMove? _move;
protected override void DeletePtr()
{
Creaturelib.Generated.AttackUseEvent.Destruct(Ptr);
}
}
}

View File

@ -0,0 +1,20 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System;
using System.Runtime.InteropServices;
namespace Creaturelib.Generated
{
internal static class AttackUseEvent
{
/// <param name="p">const AttackUseEvent *</param>
/// <returns>const ExecutingAttack *</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackUseEvent_GetAttack")]
internal static extern IntPtr GetAttack(IntPtr p);
/// <param name="p">const AttackUseEvent *</param>
/// <returns>void</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_AttackUseEvent_Destruct")]
internal static extern void Destruct(IntPtr p);
}
}

View File

@ -0,0 +1,25 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System;
using System.Runtime.InteropServices;
namespace Creaturelib.Generated
{
internal static class ChangeSpeciesEvent
{
/// <param name="p">const ChangeSpeciesEvent *</param>
/// <returns>const Creature *</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ChangeSpeciesEvent_GetCreature")]
internal static extern IntPtr GetCreature(IntPtr p);
/// <param name="p">const ChangeSpeciesEvent *</param>
/// <returns>const CreatureSpecies *</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ChangeSpeciesEvent_GetNewSpecies")]
internal static extern IntPtr GetNewSpecies(IntPtr p);
/// <param name="p">const ChangeSpeciesEvent *</param>
/// <returns>void</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ChangeSpeciesEvent_Destruct")]
internal static extern void Destruct(IntPtr p);
}
}

View File

@ -0,0 +1,25 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System;
using System.Runtime.InteropServices;
namespace Creaturelib.Generated
{
internal static class ChangeVariantEvent
{
/// <param name="p">const ChangeVariantEvent *</param>
/// <returns>const Creature *</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ChangeVariantEvent_GetCreature")]
internal static extern IntPtr GetCreature(IntPtr p);
/// <param name="p">const ChangeVariantEvent *</param>
/// <returns>const SpeciesVariant *</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ChangeVariantEvent_GetNewVariant")]
internal static extern IntPtr GetNewVariant(IntPtr p);
/// <param name="p">const ChangeVariantEvent *</param>
/// <returns>void</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ChangeVariantEvent_Destruct")]
internal static extern void Destruct(IntPtr p);
}
}

View File

@ -7,7 +7,7 @@ namespace Creaturelib.Generated
internal static class ExperienceGainEvent
{
/// <param name="p">const ExperienceGainEvent *</param>
/// <returns>Creature *</returns>
/// <returns>const Creature *</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ExperienceGainEvent_GetCreature")]
internal static extern IntPtr GetCreature(IntPtr p);

View File

@ -0,0 +1,20 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System;
using System.Runtime.InteropServices;
namespace Creaturelib.Generated
{
internal static class MissEvent
{
/// <param name="p">const MissEvent *</param>
/// <returns>const Creature *</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_MissEvent_GetCreature")]
internal static extern IntPtr GetCreature(IntPtr p);
/// <param name="p">const MissEvent *</param>
/// <returns>void</returns>
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_MissEvent_Destruct")]
internal static extern void Destruct(IntPtr p);
}
}

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

Binary file not shown.

File diff suppressed because one or more lines are too long