Restructure event/container system.

This commit is contained in:
2023-01-31 15:53:43 +08:00
parent 9700992c3a
commit a1ce459a0e
9 changed files with 241 additions and 223 deletions

View File

@@ -21,34 +21,37 @@ namespace Cryville.Crtr {
SectionalGameObject[] sgos;
Vector3 bpos; Quaternion brot;
Vector3 spos;
protected override void PreAwake(ContainerState s) {
base.PreAwake(s);
public override void StartPhysicalUpdate(ContainerState s) {
base.StartPhysicalUpdate(s);
if (CanDoGraphicalUpdate(s)) {
TransformAwake(s);
}
}
public override void StartPreGraphicalUpdate(ContainerState s) {
base.StartPreGraphicalUpdate(s);
TransformAwake(s);
}
public override void StartGraphicalUpdate(ContainerState s) {
base.StartGraphicalUpdate(s);
if (gogroup) {
TransformAwake(s);
var p = GetCurrentWorldPoint();
foreach (var i in sgos) {
i.Reset();
i.AppendPoint(p, s.QuatDir);
}
}
}
void TransformAwake(ContainerState s) {
pwp = Vector3.zero;
cpt = s.ScreenPoint;
ptime = s.Time;
if (s.CloneType == 2) {
#if UNITY_5_6_OR_NEWER
a_head.Transform.SetPositionAndRotation(GetCurrentWorldPoint(), Quaternion.Euler(s.Direction));
#else
a_head.Transform.position = GetCurrentWorldPoint();
a_head.Transform.rotation = Quaternion.Euler(s.Direction);
#endif
}
else if (s.CloneType == 3) {
if (s.CloneType == 3) {
spos = Vector3.zero;
bpos = cpt;
brot = Quaternion.Euler(s.Direction);
}
}
protected override void Awake(ContainerState s) {
base.Awake(s);
if (!gogroup) return;
var p = GetCurrentWorldPoint();
foreach (var i in sgos) {
i.Reset();
i.AppendPoint(p, s.QuatDir);
}
}
Vector3 cpt; // Current point
Vector3 ppt = Vector3.zero; // Previous point
@@ -58,7 +61,7 @@ namespace Cryville.Crtr {
public override void Update(ContainerState s, StampedEvent ev) {
base.Update(s, ev);
if (s.CloneType == 2 || s.CloneType == 3) {
if (CanDoGraphicalUpdate(s)) {
var tpt = s.ScreenPoint;
var tsv = s.ScrollVelocity;
@@ -102,24 +105,14 @@ namespace Cryville.Crtr {
spos = bpos - GetCurrentWorldPoint();
}
public override void EndUpdate(ContainerState s) {
base.EndUpdate(s);
if (s.CloneType == 0 || s.CloneType == 2) {
EndUpdatePosition(ts);
var p = GetCurrentWorldPoint();
foreach (var i in sgos) {
i.AppendPoint(p, s.QuatDir);
i.Seal();
}
#if UNITY_5_6_OR_NEWER
a_tail.Transform.SetPositionAndRotation(GetCurrentWorldPoint(), Quaternion.Euler(ts.Direction));
#else
a_tail.Transform.position = GetCurrentWorldPoint();
a_tail.Transform.rotation = Quaternion.Euler(ts.Direction);
#endif
public override void EndGraphicalUpdate(ContainerState s) {
base.EndGraphicalUpdate(s);
EndUpdatePosition(s);
var p = GetCurrentWorldPoint();
foreach (var i in sgos) {
i.AppendPoint(p, s.QuatDir);
i.Seal();
}
else if (s.CloneType == 3) EndUpdatePosition(ns);
else if (s.CloneType >= 16) EndUpdatePosition(ps);
}
void EndUpdatePosition(ContainerState s) {