2020-08-10 10:45:24 +00:00
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
|
|
|
|
|
namespace QSB.Events
|
|
|
|
|
{
|
|
|
|
|
class PlayerReadyEvent : QSBEvent<ToggleMessage>
|
|
|
|
|
{
|
|
|
|
|
public override MessageType Type => MessageType.PlayerReady;
|
|
|
|
|
|
|
|
|
|
public override void SetupListener()
|
|
|
|
|
{
|
|
|
|
|
GlobalMessenger<bool>.AddListener("QSBPlayerReady", ready => SendEvent(
|
|
|
|
|
new ToggleMessage {
|
2020-08-10 13:40:06 +00:00
|
|
|
|
SenderId = LocalPlayerId,
|
2020-08-10 10:45:24 +00:00
|
|
|
|
ToggleValue = ready
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnServerReceive(ToggleMessage message)
|
|
|
|
|
{
|
2020-08-10 11:02:01 +00:00
|
|
|
|
DebugLog.ToConsole($"Receieved ready message from {message.SenderId}");
|
2020-08-10 10:45:24 +00:00
|
|
|
|
PlayerRegistry.GetPlayer(message.SenderId).IsReady = message.ToggleValue;
|
|
|
|
|
PlayerState.LocalInstance.Send();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|