示例#1
0
        /// <summary>
        /// Clone the Makeup of a Sim
        /// </summary>
        /// <returns>the new Package for the patient Sim</returns>
        /// <param name="eyecolor">true, if you want to alter the eyecolor</param>
        /// <param name="makeups">true, if you want to alter the makeup</param>
        public SimPe.Packages.GeneratableFile CloneMakeup(bool eyecolor, bool makeups)
        {
            SimPe.Packages.GeneratableFile ret = SimPe.Packages.GeneratableFile.LoadFromFile((string)null);

            ArrayList list = new ArrayList();

            list.Add((uint)0xE86B1EEF);             //make sure the compressed Directory won't be copied!
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in patient.Index)
            {
                if (!list.Contains(pfd.Type))
                {
                    Interfaces.Files.IPackedFile fl = patient.Read(pfd);

                    Interfaces.Files.IPackedFileDescriptor newpfd = ret.NewDescriptor(pfd.Type, pfd.SubType, pfd.Group, pfd.Instance);
                    newpfd.UserData = fl.UncompressedData;
                    ret.Add(newpfd);
                }
            }

            //Update TXMT Files for the Face
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = ret.FindFiles(Data.MetaData.TXMT);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                rcol.ProcessData(pfd, ret);

                MaterialDefinition md = (MaterialDefinition)rcol.Blocks[0];
                this.UpdateMakeup(md, eyecolor, makeups);

                rcol.SynchronizeUserData();
            }

            if (eyecolor)
            {
                //Update DNA File
                Interfaces.Files.IPackedFileDescriptor dna  = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, spatient.Instance);
                Interfaces.Files.IPackedFileDescriptor adna = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, sarchetype.Instance);
                if ((dna != null) && (adna != null))
                {
                    SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf();
                    cpf.ProcessData(dna, ngbh);

                    SimPe.PackedFiles.Wrapper.Cpf acpf = new Cpf();
                    acpf.ProcessData(adna, ngbh);
                    cpf.GetSaveItem("3").StringValue = acpf.GetSaveItem("3").StringValue;

                    cpf.SynchronizeUserData();
                }
            }
            return(ret);
        }
示例#2
0
        /// <summary>
        /// Reads all Data from the Objects.package blonging to the same group as the passed pfd
        /// </summary>
        /// <param name="localgroup">Thr Group of the Source Object</param>
        /// <param name="package">The package that should get the Files</param>
        /// <param name="pkgcontainsbase">true, if the package does already contain the Base Object</param>
        /// <returns>The Modlename of that Object or null if none</returns>
        public static string[] BaseClone(uint localgroup, SimPe.Packages.File package, bool pkgcontainsbase)
        {
            //Get the Base Object Data from the Objects.package File
            ArrayList list = new ArrayList();

            if (pkgcontainsbase)
            {
                foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in package.Index)
                {
                    if ((pfd.Instance == 0x85) && (pfd.Type == Data.MetaData.STRING_FILE))
                    {
                        LoadModelName(list, pfd, package);
                    }
                }
            }
            else
            {
                Interfaces.Scenegraph.IScenegraphFileIndexItem[] files = FileTable.FileIndex.FindFileByGroup(localgroup);


                foreach (Interfaces.Scenegraph.IScenegraphFileIndexItem item in files)
                {
                    Interfaces.Files.IPackedFile file = item.Package.Read(item.FileDescriptor);

                    SimPe.Packages.PackedFileDescriptor npfd = new SimPe.Packages.PackedFileDescriptor();

                    npfd.UserData = file.UncompressedData;
                    npfd.Group    = item.FileDescriptor.Group;
                    npfd.Instance = item.FileDescriptor.Instance;
                    npfd.SubType  = item.FileDescriptor.SubType;
                    npfd.Type     = item.FileDescriptor.Type;

                    if (package.FindFile(npfd) == null)
                    {
                        package.Add(npfd);
                    }

                    if ((npfd.Instance == 0x85) && (npfd.Type == Data.MetaData.STRING_FILE))
                    {
                        LoadModelName(list, npfd, item.Package);
                    }
                }
            }

            string[] refname = new string[list.Count];
            list.CopyTo(refname);

            return(refname);
        }
示例#3
0
        /// <summary>
        /// Clone the Face of a Sim
        /// </summary>
        /// <returns>the new Package for the patient Sim</returns>
        public SimPe.Packages.GeneratableFile CloneFace()
        {
            SimPe.Packages.GeneratableFile ret = SimPe.Packages.GeneratableFile.LoadFromFile((string)null);



            ArrayList list = new ArrayList();

            list.Add((uint)0xCCCEF852);             //LxNR, Face

            uint hashgroup = this.GetPatientHash();


            foreach (Interfaces.Files.IPackedFileDescriptor pfd in archetype.Index)
            {
                if (list.Contains(pfd.Type))
                {
                    Interfaces.Files.IPackedFile fl = archetype.Read(pfd);

                    Interfaces.Files.IPackedFileDescriptor newpfd = ret.NewDescriptor(pfd.Type, pfd.SubType, pfd.Group, pfd.Instance);
                    newpfd.UserData = fl.UncompressedData;
                    ret.Add(newpfd);
                }
            }

            list.Add((uint)0xE86B1EEF);             //make sure the compressed Directory won't be copied!
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in patient.Index)
            {
                if (!list.Contains(pfd.Type))
                {
                    Interfaces.Files.IPackedFile fl = patient.Read(pfd);

                    Interfaces.Files.IPackedFileDescriptor newpfd = ret.NewDescriptor(pfd.Type, pfd.SubType, pfd.Group, pfd.Instance);
                    newpfd.UserData = fl.UncompressedData;
                    ret.Add(newpfd);
                }
            }

            UpdateFaceStructure(ret);
            return(ret);
        }
