55 lines
1.2 KiB
C#
Raw Normal View History

2021-11-30 16:57:04 -08:00
using QSB.Messaging;
2021-12-22 01:16:44 -08:00
using QSB.WorldSync;
using QuantumUNET;
2021-11-30 16:57:04 -08:00
using QuantumUNET.Transport;
2021-12-01 17:50:56 -08:00
namespace QSB.AuthoritySync
2021-11-30 16:57:04 -08:00
{
2021-12-24 22:33:29 -08:00
/// <summary>
/// always sent to host
/// </summary>
2021-12-22 01:16:44 -08:00
public class AuthQueueMessage : QSBEnumMessage<AuthQueueAction>
2021-11-30 16:57:04 -08:00
{
2021-12-22 17:13:54 -08:00
private QNetworkInstanceId NetId;
2021-12-22 01:16:44 -08:00
2021-12-22 17:13:54 -08:00
public AuthQueueMessage(QNetworkInstanceId netId, AuthQueueAction action)
{
To = 0;
NetId = netId;
Value = action;
}
2021-11-30 16:57:04 -08:00
public override void Serialize(QNetworkWriter writer)
{
base.Serialize(writer);
2021-12-22 01:16:44 -08:00
writer.Write(NetId);
2021-11-30 16:57:04 -08:00
}
2021-12-22 01:16:44 -08:00
2021-12-25 18:57:20 -08:00
public override void Deserialize(QNetworkReader reader)
{
base.Deserialize(reader);
NetId = reader.ReadNetworkId();
}
2021-12-22 01:16:44 -08:00
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
2021-12-25 18:57:20 -08:00
public override void OnReceiveLocal() => OnReceiveRemote();
2021-12-22 01:16:44 -08:00
public override void OnReceiveRemote() => QNetworkServer.objects[NetId].UpdateAuthQueue(From, Value);
2021-11-30 16:57:04 -08:00
}
2021-12-17 20:11:38 -08:00
public enum AuthQueueAction
{
/// <summary>
2021-12-26 04:04:21 -08:00
/// add player to the queue
2021-12-17 20:11:38 -08:00
/// </summary>
Add,
/// <summary>
2021-12-26 04:04:21 -08:00
/// remove player from the queue
2021-12-17 20:11:38 -08:00
/// </summary>
Remove,
/// <summary>
2021-12-26 04:04:21 -08:00
/// add player to the queue and force them to the front
2021-12-17 20:11:38 -08:00
/// </summary>
Force
}
2021-11-30 16:57:04 -08:00
}