21 lines
624 B
C#
Raw Normal View History

2022-01-18 10:06:15 -08:00
using Mirror;
using System;
using System.Collections.Generic;
namespace QSB.Utility.VariableSync
2021-11-26 17:36:14 +00:00
{
2022-01-18 10:06:15 -08:00
public abstract class BaseVariableSyncer<T> : QSBNetworkBehaviour
2022-01-14 18:15:48 -08:00
{
protected override float SendInterval => 0.1f;
2022-01-18 10:06:15 -08:00
private T _prevValue;
[NonSerialized]
public T Value;
protected override bool HasChanged() => !EqualityComparer<T>.Default.Equals(_prevValue, Value);
protected override void UpdatePrevData() => _prevValue = Value;
protected override void Serialize(NetworkWriter writer) => writer.Write(Value);
protected override void Deserialize(NetworkReader reader) => Value = reader.Read<T>();
2022-01-14 18:15:48 -08:00
}
2021-11-26 17:36:14 +00:00
}