using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class SetMptaContRxInfoInfo : PacketInfoBase
{
	public override string Name => "Set Mpta Cont Rx Info";

	public override string DisplayGroup => "Vendor Specific";

	public SetMptaContRxInfoInfo(SetMptaContRxInfo packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		SetMptaContRxInfo setMptaContRxInfo = (SetMptaContRxInfo)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("Sub OpCode", SetMptaContRxInfo.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToDescription(), 8, FormatValue(setMptaContRxInfo.UserFields.SubOpcode, 8), SetMptaContRxInfo.UserFieldsWrapper.SubOpcodeInfo.SubOpcodeToString(SetMptaContRxInfo.UserFieldsWrapper.SubOpcodeInfo.ValueToSubOpcode(setMptaContRxInfo.UserFields.SubOpcode)), "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Link Id", "Link id", 8, FormatValue(setMptaContRxInfo.UserFields.LinkId, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Rssi", "Rx Rssi", 8, FormatValue(setMptaContRxInfo.UserFields.Rssi, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("Channel", "Rx Channel", 8, FormatValue(setMptaContRxInfo.UserFields.Channel, 8), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		SetMptaContRxInfo setMptaContRxInfo = (SetMptaContRxInfo)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field SubOpcode");
		}
		if (index == ++num)
		{
			setMptaContRxInfo.UserFields.LinkId = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setMptaContRxInfo.UserFields.Rssi = Convert.ToUInt32(value, 16);
		}
		else if (index == ++num)
		{
			setMptaContRxInfo.UserFields.Channel = Convert.ToUInt32(value, 16);
		}
	}
}
