quantum-space-buddies/QSB/AuthoritySync/AuthQueueMessage.cs

57 lines
1.2 KiB
C#
Raw Normal View History

2021-12-01 00:57:04 +00:00
using QSB.Messaging;
2021-12-22 09:16:44 +00:00
using QSB.WorldSync;
using QuantumUNET;
2021-12-01 00:57:04 +00:00
using QuantumUNET.Transport;
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;
}
public AuthQueueMessage() { }
2021-12-01 00:57:04 +00:00
public override void Deserialize(QNetworkReader reader)
{
base.Deserialize(reader);
2021-12-22 09:16:44 +00:00
NetId = reader.ReadNetworkId();
2021-12-01 00:57:04 +00:00
}
public override void Serialize(QNetworkWriter writer)
{
base.Serialize(writer);
2021-12-22 09:16:44 +00:00
writer.Write(NetId);
2021-12-01 00:57:04 +00:00
}
2021-12-22 09:16:44 +00:00
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
public override void OnReceiveLocal() => QNetworkServer.objects[NetId].UpdateAuthQueue(From, Value);
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-23 09:50:09 +00:00
/// add id to the queue
2021-12-18 04:11:38 +00:00
/// </summary>
Add,
/// <summary>
2021-12-23 09:50:09 +00:00
/// remove id from the queue
2021-12-18 04:11:38 +00:00
/// </summary>
Remove,
/// <summary>
2021-12-23 09:50:09 +00:00
/// add id to the queue and force it to the front
2021-12-18 04:11:38 +00:00
/// </summary>
Force
}
2021-12-01 00:57:04 +00:00
}