/// <summary> /// Gets the model info from the modelchara exd data /// </summary> /// <param name="modelCharaEx">The modelchara ex data</param> /// <param name="index">The index of the data</param> /// <returns>The XivModelInfo data</returns> public static XivModelInfo GetModelInfo(Dictionary <int, byte[]> modelCharaEx, int index) { var xivModelInfo = new XivMonsterModelInfo(); // These are the offsets to relevant data // These will need to be changed if data gets added or removed with a patch const int modelDataOffset = 4; // Big Endian Byte Order using (var br = new BinaryReaderBE(new MemoryStream(modelCharaEx[index]))) { xivModelInfo.PrimaryID = br.ReadInt16(); br.BaseStream.Seek(modelDataOffset, SeekOrigin.Begin); var modelType = br.ReadByte(); xivModelInfo.SecondaryID = br.ReadByte(); xivModelInfo.ImcSubsetID = br.ReadByte(); if (modelType == 2) { xivModelInfo.ModelType = XivItemType.demihuman; } else if (modelType == 3) { xivModelInfo.ModelType = XivItemType.monster; } else { xivModelInfo.ModelType = XivItemType.unknown; } } return(xivModelInfo); }
/// <summary> /// Gets the model info from the modelchara exd file /// </summary> /// <param name="gameDirectory">The game directory</param> /// <param name="index">The index of the data</param> /// <returns>The XivModelInfo data</returns> public static async Task <XivModelInfo> GetModelInfo(DirectoryInfo gameDirectory, int index) { var xivModelInfo = new XivMonsterModelInfo(); // These are the offsets to relevant data // These will need to be changed if data gets added or removed with a patch int startOffset = 8; int modelDataOffset = 12; var ex = new Ex(gameDirectory); var modelCharaEx = await ex.ReadExData(XivEx.modelchara); // Big Endian Byte Order using (var br = new BinaryReaderBE(new MemoryStream(modelCharaEx[index]))) { br.BaseStream.Seek(startOffset, SeekOrigin.Begin); xivModelInfo.PrimaryID = br.ReadInt16(); br.BaseStream.Seek(modelDataOffset, SeekOrigin.Begin); var modelType = br.ReadByte(); xivModelInfo.SecondaryID = br.ReadByte(); xivModelInfo.ImcSubsetID = br.ReadByte(); if (modelType == 2) { xivModelInfo.ModelType = XivItemType.demihuman; } else if (modelType == 3) { xivModelInfo.ModelType = XivItemType.monster; } else { xivModelInfo.ModelType = XivItemType.unknown; } } return(xivModelInfo); }