mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-10 06:51:36 +00:00
35 lines
929 B
C#
35 lines
929 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)
|
|||
|
{
|
|||
|
PlayerRegistry.GetPlayer(message.SenderId).IsReady = message.ToggleValue;
|
|||
|
PlayerState.LocalInstance.Send();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|