diff --git a/Assets/Cryville/Crtr/ChartPlayer.cs b/Assets/Cryville/Crtr/ChartPlayer.cs index 0295c5f..7c2e61a 100644 --- a/Assets/Cryville/Crtr/ChartPlayer.cs +++ b/Assets/Cryville/Crtr/ChartPlayer.cs @@ -504,11 +504,11 @@ namespace Cryville.Crtr { cbus = batcher.Batch(); Logger.Log("main", 0, "Load/WorkerThread", "Batched {0} event batches", cbus.events.Count); + LoadSkin(info.skinFile); + judge = new Judge(pruleset); etor.ContextJudge = judge; - LoadSkin(info.skinFile); - cbus.AttachSystems(pskin, judge); Logger.Log("main", 0, "Load/WorkerThread", "Attaching handlers"); var ch = new ChartHandler(chart, dir); diff --git a/Assets/Cryville/Crtr/Judge.cs b/Assets/Cryville/Crtr/Judge.cs index 256b175..ee77eaa 100644 --- a/Assets/Cryville/Crtr/Judge.cs +++ b/Assets/Cryville/Crtr/Judge.cs @@ -31,9 +31,12 @@ namespace Cryville.Crtr { _etor = ChartPlayer.etor; _rs = rs; foreach (var s in rs.scores) { - var name = s.Key.Key; - scoreDefs.Add(name, s.Value); - scores.Add(name, s.Value.init); + var key = s.Key; + scoreSrcs.Add(key.Key, new PropSrc.Float(() => scores[key.Key])); + scoreOps.Add(key.Key, new PropOp.Float(v => scores[key.Key] = v)); + scoreFmtKeys.Add(key.Key, IdentifierManager.SharedInstance.Request("_score_" + (string)key.Name)); + scoreDefs.Add(key.Key, s.Value); + scores.Add(key.Key, s.Value.init); } } public void Prepare(float st, float et, Identifier input, JudgeDefinition def, ContainerState container) { @@ -143,12 +146,24 @@ namespace Cryville.Crtr { actlist.Insert(index, ev); } } - void UpdateScore(Dictionary scores) { - foreach (var score in scores) { - // TODO + void UpdateScore(Dictionary scoreops) { + foreach (var scoreop in scoreops) { + var key = scoreop.Key; + _etor.ContextSelfValue = scoreSrcs[key.name.Key]; + _etor.Evaluate(scoreOps[key.name.Key], scoreop.Value); + foreach (var s in _rs.scores) { + if (s.Value.value != null) { + _etor.ContextSelfValue = scoreSrcs[s.Key.Key]; + _etor.Evaluate(scoreOps[s.Key.Key], s.Value.value); + } + } } + ScoreCache.Clear(); } - public readonly Dictionary scoreDefs = new Dictionary(); + readonly Dictionary scoreFmtKeys = new Dictionary(); + readonly Dictionary scoreSrcs = new Dictionary(); + readonly Dictionary scoreOps = new Dictionary(); + readonly Dictionary scoreDefs = new Dictionary(); public readonly Dictionary scores = new Dictionary(); readonly Dictionary ScoreCache = new Dictionary(); readonly object _lock = new object(); @@ -156,7 +171,7 @@ namespace Cryville.Crtr { lock (_lock) { if (ScoreCache.Count == 0) { foreach (var s in scores) - ScoreCache.Add(s.Key, s.Value.ToString(scoreDefs[s.Key].format)); + ScoreCache.Add(scoreFmtKeys[s.Key], s.Value.ToString(scoreDefs[s.Key].format)); } return ScoreCache; } diff --git a/Assets/Cryville/Crtr/PdtEvaluator.cs b/Assets/Cryville/Crtr/PdtEvaluator.cs index 792fa9f..588409a 100644 --- a/Assets/Cryville/Crtr/PdtEvaluator.cs +++ b/Assets/Cryville/Crtr/PdtEvaluator.cs @@ -24,6 +24,7 @@ namespace Cryville.Crtr { var id = new Identifier(name); PropSrc prop; string str; + float num; if (ContextEvent != null && ContextEvent.PropSrcs.TryGetValue(name, out prop)) { prop.Get(out type, out value); } @@ -31,6 +32,12 @@ namespace Cryville.Crtr { var vec = ContextState.GetRawValue(id); new VectorSrc(() => vec).Get(out type, out value); } + else if (ContextJudge != null && ContextJudge.scores.TryGetValue(name, out num)) { + type = PdtInternalType.Number; + LoadNum(num); + value = _numbuf; + RevokePotentialConstant(); + } else if (ContextJudge != null && ContextJudge.GetFormattedScoreStrings().TryGetValue(name, out str)) { type = PdtInternalType.String; value = GetBytes(str); diff --git a/Assets/Cryville/Crtr/Ruleset.cs b/Assets/Cryville/Crtr/Ruleset.cs index 1c0322f..b85810e 100644 --- a/Assets/Cryville/Crtr/Ruleset.cs +++ b/Assets/Cryville/Crtr/Ruleset.cs @@ -45,8 +45,12 @@ namespace Cryville.Crtr { } foreach (var j in judges.Values) { if (j.hit != null) etor.Optimize(j.hit); - if (j.scores != null) foreach (var e in j.scores.Values) { - etor.Optimize(e); + if (j.scores != null) { + foreach (var s in j.scores) { + if (s.Key.op != default(Identifier)) + etor.PatchCompound(s.Key.name.Key, s.Key.op.Key, s.Value); + etor.Optimize(s.Value); + } } } foreach (var s in scores.Values) {