using System;
using QCRPG.Framework;

namespace QCRPG.TSL.BT.Packets;

public class CsrWarmResetEventInfo : PacketInfoBase
{
	public override string Name => "Csr Warm Reset Event";

	public override string DisplayGroup => "Vendor Specific CSR";

	public CsrWarmResetEventInfo(CsrWarmResetEvent packet)
		: base(packet)
	{
		UpdateFieldInfoFromPacket();
	}

	public override void UpdateFieldInfoFromPacket()
	{
		CsrWarmResetEvent csrWarmResetEvent = (CsrWarmResetEvent)packet;
		fieldInfoList.Clear();
		fieldInfoList.Add(new PacketFieldInfo("SEQNO", "", 16, FormatValue(csrWarmResetEvent.UserFields.Seqno, 16), "", "", "", settable: false, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
		fieldInfoList.Add(new PacketFieldInfo("STATUS", "", 16, FormatValue(csrWarmResetEvent.UserFields.Status, 16), "", "", "", settable: true, littleEndianTransport: false, omitFromTransport: false, DataEntryMode.RightAlignedHex));
	}

	public override void UpdatePacketFromFieldInfo(int index, string value)
	{
		CsrWarmResetEvent csrWarmResetEvent = (CsrWarmResetEvent)packet;
		int num = -1;
		if (index == ++num)
		{
			throw new Exception("Tried to set non-settable field Seqno");
		}
		if (index == ++num)
		{
			csrWarmResetEvent.UserFields.Status = Convert.ToUInt32(value, 16);
		}
	}
}
