Update internal judge event data structure.
This commit is contained in:
@@ -8,13 +8,22 @@ namespace Cryville.Crtr {
|
|||||||
readonly PdtRuleset _rs;
|
readonly PdtRuleset _rs;
|
||||||
readonly Dictionary<Identifier, float> ct
|
readonly Dictionary<Identifier, float> ct
|
||||||
= new Dictionary<Identifier, float>();
|
= new Dictionary<Identifier, float>();
|
||||||
readonly Dictionary<Identifier, Dictionary<float, JudgeEvent>> evs
|
readonly Dictionary<Identifier, List<JudgeEvent>> evs
|
||||||
= new Dictionary<Identifier, Dictionary<float, JudgeEvent>>();
|
= new Dictionary<Identifier, List<JudgeEvent>>();
|
||||||
|
readonly Dictionary<Identifier, List<JudgeEvent>> activeEvs
|
||||||
|
= new Dictionary<Identifier, List<JudgeEvent>>();
|
||||||
struct JudgeEvent {
|
struct JudgeEvent {
|
||||||
public float EndTime;
|
public float StartTime { get; set; }
|
||||||
|
public float EndTime { get; set; }
|
||||||
public JudgeDefinition Definition { get; set; }
|
public JudgeDefinition Definition { get; set; }
|
||||||
public ContainerState State { get; set; }
|
public ContainerState State { get; set; }
|
||||||
}
|
}
|
||||||
|
static IComparer<JudgeEvent> _stcmp = new JudgeEventStartTimeComparer();
|
||||||
|
class JudgeEventStartTimeComparer : IComparer<JudgeEvent> {
|
||||||
|
public int Compare(JudgeEvent x, JudgeEvent y) {
|
||||||
|
return x.StartTime.CompareTo(y.StartTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
public Judge(PdtRuleset rs) {
|
public Judge(PdtRuleset rs) {
|
||||||
_rs = rs;
|
_rs = rs;
|
||||||
foreach (var s in rs.scores) {
|
foreach (var s in rs.scores) {
|
||||||
@@ -23,13 +32,22 @@ namespace Cryville.Crtr {
|
|||||||
scores.Add(name, s.Value.init);
|
scores.Add(name, s.Value.init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void Prepare(float time, Identifier input, JudgeDefinition def, ContainerState container) {
|
public void Prepare(float st, float et, Identifier input, JudgeDefinition def, ContainerState container) {
|
||||||
Dictionary<float, JudgeEvent> list;
|
List<JudgeEvent> list;
|
||||||
if (!evs.TryGetValue(input, out list)) {
|
if (!evs.TryGetValue(input, out list)) {
|
||||||
ct.Add(input, 0);
|
ct.Add(input, 0);
|
||||||
evs.Add(input, list = new Dictionary<float, JudgeEvent>());
|
evs.Add(input, list = new List<JudgeEvent>());
|
||||||
|
activeEvs.Add(input, new List<JudgeEvent>());
|
||||||
}
|
}
|
||||||
list.Add(time + def.clip[0], new JudgeEvent { EndTime = time + def.clip[1], Definition = def, State = container });
|
var ev = new JudgeEvent {
|
||||||
|
StartTime = st + def.clip[0],
|
||||||
|
EndTime = et + def.clip[1],
|
||||||
|
Definition = def,
|
||||||
|
State = container,
|
||||||
|
};
|
||||||
|
var index = list.BinarySearch(ev, _stcmp);
|
||||||
|
if (index < 0) index = ~index;
|
||||||
|
list.Insert(index, ev);
|
||||||
}
|
}
|
||||||
public void Feed(string target, float ft, float tt) {
|
public void Feed(string target, float ft, float tt) {
|
||||||
Logger.Log("main", 0, "Judge", "Feed {0}: {1}->{2}", target, ft, tt);
|
Logger.Log("main", 0, "Judge", "Feed {0}: {1}->{2}", target, ft, tt);
|
||||||
|
@@ -99,7 +99,7 @@ namespace Cryville.Crtr {
|
|||||||
ChartPlayer.etor.ContextEvent = tev;
|
ChartPlayer.etor.ContextEvent = tev;
|
||||||
ChartPlayer.etor.ContextState = s;
|
ChartPlayer.etor.ContextState = s;
|
||||||
ChartPlayer.etor.Evaluate(new PropOp.Identifier(v => name = new Identifier(v)), ruleset.judges[tev.Id].input);
|
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);
|
judge.Prepare(ev.Time, ev.Time + ev.Duration, name, ruleset.judges[tev.Id], cs);
|
||||||
ChartPlayer.etor.ContextState = null;
|
ChartPlayer.etor.ContextState = null;
|
||||||
ChartPlayer.etor.ContextEvent = null;
|
ChartPlayer.etor.ContextEvent = null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user