2021-12-22 18:27:12 -08:00
|
|
|
|
using OWML.Common;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Player;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.ClientServerStateSync.Messages;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// sets the state both locally and remotely
|
|
|
|
|
/// </summary>
|
2023-07-28 19:30:57 +01:00
|
|
|
|
public class ClientStateMessage : QSBMessage<ClientState>
|
2021-12-22 18:27:12 -08:00
|
|
|
|
{
|
2022-03-10 17:57:50 -08:00
|
|
|
|
public ClientStateMessage(ClientState state) : base(state) { }
|
2021-12-22 18:27:12 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void OnReceiveLocal()
|
|
|
|
|
=> ClientStateManager.Instance.ChangeClientState(Data);
|
2021-12-22 18:27:12 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
if (From == uint.MaxValue)
|
2021-12-22 18:27:12 -08:00
|
|
|
|
{
|
2022-03-02 19:46:33 -08:00
|
|
|
|
DebugLog.ToConsole($"Error - ID is uint.MaxValue!", MessageType.Error);
|
|
|
|
|
return;
|
2022-02-27 04:40:44 -08:00
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
|
|
|
player.State = Data;
|
2021-12-22 18:27:12 -08:00
|
|
|
|
}
|
2022-02-24 22:04:54 -08:00
|
|
|
|
}
|