Optimize anchor identifiers.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
using Cryville.Common;
|
||||||
using Cryville.Crtr.Components;
|
using Cryville.Crtr.Components;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -36,7 +37,7 @@ namespace Cryville.Crtr.Event {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Transform gogroup;
|
public Transform gogroup;
|
||||||
|
|
||||||
public readonly Dictionary<string, Anchor> Anchors = new Dictionary<string, Anchor>();
|
public readonly Dictionary<int, Anchor> Anchors = new Dictionary<int, Anchor>();
|
||||||
protected Transform a_head;
|
protected Transform a_head;
|
||||||
protected Transform a_tail;
|
protected Transform a_tail;
|
||||||
public Vector3 Position {
|
public Vector3 Position {
|
||||||
@@ -75,17 +76,22 @@ namespace Cryville.Crtr.Event {
|
|||||||
public abstract string TypeName {
|
public abstract string TypeName {
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
protected readonly static int _a_head = IdentifierManager.SharedInstance.Request("head");
|
||||||
|
protected readonly static int _a_tail = IdentifierManager.SharedInstance.Request("tail");
|
||||||
public virtual void PreInit() {
|
public virtual void PreInit() {
|
||||||
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_head = new GameObject("::head").transform;
|
a_head = RegisterAnchor(_a_head);
|
||||||
a_head.SetParent(gogroup, false);
|
a_tail = RegisterAnchor(_a_tail);
|
||||||
Anchors.Add("head", new Anchor() { Transform = a_head });
|
|
||||||
a_tail = new GameObject("::tail").transform;
|
|
||||||
a_tail.SetParent(gogroup, false);
|
|
||||||
Anchors.Add("tail", new Anchor() { Transform = a_tail });
|
|
||||||
}
|
}
|
||||||
|
protected Transform 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;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called upon StartUpdate of ps 17.
|
/// Called upon StartUpdate of ps 17.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -108,10 +114,10 @@ namespace Cryville.Crtr.Event {
|
|||||||
protected virtual void PreAwake(ContainerState s) {
|
protected virtual void PreAwake(ContainerState s) {
|
||||||
if (gogroup) gogroup.gameObject.SetActive(true);
|
if (gogroup) gogroup.gameObject.SetActive(true);
|
||||||
Awoken = true; Alive = true;
|
Awoken = true; Alive = true;
|
||||||
OpenAnchor("head");
|
OpenAnchor(_a_head);
|
||||||
}
|
}
|
||||||
protected virtual void Awake(ContainerState s) {
|
protected virtual void Awake(ContainerState s) {
|
||||||
CloseAnchor("head");
|
CloseAnchor(_a_head);
|
||||||
}
|
}
|
||||||
protected virtual void GetPosition(ContainerState s) { }
|
protected virtual void GetPosition(ContainerState s) { }
|
||||||
public virtual void StartUpdate(ContainerState s) {
|
public virtual void StartUpdate(ContainerState s) {
|
||||||
@@ -138,10 +144,10 @@ namespace Cryville.Crtr.Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual void Anchor() { }
|
public virtual void Anchor() { }
|
||||||
protected void OpenAnchor(string name) {
|
protected void OpenAnchor(int name) {
|
||||||
if (Anchors.ContainsKey(name)) Anchors[name].Open();
|
if (Anchors.ContainsKey(name)) Anchors[name].Open();
|
||||||
}
|
}
|
||||||
protected void CloseAnchor(string name) {
|
protected void CloseAnchor(int name) {
|
||||||
if (Anchors.ContainsKey(name)) Anchors[name].Close();
|
if (Anchors.ContainsKey(name)) Anchors[name].Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,9 +101,9 @@ namespace Cryville.Crtr {
|
|||||||
a_tail.rotation = Quaternion.Euler(ts.Direction);
|
a_tail.rotation = Quaternion.Euler(ts.Direction);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
OpenAnchor("tail");
|
OpenAnchor(_a_tail);
|
||||||
base.EndUpdate(s);
|
base.EndUpdate(s);
|
||||||
CloseAnchor("tail");
|
CloseAnchor(_a_tail);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 GetFramePoint(ContainerState state, float track) {
|
Vector3 GetFramePoint(ContainerState state, float track) {
|
||||||
@@ -115,7 +115,7 @@ namespace Cryville.Crtr {
|
|||||||
return Quaternion.LookRotation(r, state.Normal);
|
return Quaternion.LookRotation(r, state.Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Vector3> ctrl = new List<Vector3>(2);
|
readonly List<Vector3> ctrl = new List<Vector3>(2);
|
||||||
Vector3 GetFrame(ContainerState state, float track, Func<ContainerState, Vector3> func) {
|
Vector3 GetFrame(ContainerState state, float track, Func<ContainerState, Vector3> func) {
|
||||||
// TODO
|
// TODO
|
||||||
int id = Mathf.FloorToInt(track);
|
int id = Mathf.FloorToInt(track);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Cryville.Common;
|
||||||
using Cryville.Common.Pdt;
|
using Cryville.Common.Pdt;
|
||||||
using Cryville.Crtr.Components;
|
using Cryville.Crtr.Components;
|
||||||
using Cryville.Crtr.Event;
|
using Cryville.Crtr.Event;
|
||||||
@@ -88,9 +89,9 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class Anchor : SkinSelector {
|
public class Anchor : SkinSelector {
|
||||||
public string Name { get; private set; }
|
public int Name { get; private set; }
|
||||||
public Anchor(string name) {
|
public Anchor(string name) {
|
||||||
Name = name;
|
Name = IdentifierManager.SharedInstance.Request(name);
|
||||||
}
|
}
|
||||||
public override bool IsStatic {
|
public override bool IsStatic {
|
||||||
get { return true; }
|
get { return true; }
|
||||||
|
|||||||
@@ -107,9 +107,9 @@ namespace Cryville.Crtr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override void EndUpdate(ContainerState s) {
|
public override void EndUpdate(ContainerState s) {
|
||||||
OpenAnchor("tail");
|
OpenAnchor(_a_tail);
|
||||||
base.EndUpdate(s);
|
base.EndUpdate(s);
|
||||||
CloseAnchor("tail");
|
CloseAnchor(_a_tail);
|
||||||
if (s.CloneType == 0 || s.CloneType == 2) {
|
if (s.CloneType == 0 || s.CloneType == 2) {
|
||||||
EndUpdatePosition(ts);
|
EndUpdatePosition(ts);
|
||||||
var p = GetCurrentWorldPoint();
|
var p = GetCurrentWorldPoint();
|
||||||
|
|||||||
Reference in New Issue
Block a user