mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-17 19:11:32 +00:00
40 lines
786 B
C#
40 lines
786 B
C#
using QuantumUNET;
|
|
using UnityEngine;
|
|
using UnityEngine.Networking;
|
|
|
|
namespace QSB.Animation.Player.Thrusters
|
|
{
|
|
public class JetpackAccelerationSync : QNetworkBehaviour
|
|
{
|
|
[SyncVar]
|
|
private Vector3 _localAcceleration;
|
|
[SyncVar]
|
|
private bool _isThrusting;
|
|
|
|
private ThrusterModel _thrusterModel;
|
|
|
|
public Vector3 LocalAcceleration => _localAcceleration;
|
|
public bool IsThrusting => _isThrusting;
|
|
|
|
public void Init(ThrusterModel model)
|
|
=> _thrusterModel = model;
|
|
|
|
public void Update()
|
|
{
|
|
if (IsLocalPlayer)
|
|
{
|
|
SyncLocalAccel();
|
|
}
|
|
}
|
|
|
|
private void SyncLocalAccel()
|
|
{
|
|
if (_thrusterModel != null)
|
|
{
|
|
_localAcceleration = _thrusterModel.GetLocalAcceleration();
|
|
_isThrusting = _thrusterModel.IsTranslationalThrusterFiring();
|
|
}
|
|
}
|
|
}
|
|
}
|