mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-10 06:51:36 +00:00
27 lines
763 B
C#
27 lines
763 B
C#
using QSB.Messaging;
|
|
|
|
namespace QSB.Events
|
|
{
|
|
public class PlayerReadyEvent : QSBEvent<ToggleMessage>
|
|
{
|
|
public override MessageType Type => MessageType.PlayerReady;
|
|
|
|
public override void SetupListener()
|
|
{
|
|
GlobalMessenger<bool>.AddListener(EventNames.QSBPlayerReady, ready => SendEvent(CreateMessage(ready)));
|
|
}
|
|
|
|
private ToggleMessage CreateMessage(bool ready) => new ToggleMessage
|
|
{
|
|
SenderId = LocalPlayerId,
|
|
ToggleValue = ready
|
|
};
|
|
|
|
public override void OnServerReceive(ToggleMessage message)
|
|
{
|
|
PlayerRegistry.GetPlayer(message.SenderId).IsReady = message.ToggleValue;
|
|
PlayerState.LocalInstance.Send();
|
|
}
|
|
}
|
|
}
|