namespace Decal.Filters;

public sealed class VitalFormulaTable : RawTable<VitalFormula>
{
	internal VitalFormulaTable(byte[] Data)
	{
		LoadFrom(Data);
	}

	internal override bool LoadFrom(byte[] Data)
	{
		int Index = 0;
		if (Get.DWord(Data, ref Index) != 234881027)
		{
			return false;
		}
		if ((Data.Length - Index) % 24 != 0)
		{
			return false;
		}
		int num = (Data.Length - 4) / 24;
		InitializeTable(num);
		for (int i = 0; i < num; i++)
		{
			VitalFormula vitalFormula = new VitalFormula();
			vitalFormula.Unknown = Get.DWord(Data, ref Index);
			vitalFormula.IsAttribute1Valid = Get.DWord(Data, ref Index) == 1;
			vitalFormula.IsAttribute2Valid = Get.DWord(Data, ref Index) == 1;
			vitalFormula.AttributeDivisor = Get.DWord(Data, ref Index);
			vitalFormula.Attribute1Id = Get.DWord(Data, ref Index);
			vitalFormula.Attribute2Id = Get.DWord(Data, ref Index);
			Add(vitalFormula);
		}
		return true;
	}
}
