quantum-space-buddies/QSB/TimeSync/Events/ServerTimeEvent.cs
Mister_Nebula ffda3be2dc cleanup
2020-11-03 22:13:12 +00:00

28 lines
926 B
C#

using QSB.EventsCore;
namespace QSB.TimeSync.Events
{
public class ServerTimeEvent : QSBEvent<ServerTimeMessage>
{
public override EventType Type => EventType.ServerTime;
public override void SetupListener() => GlobalMessenger<float, int>.AddListener(EventNames.QSBServerTime, Handler);
public override void CloseListener() => GlobalMessenger<float, int>.RemoveListener(EventNames.QSBServerTime, Handler);
private void Handler(float time, int count) => SendEvent(CreateMessage(time, count));
private ServerTimeMessage CreateMessage(float time, int count) => new ServerTimeMessage
{
AboutId = LocalPlayerId,
ServerTime = time,
LoopCount = count
};
public override void OnReceiveRemote(ServerTimeMessage message)
{
WakeUpSync.LocalInstance.OnClientReceiveMessage(message);
}
}
}