65 lines
1.4 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>
/// 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();
OnlySendToHost = reader.ReadBoolean();
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);
writer.Write(OnlySendToHost);
if (!OnlySendToHost)
{
writer.Write(OnlySendToSpecific);
if (OnlySendToSpecific)
{
writer.Write(ForId);
}
}
2020-12-02 21:23:01 +00:00
}
}
}