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;
|
2022-08-14 23:35:19 +00:00
|
|
|
|
private float SecondsRemaining;
|
2021-12-23 05:06:58 +00:00
|
|
|
|
|
2022-08-14 23:35:19 +00:00
|
|
|
|
public ServerTimeMessage(float time, int count, float secondsRemaining)
|
2022-03-03 03:46:33 +00:00
|
|
|
|
{
|
|
|
|
|
ServerTime = time;
|
|
|
|
|
LoopCount = count;
|
2022-08-14 23:35:19 +00:00
|
|
|
|
SecondsRemaining = secondsRemaining;
|
2022-03-03 03:46:33 +00:00
|
|
|
|
}
|
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-08-14 23:35:19 +00:00
|
|
|
|
writer.Write(SecondsRemaining);
|
2022-03-03 03:46:33 +00:00
|
|
|
|
}
|
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-08-14 23:35:19 +00:00
|
|
|
|
SecondsRemaining = reader.Read<float>();
|
2022-02-27 12:40:44 +00:00
|
|
|
|
}
|
2022-03-03 03:46:33 +00:00
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
2023-03-09 16:38:17 +00:00
|
|
|
|
=> WakeUpSync.LocalInstance?.OnClientReceiveMessage(ServerTime, LoopCount, SecondsRemaining);
|
2022-08-14 23:35:19 +00:00
|
|
|
|
}
|