Implement judge event preparation.

This commit is contained in:
2022-11-12 00:55:37 +08:00
parent 8af09a7167
commit d10e6ea18b
2 changed files with 19 additions and 3 deletions

View File

@@ -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) {