mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 06:35:45 +00:00
36 lines
1012 B
C#
36 lines
1012 B
C#
using QSB.Messaging;
|
|
using QSB.Utility;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
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("Received ready message from " + message.SenderId);
|
|
PlayerRegistry.GetPlayer(message.SenderId).IsReady = message.ToggleValue;
|
|
PlayerState.LocalInstance.Send();
|
|
}
|
|
}
|
|
}
|