quantum-space-buddies/QSB/DeathSync/Events/StartLoopEvent.cs
Mister_Nebula 460a974ee2 cleanup
2021-08-09 11:49:58 +01:00

32 lines
955 B
C#

using QSB.ClientServerStateSync;
using QSB.Events;
using QSB.Messaging;
using QSB.Utility;
namespace QSB.DeathSync.Events
{
internal class StartLoopEvent : QSBEvent<PlayerMessage>
{
public override EventType Type => EventType.StartLoop;
public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBStartLoop, Handler);
public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBStartLoop, Handler);
private void Handler() => SendEvent(CreateMessage());
private PlayerMessage CreateMessage() => new PlayerMessage
{
AboutId = LocalPlayerId
};
public override void OnReceiveLocal(bool server, PlayerMessage message)
=> OnReceiveRemote(server, message);
public override void OnReceiveRemote(bool server, PlayerMessage message)
{
DebugLog.DebugWrite($" ~~~ LOOP START ~~~");
QSBEventManager.FireEvent(EventNames.QSBClientState, ClientState.AliveInSolarSystem);
}
}
}