namespace Decal.Filters;

public sealed class LevelTables : RawTable<object>
{
	private AttributeXPTable mAttrXP;

	private VitalXPTable mVitalXP;

	private TrainedSkillXPTable mTrainXP;

	private SpecializedSkillXPTable mSpecXP;

	private CharacterXPTable mLevelXP;

	private CharacterSkillCreditsTable mSkillCredits;

	public AttributeXPTable AttributeXP => mAttrXP;

	public VitalXPTable VitalXP => mVitalXP;

	public TrainedSkillXPTable TrainedSkillXP => mTrainXP;

	public SpecializedSkillXPTable SpecializedSkillXP => mSpecXP;

	public CharacterXPTable CharacterXP => mLevelXP;

	public CharacterSkillCreditsTable CharacterSkillCredits => mSkillCredits;

	internal LevelTables(byte[] Data)
	{
		LoadFrom(Data);
	}

	internal override bool LoadFrom(byte[] Data)
	{
		int Index = 0;
		if (Get.DWord(Data, ref Index) != 234881048)
		{
			return false;
		}
		int num = Get.DWord(Data, ref Index) + 1;
		int num2 = Get.DWord(Data, ref Index) + 1;
		int num3 = Get.DWord(Data, ref Index) + 1;
		int num4 = Get.DWord(Data, ref Index) + 1;
		int num5 = Get.DWord(Data, ref Index) + 1;
		mAttrXP = new AttributeXPTable(num);
		mVitalXP = new VitalXPTable(num2);
		mTrainXP = new TrainedSkillXPTable(num3);
		mSpecXP = new SpecializedSkillXPTable(num4);
		mLevelXP = new CharacterXPTable(num5);
		mSkillCredits = new CharacterSkillCreditsTable(num5);
		for (int i = 0; i < num; i++)
		{
			mAttrXP.Add(Get.DWord(Data, ref Index) & 0xFFFFFFFFu);
		}
		for (int j = 0; j < num2; j++)
		{
			mVitalXP.Add(Get.DWord(Data, ref Index) & 0xFFFFFFFFu);
		}
		for (int k = 0; k < num3; k++)
		{
			mTrainXP.Add(Get.DWord(Data, ref Index) & 0xFFFFFFFFu);
		}
		for (int l = 0; l < num4; l++)
		{
			mSpecXP.Add(Get.DWord(Data, ref Index) & 0xFFFFFFFFu);
		}
		for (int m = 0; m < num5; m++)
		{
			mLevelXP.Add(Get.QWord(Data, ref Index));
		}
		for (int n = 0; n < num5; n++)
		{
			mSkillCredits.Add(Get.Byte(Data, ref Index));
		}
		return true;
	}
}
