small changes
This commit is contained in:
@@ -18,6 +18,12 @@ namespace RebootKit.Engine.Animations {
|
||||
bool TryFindChild(string name, out IReAnimatorNode node);
|
||||
}
|
||||
|
||||
public enum ReAnimatorTickMode {
|
||||
Update,
|
||||
Fixed,
|
||||
Manual
|
||||
}
|
||||
|
||||
[DefaultExecutionOrder(-100)]
|
||||
public class ReAnimator : MonoBehaviour {
|
||||
static readonly Logger s_Logger = new Logger(nameof(ReAnimator));
|
||||
@@ -25,7 +31,7 @@ namespace RebootKit.Engine.Animations {
|
||||
[SerializeField] Animator m_Animator;
|
||||
[SerializeField] LayerMixerNode m_Root;
|
||||
|
||||
PlayableGraph m_Graph;
|
||||
public PlayableGraph Graph { get; private set; }
|
||||
AnimationPlayableOutput m_Output;
|
||||
|
||||
void Awake() {
|
||||
@@ -33,24 +39,26 @@ namespace RebootKit.Engine.Animations {
|
||||
|
||||
m_Animator.runtimeAnimatorController = null;
|
||||
|
||||
m_Graph = PlayableGraph.Create(name);
|
||||
m_Output = AnimationPlayableOutput.Create(m_Graph, "Animation Output", m_Animator);
|
||||
|
||||
if (m_Root.Build(m_Graph) is AnimationLayerMixerPlayable layerMixer) {
|
||||
Graph = PlayableGraph.Create(name);
|
||||
m_Output = AnimationPlayableOutput.Create(Graph, "Animation Output", m_Animator);
|
||||
|
||||
if (m_Root.Build(Graph) is AnimationLayerMixerPlayable layerMixer) {
|
||||
m_Output.SetSourcePlayable(layerMixer, 0);
|
||||
}
|
||||
|
||||
m_Graph.Play();
|
||||
Graph.Play();
|
||||
}
|
||||
|
||||
void OnDestroy() {
|
||||
if (m_Graph.IsValid()) {
|
||||
m_Graph.Destroy();
|
||||
if (Graph.IsValid()) {
|
||||
Graph.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void Update() {
|
||||
m_Root.Tick(Time.deltaTime);
|
||||
float dt = Time.deltaTime;
|
||||
m_Root.Tick(dt);
|
||||
Graph.Evaluate(dt);
|
||||
}
|
||||
|
||||
public void SetLayerWeight(int layer, float weight) {
|
||||
@@ -71,7 +79,7 @@ namespace RebootKit.Engine.Animations {
|
||||
if (node is TNode tnode) {
|
||||
return tnode;
|
||||
}
|
||||
|
||||
|
||||
s_Logger.Error($"Couldn't find node with name: {nodeName} of type {typeof(TNode).Name}");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace RebootKit.Engine.Development {
|
||||
Resolution resolution = Screen.currentResolution;
|
||||
|
||||
m_StringBuilder.Append("fps: ");
|
||||
m_StringBuilder.Append(Mathf.RoundToInt(1f / Time.deltaTime));
|
||||
m_StringBuilder.Append(Mathf.RoundToInt(1.0f / Time.unscaledDeltaTime));
|
||||
m_StringBuilder.Append(" | dt: ");
|
||||
m_StringBuilder.Append(Time.deltaTime.ToString("F4"));
|
||||
m_StringBuilder.Append("ms | runtime: ");
|
||||
|
||||
@@ -422,7 +422,7 @@ namespace RebootKit.Engine.Simulation {
|
||||
return;
|
||||
}
|
||||
|
||||
ActorCommand command = new ActorCommand {
|
||||
var command = new ActorCommand {
|
||||
ActorID = ActorID,
|
||||
CommandID = commandID,
|
||||
Data = data
|
||||
@@ -448,7 +448,7 @@ namespace RebootKit.Engine.Simulation {
|
||||
return;
|
||||
}
|
||||
|
||||
ActorEvent actorEvent = new ActorEvent {
|
||||
var actorEvent = new ActorEvent {
|
||||
ActorID = ActorID,
|
||||
EventID = eventID,
|
||||
Data = data
|
||||
@@ -488,15 +488,16 @@ namespace RebootKit.Engine.Simulation {
|
||||
}
|
||||
|
||||
internal ActorCoreStateSnapshot GetCoreStateSnapshot() {
|
||||
ActorCoreStateSnapshot snapshot = new ActorCoreStateSnapshot();
|
||||
snapshot.ActorID = ActorID;
|
||||
snapshot.Timestamp = DateTime.UtcNow;
|
||||
snapshot.Position = transform.localPosition;
|
||||
snapshot.Rotation = transform.localRotation;
|
||||
snapshot.Scale = transform.localScale;
|
||||
snapshot.Flags = Flags;
|
||||
var snapshot = new ActorCoreStateSnapshot {
|
||||
ActorID = ActorID,
|
||||
Timestamp = DateTime.UtcNow,
|
||||
Position = transform.localPosition,
|
||||
Rotation = transform.localRotation,
|
||||
Scale = transform.localScale,
|
||||
Flags = Flags,
|
||||
MasterActorID = MasterActor != null ? MasterActor.ActorID : (ushort)0
|
||||
};
|
||||
|
||||
snapshot.MasterActorID = MasterActor != null ? MasterActor.ActorID : (ushort)0;
|
||||
if (snapshot.MasterActorID != 0) {
|
||||
snapshot.MasterSocketName = MasterSocketName;
|
||||
} else {
|
||||
@@ -569,7 +570,7 @@ namespace RebootKit.Engine.Simulation {
|
||||
}
|
||||
|
||||
internal ActorTransformSyncData GetTransformSyncDataForClient(ulong clientID) {
|
||||
ActorTransformSyncData data = new ActorTransformSyncData {
|
||||
var data = new ActorTransformSyncData {
|
||||
ActorID = ActorID,
|
||||
SyncMode = ActorTransformSyncMode.None
|
||||
};
|
||||
@@ -643,8 +644,7 @@ namespace RebootKit.Engine.Simulation {
|
||||
transform.localPosition = socket.localPosition;
|
||||
transform.localRotation = socket.localRotation;
|
||||
} else {
|
||||
s_ActorLogger
|
||||
.Error($"Failed to update mounted transform: Socket {MasterSocketName} not found on {MasterActor.name}");
|
||||
s_ActorLogger.Error($"Failed to update mounted transform: Socket {MasterSocketName} not found on {MasterActor.name}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -664,8 +664,7 @@ namespace RebootKit.Engine.Simulation {
|
||||
}
|
||||
|
||||
if (actorCommand.ActorID != ActorID) {
|
||||
s_ActorLogger
|
||||
.Error($"Actor command ActorID {actorCommand.ActorID} does not match this actor's ID {ActorID}");
|
||||
s_ActorLogger.Error($"Actor command ActorID {actorCommand.ActorID} does not match this actor's ID {ActorID}");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -679,8 +678,7 @@ namespace RebootKit.Engine.Simulation {
|
||||
}
|
||||
|
||||
if (actorEvent.ActorID != ActorID) {
|
||||
s_ActorLogger
|
||||
.Error($"Actor event ActorID {actorEvent.ActorID} does not match this actor's ID {ActorID}");
|
||||
s_ActorLogger.Error($"Actor event ActorID {actorEvent.ActorID} does not match this actor's ID {ActorID}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user