Change anchor opening to single only.

This commit is contained in:
2023-01-16 13:33:25 +08:00
parent 609bb317d0
commit a09a5686d7
2 changed files with 10 additions and 9 deletions

View File

@@ -60,7 +60,7 @@ namespace Cryville.Crtr.Event {
get; get;
} }
public readonly Dictionary<int, List<Anchor>> Anchors = new Dictionary<int, List<Anchor>>(); public readonly Dictionary<int, List<Anchor>> Anchors = new Dictionary<int, List<Anchor>>();
public readonly Dictionary<int, Anchor> OpenAnchors = new Dictionary<int, Anchor>(); public Anchor OpenedAnchor;
protected Anchor a_cur; protected Anchor a_cur;
protected Anchor a_head; protected Anchor a_head;
protected Anchor a_tail; protected Anchor a_tail;
@@ -113,7 +113,7 @@ namespace Cryville.Crtr.Event {
Awoken = true; Alive = true; Awoken = true; Alive = true;
} }
protected virtual void Awake(ContainerState s) { protected virtual void Awake(ContainerState s) {
if (gogroup) CloseAnchor(a_head); if (gogroup) CloseAnchor();
} }
protected virtual void GetPosition(ContainerState s) { } protected virtual void GetPosition(ContainerState s) { }
public virtual void StartUpdate(ContainerState s) { public virtual void StartUpdate(ContainerState s) {
@@ -152,7 +152,7 @@ namespace Cryville.Crtr.Event {
tev.Target.Transform.rotation = Quaternion.Euler(s.Direction); tev.Target.Transform.rotation = Quaternion.Euler(s.Direction);
#endif #endif
skinContainer.MatchDynamic(s); skinContainer.MatchDynamic(s);
CloseAnchor(tev.Target); CloseAnchor();
} }
anchorEvPool.Return(tev); anchorEvPool.Return(tev);
} }
@@ -164,7 +164,7 @@ namespace Cryville.Crtr.Event {
if (gogroup && s.CloneType <= 2) { if (gogroup && s.CloneType <= 2) {
OpenAnchor(a_tail); OpenAnchor(a_tail);
skinContainer.MatchDynamic(s); skinContainer.MatchDynamic(s);
CloseAnchor(a_tail); CloseAnchor();
} }
} }
} }
@@ -172,10 +172,11 @@ namespace Cryville.Crtr.Event {
if (cs.Working) PushAnchorEvent(cs.Time, a_cur); if (cs.Working) PushAnchorEvent(cs.Time, a_cur);
} }
protected void OpenAnchor(Anchor anchor) { protected void OpenAnchor(Anchor anchor) {
OpenAnchors.Add(anchor.Name, anchor); if (OpenedAnchor != null) throw new InvalidOperationException("An anchor has been opened");
OpenedAnchor = anchor;
} }
protected void CloseAnchor(Anchor anchor) { protected void CloseAnchor() {
OpenAnchors.Remove(anchor.Name); OpenedAnchor = null;
} }
} }
} }

View File

@@ -89,7 +89,7 @@ namespace Cryville.Crtr {
else return Enumerable.Empty<Transform>(); else return Enumerable.Empty<Transform>();
} }
public override bool IsUpdatable(ContainerState h) { public override bool IsUpdatable(ContainerState h) {
return h.Handler.OpenAnchors.ContainsKey(Name); return h.Handler.OpenedAnchor.Name == Name;
} }
} }
public class AtAnchor : SkinSelector { public class AtAnchor : SkinSelector {
@@ -101,7 +101,7 @@ namespace Cryville.Crtr {
return IsUpdatable(h) ? a : null; return IsUpdatable(h) ? a : null;
} }
public override bool IsUpdatable(ContainerState h) { public override bool IsUpdatable(ContainerState h) {
return h.Handler.OpenAnchors.ContainsKey(Name); return h.Handler.OpenedAnchor.Name == Name;
} }
} }
public class Property : SkinSelector { public class Property : SkinSelector {