Move arbitrary property operator to PropOp.

This commit is contained in:
2022-11-06 00:30:36 +08:00
parent 9d4f938675
commit 7f02b75b29
2 changed files with 11 additions and 11 deletions

View File

@@ -8,6 +8,15 @@ using RBeatTime = Cryville.Crtr.BeatTime;
namespace Cryville.Crtr {
public abstract class PropOp : PdtOperator {
internal PropOp() : base(1) { }
public class Arbitrary : PropOp {
public int Name { get; set; }
protected override void Execute() {
var op = GetOperand(0);
var value = new byte[op.Length];
op.CopyTo(value, 0);
ChartPlayer.etor.ContextCascadeUpdate(Name, new PropSrc.Arbitrary(op.Type, value));
}
}
public class Boolean : PropOp {
readonly Action<bool> _cb;
public Boolean(Action<bool> cb) { _cb = cb; }

View File

@@ -58,16 +58,7 @@ namespace Cryville.Crtr {
}
}
public class Constraint {
class ArbitraryOp : PropOp {
public int name;
protected override void Execute() {
var op = GetOperand(0);
var value = new byte[op.Length];
op.CopyTo(value, 0);
ChartPlayer.etor.ContextCascadeUpdate(name, new PropSrc.Arbitrary(op.Type, value));
}
}
static readonly ArbitraryOp _arbop = new ArbitraryOp();
static readonly PropOp.Arbitrary _arbop = new PropOp.Arbitrary();
[ElementList]
public Dictionary<RulesetSelectors, Constraint> Elements = new Dictionary<RulesetSelectors, Constraint>();
[PropertyList]
@@ -96,7 +87,7 @@ namespace Cryville.Crtr {
etor.ContextSelfValue = null;
break;
case PropertyType.Variable:
_arbop.name = name;
_arbop.Name = name;
etor.Evaluate(_arbop, prop.Value);
break;
default: throw new NotSupportedException("Unknown property key type");