mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2024-12-29 12:21:25 +00:00
78 lines
1.7 KiB
C#
78 lines
1.7 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()
|
|
{
|
|
// fixes #590
|
|
if (ModelShipManager.Instance.CurrentFlyer == uint.MaxValue)
|
|
{
|
|
if (ThrusterModel)
|
|
{
|
|
AccelerationSyncer.Value = Vector3.zero;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|