54 lines
1.2 KiB
C#
Raw Normal View History

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
{
/// <summary>
/// The Player ID that is sending this message
/// </summary>
2020-12-02 21:23:01 +00:00
public uint FromId { get; set; }
/// <summary>
/// The Player ID that this message is about
/// </summary>
2020-12-02 21:23:01 +00:00
public uint AboutId { get; set; }
/// <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
/// <summary>
/// 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
/// </summary>
public uint ForId { get; set; } = uint.MaxValue;
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();
OnlySendToHost = reader.ReadBoolean();
if (!OnlySendToHost)
{
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);
writer.Write(OnlySendToHost);
if (!OnlySendToHost)
{
2021-12-06 00:49:56 -08:00
writer.Write(ForId);
}
2020-12-02 21:23:01 +00:00
}
}
}