quantum-space-buddies/QSB/Events/ServerTimeEvent.cs

26 lines
732 B
C#
Raw Normal View History

2020-08-09 19:33:36 +01:00
using QSB.Messaging;
2020-08-09 20:46:02 +01:00
using QSB.TimeSync;
2020-08-09 19:33:36 +01:00
namespace QSB.Events
{
2020-08-10 11:45:24 +01:00
class ServerTimeEvent : QSBEvent<ServerTimeMessage>
2020-08-09 19:33:36 +01:00
{
2020-08-10 11:45:24 +01:00
public override MessageType Type => MessageType.ServerTime;
2020-08-09 19:33:36 +01:00
public override void SetupListener()
{
GlobalMessenger<float, int>.AddListener("QSBServerTime", (time, count) => SendEvent(
2020-08-09 21:46:51 +01:00
new ServerTimeMessage {
2020-08-09 20:46:02 +01:00
SenderId = PlayerRegistry.LocalPlayer.NetId,
2020-08-09 19:33:36 +01:00
ServerTime = time,
LoopCount = count
}));
}
2020-08-09 20:46:02 +01:00
2020-08-09 21:46:51 +01:00
public override void OnReceive(ServerTimeMessage message)
2020-08-09 20:46:02 +01:00
{
WakeUpSync.LocalInstance.OnClientReceiveMessage(message);
}
2020-08-09 19:33:36 +01:00
}
}