public static bool inheritsFrom(ME3ExportEntry entry, string baseClass) { string className = entry.ClassName; while (Classes.ContainsKey(className)) { if (className == baseClass) { return(true); } className = Classes[className].baseClass; } return(false); }
public static bool inheritsFrom(ME3ExportEntry entry, string baseClass) { string className = entry.ClassName; while (Classes.ContainsKey(className)) { if (className == baseClass) { return true; } className = Classes[className].baseClass; } return false; }
public ME3Texture2D(ME3PCCObject pccObj, int texIdx) { pccRef = pccObj; // check if texIdx is an Export index and a Texture2D class if (pccObj.isExport(texIdx) && (pccObj.Exports[texIdx].ClassName == className)) { ME3ExportEntry expEntry = pccObj.Exports[texIdx]; properties = new Dictionary <string, PropertyReader.Property>(); byte[] rawData = (byte[])expEntry.Data.Clone(); int propertiesOffset = PropertyReader.detectStart(pccObj, rawData); headerData = new byte[propertiesOffset]; Buffer.BlockCopy(rawData, 0, headerData, 0, propertiesOffset); pccOffset = (uint)expEntry.DataOffset; List <PropertyReader.Property> tempProperties = PropertyReader.getPropList(pccObj, rawData); texName = expEntry.ObjectName; for (int i = 0; i < tempProperties.Count; i++) { PropertyReader.Property property = tempProperties[i]; if (!properties.ContainsKey(pccObj.Names[property.Name])) { properties.Add(pccObj.Names[property.Name], property); } switch (pccObj.Names[property.Name]) { case "Format": texFormat = Textures.Methods.ParseFormat(pccObj.Names[property.Value.IntValue].Substring(3)); break; case "TextureFileCacheName": arcName = pccObj.Names[property.Value.IntValue]; break; case "LODGroup": LODGroup = pccObj.Names[property.Value.IntValue]; break; case "None": dataOffset = (uint)(property.offsetval + property.Size); break; } } // if "None" property isn't found throws an exception if (dataOffset == 0) { throw new Exception("\"None\" property not found"); } else { imageData = new byte[rawData.Length - dataOffset]; Buffer.BlockCopy(rawData, (int)dataOffset, imageData, 0, (int)(rawData.Length - dataOffset)); } } else { throw new Exception("Texture2D " + texIdx + " not found"); } pccExpIdx = texIdx; MemoryStream dataStream = new MemoryStream(imageData); numMipMaps = dataStream.ReadValueU32(); uint count = numMipMaps; privateImageList = new List <ImageInfo>(); while (dataStream.Position < dataStream.Length && count > 0) { ImageInfo imgInfo = new ImageInfo(); imgInfo.storageType = (storage)dataStream.ReadValueS32(); imgInfo.uncSize = dataStream.ReadValueS32(); imgInfo.cprSize = dataStream.ReadValueS32(); imgInfo.offset = dataStream.ReadValueS32(); if (imgInfo.storageType == storage.pccSto) { //imgInfo.offset = (int)(pccOffset + dataOffset); // saving pcc offset as relative to exportdata offset, not absolute imgInfo.offset = (int)dataStream.Position; // saving pcc offset as relative to exportdata offset, not absolute //MessageBox.Show("Pcc class offset: " + pccOffset + "\nimages data offset: " + imgInfo.offset.ToString()); dataStream.Seek(imgInfo.uncSize, SeekOrigin.Current); } imgInfo.imgSize = new ImageSize(dataStream.ReadValueU32(), dataStream.ReadValueU32()); imgList.Add(imgInfo); count--; } // save what remains /*int remainingBytes = (int)(dataStream.Length - dataStream.Position); * footerData = new byte[remainingBytes]; * dataStream.Read(footerData, 0, footerData.Length);*/ }
public ME3BioConversation(ME3ExportEntry exp) { pcc = exp.FileRef as ME3Package; export = exp; ReadData(); }
private bool importExport(IMEPackage importpcc, int n, int link) { IExportEntry ex = importpcc.getExport(n); IExportEntry nex = null; switch (pcc.Game) { case MEGame.ME1: nex = new ME1ExportEntry(pcc as ME1Package); break; case MEGame.ME2: nex = new ME2ExportEntry(pcc as ME2Package); break; case MEGame.ME3: nex = new ME3ExportEntry(pcc as ME3Package); break; } byte[] idata = ex.Data; PropertyCollection props = ex.GetProperties(); int start = ex.GetPropertyStart(); int end = props.endOffset; MemoryStream res = new MemoryStream(); if ((importpcc.getExport(n).ObjectFlags & (ulong)UnrealFlags.EObjectFlags.HasStack) != 0) { byte[] stackdummy = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, //Lets hope for the best :D 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,}; if (pcc.Game != MEGame.ME3) { stackdummy = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,}; } res.Write(stackdummy, 0, stackdummy.Length); } else { res.Write(new byte[start], 0, start); } //store copy of names list in case something goes wrong List<string> names = pcc.Names.ToList(); try { props.WriteTo(res, pcc); } catch (Exception exception) { //restore namelist pcc.setNames(names); MessageBox.Show("Error occured while trying to import " + ex.ObjectName + " : " + exception.Message); return false; } if (importpcc.Game == MEGame.ME3 && importpcc.getObjectName(ex.idxClass) == "SkeletalMesh") { SkeletalMesh skl = new SkeletalMesh(importpcc as ME3Package, n); SkeletalMesh.BoneStruct bone; for (int i = 0; i < skl.Bones.Count; i++) { bone = skl.Bones[i]; string s = importpcc.getNameEntry(bone.Name); bone.Name = pcc.FindNameOrAdd(s); skl.Bones[i] = bone; } SkeletalMesh.TailNamesStruct tailName; for (int i = 0; i < skl.TailNames.Count; i++) { tailName = skl.TailNames[i]; string s = importpcc.getNameEntry(tailName.Name); tailName.Name = pcc.FindNameOrAdd(s); skl.TailNames[i] = tailName; } SerializingContainer container = new SerializingContainer(res); container.isLoading = false; skl.Serialize(container); } else { res.Write(idata, end, idata.Length - end); } nex.setHeader((byte[])ex.header.Clone()); nex.Data = res.ToArray(); nex.idxObjectName = pcc.FindNameOrAdd(importpcc.getNameEntry(ex.idxObjectName)); nex.idxLink = link; nex.idxArchtype = nex.idxClass = nex.idxClassParent = 0; pcc.addExport(nex); return true; }