quantum-space-buddies/QSB/ClientServerStateSync/Messages/ClientStateMessage.cs

30 lines
656 B
C#
Raw Normal View History

2021-12-23 02:27:12 +00:00
using OWML.Common;
using QSB.Messaging;
using QSB.Player;
using QSB.Utility;
2021-12-23 21:57:33 +00:00
namespace QSB.ClientServerStateSync.Messages
2021-12-23 02:27:12 +00:00
{
internal class ClientStateMessage : QSBEnumMessage<ClientState>
{
public ClientStateMessage(ClientState state) => Value = state;
public ClientStateMessage() { }
public override void OnReceiveLocal()
=> ClientStateManager.Instance.ChangeClientState(Value);
public override void OnReceiveRemote()
{
if (From == uint.MaxValue)
{
DebugLog.ToConsole($"Error - ID is uint.MaxValue!", MessageType.Error);
return;
}
var player = QSBPlayerManager.GetPlayer(From);
player.State = Value;
}
}
}