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(); _thrusterAudio = modelShip.GetComponentInChildren(); 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(); } } }