namespace Decal.Filters;

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

	internal override bool LoadFrom(byte[] Data)
	{
		int Index = 0;
		if (Get.DWord(Data, ref Index) != 234881039)
		{
			return false;
		}
		int num = Get.Word(Data, ref Index);
		InitializeTable(num);
		Index += 2;
		for (int i = 0; i < num; i++)
		{
			Component component = new Component(Get.DWord(Data, ref Index));
			component.Name = Get.EncString(Data, ref Index);
			component.Type = ComponentType.GetById(Get.DWord(Data, ref Index));
			component.IconId = Get.DWord(Data, ref Index);
			component.SortKey = Get.DWord(Data, ref Index);
			component.GestureId = Get.DWord(Data, ref Index);
			component.GestureSpeed = Get.Float(Data, ref Index);
			component.Word = Get.EncString(Data, ref Index);
			component.BurnRate = Get.Float(Data, ref Index);
			Add(component);
		}
		return true;
	}
}
