mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-25 06:35:45 +00:00
83e8112c0a
* Sync full state on init * Sync game state on start
36 lines
876 B
C#
36 lines
876 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using QSB.Messaging;
|
|
using QSB.TransformSync;
|
|
using UnityEngine;
|
|
using UnityEngine.Networking;
|
|
|
|
namespace QSB.Events
|
|
{
|
|
class GameState : NetworkBehaviour
|
|
{
|
|
private MessageHandler<FullStateMessage> _messageHandler;
|
|
|
|
private void Awake()
|
|
{
|
|
_messageHandler = new MessageHandler<FullStateMessage>();
|
|
_messageHandler.OnClientReceiveMessage += OnClientReceiveMessage;
|
|
}
|
|
|
|
private void OnClientReceiveMessage(FullStateMessage message)
|
|
{
|
|
PlayerJoin.PlayerNames = message.PlayerNames;
|
|
}
|
|
|
|
public void Send()
|
|
{
|
|
var message = new FullStateMessage()
|
|
{
|
|
PlayerNames = PlayerJoin.PlayerNames
|
|
};
|
|
|
|
_messageHandler.SendToAll(message);
|
|
}
|
|
}
|
|
}
|