quantum-space-buddies/QSB/Syncs/QSBNetworkTransform.cs
JohnCorby 13f5e2ebc3 - no more initial state for qsb network behaviours because it is dumb and i hate it
- spawn authqueue objects with no authority for real instead of with server authority
2022-01-27 03:15:52 -08:00

37 lines
876 B
C#

using Mirror;
using QSB.Utility;
using UnityEngine;
namespace QSB.Syncs
{
public class QSBNetworkTransform : QSBNetworkBehaviour
{
protected override float SendInterval => 0.05f;
protected Vector3 _prevPosition;
protected Quaternion _prevRotation;
protected override void UpdatePrevData()
{
_prevPosition = transform.position;
_prevRotation = transform.rotation;
}
protected override bool HasChanged() =>
Vector3.Distance(transform.position, _prevPosition) > 1E-05f ||
Quaternion.Angle(transform.rotation, _prevRotation) > 1E-05f;
protected override void Serialize(NetworkWriter writer)
{
writer.Write(transform.position);
writer.Write(transform.rotation);
}
protected override void Deserialize(NetworkReader reader)
{
transform.position = reader.ReadVector3();
transform.rotation = reader.ReadQuaternion();
}
}
}