mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-29 00:32:43 +00:00
48 lines
946 B
C#
48 lines
946 B
C#
|
using Mirror;
|
|||
|
using QSB.Player;
|
|||
|
using QSB.Utility.VariableSync;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace QSB.ShipSync;
|
|||
|
|
|||
|
public class ShipThrusterVariableSyncer : NetworkBehaviour
|
|||
|
{
|
|||
|
public Vector3VariableSyncer AccelerationSyncer;
|
|||
|
|
|||
|
private ShipThrusterModel _thrusterModel;
|
|||
|
|
|||
|
public void Init()
|
|||
|
{
|
|||
|
_thrusterModel = Locator.GetShipBody().GetComponent<ShipThrusterModel>();
|
|||
|
}
|
|||
|
|
|||
|
public void Update()
|
|||
|
{
|
|||
|
if (QSBPlayerManager.LocalPlayer.FlyingShip)
|
|||
|
{
|
|||
|
GetFromShip();
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if (AccelerationSyncer.HasChanged())
|
|||
|
{
|
|||
|
if (AccelerationSyncer.Value == Vector3.zero)
|
|||
|
{
|
|||
|
foreach (var item in ShipThrusterManager.ShipFlameControllers)
|
|||
|
{
|
|||
|
item.OnStopTranslationalThrust();
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
foreach (var item in ShipThrusterManager.ShipFlameControllers)
|
|||
|
{
|
|||
|
item.OnStartTranslationalThrust();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void GetFromShip() => AccelerationSyncer.Value = _thrusterModel.GetLocalAcceleration();
|
|||
|
}
|
|||
|
|