mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-09 12:54:51 +00:00
24 lines
823 B
C#
24 lines
823 B
C#
using QSB.Events;
|
|
|
|
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(bool server, ServerTimeMessage message) =>
|
|
WakeUpSync.LocalInstance.OnClientReceiveMessage(message);
|
|
}
|
|
} |