Remove dynamic judge anchors. Add judge time properties.
This commit is contained in:
@@ -7,10 +7,10 @@ namespace Cryville.Crtr {
|
||||
public Transform Transform { get; private set; }
|
||||
public SkinContext SkinContext { get; private set; }
|
||||
public Dictionary<int, PropSrc> PropSrcs { get; private set; }
|
||||
public Anchor(int name, Transform transform, bool hasProps = false) {
|
||||
public Anchor(int name, Transform transform, int propSrcCount = 0) {
|
||||
Name = name;
|
||||
Transform = transform;
|
||||
if (hasProps) PropSrcs = new Dictionary<int, PropSrc>();
|
||||
if (propSrcCount > 0) PropSrcs = new Dictionary<int, PropSrc>(propSrcCount);
|
||||
SkinContext = new SkinContext(transform, PropSrcs);
|
||||
}
|
||||
}
|
||||
|
@@ -77,10 +77,10 @@ namespace Cryville.Crtr.Event {
|
||||
a_head = RegisterAnchor(_a_head);
|
||||
a_tail = RegisterAnchor(_a_tail);
|
||||
}
|
||||
protected Anchor RegisterAnchor(int name, bool hasPropSrcs = false) {
|
||||
protected Anchor RegisterAnchor(int name, int propSrcCount = 0) {
|
||||
var go = new GameObject("." + IdentifierManager.SharedInstance.Retrieve(name)).transform;
|
||||
go.SetParent(gogroup, false);
|
||||
var result = new Anchor(name, go, hasPropSrcs);
|
||||
var result = new Anchor(name, go, propSrcCount);
|
||||
List<Anchor> list;
|
||||
if (!Anchors.TryGetValue(name, out list))
|
||||
Anchors.Add(name, list = new List<Anchor>());
|
||||
|
@@ -23,49 +23,34 @@ namespace Cryville.Crtr {
|
||||
|
||||
SectionalGameObject[] sgos;
|
||||
readonly Dictionary<Chart.Judge, JudgeState> judges = new Dictionary<Chart.Judge, JudgeState>();
|
||||
readonly Dictionary<int, DynamicJudgeAnchorPair> dynJudgeAnchors = new Dictionary<int, DynamicJudgeAnchorPair>();
|
||||
class JudgeState {
|
||||
static readonly int _var_judge_result = IdentifierManager.SharedInstance.Request("judge_result");
|
||||
static readonly int _var_judge_time_absolute = IdentifierManager.SharedInstance.Request("judge_time_absolute");
|
||||
static readonly int _var_judge_time_relative = IdentifierManager.SharedInstance.Request("judge_time_relative");
|
||||
public Anchor StaticAnchor { get; private set; }
|
||||
public DynamicJudgeAnchorPair DynamicAnchors { get; private set; }
|
||||
public bool Judged { get; private set; }
|
||||
public float AbsoluteTime { get; private set; }
|
||||
PropSrc _jtabsPropSrc;
|
||||
public float RelativeTime { get; private set; }
|
||||
int _result = 0;
|
||||
PropSrc _jtrelPropSrc;
|
||||
public int Result { get; private set; }
|
||||
PropSrc _resultPropSrc;
|
||||
public JudgeState(NoteHandler handler, int name) {
|
||||
StaticAnchor = handler.RegisterAnchor(handler.judge.judgeMap[name], true);
|
||||
DynamicAnchors = handler.GetDynamicJudgeAnchorPair(name);
|
||||
StaticAnchor = handler.RegisterAnchor(handler.judge.judgeMap[name], 3);
|
||||
}
|
||||
public void MarkJudged(float abs, float rel, int result) {
|
||||
Judged = true;
|
||||
AbsoluteTime = abs;
|
||||
RelativeTime = rel;
|
||||
_result = result;
|
||||
Result = result;
|
||||
_jtabsPropSrc.Invalidate();
|
||||
_jtrelPropSrc.Invalidate();
|
||||
_resultPropSrc.Invalidate();
|
||||
}
|
||||
public void InitPropSrcs() {
|
||||
StaticAnchor.PropSrcs.Add(_var_judge_result, _resultPropSrc = new PropSrc.Identifier(() => _result));
|
||||
StaticAnchor.PropSrcs.Add(_var_judge_result, _resultPropSrc = new PropSrc.Identifier(() => Result));
|
||||
StaticAnchor.PropSrcs.Add(_var_judge_time_absolute, _jtabsPropSrc = new PropSrc.Float(() => AbsoluteTime));
|
||||
StaticAnchor.PropSrcs.Add(_var_judge_time_relative, _jtrelPropSrc = new PropSrc.Float(() => RelativeTime));
|
||||
}
|
||||
}
|
||||
class DynamicJudgeAnchorPair {
|
||||
public Anchor Absolute { get; private set; }
|
||||
public Anchor Relative { get; private set; }
|
||||
public DynamicJudgeAnchorPair(Anchor absolute, Anchor relative) {
|
||||
Absolute = absolute;
|
||||
Relative = relative;
|
||||
}
|
||||
}
|
||||
DynamicJudgeAnchorPair GetDynamicJudgeAnchorPair(int name) {
|
||||
DynamicJudgeAnchorPair result;
|
||||
if (!dynJudgeAnchors.TryGetValue(name, out result)) {
|
||||
dynJudgeAnchors.Add(name, result = new DynamicJudgeAnchorPair(
|
||||
RegisterAnchor(judge.jtabsMap[name]),
|
||||
RegisterAnchor(judge.jtrelMap[name])
|
||||
));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public override void PreInit() {
|
||||
base.PreInit();
|
||||
@@ -137,11 +122,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
public override void Anchor() {
|
||||
base.Anchor();
|
||||
foreach (var j in judges.Values) {
|
||||
if (!j.Judged) continue;
|
||||
PushAnchorEvent(j.AbsoluteTime, j.DynamicAnchors.Absolute);
|
||||
PushAnchorEvent(j.RelativeTime + cs.Time, j.DynamicAnchors.Relative);
|
||||
}
|
||||
// TODO Push Dynamic Anchor Events
|
||||
}
|
||||
|
||||
public override void EndUpdate(ContainerState s) {
|
||||
|
Reference in New Issue
Block a user