Exemplo n.º 1
0
        static Stream ProcessCCMesh(IPackfileEntry oldFile, string oldName, string newName)
        {
            MemoryStream outStream = new MemoryStream();

            using (Stream inStream = oldFile.GetStream())
            {
                VFile.VFile vFile = new VFile.VFile(inStream);
                StaticMesh  mesh  = new StaticMesh(inStream);

                for (int i = 0; i < vFile.References.Count; i++)
                {
                    string reference = vFile.References[i];
                    if (textureNameMap.ContainsKey(reference))
                    {
                        vFile.References[i] = textureNameMap[reference];
                    }
                }

                string[] textureNames = new string[mesh.TextureNames.Count];
                mesh.TextureNames.Keys.CopyTo(textureNames, 0);

                foreach (string textureName in textureNames)
                {
                    if (textureNameMap.ContainsKey(textureName))
                    {
                        mesh.RenameTexture(textureName, textureNameMap[textureName]);
                    }
                }

                vFile.Save(outStream);
                mesh.Save(outStream);
            }

            return(outStream);
        }
Exemplo n.º 2
0
        static Stream ProcessClothSim(IPackfileEntry oldFile, string newName)
        {
            MemoryStream outStream = new MemoryStream();

            using (Stream inStream = oldFile.GetStream())
            {
                ClothSimulationFile file = new ClothSimulationFile(inStream);
                file.Header.Name = newName;
                file.Save(outStream);
            }

            return(outStream);
        }
Exemplo n.º 3
0
        static Stream ProcessPeg(IPackfileEntry pegEntry, string newName)
        {
            textureNameMap.Clear();

            using (Stream pegStream = pegEntry.GetStream())
            {
                PegFile peg = new PegFile(pegStream);

                string sharedPrefix = FilterPegEntryFilename(peg.Entries[0].Filename);
                foreach (PegEntry entry in peg.Entries)
                {
                    while (!FilterPegEntryFilename(entry.Filename).StartsWith(sharedPrefix))
                    {
                        sharedPrefix = sharedPrefix.Substring(0, sharedPrefix.Length - 1);
                    }
                }

                foreach (PegEntry entry in peg.Entries)
                {
                    string newFilename = null;
                    if (sharedPrefix == "")
                    {
                        newFilename = newName + "_" + entry.Filename;
                    }
                    else
                    {
                        newFilename = entry.Filename.Replace(sharedPrefix, newName + "_").ToLowerInvariant();
                        if (newFilename.StartsWith("cf_cf_") || newFilename.StartsWith("cf_cm_") || newFilename.StartsWith("cm_cf_") || newFilename.StartsWith("cm_cm_"))
                        {
                            newFilename = newFilename.Remove(3, 3);
                        }
                    }

                    if (!textureNameMap.ContainsKey(entry.Filename))
                    {
                        textureNameMap.Add(entry.Filename, newFilename);
                    }

                    entry.Filename = newFilename;
                }

                MemoryStream outStream = new MemoryStream();
                peg.Save(outStream);

                return(outStream);
            }
        }