quantum-space-buddies/QSB/OwnershipSync/OwnerQueueMessage.cs

34 lines
849 B
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
2023-05-08 11:30:59 -07:00
namespace QSB.OwnershipSync;
2022-03-02 19:46:33 -08:00
/// <summary>
/// always sent to host
/// </summary>
2023-05-08 11:41:43 -07:00
public class OwnerQueueMessage : QSBMessage<(uint NetId, OwnerQueueAction Action)>
{
2023-05-08 11:41:43 -07:00
public OwnerQueueMessage(uint netId, OwnerQueueAction action) : base((netId, action)) =>
2022-03-02 19:46:33 -08:00
To = 0;
2021-12-17 20:11:38 -08:00
2022-03-02 19:46:33 -08:00
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
public override void OnReceiveLocal() => OnReceiveRemote();
2023-05-08 11:41:43 -07:00
public override void OnReceiveRemote() => NetworkServer.spawned[Data.NetId].ServerUpdateOwnerQueue(From, Data.Action);
}
2022-03-02 19:46:33 -08:00
2023-05-08 11:41:43 -07:00
public enum OwnerQueueAction
2022-03-02 19:46:33 -08:00
{
/// <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
}