using QuantumUNET.Messages;
using QuantumUNET.Transport;
namespace QSB.Messaging
{
public class PlayerMessage : QMessageBase
{
///
/// The Player ID that is sending this message
///
public uint FromId { get; set; }
///
/// The Player ID that this message is about
///
public uint AboutId { get; set; }
///
/// If true, only send this message to the host of the current session
/// (OnReceiveLocal/Remote is not called on any other client)
///
public bool OnlySendToHost { get; set; }
///
/// 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
///
public uint ForId { get; set; } = uint.MaxValue;
public override void Deserialize(QNetworkReader reader)
{
FromId = reader.ReadUInt32();
AboutId = reader.ReadUInt32();
OnlySendToHost = reader.ReadBoolean();
if (!OnlySendToHost)
{
reader.ReadUInt32();
}
}
public override void Serialize(QNetworkWriter writer)
{
writer.Write(FromId);
writer.Write(AboutId);
writer.Write(OnlySendToHost);
if (!OnlySendToHost)
{
writer.Write(ForId);
}
}
}
}