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

33 lines
691 B
C#
Raw Normal View History

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