Prevents dynamic anchor set twice. Implement special dynamic anchors.
This commit is contained in:
@@ -75,6 +75,7 @@ namespace Cryville.Crtr.Event {
|
||||
|
||||
public readonly Dictionary<int, List<Anchor>> Anchors = new Dictionary<int, List<Anchor>>();
|
||||
public readonly Dictionary<int, Anchor> DynamicAnchors = new Dictionary<int, Anchor>();
|
||||
public readonly Dictionary<int, bool> DynamicAnchorSet = new Dictionary<int, bool>();
|
||||
public Anchor OpenedAnchor;
|
||||
protected Anchor a_cur;
|
||||
protected Anchor a_head;
|
||||
@@ -91,6 +92,7 @@ namespace Cryville.Crtr.Event {
|
||||
if (DynamicAnchors.ContainsKey(name))
|
||||
throw new ArgumentException(string.Format("The anchor \"{0}\" already exists", strname));
|
||||
DynamicAnchors.Add(name, result);
|
||||
DynamicAnchorSet.Add(name, false);
|
||||
}
|
||||
List<Anchor> list;
|
||||
if (!Anchors.TryGetValue(name, out list))
|
||||
@@ -179,11 +181,12 @@ namespace Cryville.Crtr.Event {
|
||||
protected static bool CanDoGraphicalUpdate(ContainerState s) { return s.CloneType >= 2 && s.CloneType < 16; }
|
||||
#region Anchor
|
||||
public virtual void Anchor() {
|
||||
foreach (var a in DynamicAnchors.Keys) DynamicAnchorSet[a] = false;
|
||||
skinContainer.MatchDynamic(cs);
|
||||
if (cs.Active) PushAnchorEvent(cs.Time, a_cur);
|
||||
if (Alive) {
|
||||
PushAnchorEvent(cs.StampedContainer.Time, a_head, -1, true);
|
||||
PushAnchorEvent(cs.StampedContainer.Time + cs.StampedContainer.Duration, a_tail, 1, true);
|
||||
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);
|
||||
}
|
||||
}
|
||||
static readonly SimpleObjectPool<StampedEvent.Anchor> anchorEvPool
|
||||
@@ -192,7 +195,10 @@ namespace Cryville.Crtr.Event {
|
||||
Anchor anchor;
|
||||
if (!DynamicAnchors.TryGetValue(name, out anchor))
|
||||
throw new ArgumentException(string.Format("Specified anchor \"{0}\" not found", IdentifierManager.SharedInstance.Retrieve(name)));
|
||||
if (DynamicAnchorSet[name])
|
||||
throw new InvalidOperationException(string.Format("Specified anchor \"{0}\" has been set", IdentifierManager.SharedInstance.Retrieve(name)));
|
||||
PushAnchorEvent(time, anchor);
|
||||
DynamicAnchorSet[name] = true;
|
||||
}
|
||||
void PushAnchorEvent(double time, Anchor anchor, int priority = 0, bool forced = false) {
|
||||
var tev = anchorEvPool.Rent();
|
||||
|
Reference in New Issue
Block a user