示例#4
0
        /// <summary>
        /// Load FileDescriptors that are stored in the given File
        /// </summary>
        /// <param name="flname"></param>
        /// <param name="list">null or the list that should be used to add the Items</param>
        /// <returns></returns>
        public static void LoadDescriptorsFromDisk(string flname, PackedFileDescriptors list)
        {
            if (list == null)
            {
                return;
            }
            bool run = WaitingScreen.Running;

            if (!run)
            {
                WaitingScreen.Wait();
            }
            WaitingScreen.UpdateMessage("Load Descriptors From Disk");
            //list = new PackedFileDescriptors();
            try
            {
                if (flname.ToLower().EndsWith("package.xml"))
                {
                    SimPe.Packages.File pkg = Packages.GeneratableFile.LoadFromStream(XmlPackageReader.OpenExtractedPackage(null, flname));
                    foreach (Interfaces.Files.IPackedFileDescriptor pfd in pkg.Index)
                    {
                        Interfaces.Files.IPackedFile file = pkg.Read(pfd);
                        pfd.UserData = file.UncompressedData;
                        if (!list.Contains(pfd))
                        {
                            list.Add(pfd);
                        }
                    }
                }
                else if (flname.ToLower().EndsWith(".xml"))
                {
                    Interfaces.Files.IPackedFileDescriptor pfd = XmlPackageReader.OpenExtractedPackedFile(flname);
                    if (!list.Contains(pfd))
                    {
                        list.Add(pfd);
                    }
                }
                else if (flname.ToLower().EndsWith(".package") || flname.ToLower().EndsWith(".simpedis"))
                {
                    SimPe.Packages.File pkg = SimPe.Packages.File.LoadFromFile(flname);
                    foreach (Interfaces.Files.IPackedFileDescriptor pfd in pkg.Index)
                    {
                        Interfaces.Files.IPackedFile file = pkg.Read(pfd);
                        pfd.UserData = file.UncompressedData;
                        if (!list.Contains(pfd))
                        {
                            list.Add(pfd);
                        }
                    }
                }
                else
                {
                    Packages.PackedFileDescriptor pfd = new SimPe.Packages.PackedFileDescriptor();
                    pfd.Type = 0xffffffff;
                    ToolLoaderItemExt.OpenPackedFile(flname, ref pfd);
                    list.Add(pfd);
                }
            }
            finally
            {
                if (!run)
                {
                    WaitingScreen.Stop();
                }
            }
        }
示例#5
0
        /// <summary>
        /// Create a cloned Sim
        /// </summary>
        /// <returns>the new Package for the patient Sim</returns>
        public SimPe.Packages.GeneratableFile CloneSim()
        {
            SimPe.Packages.GeneratableFile ret = SimPe.Packages.GeneratableFile.LoadFromFile((string)null);



            ArrayList list = new ArrayList();

            list.Add((uint)0xAC506764);             //3IDR
            list.Add(Data.MetaData.GZPS);           //GZPS, Property Set
            list.Add((uint)0xAC598EAC);             //AGED
            list.Add((uint)0xCCCEF852);             //LxNR, Face
            list.Add((uint)0x856DDBAC);             //IMG
            list.Add((uint)0x534C4F54);             //SLOT
            list.AddRange(Data.MetaData.RcolList);

            uint hashgroup = this.GetPatientHash();


            foreach (Interfaces.Files.IPackedFileDescriptor pfd in archetype.Index)
            {
                if (list.Contains(pfd.Type))
                {
                    Interfaces.Files.IPackedFile fl = archetype.Read(pfd);

                    Interfaces.Files.IPackedFileDescriptor newpfd = ret.NewDescriptor(pfd.Type, pfd.SubType, pfd.Group, pfd.Instance);
                    newpfd.UserData = fl.UncompressedData;
                    ret.Add(newpfd);

                    ///This is a scenegraph Resource and needs a new Hash
                    if (Data.MetaData.RcolList.Contains(pfd.Type))
                    {
                        SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                        rcol.ProcessData(newpfd, ret);

                        rcol.FileName = "#0x" + Helper.HexString(hashgroup) + "!" + Hashes.StripHashFromName(rcol.FileName);

                        switch (pfd.Type)
                        {
                        case Data.MetaData.SHPE:
                        {
                            Shape shp = (Shape)rcol.Blocks[0];
                            foreach (ShapeItem i in shp.Items)
                            {
                                i.FileName = "#0x" + Helper.HexString(hashgroup) + "!" + Hashes.StripHashFromName(i.FileName);
                            }
                            break;
                        }
                        }
                        rcol.SynchronizeUserData();
                    }
                }
            }

            list.Add((uint)0xE86B1EEF);             //make sure the compressed Directory won't be copied!
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in patient.Index)
            {
                if (!list.Contains(pfd.Type))
                {
                    Interfaces.Files.IPackedFile fl = patient.Read(pfd);

                    Interfaces.Files.IPackedFileDescriptor newpfd = ret.NewDescriptor(pfd.Type, pfd.SubType, pfd.Group, pfd.Instance);
                    newpfd.UserData = fl.UncompressedData;
                    ret.Add(newpfd);
                }
            }

            //Copy DNA File
            Interfaces.Files.IPackedFileDescriptor dna = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, sarchetype.Instance);
            if (dna != null)
            {
                Interfaces.Files.IPackedFileDescriptor tna = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, spatient.Instance);
                if (tna == null)
                {
                    tna         = ngbh.NewDescriptor(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, spatient.Instance);
                    tna.Changed = true;
                    ngbh.Add(tna);
                }

                Interfaces.Files.IPackedFile fl = ngbh.Read(dna);

                tna.UserData = fl.UncompressedData;
            }

            UpdateFaceStructure(ret);
            return(ret);
        }
示例#6
0
        /// <summary>
        /// Change the SkinTone of a Sim
        /// </summary>
        /// <param name="skin">the new skintone</param>
        /// param name="skinfiles">a Hashtable listing al Proerty Sets for each available skintone (key=skintone string, value= ArrayList of Cpf Objects)</param>
        /// <returns>the new Package for the patient Sim</returns>
        public SimPe.Packages.GeneratableFile CloneSkinTone(string skin, Hashtable skinfiles)
        {
            SimPe.Packages.GeneratableFile ret = SimPe.Packages.GeneratableFile.LoadFromFile((string)null);
            string pskin = GetSkintone(this.patient);

            ArrayList list = new ArrayList();

            list.Add((uint)0xE86B1EEF);             //make sure the compressed Directory won't be copied!
            foreach (Interfaces.Files.IPackedFileDescriptor pfd in patient.Index)
            {
                if (!list.Contains(pfd.Type))
                {
                    Interfaces.Files.IPackedFile fl = patient.Read(pfd);

                    Interfaces.Files.IPackedFileDescriptor newpfd = ret.NewDescriptor(pfd.Type, pfd.SubType, pfd.Group, pfd.Instance);
                    newpfd.UserData = fl.UncompressedData;
                    ret.Add(newpfd);

                    switch (newpfd.Type)
                    {
                    case (uint)0xAC598EAC:                             //AGED
                    {
                        SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf();
                        cpf.ProcessData(newpfd, ret);
                        cpf.GetSaveItem("skincolor").StringValue = skin;

                        cpf.SynchronizeUserData();
                        break;
                    }

                    case Data.MetaData.GZPS:
                    {
                        SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf();
                        cpf.ProcessData(newpfd, ret);
                        cpf.GetSaveItem("skintone").StringValue = skin;

                        cpf.SynchronizeUserData();
                        break;
                    }

                    case Data.MetaData.TXMT:
                    {
                        SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                        rcol.ProcessData(newpfd, ret);
                        MaterialDefinition txmt = (MaterialDefinition)rcol.Blocks[0];
                        txmt.FindProperty("cafSkinTone").Value = skin;

                        rcol.SynchronizeUserData();
                        break;
                    }
                    }
                }
            }

            //Update DNA File
            Interfaces.Files.IPackedFileDescriptor dna = ngbh.FindFile(0xEBFEE33F, 0, Data.MetaData.LOCAL_GROUP, spatient.Instance);
            if (dna != null)
            {
                SimPe.PackedFiles.Wrapper.Cpf cpf = new Cpf();
                cpf.ProcessData(dna, ngbh);
                cpf.GetSaveItem("2").StringValue = skin;
                cpf.GetSaveItem("6").StringValue = skin;

                cpf.SynchronizeUserData();
            }

            //Update 3IDR Files
            SimPe.Interfaces.Files.IPackedFileDescriptor[] pfds = ret.FindFiles(0xAC506764);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.RefFile reffile = new RefFile();
                reffile.ProcessData(pfd, ret);

                UpdateSkintone(reffile, skin, skinfiles);
            }

            //Update TXMT Files for the Face
            pfds = ret.FindFiles(Data.MetaData.TXMT);
            foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in pfds)
            {
                SimPe.Plugin.Rcol rcol = new GenericRcol(null, false);
                rcol.ProcessData(pfd, ret);

                MaterialDefinition md = (MaterialDefinition)rcol.Blocks[0];
                this.UpdateSkintone(md, skin, skinfiles);

                rcol.SynchronizeUserData();
            }


            return(ret);
        }