2022-01-14 18:15:48 -08:00
|
|
|
|
using Mirror;
|
|
|
|
|
using System;
|
2021-11-26 17:36:14 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.Utility.VariableSync
|
|
|
|
|
{
|
2022-01-14 22:46:01 -08:00
|
|
|
|
public class FloatVariableSyncer : BaseVariableSyncer
|
2022-01-14 18:15:48 -08:00
|
|
|
|
{
|
|
|
|
|
private float _prevValue;
|
|
|
|
|
[NonSerialized]
|
|
|
|
|
public float Value;
|
|
|
|
|
|
|
|
|
|
protected override bool HasChanged() => Value != _prevValue;
|
2022-01-14 20:15:32 -08:00
|
|
|
|
protected override void UpdatePrevData() => _prevValue = Value;
|
2022-01-16 07:23:35 -08:00
|
|
|
|
protected override void Serialize(NetworkWriter writer, bool initialState) => writer.Write(Value);
|
|
|
|
|
protected override void Deserialize(NetworkReader reader, bool initialState) => Value = reader.Read<float>();
|
2022-01-14 18:15:48 -08:00
|
|
|
|
}
|
2021-11-26 17:36:14 +00:00
|
|
|
|
}
|