using System.Collections.Generic;
using System.IO;
using Dalamud.Data;
using Lumina.Excel;
using Lumina.Excel.Sheets;
using Newtonsoft.Json;
namespace Dalamud.Game.Text.SeStringHandling.Payloads;
///
/// An SeString Payload representing an interactable status link.
///
public class StatusPayload : Payload
{
[JsonProperty]
private uint statusId;
///
/// Initializes a new instance of the class.
/// Creates a new StatusPayload for the given status id.
///
/// The id of the Status for this link.
public StatusPayload(uint statusId)
{
this.statusId = statusId;
}
///
/// Initializes a new instance of the class.
/// Creates a new StatusPayload for the given status id.
///
internal StatusPayload()
{
}
///
public override PayloadType Type => PayloadType.Status;
///
/// Gets the Lumina Status object represented by this payload.
///
[JsonIgnore]
public RowRef Status => LuminaUtils.CreateRef(this.statusId);
///
public override string ToString()
{
return $"{this.Type} - StatusId: {this.statusId}, Name: {this.Status.ValueNullable?.Name}";
}
///
protected override byte[] EncodeImpl()
{
var idBytes = MakeInteger(this.statusId);
var chunkLen = idBytes.Length + 7;
var bytes = new List()
{
START_BYTE, (byte)SeStringChunkType.Interactable, (byte)chunkLen, (byte)EmbeddedInfoType.Status,
};
bytes.AddRange(idBytes);
// unk
bytes.AddRange([0x01, 0x01, 0xFF, 0x02, 0x20, END_BYTE]);
return bytes.ToArray();
}
///
protected override void DecodeImpl(BinaryReader reader, long endOfStream)
{
this.statusId = GetInteger(reader);
}
}