2020-12-16 09:08:38 +00:00
|
|
|
|
using QuantumUNET.Messages;
|
|
|
|
|
using QuantumUNET.Transport;
|
2020-03-06 19:03:35 +01:00
|
|
|
|
|
2020-12-14 16:28:03 +00:00
|
|
|
|
namespace QSB.Messaging
|
2020-03-06 19:03:35 +01:00
|
|
|
|
{
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public class PlayerMessage : QMessageBase
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
2021-08-08 20:05:34 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The Player ID that is sending this message
|
|
|
|
|
/// </summary>
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public uint FromId { get; set; }
|
2021-08-08 20:05:34 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The Player ID that this message is about
|
|
|
|
|
/// </summary>
|
2020-12-02 21:23:01 +00:00
|
|
|
|
public uint AboutId { get; set; }
|
2021-08-08 20:05:34 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2021-12-06 00:11:55 -08:00
|
|
|
|
/// If true, only send this message to the host of the current session
|
2021-08-08 20:05:34 +01:00
|
|
|
|
/// (OnReceiveLocal/Remote is not called on any other client)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool OnlySendToHost { get; set; }
|
2020-08-20 19:31:10 +01:00
|
|
|
|
|
2021-12-05 23:47:09 -08:00
|
|
|
|
/// <summary>
|
2021-12-06 00:11:55 -08:00
|
|
|
|
/// The Player ID that this message is for.
|
|
|
|
|
/// By default, this is uint.MaxValue,
|
|
|
|
|
/// which means this is ignored and the message is sent to all clients
|
2021-12-05 23:47:09 -08:00
|
|
|
|
/// </summary>
|
2021-12-06 00:11:55 -08:00
|
|
|
|
public uint ForId { get; set; } = uint.MaxValue;
|
2021-12-05 23:47:09 -08:00
|
|
|
|
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public override void Deserialize(QNetworkReader reader)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
FromId = reader.ReadUInt32();
|
|
|
|
|
AboutId = reader.ReadUInt32();
|
2021-08-08 20:05:34 +01:00
|
|
|
|
OnlySendToHost = reader.ReadBoolean();
|
2021-12-05 23:47:09 -08:00
|
|
|
|
if (!OnlySendToHost)
|
|
|
|
|
{
|
2021-12-06 00:11:55 -08:00
|
|
|
|
reader.ReadUInt32();
|
2021-12-05 23:47:09 -08:00
|
|
|
|
}
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
2020-03-06 19:03:35 +01:00
|
|
|
|
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public override void Serialize(QNetworkWriter writer)
|
2020-12-02 21:23:01 +00:00
|
|
|
|
{
|
|
|
|
|
writer.Write(FromId);
|
|
|
|
|
writer.Write(AboutId);
|
2021-08-08 20:05:34 +01:00
|
|
|
|
writer.Write(OnlySendToHost);
|
2021-12-05 23:47:09 -08:00
|
|
|
|
if (!OnlySendToHost)
|
|
|
|
|
{
|
2021-12-06 00:49:56 -08:00
|
|
|
|
writer.Write(ForId);
|
2021-12-05 23:47:09 -08:00
|
|
|
|
}
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-05 23:47:09 -08:00
|
|
|
|
}
|