mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-11 00:52:19 +00:00
18a520bc78
* cleanup
40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
using QSB.Messaging;
|
|
using UnityEngine.Networking;
|
|
|
|
namespace QSB.Events
|
|
{
|
|
public class GameState : NetworkBehaviour
|
|
{
|
|
public static GameState LocalInstance { get; private set; }
|
|
|
|
private MessageHandler<FullStateMessage> _messageHandler;
|
|
|
|
private void Awake()
|
|
{
|
|
_messageHandler = new MessageHandler<FullStateMessage>();
|
|
_messageHandler.OnClientReceiveMessage += OnClientReceiveMessage;
|
|
|
|
LocalInstance = this;
|
|
}
|
|
|
|
private void OnClientReceiveMessage(FullStateMessage message)
|
|
{
|
|
PlayerRegistry.HandleFullStateMessage(message);
|
|
}
|
|
|
|
public void Send()
|
|
{
|
|
foreach (var player in PlayerRegistry.PlayerList)
|
|
{
|
|
var message = new FullStateMessage
|
|
{
|
|
PlayerName = player.Name,
|
|
SenderId = player.NetId
|
|
};
|
|
|
|
_messageHandler.SendToAll(message);
|
|
}
|
|
}
|
|
}
|
|
}
|