Implement input name evaluation. Implement context state.
This commit is contained in:
@@ -397,14 +397,20 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
public class Judge : ChartEvent {
|
||||
public string name;
|
||||
[JsonIgnore]
|
||||
public Identifier Id;
|
||||
public string name {
|
||||
get { return Id.ToString(); }
|
||||
set { Id = new Identifier(value); }
|
||||
}
|
||||
|
||||
public override int Priority {
|
||||
get { return 0; }
|
||||
}
|
||||
|
||||
public Judge() {
|
||||
SubmitPropSrc("name", new PropSrc.String(() => name));
|
||||
SubmitPropOp("name", new PropOp.String(v => name = v));
|
||||
SubmitPropSrc("name", new PropSrc.Identifier(() => Id.Key));
|
||||
SubmitPropOp("name", new PropOp.Identifier(v => Id = new Identifier(v)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -518,7 +518,7 @@ namespace Cryville.Crtr {
|
||||
foreach (var ts in gs.Value.Children) {
|
||||
ContainerHandler th;
|
||||
if (ts.Key is Chart.Note) {
|
||||
th = new NoteHandler(gh, (Chart.Note)ts.Key, judge);
|
||||
th = new NoteHandler(gh, (Chart.Note)ts.Key, pruleset, judge);
|
||||
}
|
||||
else {
|
||||
th = new TrackHandler(gh, (Chart.Track)ts.Key);
|
||||
|
@@ -214,27 +214,31 @@ namespace Cryville.Crtr.Event {
|
||||
this.judge = judge;
|
||||
}
|
||||
|
||||
public T GetRawValue<T>(Identifier key) where T : Vector {
|
||||
public Vector GetRawValue(Identifier key) {
|
||||
Vector tr;
|
||||
if (!CachedValues.TryGetValue(key, out tr)) {
|
||||
tr = (Vector)ReflectionHelper.InvokeEmptyConstructor(typeof(T));
|
||||
tr = (Vector)ReflectionHelper.InvokeEmptyConstructor(ChartPlayer.motionRegistry[key].Type);
|
||||
CachedValues.Add(key, tr);
|
||||
CachedValueStates[key] = false;
|
||||
}
|
||||
T r = (T)tr;
|
||||
Vector r = tr;
|
||||
#if !DISABLE_CACHE
|
||||
if (CachedValueStates[key]) return r;
|
||||
#endif
|
||||
float reltime = 0;
|
||||
if (rootPrototype != null) reltime = Time - rootPrototype.Time;
|
||||
GetMotionValue(key).GetValue(reltime, ref r);
|
||||
if (Parent != null) r.ApplyFrom(Parent.GetRawValue<T>(key));
|
||||
if (Parent != null) r.ApplyFrom(Parent.GetRawValue(key));
|
||||
#if !DISABLE_CACHE
|
||||
CachedValueStates[key] = true;
|
||||
#endif
|
||||
return r;
|
||||
}
|
||||
|
||||
public T GetRawValue<T>(Identifier key) where T : Vector {
|
||||
return (T)GetRawValue(key);
|
||||
}
|
||||
|
||||
static readonly Identifier n_pt = new Identifier("pt");
|
||||
public Vector2 ScreenPoint {
|
||||
get {
|
||||
|
@@ -50,7 +50,6 @@ namespace Cryville.Crtr {
|
||||
public class JudgeDefinition {
|
||||
public PdtExpression clip;
|
||||
public PdtExpression input;
|
||||
public Identifier InputName;
|
||||
public PdtExpression hit;
|
||||
public Identifier[] pass;
|
||||
public Identifier miss;
|
||||
|
@@ -1,3 +1,4 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Math;
|
||||
using Cryville.Crtr.Components;
|
||||
using Cryville.Crtr.Event;
|
||||
@@ -9,10 +10,12 @@ namespace Cryville.Crtr {
|
||||
class NoteHandler : ContainerHandler {
|
||||
readonly GroupHandler gh;
|
||||
public readonly Chart.Note Event;
|
||||
readonly PdtRuleset ruleset;
|
||||
readonly Judge judge;
|
||||
public NoteHandler(GroupHandler gh, Chart.Note ev, Judge j) : base() {
|
||||
public NoteHandler(GroupHandler gh, Chart.Note ev, PdtRuleset rs, Judge j) : base() {
|
||||
this.gh = gh;
|
||||
Event = ev;
|
||||
ruleset = rs;
|
||||
judge = j;
|
||||
}
|
||||
|
||||
@@ -90,6 +93,15 @@ namespace Cryville.Crtr {
|
||||
else if (s.CloneType == 16) {
|
||||
if (ev == null) { }
|
||||
else if (ev.Unstamped == null) { }
|
||||
else if (ev.Unstamped is Chart.Judge) {
|
||||
var tev = (Chart.Judge)ev.Unstamped;
|
||||
Identifier name;
|
||||
ChartPlayer.etor.ContextEvent = tev;
|
||||
ChartPlayer.etor.ContextState = s;
|
||||
ChartPlayer.etor.Evaluate(new PropOp.Identifier(v => name = new Identifier(v)), ruleset.judges[tev.Id].input);
|
||||
ChartPlayer.etor.ContextState = null;
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
}
|
||||
else if (ev.Unstamped is Chart.Motion) {
|
||||
/*var tev = (Chart.Motion)ev.Unstamped;
|
||||
if (tev.Name != "judge") return;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Crtr.Event;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@@ -20,11 +21,16 @@ namespace Cryville.Crtr {
|
||||
else if (name == _var_true) { LoadNum(1); type = PdtInternalType.Number; value = _numbuf; }
|
||||
else if (name == _var_false) { LoadNum(0); type = PdtInternalType.Number; value = _numbuf; }
|
||||
else {
|
||||
var id = new Identifier(name);
|
||||
PropSrc prop;
|
||||
string str;
|
||||
if (ContextEvent != null && ContextEvent.PropSrcs.TryGetValue(name, out prop)) {
|
||||
prop.Get(out type, out value);
|
||||
}
|
||||
else if (ContextState != null && ChartPlayer.motionRegistry.ContainsKey(id)) {
|
||||
var vec = ContextState.GetRawValue(id);
|
||||
new VectorSrc(() => vec).Get(out type, out value);
|
||||
}
|
||||
else if (ContextJudge != null && ContextJudge.GetFormattedScoreStrings().TryGetValue(name, out str)) {
|
||||
type = PdtInternalType.String;
|
||||
value = GetBytes(str);
|
||||
@@ -41,7 +47,6 @@ namespace Cryville.Crtr {
|
||||
value = _numbuf;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
unsafe void LoadNum(int value) {
|
||||
@@ -93,6 +98,7 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
public ChartEvent ContextEvent { private get; set; }
|
||||
public ContainerState ContextState { private get; set; }
|
||||
public Transform ContextTransform { private get; set; }
|
||||
public Judge ContextJudge { private get; set; }
|
||||
public PropSrc ContextSelfValue { private get; set; }
|
||||
|
@@ -56,6 +56,14 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Identifier : PropSrc {
|
||||
readonly Func<int> _cb;
|
||||
public Identifier(Func<int> cb) { _cb = cb; }
|
||||
protected override void InternalGet(out int type, out byte[] value) {
|
||||
type = PdtInternalType.Undefined;
|
||||
value = BitConverter.GetBytes(_cb());
|
||||
}
|
||||
}
|
||||
public class BeatTime : PropSrc {
|
||||
readonly Func<RBeatTime> _cb;
|
||||
public BeatTime(Func<RBeatTime> cb) { _cb = cb; }
|
||||
|
Reference in New Issue
Block a user