From 7f02b75b29aba99e713cd209895cf02755b46113 Mon Sep 17 00:00:00 2001 From: PopSlime Date: Sun, 6 Nov 2022 00:30:36 +0800 Subject: [PATCH] Move arbitrary property operator to PropOp. --- Assets/Cryville/Crtr/PropOp.cs | 9 +++++++++ Assets/Cryville/Crtr/Ruleset.cs | 13 ++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Assets/Cryville/Crtr/PropOp.cs b/Assets/Cryville/Crtr/PropOp.cs index 6142f4b..d31eb51 100644 --- a/Assets/Cryville/Crtr/PropOp.cs +++ b/Assets/Cryville/Crtr/PropOp.cs @@ -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 _cb; public Boolean(Action cb) { _cb = cb; } diff --git a/Assets/Cryville/Crtr/Ruleset.cs b/Assets/Cryville/Crtr/Ruleset.cs index ce486e9..3a5163b 100644 --- a/Assets/Cryville/Crtr/Ruleset.cs +++ b/Assets/Cryville/Crtr/Ruleset.cs @@ -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 Elements = new Dictionary(); [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");