45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using PkmnLibSharp.Utilities;
|
|
|
|
namespace PkmnLibSharp.Library
|
|
{
|
|
public class Ability : PointerWrapper
|
|
{
|
|
public Ability(string name, string effect, EffectParameter[] parameters)
|
|
{
|
|
var pars = parameters.Select(x => x.Ptr).ToArray();
|
|
Initialize(Creaturelib.Generated.Talent.Construct(name.ToPtr(), effect.ToPtr(), pars.ArrayPtr(), (ulong)pars.Length));
|
|
foreach (var intPtr in pars)
|
|
Marshal.FreeHGlobal(intPtr);
|
|
}
|
|
|
|
private string? _name;
|
|
public string Name
|
|
{
|
|
get
|
|
{
|
|
if (_name != null) return _name;
|
|
_name = Creaturelib.Generated.Talent.GetName(Ptr).PtrString();
|
|
return _name!;
|
|
}
|
|
}
|
|
|
|
private string? _effect;
|
|
public string Effect
|
|
{
|
|
get
|
|
{
|
|
if (_effect != null) return _effect;
|
|
_effect = Creaturelib.Generated.Talent.GetEffect(Ptr).PtrString();
|
|
return _effect!;
|
|
}
|
|
}
|
|
|
|
|
|
protected override void DeletePtr()
|
|
{
|
|
Creaturelib.Generated.Talent.Destruct(Ptr);
|
|
}
|
|
}
|
|
} |