40 lines
1.0 KiB
C#
Raw Normal View History

2020-07-28 15:59:24 +02:00
using QSB.Messaging;
using UnityEngine.Networking;
namespace QSB.Events
{
2020-07-28 15:59:24 +02:00
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()
{
2020-07-28 15:59:24 +02:00
foreach (var player in PlayerRegistry.PlayerList)
{
2020-07-28 15:59:24 +02:00
var message = new FullStateMessage
{
PlayerName = player.Name,
SenderId = player.NetId
};
_messageHandler.SendToAll(message);
}
}
}
}