quantum-space-buddies/QSB/Utility/VariableSync/BaseVariableSyncer.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

21 lines
624 B
C#

using Mirror;
using System;
using System.Collections.Generic;
namespace QSB.Utility.VariableSync
{
public abstract class BaseVariableSyncer<T> : QSBNetworkBehaviour
{
protected override float SendInterval => 0.1f;
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>();
}
}