quantum-space-buddies/QSB/SaveSync/Events/RequestGameStateEvent.cs

24 lines
755 B
C#
Raw Normal View History

2021-12-05 14:06:43 +00:00
using QSB.Events;
using QSB.Messaging;
namespace QSB.SaveSync.Events
{
internal class RequestGameStateEvent : QSBEvent<PlayerMessage>
{
public override bool RequireWorldObjectsReady => false;
public override void SetupListener() => GlobalMessenger.AddListener(EventNames.QSBRequestGameDetails, Handler);
public override void CloseListener() => GlobalMessenger.RemoveListener(EventNames.QSBRequestGameDetails, Handler);
private void Handler() => SendEvent(CreateMessage());
private PlayerMessage CreateMessage() => new()
{
AboutId = LocalPlayerId,
OnlySendToHost = true
};
2021-12-05 23:34:49 +00:00
public override void OnReceiveRemote(bool isHost, PlayerMessage message) => QSBEventManager.FireEvent(EventNames.QSBGameDetails, message.FromId);
2021-12-05 14:06:43 +00:00
}
}