2022-01-14 18:15:48 -08:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QuantumUNET.Transport;
|
|
|
|
|
using System;
|
2021-11-26 19:33:56 +00:00
|
|
|
|
|
|
|
|
|
namespace QSB.Utility.VariableSync
|
|
|
|
|
{
|
2022-01-14 18:15:48 -08:00
|
|
|
|
public class BoolVariableSyncer2 : BaseVariableSyncer2
|
|
|
|
|
{
|
|
|
|
|
private bool _prevValue;
|
|
|
|
|
[NonSerialized]
|
|
|
|
|
public bool Value;
|
|
|
|
|
|
|
|
|
|
protected override bool HasChanged() => Value != _prevValue;
|
|
|
|
|
|
|
|
|
|
protected override void Serialize(NetworkWriter writer)
|
|
|
|
|
{
|
|
|
|
|
_prevValue = Value;
|
|
|
|
|
writer.Write(Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Deserialize(NetworkReader reader)
|
|
|
|
|
{
|
|
|
|
|
_prevValue = Value;
|
|
|
|
|
Value = reader.Read<bool>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-14 21:42:40 -08:00
|
|
|
|
public class BoolVariableSyncer : BaseVariableSyncer<bool>
|
2021-11-26 19:33:56 +00:00
|
|
|
|
{
|
2021-12-14 21:42:40 -08:00
|
|
|
|
protected override void WriteValue(QNetworkWriter writer, bool value) => writer.Write(value);
|
|
|
|
|
protected override bool ReadValue(QNetworkReader reader) => reader.ReadBoolean();
|
2021-11-26 19:33:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|