using Newtonsoft.Json;
using UAssetAPI.UnrealTypes;
namespace UAssetAPI.Kismet.Bytecode
{
///
/// A Kismet bytecode instruction.
///
[JsonObject(MemberSerialization.OptIn)]
public class KismetExpression
{
///
/// The token of this expression.
///
public virtual EExprToken Token { get { return EExprToken.EX_Nothing; } }
///
/// The token of this instruction expressed as a string.
///
public string Inst { get { return Token.ToString().Substring(3, Token.ToString().Length - 3); } }
///
/// An optional tag which can be set on any expression in memory. This is for the user only, and has no bearing in the API itself.
///
public object Tag;
public object RawValue;
public void SetObject(object value)
{
RawValue = value;
}
public T GetObject()
{
return (T)RawValue;
}
public KismetExpression()
{
}
///
/// Reads out an expression from a BinaryReader.
///
/// The BinaryReader to read from.
public virtual void Read(AssetBinaryReader reader)
{
}
///
/// Writes an expression to a BinaryWriter.
///
/// The BinaryWriter to write from.
/// The iCode offset of the data that was written.
public virtual int Write(AssetBinaryWriter writer)
{
return 0;
}
}
public abstract class KismetExpression : KismetExpression
{
///
/// The value of this expression if it is a constant.
///
[JsonProperty]
public T Value
{
get => GetObject();
set => SetObject(value);
}
public KismetExpression() : base()
{
}
}
}