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>
|
|
|
|
|
/// If true, only send this message to the host of the current session
|
|
|
|
|
/// (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>
|
|
|
|
|
/// If true, only send this message to ForId
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool OnlySendToSpecific { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The Player ID that this message is for
|
|
|
|
|
/// </summary>
|
|
|
|
|
public uint ForId { get; set; }
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
OnlySendToSpecific = reader.ReadBoolean();
|
|
|
|
|
if (OnlySendToSpecific)
|
|
|
|
|
{
|
|
|
|
|
ForId = reader.ReadUInt32();
|
|
|
|
|
}
|
|
|
|
|
}
|
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)
|
|
|
|
|
{
|
|
|
|
|
writer.Write(OnlySendToSpecific);
|
|
|
|
|
if (OnlySendToSpecific)
|
|
|
|
|
{
|
|
|
|
|
writer.Write(ForId);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-02 21:23:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-05 23:47:09 -08:00
|
|
|
|
}
|