mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-18 04:10:36 +00:00
27 lines
804 B
C#
27 lines
804 B
C#
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 {
|
|
SenderId = LocalPlayerId,
|
|
ToggleValue = ready
|
|
}));
|
|
}
|
|
|
|
public override void OnServerReceive(ToggleMessage message)
|
|
{
|
|
DebugLog.ToConsole($"Receieved ready message from {message.SenderId}");
|
|
PlayerRegistry.GetPlayer(message.SenderId).IsReady = message.ToggleValue;
|
|
PlayerState.LocalInstance.Send();
|
|
}
|
|
}
|
|
}
|