mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
67 lines
1.5 KiB
C#
67 lines
1.5 KiB
C#
using QSB.Player;
|
|
using QSB.Player.TransformSync;
|
|
using QSB.Utility.VariableSync;
|
|
using UnityEngine;
|
|
|
|
namespace QSB.ModelShip;
|
|
|
|
public class ModelShipThrusterVariableSyncer : MonoBehaviour
|
|
{
|
|
public Vector3VariableSyncer AccelerationSyncer;
|
|
|
|
public ThrusterModel ThrusterModel { get; private set; }
|
|
private ThrusterAudio _thrusterAudio;
|
|
|
|
|
|
public void Init(GameObject modelShip)
|
|
{
|
|
ThrusterModel = modelShip.GetComponent<ThrusterModel>();
|
|
_thrusterAudio = modelShip.GetComponentInChildren<ThrusterAudio>();
|
|
|
|
ModelShipThrusterManager.CreateModelShipVFX(modelShip);
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
if (PlayerTransformSync.LocalInstance && QSBPlayerManager.LocalPlayer.FlyingModelShip)
|
|
{
|
|
GetFromShip();
|
|
return;
|
|
}
|
|
|
|
if (AccelerationSyncer.public_HasChanged())
|
|
{
|
|
if (AccelerationSyncer.Value == Vector3.zero)
|
|
{
|
|
foreach (var item in ModelShipThrusterManager.ThrusterFlameControllers)
|
|
{
|
|
item.OnStopTranslationalThrust();
|
|
}
|
|
|
|
_thrusterAudio.OnStopTranslationalThrust();
|
|
|
|
ModelShipThrusterManager.ThrusterWashController.OnStopTranslationalThrust();
|
|
}
|
|
else
|
|
{
|
|
foreach (var item in ModelShipThrusterManager.ThrusterFlameControllers)
|
|
{
|
|
item.OnStartTranslationalThrust();
|
|
}
|
|
|
|
_thrusterAudio.OnStartTranslationalThrust();
|
|
|
|
ModelShipThrusterManager.ThrusterWashController.OnStartTranslationalThrust();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void GetFromShip()
|
|
{
|
|
if (ThrusterModel)
|
|
{
|
|
AccelerationSyncer.Value = ThrusterModel.GetLocalAcceleration();
|
|
}
|
|
}
|
|
}
|