Cleanup anchor related code.
This commit is contained in:
@@ -70,15 +70,16 @@ namespace Cryville.Crtr.Event {
|
||||
gogroup = new GameObject(TypeName + ":" + Container.GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
|
||||
if (cs.Parent != null)
|
||||
gogroup.SetParent(cs.Parent.Handler.gogroup, false);
|
||||
a_cur = RegisterAnchor(_a_cur);
|
||||
a_head = RegisterAnchor(_a_head);
|
||||
a_tail = RegisterAnchor(_a_tail);
|
||||
a_cur = RegisterAnchor(_a_cur).Transform;
|
||||
a_head = RegisterAnchor(_a_head).Transform;
|
||||
a_tail = RegisterAnchor(_a_tail).Transform;
|
||||
}
|
||||
protected Transform RegisterAnchor(int name) {
|
||||
protected Anchor RegisterAnchor(int name) {
|
||||
var go = new GameObject("." + IdentifierManager.SharedInstance.Retrieve(name)).transform;
|
||||
go.SetParent(gogroup, false);
|
||||
Anchors.Add(name, new Anchor() { Transform = go });
|
||||
return go;
|
||||
var result = new Anchor() { Transform = go };
|
||||
Anchors.Add(name, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -120,24 +121,25 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
static readonly SimpleObjectPool<StampedEvent.Anchor> anchorEvPool
|
||||
= new SimpleObjectPool<StampedEvent.Anchor>(1024);
|
||||
protected void PushAnchorEvent(int name, double time) {
|
||||
var tev = anchorEvPool.Rent();
|
||||
tev.Time = time;
|
||||
tev.Container = Container;
|
||||
tev.Name = name;
|
||||
ts.Bus.PushTempEvent(tev);
|
||||
}
|
||||
public virtual void Update(ContainerState s, StampedEvent ev) {
|
||||
bool flag = !Awoken && s.CloneType >= 2 && s.CloneType < 16;
|
||||
if (flag) PreAwake(s);
|
||||
if (s.CloneType <= 2) if (gogroup) skinContainer.MatchDynamic(s);
|
||||
if (flag) Awake(s);
|
||||
if (s.CloneType == 0) {
|
||||
var tev = anchorEvPool.Rent();
|
||||
tev.Time = s.Time;
|
||||
tev.Container = s.Container;
|
||||
tev.Name = _a_cur;
|
||||
ts.Bus.PushTempEvent(tev);
|
||||
}
|
||||
}
|
||||
public virtual void ExUpdate(ContainerState s, StampedEvent ev) {
|
||||
if (ev is StampedEvent.Anchor) {
|
||||
var tev = (StampedEvent.Anchor)ev;
|
||||
if (gogroup) {
|
||||
OpenAnchor(tev.Name);
|
||||
Anchors[tev.Name].Transform.SetPositionAndRotation(Position, Rotation);
|
||||
skinContainer.MatchDynamic(s);
|
||||
CloseAnchor(tev.Name);
|
||||
}
|
||||
@@ -151,7 +153,9 @@ namespace Cryville.Crtr.Event {
|
||||
if (gogroup && s.CloneType <= 2) skinContainer.MatchDynamic(s);
|
||||
}
|
||||
}
|
||||
public virtual void Anchor() { }
|
||||
public virtual void Anchor() {
|
||||
if (cs.Working) PushAnchorEvent(_a_cur, cs.Time);
|
||||
}
|
||||
protected void OpenAnchor(int name) {
|
||||
if (Anchors.ContainsKey(name)) Anchors[name].Open();
|
||||
}
|
||||
|
Reference in New Issue
Block a user