mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-07 13:05:41 +00:00
57 lines
1.2 KiB
C#
57 lines
1.2 KiB
C#
using QSB.Messaging;
|
|
using QSB.WorldSync;
|
|
using QuantumUNET;
|
|
using QuantumUNET.Transport;
|
|
|
|
namespace QSB.AuthoritySync
|
|
{
|
|
/// <summary>
|
|
/// always sent to host
|
|
/// </summary>
|
|
public class AuthQueueMessage : QSBEnumMessage<AuthQueueAction>
|
|
{
|
|
private QNetworkInstanceId NetId;
|
|
|
|
public AuthQueueMessage(QNetworkInstanceId netId, AuthQueueAction action)
|
|
{
|
|
To = 0;
|
|
NetId = netId;
|
|
Value = action;
|
|
}
|
|
|
|
public AuthQueueMessage() { }
|
|
|
|
public override void Deserialize(QNetworkReader reader)
|
|
{
|
|
base.Deserialize(reader);
|
|
NetId = reader.ReadNetworkId();
|
|
}
|
|
|
|
public override void Serialize(QNetworkWriter writer)
|
|
{
|
|
base.Serialize(writer);
|
|
writer.Write(NetId);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
public enum AuthQueueAction
|
|
{
|
|
/// <summary>
|
|
/// add id to the queue
|
|
/// </summary>
|
|
Add,
|
|
/// <summary>
|
|
/// remove id from the queue
|
|
/// </summary>
|
|
Remove,
|
|
/// <summary>
|
|
/// add id to the queue and force it to the front
|
|
/// </summary>
|
|
Force
|
|
}
|
|
}
|