2022-05-19 14:34:49 +01:00

19 lines
606 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;
protected T PrevValue;
[NonSerialized]
public T Value;
public 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>();
}