mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-06 00:39:55 +00:00
remove need for CrouchSync
This commit is contained in:
parent
6c690da7e9
commit
84f2a6f999
@ -17,8 +17,6 @@ public class AnimationSync : PlayerSyncObject
|
|||||||
private AnimatorOverrideController _unsuitedAnimController;
|
private AnimatorOverrideController _unsuitedAnimController;
|
||||||
private GameObject _suitedGraphics;
|
private GameObject _suitedGraphics;
|
||||||
private GameObject _unsuitedGraphics;
|
private GameObject _unsuitedGraphics;
|
||||||
private PlayerCharacterController _playerController;
|
|
||||||
private CrouchSync _crouchSync;
|
|
||||||
|
|
||||||
public AnimatorMirror Mirror { get; private set; }
|
public AnimatorMirror Mirror { get; private set; }
|
||||||
public bool InSuitedUpState { get; set; }
|
public bool InSuitedUpState { get; set; }
|
||||||
@ -74,10 +72,6 @@ public class AnimationSync : PlayerSyncObject
|
|||||||
public void InitLocal(Transform body)
|
public void InitLocal(Transform body)
|
||||||
{
|
{
|
||||||
InitCommon(body);
|
InitCommon(body);
|
||||||
|
|
||||||
_playerController = body.parent.GetComponent<PlayerCharacterController>();
|
|
||||||
|
|
||||||
InitCrouchSync();
|
|
||||||
InitAccelerationSync();
|
InitAccelerationSync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +79,6 @@ public class AnimationSync : PlayerSyncObject
|
|||||||
{
|
{
|
||||||
InitCommon(body);
|
InitCommon(body);
|
||||||
SetSuitState(QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse);
|
SetSuitState(QSBSceneManager.CurrentScene == OWScene.EyeOfTheUniverse);
|
||||||
InitCrouchSync();
|
|
||||||
InitAccelerationSync();
|
InitAccelerationSync();
|
||||||
ThrusterManager.CreateRemotePlayerVFX(Player);
|
ThrusterManager.CreateRemotePlayerVFX(Player);
|
||||||
|
|
||||||
@ -100,12 +93,6 @@ public class AnimationSync : PlayerSyncObject
|
|||||||
Player.JetpackAcceleration.Init(thrusterModel);
|
Player.JetpackAcceleration.Init(thrusterModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitCrouchSync()
|
|
||||||
{
|
|
||||||
_crouchSync = this.GetRequiredComponent<CrouchSync>();
|
|
||||||
_crouchSync.Init(_playerController, VisibleAnimator);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSuitState(bool suitedUp)
|
public void SetSuitState(bool suitedUp)
|
||||||
{
|
{
|
||||||
if (!Player.IsReady)
|
if (!Player.IsReady)
|
||||||
|
@ -61,6 +61,7 @@ public class AnimatorMirror : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
SyncParams();
|
SyncParams();
|
||||||
|
SyncLayerWeights();
|
||||||
SmoothFloats();
|
SmoothFloats();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +97,15 @@ public class AnimatorMirror : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SyncLayerWeights()
|
||||||
|
{
|
||||||
|
for (var i = 0; i < _from.layerCount; i++)
|
||||||
|
{
|
||||||
|
var weight = _from.GetLayerWeight(i);
|
||||||
|
_to.SetLayerWeight(i, weight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void SmoothFloats()
|
private void SmoothFloats()
|
||||||
{
|
{
|
||||||
foreach (var floatParam in _floatParams)
|
foreach (var floatParam in _floatParams)
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
using Mirror;
|
|
||||||
using QSB.Utility.VariableSync;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace QSB.Animation.Player;
|
|
||||||
|
|
||||||
public class CrouchSync : NetworkBehaviour
|
|
||||||
{
|
|
||||||
public AnimFloatParam CrouchParam { get; } = new AnimFloatParam();
|
|
||||||
|
|
||||||
private const float CrouchSmoothTime = 0.05f;
|
|
||||||
public const int CrouchLayerIndex = 1;
|
|
||||||
|
|
||||||
private PlayerCharacterController _playerController;
|
|
||||||
private Animator _bodyAnim;
|
|
||||||
|
|
||||||
public FloatVariableSyncer CrouchVariableSyncer;
|
|
||||||
|
|
||||||
public void Init(PlayerCharacterController playerController, Animator bodyAnim)
|
|
||||||
{
|
|
||||||
_playerController = playerController;
|
|
||||||
_bodyAnim = bodyAnim;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update()
|
|
||||||
{
|
|
||||||
if (isLocalPlayer)
|
|
||||||
{
|
|
||||||
SyncLocalCrouch();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SyncRemoteCrouch();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SyncLocalCrouch()
|
|
||||||
{
|
|
||||||
if (_playerController == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var jumpChargeFraction = _playerController.GetJumpCrouchFraction();
|
|
||||||
CrouchVariableSyncer.Value = jumpChargeFraction;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SyncRemoteCrouch()
|
|
||||||
{
|
|
||||||
if (_bodyAnim == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CrouchParam.Target = CrouchVariableSyncer.Value;
|
|
||||||
CrouchParam.Smooth(CrouchSmoothTime);
|
|
||||||
var jumpChargeFraction = CrouchParam.Current;
|
|
||||||
_bodyAnim.SetLayerWeight(CrouchLayerIndex, jumpChargeFraction);
|
|
||||||
}
|
|
||||||
}
|
|
@ -54,7 +54,7 @@ internal class PlayerAnimationPatches : QSBPatch
|
|||||||
__instance._animator.SetFloat("RunSpeedY", movementVector.z / 3f);
|
__instance._animator.SetFloat("RunSpeedY", movementVector.z / 3f);
|
||||||
__instance._animator.SetFloat("TurnSpeed", __instance._playerController.GetTurning());
|
__instance._animator.SetFloat("TurnSpeed", __instance._playerController.GetTurning());
|
||||||
__instance._animator.SetBool("Grounded", isGrounded || isAttached || PlayerState.IsRecentlyDetached());
|
__instance._animator.SetBool("Grounded", isGrounded || isAttached || PlayerState.IsRecentlyDetached());
|
||||||
__instance._animator.SetLayerWeight(CrouchSync.CrouchLayerIndex, __instance._playerController.GetJumpCrouchFraction());
|
__instance._animator.SetLayerWeight(1, __instance._playerController.GetJumpCrouchFraction());
|
||||||
__instance._animator.SetFloat("FreefallSpeed", freefallMagnitude / 15f * (timeInFreefall / 3f));
|
__instance._animator.SetFloat("FreefallSpeed", freefallMagnitude / 15f * (timeInFreefall / 3f));
|
||||||
__instance._animator.SetBool("InZeroG", isInZeroG || isFlying);
|
__instance._animator.SetBool("InZeroG", isInZeroG || isFlying);
|
||||||
__instance._animator.SetBool("UsingJetpack", isInZeroG && PlayerState.IsWearingSuit());
|
__instance._animator.SetBool("UsingJetpack", isInZeroG && PlayerState.IsWearingSuit());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user