2022-01-14 07:38:45 +00:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QSB.Messaging;
|
2020-02-14 21:14:24 +00:00
|
|
|
|
|
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-02-25 06:04:54 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
writer.Write(ServerTime);
|
|
|
|
|
writer.Write(LoopCount);
|
|
|
|
|
}
|
2022-02-27 12:40:44 +00:00
|
|
|
|
|
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-02-27 12:40:44 +00:00
|
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
=> WakeUpSync.LocalInstance.OnClientReceiveMessage(ServerTime, LoopCount);
|
2020-02-14 21:14:24 +00:00
|
|
|
|
}
|