mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
54 lines
1.1 KiB
C#
54 lines
1.1 KiB
C#
using Mirror;
|
|
using QSB.Messaging;
|
|
using QSB.WorldSync;
|
|
|
|
namespace QSB.AuthoritySync
|
|
{
|
|
/// <summary>
|
|
/// always sent to host
|
|
/// </summary>
|
|
public class AuthQueueMessage : QSBEnumMessage<AuthQueueAction>
|
|
{
|
|
private uint NetId;
|
|
|
|
public AuthQueueMessage(uint netId, AuthQueueAction action)
|
|
{
|
|
To = 0;
|
|
NetId = netId;
|
|
Value = action;
|
|
}
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
|
{
|
|
base.Serialize(writer);
|
|
writer.Write(NetId);
|
|
}
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
|
{
|
|
base.Deserialize(reader);
|
|
NetId = reader.ReadUInt();
|
|
}
|
|
|
|
public override bool ShouldReceive => WorldObjectManager.AllObjectsReady;
|
|
public override void OnReceiveLocal() => OnReceiveRemote();
|
|
public override void OnReceiveRemote() => NetworkServer.spawned[NetId].UpdateAuthQueue(From, Value);
|
|
}
|
|
|
|
public enum AuthQueueAction
|
|
{
|
|
/// <summary>
|
|
/// add player to the queue
|
|
/// </summary>
|
|
Add,
|
|
/// <summary>
|
|
/// remove player from the queue
|
|
/// </summary>
|
|
Remove,
|
|
/// <summary>
|
|
/// add player to the queue and force them to the front
|
|
/// </summary>
|
|
Force
|
|
}
|
|
}
|