Example #1
0
        public override VirtualFilesystemDirectory ExportToVFS()
        {
            VirtualFilesystemDirectory new_dir = SourceDirectory;

            new_dir.Name = Name;

            VirtualFilesystemFile dzr_file = SourceDirectory.GetFileAtPath("dzr/room.dzr");

            using (MemoryStream mem = new MemoryStream())
            {
                using (EndianBinaryWriter writer = new EndianBinaryWriter(mem, Endian.Big))
                {
                    SceneDataExporter exporter = new SceneDataExporter();
                    exporter.ExportToStream(writer, this);

                    writer.Flush();

                    dzr_file.Data = mem.ToArray();
                }
            }

            return(new_dir);
        }
Example #2
0
        public override VirtualFilesystemDirectory ExportToVFS()
        {
            VirtualFilesystemDirectory new_dir = SourceDirectory;

            new_dir.Name = Name;

            VirtualFilesystemFile dzs_file = SourceDirectory.GetFileAtPath("dzs/stage.dzs");

            using (MemoryStream mem = new MemoryStream())
            {
                using (EndianBinaryWriter writer = new EndianBinaryWriter(mem, Endian.Big))
                {
                    SceneDataExporter exporter = new SceneDataExporter();
                    exporter.ExportToStream(writer, this);

                    writer.Flush();

                    dzs_file.Data = mem.ToArray();
                }
            }

            List <J3DNode> meshes = GetChildrenOfType <J3DNode>();

            for (int i = 0; i < meshes.Count; i++)
            {
                string modelExt = meshes[i].Model.StudioType == "bdl4" ? "bdl" : "bmd";

                VirtualFilesystemFile modelFile = SourceDirectory.GetFileAtPath($"{ modelExt }/{ meshes[i].Name }.{ modelExt }");
                byte[] data = File.ReadAllBytes(meshes[i].Filename);

                if (modelFile != null)
                {
                    modelFile.Data = data;
                }
                else
                {
                    VirtualFilesystemDirectory modelDir = null;

                    foreach (VirtualFilesystemNode n in new_dir.Children)
                    {
                        if (n.Name == modelExt)
                        {
                            modelDir = n as VirtualFilesystemDirectory;
                            break;
                        }
                    }

                    if (modelDir == null)
                    {
                        modelDir = new VirtualFilesystemDirectory(modelExt);
                        new_dir.Children.Add(modelDir);
                    }

                    modelDir.Children.Add(new VirtualFilesystemFile(meshes[i].Name, $".{ modelExt }", data));
                }
            }

            VirtualFilesystemFile dat_file  = SourceDirectory.GetFileAtPath("dat/event_list.dat");
            WEventList            eventlist = GetChildrenOfType <WEventList>()[0];

            using (MemoryStream ev_strm = new MemoryStream())
            {
                using (EndianBinaryWriter writer = new EndianBinaryWriter(ev_strm, Endian.Big))
                {
                    eventlist.ExportToStream(writer);
                    writer.Flush();

                    dat_file.Data = ev_strm.ToArray();
                }
            }

            return(new_dir);
        }