From ff410529b01a8c7894cdfcb13560bde8739e5e7b Mon Sep 17 00:00:00 2001 From: PopSlime Date: Fri, 10 Feb 2023 17:35:36 +0800 Subject: [PATCH] Add `invisible_bounds` contextual variable. --- Assets/Cryville/Crtr/Event/ContainerHandler.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Assets/Cryville/Crtr/Event/ContainerHandler.cs b/Assets/Cryville/Crtr/Event/ContainerHandler.cs index 49cecfb..c52ee09 100644 --- a/Assets/Cryville/Crtr/Event/ContainerHandler.cs +++ b/Assets/Cryville/Crtr/Event/ContainerHandler.cs @@ -67,6 +67,7 @@ namespace Cryville.Crtr.Event { } static readonly int _var_current_time = IdentifierManager.SharedInstance.Request("current_time"); + static readonly int _var_invisible_bounds = IdentifierManager.SharedInstance.Request("invisible_bounds"); public readonly Dictionary PropSrcs = new Dictionary(); SkinContainer skinContainer; protected Judge judge; @@ -85,6 +86,8 @@ namespace Cryville.Crtr.Event { protected readonly static int _a_cur = IdentifierManager.SharedInstance.Request("cur"); protected readonly static int _a_head = IdentifierManager.SharedInstance.Request("head"); protected readonly static int _a_tail = IdentifierManager.SharedInstance.Request("tail"); + double atime_head; + double atime_tail; public Anchor RegisterAnchor(int name, bool dyn = false, int propSrcCount = 0) { var strname = IdentifierManager.SharedInstance.Retrieve(name); var go = new GameObject("." + strname).transform; @@ -123,6 +126,7 @@ namespace Cryville.Crtr.Event { a_head = RegisterAnchor(_a_head, true); a_tail = RegisterAnchor(_a_tail, true); PropSrcs.Add(_var_current_time, new PropSrc.Float(() => (float)cs.rootPrototype.Time)); + PropSrcs.Add(_var_invisible_bounds, new PropSrc.Boolean(() => atime_head > atime_tail)); } public virtual void Init() { skinContainer.MatchStatic(ps); @@ -187,11 +191,13 @@ namespace Cryville.Crtr.Event { public virtual void Anchor() { foreach (var p in PropSrcs.Values) p.Invalidate(); foreach (var a in DynamicAnchors.Keys) DynamicAnchorSet[a] = false; + atime_head = cs.StampedContainer.Time; + atime_tail = atime_head + cs.StampedContainer.Duration; skinContainer.MatchDynamic(cs); if (cs.Active) PushAnchorEvent(cs.Time, a_cur); if (Alive) { - if (!DynamicAnchorSet[_a_head]) PushAnchorEvent(cs.StampedContainer.Time, a_head, -1, true); - if (!DynamicAnchorSet[_a_tail]) PushAnchorEvent(cs.StampedContainer.Time + cs.StampedContainer.Duration, a_tail, 1, true); + if (!DynamicAnchorSet[_a_head]) PushAnchorEvent(atime_head, a_head, -1, true); + if (!DynamicAnchorSet[_a_tail]) PushAnchorEvent(atime_tail, a_tail, 1, true); foreach (var anchors in Anchors.Values) foreach (var anchor in anchors) anchor.Transform.gameObject.SetActive(false); } } @@ -205,8 +211,8 @@ namespace Cryville.Crtr.Event { throw new InvalidOperationException(string.Format("Specified anchor \"{0}\" has been set", IdentifierManager.SharedInstance.Retrieve(name))); int priority = 0; bool forced = true; - if (name == _a_head) priority = -1; - else if (name == _a_tail) priority = 1; + if (name == _a_head) { priority = -1; atime_head = time; } + else if (name == _a_tail) { priority = 1; atime_tail = time; } else forced = false; PushAnchorEvent(time, anchor, priority, forced); DynamicAnchorSet[name] = true;