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