mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-20 15:41:01 +00:00
initial state for animationsync
This commit is contained in:
parent
47a3ac3aab
commit
763b4177ab
@ -6,7 +6,9 @@ using QSB.Animation.Player.Thrusters;
|
||||
using QSB.Messaging;
|
||||
using QSB.Player;
|
||||
using QSB.Utility;
|
||||
using QSB.WorldSync;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QSB.Animation.Player;
|
||||
@ -31,6 +33,35 @@ public class AnimationSync : PlayerSyncObject
|
||||
NetworkAnimator.enabled = false;
|
||||
}
|
||||
|
||||
protected void Start()
|
||||
=> RequestInitialStatesMessage.SendInitialState += SendInitialState;
|
||||
|
||||
protected void OnDestroy()
|
||||
=> RequestInitialStatesMessage.SendInitialState -= SendInitialState;
|
||||
|
||||
private void SendInitialState(uint to)
|
||||
{
|
||||
if (PlayerId == to)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* This wipes the NetworkAnimator's "last_X_Parameters" fields, so it assumes the parameters have changed.
|
||||
* Basically just forces the networkanimator to set all it's dirty flags.
|
||||
* I tried just manually sending the parameter message myself, but that made the client get very angry and disconnect.
|
||||
*/
|
||||
|
||||
var parameters = (AnimatorControllerParameter[])NetworkAnimator.GetType().GetField("parameters", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(NetworkAnimator);
|
||||
var lastIntParams = NetworkAnimator.GetType().GetField("lastIntParameters", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var lastFloatParams = NetworkAnimator.GetType().GetField("lastFloatParameters", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
var lastBoolParams = NetworkAnimator.GetType().GetField("lastBoolParameters", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
lastIntParams.SetValue(NetworkAnimator, new int[parameters.Length]);
|
||||
lastFloatParams.SetValue(NetworkAnimator, new float[parameters.Length]);
|
||||
lastBoolParams.SetValue(NetworkAnimator, new bool[parameters.Length]);
|
||||
}
|
||||
|
||||
private void InitCommon(Transform modelRoot)
|
||||
{
|
||||
try
|
||||
|
Loading…
x
Reference in New Issue
Block a user