54 lines
1.1 KiB
C#
Raw Normal View History

using Mirror;
using QSB.Messaging;
2021-12-22 01:16:44 -08:00
using QSB.WorldSync;
2021-11-30 16:57:04 -08:00
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
{
2022-01-14 21:18:05 -08:00
private uint NetId;
2021-12-22 01:16:44 -08:00
2022-01-14 21:18:05 -08:00
public AuthQueueMessage(uint netId, AuthQueueAction action)
2021-12-22 17:13:54 -08:00
{
To = 0;
NetId = netId;
Value = action;
}
public override void Serialize(NetworkWriter writer)
2021-11-30 16:57:04 -08:00
{
base.Serialize(writer);
2022-01-14 21:18:05 -08:00
writer.Write(NetId);
2021-11-30 16:57:04 -08:00
}
2021-12-22 01:16:44 -08:00
public override void Deserialize(NetworkReader reader)
2021-12-25 18:57:20 -08:00
{
base.Deserialize(reader);
2022-01-14 21:18:05 -08:00
NetId = reader.ReadUInt();
2021-12-25 18:57:20 -08:00
}
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
2021-12-25 18:57:20 -08:00
public override void OnReceiveLocal() => OnReceiveRemote();
2022-01-14 21:18:05 -08:00
public override void OnReceiveRemote() => NetworkServer.spawned[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
}