public static bool RandomizeExport(ExportEntry export, RandomizationOption option) { if (!CanRandomize(export)) { return(false); } //Log.Information($@"Randomizing light {export.UIndex}"); var lc = export.GetProperty <StructProperty>("LightColor"); if (lc == null) { // create var pc = new PropertyCollection(); pc.Add(new ByteProperty(255, "B")); pc.Add(new ByteProperty(255, "G")); pc.Add(new ByteProperty(255, "R")); pc.Add(new ByteProperty(0, "A")); lc = new StructProperty("Color", pc, "LightColor", true); } RStructs.RandomizeColor(lc, false); export.WriteProperty(lc); return(true); }
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); }