Revise anchor data structure.
This commit is contained in:
@@ -24,16 +24,16 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
|
||||
SectionalGameObject[] sgos;
|
||||
readonly Dictionary<Identifier, JudgeState> judges = new Dictionary<Identifier, JudgeState>();
|
||||
readonly Dictionary<Chart.Judge, JudgeState> judges = new Dictionary<Chart.Judge, JudgeState>();
|
||||
class JudgeState {
|
||||
public int AbsoluteAnchorName { get; set; }
|
||||
public int RelativeAnchorName { get; set; }
|
||||
public Anchor AbsoluteAnchor { get; private set; }
|
||||
public Anchor RelativeAnchor { get; private set; }
|
||||
public bool Judged { get; private set; }
|
||||
public float AbsoluteTime { get; private set; }
|
||||
public float RelativeTime { get; private set; }
|
||||
public JudgeState(NoteHandler handler, int name) {
|
||||
handler.RegisterAnchor(AbsoluteAnchorName = handler.judge.jtabsMap[name]);
|
||||
handler.RegisterAnchor(RelativeAnchorName = handler.judge.jtrelMap[name]);
|
||||
AbsoluteAnchor = handler.RegisterAnchor(handler.judge.jtabsMap[name]);
|
||||
RelativeAnchor = handler.RegisterAnchor(handler.judge.jtrelMap[name]);
|
||||
}
|
||||
public void MarkJudged(float abs, float rel) {
|
||||
Judged = true;
|
||||
@@ -45,11 +45,9 @@ namespace Cryville.Crtr {
|
||||
public override void PreInit() {
|
||||
base.PreInit();
|
||||
foreach (var j in Event.judges) {
|
||||
if (!judges.ContainsKey(j.Id)) {
|
||||
judges.Add(j.Id, new JudgeState(this, j.Id.Key));
|
||||
judges.Add(j, new JudgeState(this, j.Id.Key));
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void Init() {
|
||||
base.Init();
|
||||
sgos = gogroup.GetComponentsInChildren<SectionalGameObject>();
|
||||
@@ -57,10 +55,10 @@ namespace Cryville.Crtr {
|
||||
protected override void PreAwake(ContainerState s) {
|
||||
base.PreAwake(s);
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
a_head.SetPositionAndRotation(Position = GetFramePoint(s.Parent, s.Track), Rotation = GetFrameRotation(s.Parent, s.Track));
|
||||
a_head.Transform.SetPositionAndRotation(Position = GetFramePoint(s.Parent, s.Track), Rotation = GetFrameRotation(s.Parent, s.Track));
|
||||
#else
|
||||
a_head.position = Position = GetFramePoint(s.Parent, s.Track);
|
||||
a_head.rotation = Rotation = GetFrameRotation(s.Parent, s.Track);
|
||||
a_head.Transform.position = Position = GetFramePoint(s.Parent, s.Track);
|
||||
a_head.Transform.rotation = Rotation = GetFrameRotation(s.Parent, s.Track);
|
||||
#endif
|
||||
}
|
||||
protected override void Awake(ContainerState s) {
|
||||
@@ -119,8 +117,8 @@ namespace Cryville.Crtr {
|
||||
if (cs.Working) {
|
||||
foreach (var j in judges.Values) {
|
||||
if (!j.Judged) continue;
|
||||
PushAnchorEvent(j.AbsoluteAnchorName, j.AbsoluteTime);
|
||||
PushAnchorEvent(j.RelativeAnchorName, j.RelativeTime + cs.Time);
|
||||
PushAnchorEvent(j.AbsoluteTime, j.AbsoluteAnchor);
|
||||
PushAnchorEvent(j.RelativeTime + cs.Time, j.RelativeAnchor);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,10 +127,10 @@ namespace Cryville.Crtr {
|
||||
if (s.CloneType == 2 && gogroup) {
|
||||
foreach (var i in sgos) i.Seal();
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
a_tail.SetPositionAndRotation(GetFramePoint(ts.Parent, ts.Track), Quaternion.Euler(ts.Direction));
|
||||
a_tail.Transform.SetPositionAndRotation(GetFramePoint(ts.Parent, ts.Track), Quaternion.Euler(ts.Direction));
|
||||
#else
|
||||
a_tail.position = GetFramePoint(ts.Parent, ts.Track);
|
||||
a_tail.rotation = Quaternion.Euler(ts.Direction);
|
||||
a_tail.Transform.position = GetFramePoint(ts.Parent, ts.Track);
|
||||
a_tail.Transform.rotation = Quaternion.Euler(ts.Direction);
|
||||
#endif
|
||||
}
|
||||
OpenAnchor(_a_tail);
|
||||
@@ -197,7 +195,7 @@ namespace Cryville.Crtr {
|
||||
|
||||
public void ReportJudge(Judge.JudgeEvent ev, float time, Identifier result) {
|
||||
JudgeState state;
|
||||
if (!judges.TryGetValue(ev.JudgeId, out state)) return;
|
||||
if (!judges.TryGetValue(ev.BaseEvent, out state)) return;
|
||||
state.MarkJudged(time, (float)(time - cs.Time));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user