2022-01-15 06:54:18 +00:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QSB.Utility.VariableSync;
|
2021-05-07 13:58:37 +00:00
|
|
|
|
|
2022-02-25 06:04:54 +00:00
|
|
|
|
namespace QSB.Animation.Player.Thrusters;
|
|
|
|
|
|
|
|
|
|
public class JetpackAccelerationSync : NetworkBehaviour
|
2021-05-07 13:58:37 +00:00
|
|
|
|
{
|
2022-02-25 06:04:54 +00:00
|
|
|
|
public Vector3VariableSyncer AccelerationVariableSyncer;
|
|
|
|
|
public BoolVariableSyncer ThrustingVariableSyncer;
|
2021-11-26 19:33:56 +00:00
|
|
|
|
|
2022-02-25 06:04:54 +00:00
|
|
|
|
private ThrusterModel _thrusterModel;
|
2021-05-07 13:58:37 +00:00
|
|
|
|
|
2022-02-25 06:04:54 +00:00
|
|
|
|
public void Init(ThrusterModel model) => _thrusterModel = model;
|
2021-05-07 13:58:37 +00:00
|
|
|
|
|
2022-02-25 06:04:54 +00:00
|
|
|
|
public void Update()
|
|
|
|
|
{
|
|
|
|
|
if (isLocalPlayer)
|
2021-05-07 13:58:37 +00:00
|
|
|
|
{
|
2022-02-25 06:04:54 +00:00
|
|
|
|
SyncLocalAccel();
|
2021-05-07 13:58:37 +00:00
|
|
|
|
}
|
2022-02-25 06:04:54 +00:00
|
|
|
|
}
|
2021-05-07 13:58:37 +00:00
|
|
|
|
|
2022-02-25 06:04:54 +00:00
|
|
|
|
private void SyncLocalAccel()
|
|
|
|
|
{
|
|
|
|
|
if (_thrusterModel != null)
|
2021-05-07 13:58:37 +00:00
|
|
|
|
{
|
2022-02-25 06:04:54 +00:00
|
|
|
|
AccelerationVariableSyncer.Value = _thrusterModel.GetLocalAcceleration();
|
|
|
|
|
ThrustingVariableSyncer.Value = _thrusterModel.IsTranslationalThrusterFiring();
|
2021-05-07 13:58:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-25 06:04:54 +00:00
|
|
|
|
}
|