quantum-space-buddies/QSB/Animation/Player/Thrusters/JetpackAccelerationSync.cs

29 lines
549 B
C#
Raw Normal View History

using Mirror;
using QSB.Utility.VariableSync;
2021-05-07 14:58:37 +01:00
2022-03-02 19:46:33 -08:00
namespace QSB.Animation.Player.Thrusters;
2022-05-19 14:34:49 +01:00
public class JetpackAccelerationSync : NetworkBehaviour
2021-05-07 14:58:37 +01:00
{
2022-03-02 19:46:33 -08:00
public Vector3VariableSyncer AccelerationVariableSyncer;
2021-11-26 19:33:56 +00:00
2022-03-02 19:46:33 -08:00
private ThrusterModel _thrusterModel;
2021-05-07 14:58:37 +01:00
2022-03-02 19:46:33 -08:00
public void Init(ThrusterModel model) => _thrusterModel = model;
2021-05-07 14:58:37 +01:00
2022-03-02 19:46:33 -08:00
public void Update()
{
if (isLocalPlayer)
2021-05-07 14:58:37 +01:00
{
2022-03-02 19:46:33 -08:00
SyncLocalAccel();
2021-05-07 14:58:37 +01:00
}
2022-03-02 19:46:33 -08:00
}
2021-05-07 14:58:37 +01:00
2022-03-02 19:46:33 -08:00
private void SyncLocalAccel()
{
if (_thrusterModel != null)
2021-05-07 14:58:37 +01:00
{
2022-03-02 19:46:33 -08:00
AccelerationVariableSyncer.Value = _thrusterModel.GetLocalAcceleration();
2021-05-07 14:58:37 +01:00
}
}
}