PkmnLibSharp/PkmnLibSharp/Battling/History/HistoryElement.cs

40 lines
1.2 KiB
C#

using System;
using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling.History
{
public abstract class HistoryElement : PointerWrapper
{
internal HistoryElement(IntPtr ptr) : base(ptr){}
public HistoryElementKind Kind => (HistoryElementKind) Creaturelib.Generated.HistoryElement.GetKind(Ptr);
public HistoryElement? GetPrevious()
{
if (_previous != null) return _previous;
var ptr = Creaturelib.Generated.HistoryElement.GetPrevious(Ptr);
_previous = Construct(ptr);
return _previous;
}
internal static HistoryElement? Construct(IntPtr ptr)
{
if (ptr == IntPtr.Zero) return null;
var kind = (HistoryElementKind) Creaturelib.Generated.HistoryElement.GetKind(ptr);
switch (kind)
{
case HistoryElementKind.MoveUse:
return new MoveUseHistory(ptr);
default:
throw new ArgumentOutOfRangeException();
}
}
private HistoryElement? _previous;
protected override void DeletePtr()
{
}
}
}