mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-26 18:35:34 +00:00
28 lines
813 B
C#
28 lines
813 B
C#
using QSB.Messaging;
|
|
using QSB.TimeSync;
|
|
|
|
namespace QSB.Events
|
|
{
|
|
public class ServerTimeEvent : QSBEvent<ServerTimeMessage>
|
|
{
|
|
public override MessageType Type => MessageType.ServerTime;
|
|
|
|
public override void SetupListener()
|
|
{
|
|
GlobalMessenger<float, int>.AddListener(EventNames.QSBServerTime, (time, count) => SendEvent(CreateMessage(time, count)));
|
|
}
|
|
|
|
private ServerTimeMessage CreateMessage(float time, int count) => new ServerTimeMessage
|
|
{
|
|
SenderId = PlayerRegistry.LocalPlayer.NetId,
|
|
ServerTime = time,
|
|
LoopCount = count
|
|
};
|
|
|
|
public override void OnReceiveRemote(ServerTimeMessage message)
|
|
{
|
|
WakeUpSync.LocalInstance.OnClientReceiveMessage(message);
|
|
}
|
|
}
|
|
}
|