2022-01-14 07:38:45 +00:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QSB.Messaging;
|
2021-12-22 09:16:44 +00:00
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using QuantumUNET;
|
2021-12-01 00:57:04 +00:00
|
|
|
|
|
2021-12-02 01:50:56 +00:00
|
|
|
|
namespace QSB.AuthoritySync
|
2021-12-01 00:57:04 +00:00
|
|
|
|
{
|
2021-12-25 06:33:29 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// always sent to host
|
|
|
|
|
/// </summary>
|
2021-12-22 09:16:44 +00:00
|
|
|
|
public class AuthQueueMessage : QSBEnumMessage<AuthQueueAction>
|
2021-12-01 00:57:04 +00:00
|
|
|
|
{
|
2021-12-23 01:13:54 +00:00
|
|
|
|
private QNetworkInstanceId NetId;
|
2021-12-22 09:16:44 +00:00
|
|
|
|
|
2021-12-23 01:13:54 +00:00
|
|
|
|
public AuthQueueMessage(QNetworkInstanceId netId, AuthQueueAction action)
|
|
|
|
|
{
|
|
|
|
|
To = 0;
|
|
|
|
|
NetId = netId;
|
|
|
|
|
Value = action;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-14 07:38:45 +00:00
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
2021-12-01 00:57:04 +00:00
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
2022-01-14 07:43:53 +00:00
|
|
|
|
writer.Write(NetId);
|
2021-12-01 00:57:04 +00:00
|
|
|
|
}
|
2021-12-22 09:16:44 +00:00
|
|
|
|
|
2022-01-14 07:38:45 +00:00
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
2021-12-26 02:57:20 +00:00
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
2022-01-14 07:43:53 +00:00
|
|
|
|
NetId = reader.Read<QNetworkInstanceId>();
|
2021-12-26 02:57:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-22 09:16:44 +00:00
|
|
|
|
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
2021-12-26 02:57:20 +00:00
|
|
|
|
public override void OnReceiveLocal() => OnReceiveRemote();
|
2021-12-22 09:16:44 +00:00
|
|
|
|
public override void OnReceiveRemote() => QNetworkServer.objects[NetId].UpdateAuthQueue(From, Value);
|
2021-12-01 00:57:04 +00:00
|
|
|
|
}
|
2021-12-18 04:11:38 +00:00
|
|
|
|
|
|
|
|
|
public enum AuthQueueAction
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2021-12-26 12:04:21 +00:00
|
|
|
|
/// add player to the queue
|
2021-12-18 04:11:38 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
Add,
|
|
|
|
|
/// <summary>
|
2021-12-26 12:04:21 +00:00
|
|
|
|
/// remove player from the queue
|
2021-12-18 04:11:38 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
Remove,
|
|
|
|
|
/// <summary>
|
2021-12-26 12:04:21 +00:00
|
|
|
|
/// add player to the queue and force them to the front
|
2021-12-18 04:11:38 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
Force
|
|
|
|
|
}
|
2021-12-01 00:57:04 +00:00
|
|
|
|
}
|