PkmnLibSharp/PkmnLibSharp/Library/EffectParameter.cs

72 lines
1.8 KiB
C#
Raw Normal View History

2020-05-02 20:58:08 +00:00
using System;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Library
{
2020-07-08 11:50:51 +00:00
public enum EffectParameterType : byte
{
None = 0,
Bool = 1,
Int = 2,
Float = 3,
String = 4,
}
2020-05-02 20:58:08 +00:00
public class EffectParameter : PointerWrapper
{
internal EffectParameter(IntPtr ptr) : base(ptr){}
public EffectParameter(string s) : base(Creaturelib.Generated.EffectParameter.FromString(s.ToPtr()))
2020-05-02 20:58:08 +00:00
{
}
public EffectParameter(bool b) : base(Creaturelib.Generated.EffectParameter.FromBool(b.ToNative()))
2020-05-02 20:58:08 +00:00
{
}
public EffectParameter(long l) : base(Creaturelib.Generated.EffectParameter.FromInt(l))
2020-05-02 20:58:08 +00:00
{
}
public EffectParameter(float f) : base(Creaturelib.Generated.EffectParameter.FromFloat(f))
2020-05-02 20:58:08 +00:00
{
}
public EffectParameterType ParameterType =>
(EffectParameterType) Creaturelib.Generated.EffectParameter.GetType(Ptr);
2020-05-02 20:58:08 +00:00
public bool AsBool()
{
2020-05-03 09:38:49 +00:00
byte b = 0;
Creaturelib.Generated.EffectParameter.AsBool(Ptr, ref b).Assert();
2020-05-03 09:38:49 +00:00
return b == 1;
2020-05-02 20:58:08 +00:00
}
public long AsInt()
{
long i = 0;
Creaturelib.Generated.EffectParameter.AsInt(Ptr, ref i).Assert();
2020-05-02 20:58:08 +00:00
return i;
}
public float AsFloat()
{
float f = 0;
Creaturelib.Generated.EffectParameter.AsFloat(Ptr, ref f).Assert();
2020-05-02 20:58:08 +00:00
return f;
}
public string AsString()
{
2020-07-08 11:50:51 +00:00
var p = IntPtr.Zero;
Creaturelib.Generated.EffectParameter.AsString(Ptr, ref p).Assert();
return p.PtrString()!;
2020-05-02 20:58:08 +00:00
}
protected override void DeletePtr()
2020-05-02 20:58:08 +00:00
{
Creaturelib.Generated.EffectParameter.Destruct(Ptr);
2020-05-02 20:58:08 +00:00
}
}
}