2021-05-07 18:17:09 +00:00
|
|
|
|
using QuantumUNET;
|
2021-05-07 13:58:37 +00:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Animation.Player.Thrusters
|
|
|
|
|
{
|
|
|
|
|
public class JetpackAccelerationSync : QNetworkBehaviour
|
|
|
|
|
{
|
|
|
|
|
[SyncVar]
|
|
|
|
|
private Vector3 _localAcceleration;
|
2021-05-07 18:17:09 +00:00
|
|
|
|
[SyncVar]
|
|
|
|
|
private bool _isThrusting;
|
|
|
|
|
|
2021-05-07 13:58:37 +00:00
|
|
|
|
private ThrusterModel _thrusterModel;
|
|
|
|
|
|
|
|
|
|
public Vector3 LocalAcceleration => _localAcceleration;
|
2021-05-07 18:17:09 +00:00
|
|
|
|
public bool IsThrusting => _isThrusting;
|
2021-05-07 13:58:37 +00:00
|
|
|
|
|
|
|
|
|
public void Init(ThrusterModel model)
|
|
|
|
|
=> _thrusterModel = model;
|
|
|
|
|
|
|
|
|
|
public void Update()
|
|
|
|
|
{
|
|
|
|
|
if (IsLocalPlayer)
|
|
|
|
|
{
|
|
|
|
|
SyncLocalAccel();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SyncLocalAccel()
|
|
|
|
|
{
|
|
|
|
|
if (_thrusterModel != null)
|
|
|
|
|
{
|
|
|
|
|
_localAcceleration = _thrusterModel.GetLocalAcceleration();
|
2021-05-07 18:17:09 +00:00
|
|
|
|
_isThrusting = _thrusterModel.IsTranslationalThrusterFiring();
|
2021-05-07 13:58:37 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|