mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-26 09:35:26 +00:00
32 lines
927 B
C#
32 lines
927 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 = PlayerRegistry.LocalPlayer.NetId,
|
|
ToggleValue = ready
|
|
}));
|
|
}
|
|
|
|
public override void OnReceive(ToggleMessage message)
|
|
{
|
|
return;
|
|
}
|
|
|
|
public override void OnServerReceive(ToggleMessage message)
|
|
{
|
|
DebugLog.ToConsole($"Receieved ready message from {message.SenderId}");
|
|
PlayerRegistry.GetPlayer(message.SenderId).IsReady = message.ToggleValue;
|
|
PlayerState.LocalInstance.Send();
|
|
}
|
|
}
|
|
}
|