Adds ItemTurnChoice interface
continuous-integration/drone/push Build is passing Details

master
Deukhoofd 2022-04-23 18:46:25 +02:00
parent 61e48a705a
commit 907e145083
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
17 changed files with 102 additions and 18 deletions

View File

@ -0,0 +1,40 @@
using System;
using PkmnLibSharp.Battling.ChoiceTurn;
using PkmnLibSharp.Library.Items;
namespace PkmnLibSharp.Battling
{
public class ItemTurnChoice : BaseTurnChoice
{
public ItemTurnChoice(Pokemon user, Item item) : base(
Creaturelib.Generated.ItemTurnChoice.ConstructWithoutTarget(user.Ptr, item.Ptr))
{
}
public ItemTurnChoice(Pokemon user, Item item, byte targetSide, byte targetIndex) : base(
Creaturelib.Generated.ItemTurnChoice.ConstructWithTarget(user.Ptr, item.Ptr, targetSide, targetIndex))
{
}
internal ItemTurnChoice(IntPtr ptr) : base(ptr){}
private Item? _item;
public Item Item
{
get
{
if (_item != null) return _item;
var ptr = Creaturelib.Generated.ItemTurnChoice.GetItem(Ptr);
if (TryResolvePointer(ptr, out _item))
return _item!;
_item = new Item(ptr);
return _item;
}
}
protected override void DeletePtr()
{
Creaturelib.Generated.ItemTurnChoice.Destruct(Ptr);
}
}
}

View File

@ -1,6 +1,7 @@
using System;
using PkmnLibSharp.Battling.ChoiceTurn;
namespace PkmnLibSharp.Battling.ChoiceTurn
namespace PkmnLibSharp.Battling
{
public class SwitchTurnChoice : BaseTurnChoice
{

View File

@ -11,7 +11,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_FleeTurnChoice_Construct")]
internal static extern IntPtr Construct(IntPtr user);
/// <param name="p">AttackTurnChoice *</param>
/// <param name="p">FleeTurnChoice *</param>
/// <returns>void</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_FleeTurnChoice_Destruct")]
internal static extern void Destruct(IntPtr p);

View File

@ -0,0 +1,39 @@
// AUTOMATICALLY GENERATED, DO NOT EDIT
using System;
using System.Runtime.InteropServices;
namespace Creaturelib.Generated
{
internal static class ItemTurnChoice
{
/// <param name="user">Creature *</param>
/// <param name="item">Item *</param>
/// <returns>ItemTurnChoice *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemTurnChoice_ConstructWithoutTarget")]
internal static extern IntPtr ConstructWithoutTarget(IntPtr user, IntPtr item);
/// <param name="user">Creature *</param>
/// <param name="item">const Item *</param>
/// <param name="targetSide">unsigned char</param>
/// <param name="targetIndex">unsigned char</param>
/// <returns>ItemTurnChoice *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemTurnChoice_ConstructWithTarget")]
internal static extern IntPtr ConstructWithTarget(IntPtr user, IntPtr item, byte targetSide, byte targetIndex);
/// <param name="p">SwitchTurnChoice *</param>
/// <returns>void</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemTurnChoice_Destruct")]
internal static extern void Destruct(IntPtr p);
/// <param name="p">const ItemTurnChoice *</param>
/// <returns>TurnChoiceKind</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemTurnChoice_GetKind")]
internal static extern TurnChoiceKind GetKind(IntPtr p);
/// <param name="p">const ItemTurnChoice *</param>
/// <returns>const Item *</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemTurnChoice_GetItem")]
internal static extern IntPtr GetItem(IntPtr p);
}
}

View File

@ -11,7 +11,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_PassTurnChoice_Construct")]
internal static extern IntPtr Construct(IntPtr user);
/// <param name="p">AttackTurnChoice *</param>
/// <param name="p">PassTurnChoice *</param>
/// <returns>void</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_PassTurnChoice_Destruct")]
internal static extern void Destruct(IntPtr p);

View File

@ -12,7 +12,7 @@ namespace Creaturelib.Generated
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SwitchTurnChoice_Construct")]
internal static extern IntPtr Construct(IntPtr user, IntPtr newCreature);
/// <param name="p">AttackTurnChoice *</param>
/// <param name="p">SwitchTurnChoice *</param>
/// <returns>void</returns>
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_SwitchTurnChoice_Destruct")]
internal static extern void Destruct(IntPtr p);

View File

@ -22,6 +22,10 @@ namespace PkmnLibSharp.Library.Items
Initialize(p);
}
internal Item(IntPtr p) : base(p)
{
}
public string Name => _name ??= Creaturelib.Generated.Item.GetName(Ptr).PtrString()!;
public ItemCategory Category => (ItemCategory)Creaturelib.Generated.Item.GetCategory(Ptr);

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

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long