using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class LeBigSyncLostInfo : PacketInfoBase
{
	public override string Name => "Le Big Sync Lost";

	public override string DisplayGroup => "LE Controller";

	public LeBigSyncLostInfo(LeBigSyncLost packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		LeBigSyncLost leBigSyncLost = (LeBigSyncLost)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Subevent_Code", "Subevent Code for HCI_LE_BIG_Sync_Lost event.", 8, FormatValue(leBigSyncLost.UserFields.SubeventCode, 8), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("BIG_Handle", "Identifier of the Broadcast Isochronous Group.", 8, FormatValue(leBigSyncLost.UserFields.BigHandle, 8), "", "0", "EF", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Reason", ErrorCodeInfo.ErrorCodeToDescription(), 8, FormatValue(leBigSyncLost.UserFields.Reason, 8), ErrorCodeInfo.ErrorCodeToString(ErrorCodeInfo.ValueToErrorCode(leBigSyncLost.UserFields.Reason)), "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		LeBigSyncLost leBigSyncLost = (LeBigSyncLost)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubeventCode");
		}
		if (index == ++num)
		{
			leBigSyncLost.UserFields.BigHandle = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			leBigSyncLost.UserFields.Reason = Convert.ToUInt32(value, 16);
		}
	}
}
