namespace Decal.Filters;

public sealed class AttributeTable : IdNameTable<Attrib>
{
	internal AttributeTable(byte[] Data)
	{
		LoadFrom(Data);
	}

	internal override bool LoadFrom(byte[] Data)
	{
		int Index = 0;
		if (Get.DWord(Data, ref Index) != 620756998)
		{
			return false;
		}
		Index++;
		int num = Get.Byte(Data, ref Index);
		InitializeTable(num);
		for (int i = 0; i < num; i++)
		{
			Attrib attrib = new Attrib(Get.DWord(Data, ref Index));
			attrib.IconId = Get.DWord(Data, ref Index);
			Add(attrib);
		}
		Index++;
		num = Get.Byte(Data, ref Index);
		for (int j = 0; j < num; j++)
		{
			int id = Get.DWord(Data, ref Index);
			GetById(id).Name = Get.PString(Data, ref Index);
		}
		return true;
	}
}
