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;
|
gogroup = new GameObject(TypeName + ":" + Container.GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
|
||||||
if (cs.Parent != null)
|
if (cs.Parent != null)
|
||||||
gogroup.SetParent(cs.Parent.Handler.gogroup, false);
|
gogroup.SetParent(cs.Parent.Handler.gogroup, false);
|
||||||
a_cur = RegisterAnchor(_a_cur);
|
a_cur = RegisterAnchor(_a_cur).Transform;
|
||||||
a_head = RegisterAnchor(_a_head);
|
a_head = RegisterAnchor(_a_head).Transform;
|
||||||
a_tail = RegisterAnchor(_a_tail);
|
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;
|
var go = new GameObject("." + IdentifierManager.SharedInstance.Retrieve(name)).transform;
|
||||||
go.SetParent(gogroup, false);
|
go.SetParent(gogroup, false);
|
||||||
Anchors.Add(name, new Anchor() { Transform = go });
|
var result = new Anchor() { Transform = go };
|
||||||
return go;
|
Anchors.Add(name, result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -120,24 +121,25 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
static readonly SimpleObjectPool<StampedEvent.Anchor> anchorEvPool
|
static readonly SimpleObjectPool<StampedEvent.Anchor> anchorEvPool
|
||||||
= new SimpleObjectPool<StampedEvent.Anchor>(1024);
|
= 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) {
|
public virtual void Update(ContainerState s, StampedEvent ev) {
|
||||||
bool flag = !Awoken && s.CloneType >= 2 && s.CloneType < 16;
|
bool flag = !Awoken && s.CloneType >= 2 && s.CloneType < 16;
|
||||||
if (flag) PreAwake(s);
|
if (flag) PreAwake(s);
|
||||||
if (s.CloneType <= 2) if (gogroup) skinContainer.MatchDynamic(s);
|
if (s.CloneType <= 2) if (gogroup) skinContainer.MatchDynamic(s);
|
||||||
if (flag) Awake(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) {
|
public virtual void ExUpdate(ContainerState s, StampedEvent ev) {
|
||||||
if (ev is StampedEvent.Anchor) {
|
if (ev is StampedEvent.Anchor) {
|
||||||
var tev = (StampedEvent.Anchor)ev;
|
var tev = (StampedEvent.Anchor)ev;
|
||||||
if (gogroup) {
|
if (gogroup) {
|
||||||
OpenAnchor(tev.Name);
|
OpenAnchor(tev.Name);
|
||||||
|
Anchors[tev.Name].Transform.SetPositionAndRotation(Position, Rotation);
|
||||||
skinContainer.MatchDynamic(s);
|
skinContainer.MatchDynamic(s);
|
||||||
CloseAnchor(tev.Name);
|
CloseAnchor(tev.Name);
|
||||||
}
|
}
|
||||||
@@ -151,7 +153,9 @@ namespace Cryville.Crtr.Event {
|
|||||||
if (gogroup && s.CloneType <= 2) skinContainer.MatchDynamic(s);
|
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) {
|
protected void OpenAnchor(int name) {
|
||||||
if (Anchors.ContainsKey(name)) Anchors[name].Open();
|
if (Anchors.ContainsKey(name)) Anchors[name].Open();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,15 +90,7 @@ namespace Cryville.Crtr {
|
|||||||
Position = GetFramePoint(s.Parent, s.Track);
|
Position = GetFramePoint(s.Parent, s.Track);
|
||||||
Rotation = GetFrameRotation(s.Parent, s.Track);
|
Rotation = GetFrameRotation(s.Parent, s.Track);
|
||||||
}
|
}
|
||||||
if (s.CloneType == 0) {
|
if (s.CloneType == 2) {
|
||||||
#if UNITY_5_6_OR_NEWER
|
|
||||||
a_cur.SetPositionAndRotation(Position, Rotation);
|
|
||||||
#else
|
|
||||||
a_cur.position = Position;
|
|
||||||
a_cur.rotation = Rotation;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (s.CloneType == 2) {
|
|
||||||
if (!gogroup) return;
|
if (!gogroup) return;
|
||||||
Chart.Note tev = Event;
|
Chart.Note tev = Event;
|
||||||
if (tev.IsLong) {
|
if (tev.IsLong) {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ namespace Cryville.Crtr {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (s.CloneType == 3) {
|
else if (s.CloneType == 3) {
|
||||||
|
spos = Vector3.zero;
|
||||||
bpos = cpt;
|
bpos = cpt;
|
||||||
brot = Quaternion.Euler(s.Direction);
|
brot = Quaternion.Euler(s.Direction);
|
||||||
}
|
}
|
||||||
@@ -61,18 +62,7 @@ namespace Cryville.Crtr {
|
|||||||
|
|
||||||
public override void Update(ContainerState s, StampedEvent ev) {
|
public override void Update(ContainerState s, StampedEvent ev) {
|
||||||
base.Update(s, ev);
|
base.Update(s, ev);
|
||||||
if (s.CloneType == 0) {
|
if (s.CloneType == 2 || s.CloneType == 3) {
|
||||||
pwp = Vector3.zero;
|
|
||||||
cpt = s.ScreenPoint;
|
|
||||||
spos = Vector3.zero;
|
|
||||||
#if UNITY_5_6_OR_NEWER
|
|
||||||
a_cur.SetPositionAndRotation(s.ScreenPoint, Quaternion.Euler(s.Direction));
|
|
||||||
#else
|
|
||||||
a_cur.position = s.ScreenPoint;
|
|
||||||
a_cur.rotation = Quaternion.Euler(s.Direction);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else if (s.CloneType == 2 || s.CloneType == 3) {
|
|
||||||
var tpt = s.ScreenPoint;
|
var tpt = s.ScreenPoint;
|
||||||
var tsv = s.ScrollVelocity;
|
var tsv = s.ScrollVelocity;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user