quantum-space-buddies/QSB/TimeSync/Messages/ServerTimeMessage.cs

34 lines
717 B
C#
Raw Normal View History

using Mirror;
using QSB.Messaging;
namespace QSB.TimeSync.Messages
{
public class ServerTimeMessage : QSBMessage
{
private float ServerTime;
private int LoopCount;
2021-12-23 05:06:58 +00:00
public ServerTimeMessage(float time, int count)
{
ServerTime = time;
LoopCount = count;
}
2021-12-23 05:06:58 +00:00
public override void Serialize(NetworkWriter writer)
{
base.Serialize(writer);
writer.Write(ServerTime);
writer.Write(LoopCount);
}
public override void Deserialize(NetworkReader reader)
{
base.Deserialize(reader);
ServerTime = reader.Read<float>();
LoopCount = reader.Read<int>();
}
public override void OnReceiveRemote()
=> WakeUpSync.LocalInstance.OnClientReceiveMessage(ServerTime, LoopCount);
}
}