コード例 #1
0
        public static bool inheritsFrom(ME2ExportEntry entry, string baseClass)
        {
            string className = entry.ClassName;

            while (Classes.ContainsKey(className))
            {
                if (className == baseClass)
                {
                    return(true);
                }
                className = Classes[className].baseClass;
            }
            return(false);
        }
コード例 #2
0
 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;
 }
コード例 #3
0
ファイル: ME2Package.cs プロジェクト: ME3Explorer/ME3Explorer
        public void addExport(ME2ExportEntry exportEntry)
        {
            if (exportEntry.FileRef != this)
                throw new Exception("you cannot add a new export entry from another pcc file, it has invalid references!");

            exportEntry.DataChanged = true;
            exportEntry.Index = exports.Count;
            exportEntry.PropertyChanged += exportChanged;
            exports.Add(exportEntry);
            ExportCount = exports.Count;

            updateTools(PackageChange.ExportAdd, ExportCount);
        }
コード例 #4
0
 public static bool inheritsFrom(ME2ExportEntry entry, string baseClass)
 {
     string className = entry.ClassName;
     while (Classes.ContainsKey(className))
     {
         if (className == baseClass)
         {
             return true;
         }
         className = Classes[className].baseClass;
     }
     return false;
 }
コード例 #5
0
ファイル: ME2Package.cs プロジェクト: ME3Explorer/ME3Explorer
        void ReadExports(MemoryStream fs)
        {
            fs.Seek(ExportOffset, SeekOrigin.Begin);
            exports = new List<ME2ExportEntry>();
            byte[] buffer;
            for (int i = 0; i < ExportCount; i++)
            {
                long start = fs.Position;

                fs.Seek(40, SeekOrigin.Current);
                int count = fs.ReadValueS32();
                fs.Seek(4 + count * 12, SeekOrigin.Current);
                count = fs.ReadValueS32();
                fs.Seek(4 + count * 4, SeekOrigin.Current);
                fs.Seek(16, SeekOrigin.Current);
                long end = fs.Position;
                fs.Seek(start, SeekOrigin.Begin);

                ME2ExportEntry exp = new ME2ExportEntry(this, fs.ReadBytes((int)(end - start)), (uint)start);
                buffer = new byte[exp.DataSize];
                fs.Seek(exp.DataOffset, SeekOrigin.Begin);
                fs.Read(buffer, 0, buffer.Length);
                exp.Data = buffer;
                exp.DataChanged = false;
                exp.Index = i;
                exp.PropertyChanged += exportChanged;
                exports.Add(exp);
                fs.Seek(end, SeekOrigin.Begin);
            }
        }