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