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

30 lines
818 B
C#
Raw Normal View History

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