// ---- METHODS ------------------------------------------------------------------------------------------------ void IResData.Load(ResFileLoader loader) { signature = loader.ReadString(4, Encoding.ASCII); uint materialAnimOffset = 0; ushort materialCount = 0; if (signature == "FMAA") { if (loader.ResFile.VersionMajor2 == 9) { Flags = loader.ReadEnum <MaterialAnimFlags>(true); loader.ReadUInt16(); } else { ((Switch.Core.ResFileSwitchLoader)loader).LoadHeaderBlock(); } Name = loader.LoadString(); Path = loader.LoadString(); BindModel = loader.Load <Model>(true); uint BindIndicesOffset = loader.ReadOffset(); materialAnimOffset = loader.ReadOffset(); uint unk = loader.ReadOffset(); //Empty section. Maybe set at runtime uint TextureNameArrayOffset = loader.ReadOffset(); UserData = loader.LoadDictValues <UserData>(); uint TextureBindArrayOffset = loader.ReadOffset(); if (loader.ResFile.VersionMajor2 != 9) { Flags = loader.ReadEnum <MaterialAnimFlags>(true); } ushort numUserData = 0; ushort CurveCount = 0; if (loader.ResFile.VersionMajor2 == 9) { FrameCount = loader.ReadInt32(); BakedSize = loader.ReadUInt32(); numUserData = loader.ReadUInt16(); materialCount = loader.ReadUInt16(); CurveCount = loader.ReadUInt16(); } else { numUserData = loader.ReadUInt16(); materialCount = loader.ReadUInt16(); CurveCount = loader.ReadUInt16(); FrameCount = loader.ReadInt32(); BakedSize = loader.ReadUInt32(); } ushort ShaderParamAnimCount = loader.ReadUInt16(); ushort TexturePatternAnimCount = loader.ReadUInt16(); ushort VisabiltyAnimCount = loader.ReadUInt16(); ushort TextureCount = loader.ReadUInt16(); if (loader.ResFile.VersionMajor2 == 9) { loader.ReadUInt16(); //padding } BindIndices = loader.LoadCustom(() => loader.ReadUInt16s(materialCount), BindIndicesOffset); var textureList = loader.LoadCustom(() => loader.LoadStrings(TextureCount), TextureNameArrayOffset); TextureBindArray = loader.LoadCustom(() => loader.ReadInt64s(TextureCount), TextureBindArrayOffset); if (textureList == null) { textureList = new List <string>(); } foreach (var tex in textureList) { TextureNames.Add(tex, new TextureRef() { Name = tex }); } } else if (signature == "FSHU") { if (loader.ResFile.Version >= 0x02040000) { Name = loader.LoadString(); Path = loader.LoadString(); Flags = (MaterialAnimFlags)loader.ReadUInt32(); if (loader.ResFile.Version >= 0x03040000) { FrameCount = loader.ReadInt32(); materialCount = loader.ReadUInt16(); ushort numUserData = loader.ReadUInt16(); int numParamAnim = loader.ReadInt32(); int numCurve = loader.ReadInt32(); BakedSize = loader.ReadUInt32(); } else { FrameCount = loader.ReadUInt16(); materialCount = loader.ReadUInt16(); UnknownValue = loader.ReadUInt32(); int numCurve = loader.ReadInt32(); BakedSize = loader.ReadUInt32(); int padding2 = loader.ReadInt32(); } BindModel = loader.Load <Model>(); BindIndices = loader.LoadCustom(() => loader.ReadUInt16s(materialCount)); materialAnimOffset = loader.ReadOffset(); UserData = loader.LoadDict <UserData>(); } else { Flags = (MaterialAnimFlags)loader.ReadUInt32(); FrameCount = loader.ReadInt16(); materialCount = loader.ReadUInt16(); ushort numUserData = loader.ReadUInt16(); ushort unk = loader.ReadUInt16(); BakedSize = loader.ReadUInt32(); Name = loader.LoadString(); Path = loader.LoadString(); BindModel = loader.Load <Model>(); BindIndices = loader.LoadCustom(() => loader.ReadUInt16s(materialCount)); materialAnimOffset = loader.ReadOffset(); } } else if (signature == "FTXP") { Name = loader.LoadString(); Path = loader.LoadString(); Flags = loader.ReadEnum <MaterialAnimFlags>(true); ushort numTextureRef = 0; if (loader.ResFile.Version >= 0x03040000) { ushort numUserData = loader.ReadUInt16(); FrameCount = loader.ReadInt32(); numTextureRef = loader.ReadUInt16(); materialCount = loader.ReadUInt16(); int numPatAnim = loader.ReadInt32(); int numCurve = loader.ReadInt32(); BakedSize = loader.ReadUInt32(); } else { FrameCount = loader.ReadUInt16(); numTextureRef = loader.ReadUInt16(); materialCount = loader.ReadUInt16(); ushort numUserData = loader.ReadUInt16(); int numPatAnim = loader.ReadInt16(); int numCurve = loader.ReadInt32(); BakedSize = loader.ReadUInt32(); loader.Seek(4); //padding } BindModel = loader.Load <Model>(); BindIndices = loader.LoadCustom(() => loader.ReadUInt16s(materialCount)); materialAnimOffset = loader.ReadOffset(); if (loader.ResFile.Version >= 0x03040000) { TextureNames = loader.LoadDict <TextureRef>(); } else { int TextureCount = 0; foreach (var patternAnim in MaterialAnimDataList) { foreach (var curve in patternAnim.Curves) { List <uint> frames = new List <uint>(); foreach (float key in curve.Keys) { frames.Add((uint)key); } TextureCount = (short)frames.Max(); } } var TextureRefNames = loader.LoadList <TextureRef>(numTextureRef); foreach (var texRef in TextureRefNames) { TextureNames.Add(texRef.Name, texRef); } } UserData = loader.LoadDict <UserData>(); } //Load materials and parse based on the signature of the section MaterialAnimDataList = loader.LoadCustom(() => { List <MaterialAnimData> materialAnims = new List <MaterialAnimData>(); for (int i = 0; i < materialCount; i++) { materialAnims.Add(new MaterialAnimData(loader, signature)); } return(materialAnims); }, materialAnimOffset); }