Implement judge event preparation.
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Pdt;
|
||||
using Cryville.Common.Unity.Input;
|
||||
using Cryville.Crtr.Event;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public class Judge {
|
||||
readonly PdtRuleset _rs;
|
||||
readonly Dictionary<Identifier, float> ct
|
||||
= new Dictionary<Identifier, float>();
|
||||
readonly Dictionary<Identifier, Dictionary<float, JudgeEvent>> evs
|
||||
= new Dictionary<Identifier, Dictionary<float, JudgeEvent>>();
|
||||
struct JudgeEvent {
|
||||
public float EndTime;
|
||||
public JudgeDefinition Definition { get; set; }
|
||||
public ContainerState State { get; set; }
|
||||
}
|
||||
public Judge(PdtRuleset rs) {
|
||||
_rs = rs;
|
||||
foreach (var s in rs.scores) {
|
||||
@@ -14,7 +23,13 @@ namespace Cryville.Crtr {
|
||||
scores.Add(name, s.Value.init);
|
||||
}
|
||||
}
|
||||
public void Feed(string target) {
|
||||
public void Prepare(float time, Identifier input, JudgeDefinition def, ContainerState container) {
|
||||
Dictionary<float, JudgeEvent> list;
|
||||
if (!evs.TryGetValue(input, out list)) {
|
||||
ct.Add(input, 0);
|
||||
evs.Add(input, list = new Dictionary<float, JudgeEvent>());
|
||||
}
|
||||
list.Add(time + def.clip[0], new JudgeEvent { EndTime = time + def.clip[1], Definition = def, State = container });
|
||||
}
|
||||
public void Feed(InputEvent ev) {
|
||||
|
||||
|
@@ -95,10 +95,11 @@ namespace Cryville.Crtr {
|
||||
else if (ev.Unstamped == null) { }
|
||||
else if (ev.Unstamped is Chart.Judge) {
|
||||
var tev = (Chart.Judge)ev.Unstamped;
|
||||
Identifier name;
|
||||
Identifier name = default(Identifier);
|
||||
ChartPlayer.etor.ContextEvent = tev;
|
||||
ChartPlayer.etor.ContextState = s;
|
||||
ChartPlayer.etor.Evaluate(new PropOp.Identifier(v => name = new Identifier(v)), ruleset.judges[tev.Id].input);
|
||||
judge.Prepare(ps.Time, name, ruleset.judges[tev.Id], cs);
|
||||
ChartPlayer.etor.ContextState = null;
|
||||
ChartPlayer.etor.ContextEvent = null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user