Update PkmnLib to new functionality with capture mechanics
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
cb3d3c74a1
commit
36b39ba3c4
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
||||
namespace PkmnLibSharp.Battling.Events
|
||||
{
|
||||
public class CaptureAttemptEvent : EventData
|
||||
{
|
||||
|
||||
private Pokemon? _pokemon;
|
||||
private CaptureLibrary.CaptureResult? _result;
|
||||
|
||||
internal CaptureAttemptEvent(EventDataKind kind, IntPtr ptr) : base(kind, ptr)
|
||||
{
|
||||
}
|
||||
|
||||
public Pokemon Pokemon
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_pokemon != null) return _pokemon;
|
||||
var ptr = Pkmnlib.Generated.CaptureAttemptEvent.GetPokemon(Ptr);
|
||||
if (TryResolvePointer(ptr, out _pokemon))
|
||||
return _pokemon!;
|
||||
_pokemon = Constructor.Active.ConstructPokemon(ptr)!;
|
||||
return _pokemon;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public CaptureLibrary.CaptureResult Result
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_result != null) return _result.Value;
|
||||
var p = Pkmnlib.Generated.CaptureAttemptEvent.GetResult(Ptr);
|
||||
_result = Marshal.PtrToStructure<CaptureLibrary.CaptureResult>(p);
|
||||
return _result.Value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DeletePtr()
|
||||
{
|
||||
Pkmnlib.Generated.CaptureAttemptEvent.Destruct(Ptr);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
||||
namespace PkmnLibSharp.Battling.Events
|
||||
{
|
||||
public class WeatherChangeEvent : EventData
|
||||
{
|
||||
internal WeatherChangeEvent(EventDataKind kind, IntPtr ptr) : base(kind, ptr)
|
||||
{
|
||||
}
|
||||
|
||||
public string? WeatherName => Pkmnlib.Generated.WeatherChangeEvent.GetWeatherName(Ptr).PtrString();
|
||||
|
||||
protected override void DeletePtr()
|
||||
{
|
||||
Pkmnlib.Generated.WeatherChangeEvent.Destruct(Ptr);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
||||
namespace PkmnLibSharp.Battling
|
||||
{
|
||||
public class CaptureLibrary : PointerWrapper
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct CaptureResult
|
||||
{
|
||||
[FieldOffset(0)] private readonly byte _wasCaught;
|
||||
[FieldOffset(1)] public readonly byte Shakes;
|
||||
[FieldOffset(2)] private readonly byte _wasCritical;
|
||||
|
||||
public bool WasCaught => _wasCaught == 1;
|
||||
public bool WasCritical => _wasCritical == 1;
|
||||
}
|
||||
|
||||
|
||||
internal CaptureLibrary(IntPtr ptr) : base(ptr)
|
||||
{
|
||||
}
|
||||
|
||||
public CaptureLibrary()
|
||||
{
|
||||
var ptr = this.Ptr;
|
||||
Pkmnlib.Generated.CaptureLibrary.Construct(ref ptr);
|
||||
Initialize(ptr);
|
||||
}
|
||||
|
||||
protected override void DeletePtr()
|
||||
{
|
||||
Pkmnlib.Generated.CaptureLibrary.Destruct(Ptr);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
// AUTOMATICALLY GENERATED, DO NOT EDIT
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Pkmnlib.Generated
|
||||
{
|
||||
internal static class CaptureAttemptEvent
|
||||
{
|
||||
/// <param name="p">CaptureAttemptEvent *</param>
|
||||
/// <returns>void</returns>
|
||||
[DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_CaptureAttemptEvent_Destruct")]
|
||||
internal static extern void Destruct(IntPtr p);
|
||||
|
||||
/// <param name="p">CaptureAttemptEvent *</param>
|
||||
/// <returns>const Pokemon *</returns>
|
||||
[DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_CaptureAttemptEvent_GetPokemon")]
|
||||
internal static extern IntPtr GetPokemon(IntPtr p);
|
||||
|
||||
/// <param name="p">CaptureAttemptEvent *</param>
|
||||
/// <returns>const CaptureResult</returns>
|
||||
[DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_CaptureAttemptEvent_GetResult")]
|
||||
internal static extern IntPtr GetResult(IntPtr p);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
// AUTOMATICALLY GENERATED, DO NOT EDIT
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Pkmnlib.Generated
|
||||
{
|
||||
internal static class CaptureLibrary
|
||||
{
|
||||
/// <param name="out">CaptureLibrary * &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_CaptureLibrary_Construct")]
|
||||
internal static extern byte Construct(ref IntPtr @out);
|
||||
|
||||
/// <param name="p">CaptureLibrary *</param>
|
||||
/// <returns>void</returns>
|
||||
[DllImport("libpkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_CaptureLibrary_Destruct")]
|
||||
internal static extern void Destruct(IntPtr p);
|
||||
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue