コード例 #1
0
        public static bool RandomizeIconicFemShep(RandomizationOption option)
        {
            var femF = MERFileSystem.GetPackageFile("BIOG_Female_Player_C.pcc");

            if (femF != null && File.Exists(femF))
            {
                var femP         = MEPackageHandler.OpenMEPackage(femF);
                var femMorphFace = femP.GetUExport(682);
                RBioMorphFace.RandomizeExportNonHench(femMorphFace, option);
                var matSetup = femP.GetUExport(681);
                RBioMaterialOverride.RandomizeExport(matSetup, option);

                // Copy this data into BioP_Char so you get accurate results
                var biop_charF = MERFileSystem.GetPackageFile(@"BioP_Char.pcc");
                var biop_char  = MEPackageHandler.OpenMEPackage(biop_charF);
                EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.ReplaceSingular, femMorphFace, biop_char, biop_char.GetUExport(3482), true, out IEntry _);
                EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.ReplaceSingular, matSetup, biop_char, biop_char.GetUExport(3472), true, out IEntry _);
                //biop_char.GetUExport(3482).WriteProperties(femMorphFace.GetProperties()); // Copy the morph face
                //biop_char.GetUExport(3472).WriteProperties(matSetup.GetProperties()); // Copy the material setups
                MERFileSystem.SavePackage(biop_char);
                MERFileSystem.SavePackage(femP);
            }
            return(true);
        }
コード例 #2
0
        public static bool RandomizeCharacterCreator(RandomizationOption option)
        {
            var biop_charF         = MERFileSystem.GetPackageFile(@"BioP_Char.pcc");
            var biop_char          = MEPackageHandler.OpenMEPackage(biop_charF);
            var maleFrontEndData   = biop_char.GetUExport(18753);
            var femaleFrontEndData = biop_char.GetUExport(18754);

            var codeMapMale   = CalculateCodeMap(maleFrontEndData);
            var codeMapFemale = CalculateCodeMap(femaleFrontEndData);

            var bioUI                  = CoalescedHandler.GetIniFile("BIOUI.ini");
            var bgr                    = CoalescedHandler.GetIniFile("BIOGuiResources.ini");
            var charCreatorPCS         = bgr.GetOrAddSection("SFXGame.BioSFHandler_PCNewCharacter");
            var charCreatorControllerS = bioUI.GetOrAddSection("SFXGame.BioSFHandler_NewCharacter");

            charCreatorPCS.Entries.Add(new DuplicatingIni.IniEntry("!MalePregeneratedHeadCodes", "CLEAR"));
            charCreatorControllerS.Entries.Add(new DuplicatingIni.IniEntry("!MalePregeneratedHeadCodes", "CLEAR"));

            int numToMake = 20;
            int i         = 0;

            // Male: 34 chars
            while (i < numToMake)
            {
                i++;
                charCreatorPCS.Entries.Add(GenerateHeadCode(codeMapMale, false));
                charCreatorControllerS.Entries.Add(GenerateHeadCode(codeMapMale, false));
            }



            // Female: 36 chars
            charCreatorPCS.Entries.Add(new DuplicatingIni.IniEntry(""));         //blank line
            charCreatorControllerS.Entries.Add(new DuplicatingIni.IniEntry("")); //blank line
            charCreatorPCS.Entries.Add(new DuplicatingIni.IniEntry("!FemalePregeneratedHeadCodes", "CLEAR"));
            charCreatorControllerS.Entries.Add(new DuplicatingIni.IniEntry("!FemalePregeneratedHeadCodes", "CLEAR"));
            charCreatorPCS.Entries.Add(new DuplicatingIni.IniEntry("!FemalePregeneratedHeadCodes", "CLEAR"));

            i = 0;
            while (i < numToMake)
            {
                i++;
                charCreatorPCS.Entries.Add(GenerateHeadCode(codeMapFemale, true));
                charCreatorControllerS.Entries.Add(GenerateHeadCode(codeMapFemale, true));
            }


            randomizeFrontEnd(maleFrontEndData);
            randomizeFrontEnd(femaleFrontEndData);


            //Copy the final skeleton from female into male.
            var femBase  = biop_char.GetUExport(3480);
            var maleBase = biop_char.GetUExport(3481);

            maleBase.WriteProperty(femBase.GetProperty <ArrayProperty <StructProperty> >("m_aFinalSkeleton"));

            var randomizeColors = !option.HasSubOptionSelected(CharacterCreator.SUBOPTIONKEY_CHARCREATOR_NO_COLORS);

            foreach (var export in biop_char.Exports)
            {
                if (export.ClassName == "BioMorphFace" && !export.ObjectName.Name.Contains("Iconic"))
                {
                    RBioMorphFace.RandomizeExportNonHench(export, SuperRandomOption); //.3 default
                }
                else if (export.ClassName == "MorphTarget")
                {
                    if (
                        export.ObjectName.Name.StartsWith("jaw") || export.ObjectName.Name.StartsWith("mouth") ||
                        export.ObjectName.Name.StartsWith("eye") ||
                        export.ObjectName.Name.StartsWith("cheek") ||
                        export.ObjectName.Name.StartsWith("nose") ||
                        export.ObjectName.Name.StartsWith("teeth")
                        )
                    {
                        RMorphTarget.RandomizeExport(export, option);
                    }
                }
                else if (export.ClassName == "BioMorphFaceFESliderColour" && randomizeColors)
                {
                    var colors = export.GetProperty <ArrayProperty <StructProperty> >("m_acColours");
                    foreach (var color in colors)
                    {
                        RStructs.RandomizeColor(color, true, .5, 1.5);
                    }
                    export.WriteProperty(colors);
                }
                else if (export.ClassName == "BioMorphFaceFESliderMorph")
                {
                    // These don't work becuase of the limits in the morph system
                    // So all this does is change how much the values change, not the max/min
                }
                else if (export.ClassName == "BioMorphFaceFESliderScalar" || export.ClassName == "BioMorphFaceFESliderSetMorph")
                {
                    //no idea how to randomize this lol
                    var floats   = export.GetProperty <ArrayProperty <FloatProperty> >("m_afValues");
                    var minfloat = floats.Min();
                    var maxfloat = floats.Max();
                    if (minfloat == maxfloat)
                    {
                        if (minfloat == 0)
                        {
                            maxfloat = 1;
                        }
                        else
                        {
                            var vari = minfloat / 2;
                            maxfloat = ThreadSafeRandom.NextFloat(-vari, vari) + minfloat; //+/- 50%
                        }
                    }
                    foreach (var floatval in floats)
                    {
                        floatval.Value = ThreadSafeRandom.NextFloat(minfloat, maxfloat);
                    }
                    export.WriteProperty(floats);
                }
                else if (export.ClassName == "BioMorphFaceFESliderTexture")
                {
                }
            }
            MERFileSystem.SavePackage(biop_char);
            return(true);
        }