Updates CreatureLib, implements support for ItemUseScript.
parent
cbe5747d04
commit
3a7edb2fc3
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
||||
namespace PkmnLibSharp.Battling
|
||||
{
|
||||
public class ItemUseScript : PointerWrapper
|
||||
{
|
||||
internal ItemUseScript(IntPtr ptr) : base(ptr){}
|
||||
|
||||
public bool IsItemUsable()
|
||||
{
|
||||
byte res = 0;
|
||||
Creaturelib.Generated.ItemUseScript.IsItemUsable(Ptr, ref res).Assert();
|
||||
return res == 1;
|
||||
}
|
||||
|
||||
public bool IsPokemonUseItem()
|
||||
{
|
||||
byte res = 0;
|
||||
Creaturelib.Generated.ItemUseScript.IsCreatureUseItem(Ptr, ref res).Assert();
|
||||
return res == 1;
|
||||
}
|
||||
|
||||
public bool IsUseValidForPokemon(Pokemon pokemon)
|
||||
{
|
||||
byte res = 0;
|
||||
Creaturelib.Generated.ItemUseScript.IsUseValidForCreature(Ptr, pokemon.Ptr, ref res).Assert();
|
||||
return res == 1;
|
||||
}
|
||||
|
||||
public bool IsHoldable()
|
||||
{
|
||||
byte res = 0;
|
||||
Creaturelib.Generated.ItemUseScript.IsHoldable(Ptr, ref res).Assert();
|
||||
return res == 1;
|
||||
}
|
||||
|
||||
public void OnUse()
|
||||
{
|
||||
Creaturelib.Generated.ItemUseScript.OnUse(Ptr);
|
||||
}
|
||||
|
||||
public void OnPokemonUse(Pokemon pokemon)
|
||||
{
|
||||
Creaturelib.Generated.ItemUseScript.OnCreatureUse(Ptr, pokemon.Ptr);
|
||||
}
|
||||
|
||||
protected override void DeletePtr()
|
||||
{
|
||||
Creaturelib.Generated.ItemUseScript.Destruct(Ptr);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PkmnLibSharp.Library.Items;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
||||
namespace PkmnLibSharp.Battling
|
||||
{
|
||||
public abstract class ScriptResolver : PointerWrapper
|
||||
{
|
||||
private readonly Dictionary<Item, ItemUseScript> _itemUseScripts = new Dictionary<Item, ItemUseScript>();
|
||||
|
||||
protected ScriptResolver(IntPtr ptr) : base(ptr)
|
||||
{
|
||||
}
|
||||
|
||||
public ItemUseScript? LoadItemUseScript(Item item)
|
||||
{
|
||||
if (_itemUseScripts.TryGetValue(item, out var v))
|
||||
return v;
|
||||
var ptr = IntPtr.Zero;
|
||||
Creaturelib.Generated.ScriptResolver.LoadItemScript(ref ptr, Ptr, item.Ptr);
|
||||
if (ptr == IntPtr.Zero)
|
||||
return null;
|
||||
var itemUseScript = new ItemUseScript(ptr);
|
||||
_itemUseScripts.Add(item, itemUseScript);
|
||||
return itemUseScript;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
// AUTOMATICALLY GENERATED, DO NOT EDIT
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Creaturelib.Generated
|
||||
{
|
||||
internal static class ItemUseScript
|
||||
{
|
||||
/// <param name="p">ItemUseScript *</param>
|
||||
/// <returns>void</returns>
|
||||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_Destruct")]
|
||||
internal static extern void Destruct(IntPtr p);
|
||||
|
||||
/// <param name="p">ItemUseScript *</param>
|
||||
/// <param name="out">unsigned char &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_IsItemUsable")]
|
||||
internal static extern byte IsItemUsable(IntPtr p, ref byte @out);
|
||||
|
||||
/// <param name="p">ItemUseScript *</param>
|
||||
/// <param name="out">unsigned char &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_IsCreatureUseItem")]
|
||||
internal static extern byte IsCreatureUseItem(IntPtr p, ref byte @out);
|
||||
|
||||
/// <param name="p">ItemUseScript *</param>
|
||||
/// <param name="creature">Creature *</param>
|
||||
/// <param name="out">unsigned char &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_IsUseValidForCreature")]
|
||||
internal static extern byte IsUseValidForCreature(IntPtr p, IntPtr creature, ref byte @out);
|
||||
|
||||
/// <param name="p">ItemUseScript *</param>
|
||||
/// <param name="out">unsigned char &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_IsHoldable")]
|
||||
internal static extern byte IsHoldable(IntPtr p, ref byte @out);
|
||||
|
||||
/// <param name="p">ItemUseScript *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_OnUse")]
|
||||
internal static extern byte OnUse(IntPtr p);
|
||||
|
||||
/// <param name="p">ItemUseScript *</param>
|
||||
/// <param name="creature">Creature *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_ItemUseScript_OnCreatureUse")]
|
||||
internal static extern byte OnCreatureUse(IntPtr p, IntPtr creature);
|
||||
|
||||
}
|
||||
}
|
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