/// <summary> /// 載入sample chara /// </summary> /// <param name="stream">角色圖片讀取為Stream</param> public static void LoadSampleChara(Stream stream) { Hooks.BlockChanging = true; SampleChara.chaFile = new ChaFileControl(); SampleChara.chaFile.Invoke("LoadCharaFile", new object[] { stream, true, true }); Logger.LogDebug("Loaded sample chara: " + SampleChara.chaFile.parameter.fullname); Hooks.BlockChanging = false; ChaFileFace face = MessagePackSerializer.Deserialize <ChaFileFace>(MessagePackSerializer.Serialize <ChaFileFace>(SampleChara.chaFile.custom.face)); ChaFileBody body = MessagePackSerializer.Deserialize <ChaFileBody>(MessagePackSerializer.Serialize <ChaFileBody>(SampleChara.chaFile.custom.body)); //Logger.LogMessage("Length Face: " + face.shapeValueFace.Length); //Logger.LogMessage("Length Body: " + body.shapeValueBody.Length); SampleChara.shapeValueFace = face.shapeValueFace.ToList(); SampleChara.shapeValueBody = body.shapeValueBody.ToList(); SampleChara.ABMXData = MessagePackSerializer.Deserialize <PluginData>(MessagePackSerializer.Serialize(ExtendedSave.GetExtendedDataById(SampleChara.chaFile, "KKABMPlugin.ABMData"))); if (FBIOpenUp._isABMXExist && null != SampleChara.ABMXData) { Logger.LogDebug("Loaded sample chara ABMX"); } else { Logger.LogDebug("NO sample chara ABMX"); } }
public void RandomizeEtc() { ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl; ChaFileFace face = Custom.face; Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_head); face.headId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_face_detail); face.detailId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.detailPower = RandomFloat(); face.lipGlossPower = RandomFloat(); categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyebrow); face.eyebrowId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.eyebrowColor = Custom.hair.parts[0].baseColor; categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_nose); face.noseId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_mole); face.moleId = 0; categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_lipline); face.lipLineId = RandomBool() ? categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)) : 0; face.lipLineColor = Custom.body.skinSubColor; //Color.RGBToHSV(file.custom.body.skinMainColor, out float h2, out float s2, out float num3); //face.lipLineColor = Color.HSVToRGB(h2, s2, Mathf.Max(num3 - 0.3f, 0f)); face.lipGlossPower = RandomFloat(); face.doubleTooth = RandomBool(5); }
/// <summary> /// Method to copy data to/from characters. /// </summary> /// <param from>File to copy from</param> /// <param to>File to copy to</param> protected static void SkinWriter(ChaFileBody fromBody, ChaFileFace fromFace, ChaFileBody toBody, ChaFileFace toFace) { toBody.skinMainColor = fromBody.skinMainColor; toBody.skinSubColor = fromBody.skinSubColor; toBody.sunburnId = fromBody.sunburnId; toBody.sunburnColor = fromBody.sunburnColor; toBody.skinGlossPower = fromBody.skinGlossPower; toBody.nipColor = fromBody.nipColor; toBody.nailColor = fromBody.nailColor; toBody.nipId = fromBody.nipId; toBody.paintColor = fromBody.paintColor; toBody.paintId = fromBody.paintId; toBody.paintLayout = fromBody.paintLayout; toBody.paintLayoutId = fromBody.paintLayoutId; toFace.baseMakeup = fromFace.baseMakeup; toFace.cheekGlossPower = fromFace.cheekGlossPower; toFace.detailId = fromFace.detailId; toFace.detailPower = fromFace.detailPower; toFace.headId = fromFace.headId; toFace.lipGlossPower = fromFace.lipGlossPower; toFace.lipLineColor = fromFace.lipLineColor; toFace.lipLineId = fromFace.lipLineId; toFace.moleColor = fromFace.moleColor; toFace.moleId = fromFace.moleId; toFace.moleLayout = fromFace.moleLayout; toFace.noseId = fromFace.noseId; toFace.skinId = fromFace.skinId; }
/// <summary> /// Method to copy data to/from characters. /// </summary> /// <param from>File to copy from</param> /// <param to>File to copy to</param> protected static void EyelineWriter(ChaFileFace from, ChaFileFace to) { to.eyelineUpId = from.eyelineUpId; to.eyelineDownId = from.eyelineDownId; to.eyelineUpWeight = from.eyelineUpWeight; to.eyelineColor = from.eyelineColor; }
/// <summary> /// Method to copy data to/from characters. /// </summary> /// <param from>File to copy from</param> /// <param to>File to copy to</param> protected static void FaceWriter(ChaFileFace from, ChaFileFace to) { to.foregroundEyebrow = from.foregroundEyebrow; to.foregroundEyes = from.foregroundEyes; to.doubleTooth = from.doubleTooth; for (int i = 0; i < from.shapeValueFace.Length; i++) { to.shapeValueFace[i] = from.shapeValueFace[i]; } }
/// <summary> /// Method to add data to KKATData. /// </summary> /// <param curr>Current file to copy from</param> internal static void AddEyebrow(ChaFileControl curr) { if (!_toggleEyebrow.Value) { return; } ChaFileFace add = new ChaFileFace(); EyebrowWriter(curr.custom.face, add); string key = Utilities.CreateNewKey(curr); KK_Archetypes.Data.EyebrowDict.Add(key, add); }
/// <summary> /// Method to add data to KKATData. /// </summary> /// <param curr>Current file to copy from</param> /// <param fromSelected>Flag to retrieve data from CustomCharaList</param> internal static void AddFace(ChaFileControl curr, bool fromSelected = false) { if (!_toggleFace.Value) { return; } ChaFileFace add = new ChaFileFace(); FaceWriter(curr.custom.face, add); string key = Utilities.CreateNewKey(curr); KK_Archetypes.Data.FaceDict.Add(key, add); Bones.AddFaceBones(curr, fromSelected, key); }
/// <summary> /// Method to add data to KKATData. /// </summary> /// <param curr>Current file to copy from</param> internal static void AddSkin(ChaFileControl curr) { if (!_toggleSkin.Value) { return; } ChaFileBody addBody = new ChaFileBody(); ChaFileFace addFace = new ChaFileFace(); SkinWriter(curr.custom.body, curr.custom.face, addBody, addFace); string key = Utilities.CreateNewKey(curr); KK_Archetypes.Data.SkinBodyDict.Add(key, addBody); KK_Archetypes.Data.SkinFaceDict.Add(key, addFace); }
private static void LoadFaceSiders(ChaFileFace face, List <float> list) { var n = 0; for (var i = 0; i < face.shapeValueFace.Length; i++) { face.shapeValueFace[i] = list[n++]; } face.cheekGlossPower = list[n++]; face.detailPower = list[n++]; face.eyelineUpWeight = list[n++]; face.hlDownY = list[n++]; face.hlUpY = list[n++]; face.lipGlossPower = list[n++]; face.pupilHeight = list[n++]; face.pupilWidth = list[n++]; }
public void RandomizeEyes() { ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl; ChaFileFace face = Custom.face; Dictionary <int, ListInfoBase> categoryInfo; for (int j = 0; j < 2; j++) { categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye); face.pupil[j].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.pupil[j].baseColor = RandomColor(); face.pupil[j].subColor = RandomColor(); categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_gradation); face.pupil[j].gradMaskId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.pupil[j].gradBlend = RandomFloat(); face.pupil[j].gradOffsetY = RandomFloat(); face.pupil[j].gradScale = RandomFloat(); } if (RandomBool(95)) { face.pupil[1].Copy(face.pupil[0]); } categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_hi_up); face.hlUpId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.hlUpColor = RandomBool(5) ? RandomColor() : Color.white; categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_hi_down); face.hlDownId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.hlDownColor = RandomBool(5) ? RandomColor() : Color.white; categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_white); face.whiteId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.whiteBaseColor = RandomBool(5) ? RandomColor() : Color.white; face.whiteSubColor = RandomBool(5) ? RandomColor() : Color.white; categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyeline_up); face.eyelineUpId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyeline_down); face.eyelineDownId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); float h, s, v; Color.RGBToHSV(face.pupil[0].baseColor, out h, out s, out v); v = Mathf.Clamp(v - 0.3f, 0f, 1f); face.eyelineColor = Color.HSVToRGB(h, s, v); }
/// <summary> /// Method to load data from KKATData. /// </summary> /// <param key>Key to load</param> internal static void LoadFace(string key = null) { if (!_toggleFace.Value) { return; } if (KK_Archetypes.Data.FaceDict.Count == 0) { return; } key = key == null?Utilities.GetRandomKey(KK_Archetypes.Data.FaceDict) : key; ChaFileFace add = KK_Archetypes.Data.FaceDict[key]; ChaFileFace curr = MakerAPI.GetCharacterControl().chaFile.custom.face; FaceWriter(add, curr); Bones.LoadFaceBones(key); }
private static List <float> SaveFaceSiders(ChaFileFace face) { var res = new List <float>(); for (var i = 0; i < face.shapeValueFace.Length; i++) { res.Add(face.shapeValueFace[i]); } res.Add(face.cheekGlossPower); res.Add(face.detailPower); res.Add(face.eyelineUpWeight); res.Add(face.hlDownY); res.Add(face.hlUpY); res.Add(face.lipGlossPower); res.Add(face.pupilHeight); res.Add(face.pupilWidth); return(res); }
/// <summary> /// Method to load data from KKATData. /// </summary> /// <param key>Key to load</param> internal static void LoadSkin(string key = null) { if (!_toggleSkin.Value) { return; } if (KK_Archetypes.Data.SkinBodyDict.Count != KK_Archetypes.Data.SkinFaceDict.Count || KK_Archetypes.Data.SkinFaceDict.Count == 0) { return; } key = key == null?Utilities.GetRandomKey(KK_Archetypes.Data.SkinBodyDict) : key; ChaFileBody addBody = KK_Archetypes.Data.SkinBodyDict[key]; ChaFileFace addFace = KK_Archetypes.Data.SkinFaceDict[key]; ChaFile file = MakerAPI.GetCharacterControl().chaFile; ChaFileBody currBody = file.custom.body; ChaFileFace currFace = file.custom.face; SkinWriter(addBody, addFace, currBody, currFace); }
/// <summary> /// Method to load data from KKATData. /// </summary> /// <param key>Key to load</param> internal static void LoadEyebrow(string key = null) { if (!_toggleEyebrow.Value) { return; } if (KK_Archetypes.Data.EyebrowDict.Count == 0) { return; } ChaFileFace add; if (key == null) { add = Utilities.GetRandomValue(KK_Archetypes.Data.EyebrowDict); } else { add = KK_Archetypes.Data.EyebrowDict[key]; } ChaFileFace curr = MakerAPI.GetCharacterControl().chaFile.custom.face; EyebrowWriter(add, curr); }
/// <summary> /// Method to copy data to/from characters. /// </summary> /// <param from>File to copy from</param> /// <param to>File to copy to</param> protected static void EyeColorWriter(ChaFileFace from, ChaFileFace to) { for (int j = 0; j < 2; j++) { to.pupil[j].id = from.pupil[j].id; to.pupil[j].baseColor = from.pupil[j].baseColor; to.pupil[j].subColor = from.pupil[j].subColor; to.pupil[j].gradMaskId = from.pupil[j].gradMaskId; to.pupil[j].gradBlend = from.pupil[j].gradBlend; to.pupil[j].gradOffsetY = from.pupil[j].gradOffsetY; to.pupil[j].gradScale = from.pupil[j].gradScale; } to.pupilX = from.pupilX; to.pupilY = from.pupilY; to.pupilHeight = from.pupilHeight; to.pupilWidth = from.pupilWidth; to.hlUpId = from.hlUpId; to.hlUpColor = from.hlUpColor; to.hlDownId = from.hlDownId; to.whiteId = from.whiteId; to.whiteBaseColor = from.whiteBaseColor; to.whiteSubColor = from.whiteSubColor; to.hlDownColor = from.hlDownColor; }
public static void SetExtendedDataById(this ChaFileFace messagePackObject, string id, PluginData data) => SetExtendedData(messagePackObject, id, data);
public static bool TryGetExtendedDataById(this ChaFileFace messagePackObject, string id, out PluginData data) => GetExtendedData(messagePackObject, id, out data);
private static void MemberInit(ChaFileFace __instance) => Traverse.Create(__instance).Property(ExtendedSaveDataPropertyName).SetValue(null);
public void FusionProc(string pathA, string pathB) { ChaFileControl chaFileControl1 = new ChaFileControl(); chaFileControl1.LoadCharaFile(pathA, this.customBase.modeSex, true, true); ChaFileControl chaFileControl2 = new ChaFileControl(); chaFileControl2.LoadCharaFile(pathB, this.customBase.modeSex, true, true); ChaFileFace face1 = chaFileControl1.custom.face; ChaFileFace face2 = chaFileControl2.custom.face; float num1 = 0.5f + Random.Range(-0.5f, 0.5f); float rate1 = 0.5f + Random.Range(-0.5f, 0.5f); float num2 = 0.5f + Random.Range(-0.2f, 0.2f); for (int index = 0; index < this.face.shapeValueFace.Length; ++index) { this.face.shapeValueFace[index] = Mathf.Lerp(face1.shapeValueFace[index], face2.shapeValueFace[index], num2); } this.face.headId = this.RandomIntWhich(face1.headId, face2.headId); this.face.skinId = this.RandomIntWhich(face1.skinId, face2.skinId); this.face.detailId = this.RandomIntWhich(face1.detailId, face2.detailId); this.face.detailPower = Mathf.Lerp(face1.detailPower, face2.detailPower, num1); this.face.eyebrowId = this.RandomIntWhich(face1.eyebrowId, face2.eyebrowId); this.face.eyebrowColor = this.ColorBlend(face1.eyebrowColor, face2.eyebrowColor, rate1); this.face.eyebrowLayout = Random.Range(0, 2) != 0 ? face2.eyebrowLayout : face1.eyebrowLayout; float num3 = 0.5f + Random.Range(-0.5f, 0.5f); this.face.eyebrowTilt = Mathf.Lerp(face1.eyebrowTilt, face2.eyebrowTilt, num3); bool flag = Random.Range(0, 2) != 0 ? face2.pupilSameSetting : face1.pupilSameSetting; float rate2 = 0.5f + Random.Range(-0.5f, 0.5f); for (int index = 0; index < 2; ++index) { if (flag && index == 1) { this.face.pupil[index].whiteColor = this.face.pupil[0].whiteColor; } else { this.face.pupil[index].whiteColor = this.ColorBlend(face1.pupil[index].whiteColor, face2.pupil[index].whiteColor, rate2); } } for (int index = 0; index < 2; ++index) { if (flag && index == 1) { this.face.pupil[index].pupilId = this.face.pupil[0].pupilId; } else { this.face.pupil[index].pupilId = this.RandomIntWhich(face1.pupil[index].pupilId, face2.pupil[index].pupilId); } } float rate3 = 0.5f + Random.Range(-0.5f, 0.5f); for (int index = 0; index < 2; ++index) { if (flag && index == 1) { this.face.pupil[index].pupilColor = this.face.pupil[0].pupilColor; } else { this.face.pupil[index].pupilColor = this.ColorBlend(face1.pupil[index].pupilColor, face2.pupil[index].pupilColor, rate3); } } float num4 = 0.5f + Random.Range(-0.5f, 0.5f); for (int index = 0; index < 2; ++index) { if (flag && index == 1) { this.face.pupil[index].pupilW = this.face.pupil[0].pupilW; } else { this.face.pupil[index].pupilW = Mathf.Lerp(face1.pupil[index].pupilW, face2.pupil[index].pupilW, num4); } } float num5 = 0.5f + Random.Range(-0.5f, 0.5f); for (int index = 0; index < 2; ++index) { if (flag && index == 1) { this.face.pupil[index].pupilH = this.face.pupil[0].pupilH; } else { this.face.pupil[index].pupilH = Mathf.Lerp(face1.pupil[index].pupilH, face2.pupil[index].pupilH, num5); } } float num6 = 0.5f + Random.Range(-0.5f, 0.5f); for (int index = 0; index < 2; ++index) { if (flag && index == 1) { this.face.pupil[index].pupilEmission = this.face.pupil[0].pupilEmission; } else { this.face.pupil[index].pupilEmission = Mathf.Lerp(face1.pupil[index].pupilEmission, face2.pupil[index].pupilEmission, num6); } } for (int index = 0; index < 2; ++index) { if (flag && index == 1) { this.face.pupil[index].blackId = this.face.pupil[0].blackId; } else { this.face.pupil[index].blackId = this.RandomIntWhich(face1.pupil[index].blackId, face2.pupil[index].blackId); } } float rate4 = 0.5f + Random.Range(-0.5f, 0.5f); for (int index = 0; index < 2; ++index) { if (flag && index == 1) { this.face.pupil[index].blackColor = this.face.pupil[0].blackColor; } else { this.face.pupil[index].blackColor = this.ColorBlend(face1.pupil[index].blackColor, face2.pupil[index].blackColor, rate4); } } float num7 = 0.5f + Random.Range(-0.5f, 0.5f); for (int index = 0; index < 2; ++index) { if (flag && index == 1) { this.face.pupil[index].blackW = this.face.pupil[0].blackW; } else { this.face.pupil[index].blackW = Mathf.Lerp(face1.pupil[index].blackW, face2.pupil[index].blackW, num7); } } float num8 = 0.5f + Random.Range(-0.5f, 0.5f); for (int index = 0; index < 2; ++index) { if (flag && index == 1) { this.face.pupil[index].blackH = this.face.pupil[0].blackH; } else { this.face.pupil[index].blackH = Mathf.Lerp(face1.pupil[index].blackH, face2.pupil[index].blackH, num8); } } float num9 = 0.5f + Random.Range(-0.5f, 0.5f); this.face.pupilY = Mathf.Lerp(face1.pupilY, face2.pupilY, num9); this.face.hlId = this.RandomIntWhich(face1.hlId, face2.hlId); float rate5 = 0.5f + Random.Range(-0.5f, 0.5f); this.face.hlColor = this.ColorBlend(face1.hlColor, face2.hlColor, rate5); this.face.hlLayout = Random.Range(0, 2) != 0 ? face2.hlLayout : face1.hlLayout; float num10 = 0.5f + Random.Range(-0.5f, 0.5f); this.face.hlTilt = Mathf.Lerp(face1.hlTilt, face2.hlTilt, num10); float num11 = 0.5f + Random.Range(-0.5f, 0.5f); this.face.whiteShadowScale = Mathf.Lerp(face1.whiteShadowScale, face2.whiteShadowScale, num11); this.face.eyelashesId = this.RandomIntWhich(face1.eyelashesId, face2.eyelashesId); this.face.eyelashesColor = this.ColorBlend(face1.eyelashesColor, face2.eyelashesColor, rate1); if (Random.Range(0, 2) == 0) { this.face.moleId = face1.moleId; this.face.moleColor = face1.moleColor; this.face.moleLayout = face1.moleLayout; } else { this.face.moleId = face2.moleId; this.face.moleColor = face2.moleColor; this.face.moleLayout = face2.moleLayout; } if (Random.Range(0, 2) == 0) { this.face.makeup.eyeshadowId = face1.makeup.eyeshadowId; this.face.makeup.eyeshadowColor = face1.makeup.eyeshadowColor; this.face.makeup.eyeshadowGloss = face1.makeup.eyeshadowGloss; } else { this.face.makeup.eyeshadowId = face2.makeup.eyeshadowId; this.face.makeup.eyeshadowColor = face2.makeup.eyeshadowColor; this.face.makeup.eyeshadowGloss = face2.makeup.eyeshadowGloss; } if (Random.Range(0, 2) == 0) { this.face.makeup.cheekId = face1.makeup.cheekId; this.face.makeup.cheekColor = face1.makeup.cheekColor; this.face.makeup.cheekGloss = face1.makeup.cheekGloss; } else { this.face.makeup.cheekId = face2.makeup.cheekId; this.face.makeup.cheekColor = face2.makeup.cheekColor; this.face.makeup.cheekGloss = face2.makeup.cheekGloss; } if (Random.Range(0, 2) == 0) { this.face.makeup.lipId = face1.makeup.lipId; this.face.makeup.lipColor = face1.makeup.lipColor; this.face.makeup.lipGloss = face1.makeup.lipGloss; } else { this.face.makeup.lipId = face2.makeup.lipId; this.face.makeup.lipColor = face2.makeup.lipColor; this.face.makeup.lipGloss = face2.makeup.lipGloss; } if (Random.Range(0, 2) == 0) { this.face.makeup.paintInfo[0].Copy(face1.makeup.paintInfo[0]); } else { this.face.makeup.paintInfo[0].Copy(face2.makeup.paintInfo[0]); } if (Random.Range(0, 2) == 0) { this.face.makeup.paintInfo[1].Copy(face1.makeup.paintInfo[1]); } else { this.face.makeup.paintInfo[1].Copy(face2.makeup.paintInfo[1]); } if (this.chaCtrl.sex == (byte)0) { if (Random.Range(0, 2) == 0) { this.face.beardId = face1.beardId; this.face.beardColor = face1.beardColor; } else { this.face.beardId = face2.beardId; this.face.beardColor = face2.beardColor; } } ChaFileBody body1 = chaFileControl1.custom.body; ChaFileBody body2 = chaFileControl2.custom.body; float num12 = 0.5f + Random.Range(-0.2f, 0.2f); for (int index = 0; index < this.body.shapeValueBody.Length; ++index) { this.body.shapeValueBody[index] = Mathf.Lerp(body1.shapeValueBody[index], body2.shapeValueBody[index], num12); } float num13 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.bustSoftness = Mathf.Lerp(body1.bustSoftness, body2.bustSoftness, num13); float num14 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.bustWeight = Mathf.Lerp(body1.bustWeight, body2.bustWeight, num14); this.body.skinId = this.RandomIntWhich(body1.skinId, body2.skinId); this.body.detailId = this.RandomIntWhich(body1.detailId, body2.detailId); this.body.detailPower = Mathf.Lerp(body1.detailPower, body2.detailPower, num1); float rate6 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.skinColor = this.ColorBlend(body1.skinColor, body2.skinColor, rate6); float num15 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.skinGlossPower = Mathf.Lerp(body1.skinGlossPower, body2.skinGlossPower, num15); float num16 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.skinMetallicPower = Mathf.Lerp(body1.skinMetallicPower, body2.skinMetallicPower, num16); this.body.sunburnId = this.RandomIntWhich(body1.sunburnId, body2.sunburnId); float rate7 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.sunburnColor = this.ColorBlend(body1.sunburnColor, body2.sunburnColor, rate7); if (Random.Range(0, 2) == 0) { this.body.paintInfo[0].Copy(body1.paintInfo[0]); } else { this.body.paintInfo[0].Copy(body2.paintInfo[0]); } if (Random.Range(0, 2) == 0) { this.body.paintInfo[1].Copy(body1.paintInfo[1]); } else { this.body.paintInfo[1].Copy(body2.paintInfo[1]); } this.body.nipId = this.RandomIntWhich(body1.nipId, body2.nipId); float rate8 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.nipColor = this.ColorBlend(body1.nipColor, body2.nipColor, rate8); float num17 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.nipGlossPower = Mathf.Lerp(body1.nipGlossPower, body2.nipGlossPower, num17); float num18 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.areolaSize = Mathf.Lerp(body1.areolaSize, body2.areolaSize, num18); this.body.underhairId = this.RandomIntWhich(body1.underhairId, body2.underhairId); this.body.underhairColor = this.ColorBlend(body1.underhairColor, body2.underhairColor, rate1); float rate9 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.nailColor = this.ColorBlend(body1.nailColor, body2.nailColor, rate9); float num19 = 0.5f + Random.Range(-0.5f, 0.5f); this.body.nailGlossPower = Mathf.Lerp(body1.nailGlossPower, body2.nailGlossPower, num19); ChaFileHair hair1 = chaFileControl1.custom.hair; ChaFileHair hair2 = chaFileControl2.custom.hair; if (Random.Range(0, 2) == 0) { this.chaCtrl.chaFile.custom.hair = (ChaFileHair)MessagePackSerializer.Deserialize <ChaFileHair>(MessagePackSerializer.Serialize <ChaFileHair>((M0)hair1)); } else { this.chaCtrl.chaFile.custom.hair = (ChaFileHair)MessagePackSerializer.Deserialize <ChaFileHair>(MessagePackSerializer.Serialize <ChaFileHair>((M0)hair2)); } for (int index = 0; index < this.hair.parts.Length; ++index) { this.hair.parts[index].baseColor = this.ColorBlend(hair1.parts[index].baseColor, hair2.parts[index].baseColor, rate1); this.hair.parts[index].topColor = this.ColorBlend(hair1.parts[index].topColor, hair2.parts[index].topColor, rate1); this.hair.parts[index].underColor = this.ColorBlend(hair1.parts[index].underColor, hair2.parts[index].underColor, rate1); this.hair.parts[index].specular = this.ColorBlend(hair1.parts[index].specular, hair2.parts[index].specular, rate1); this.hair.parts[index].smoothness = Mathf.Lerp(hair1.parts[index].smoothness, hair2.parts[index].smoothness, rate1); this.hair.parts[index].metallic = Mathf.Lerp(hair1.parts[index].metallic, hair2.parts[index].metallic, rate1); } if (Random.Range(0, 2) == 0) { this.chaCtrl.chaFile.CopyCoordinate(chaFileControl1.coordinate); } else { this.chaCtrl.chaFile.CopyCoordinate(chaFileControl2.coordinate); } this.chaCtrl.ChangeNowCoordinate(false, true); Singleton <Character> .Instance.customLoadGCClear = false; this.chaCtrl.Reload(false, false, false, false, true); Singleton <Character> .Instance.customLoadGCClear = true; }
/// <summary> /// Randomize the face /// </summary> private static void RandomFace(ChaFileControl file, bool eyes, bool etc) { ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl; ChaFileFace face = file.custom.face; if (eyes) { Dictionary <int, ListInfoBase> categoryInfo; for (int j = 0; j < 2; j++) { categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye); face.pupil[j].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.pupil[j].baseColor = RandomColor(); face.pupil[j].subColor = RandomColor(); categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_gradation); face.pupil[j].gradMaskId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.pupil[j].gradBlend = RandomFloat(); face.pupil[j].gradOffsetY = RandomFloat(); face.pupil[j].gradScale = RandomFloat(); } if (RandomBool(95)) { face.pupil[1].Copy(face.pupil[0]); } categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_hi_up); face.hlUpId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.hlUpColor = RandomBool(5) ? RandomColor() : Color.white; categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_hi_down); face.hlDownId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.hlDownColor = RandomBool(5) ? RandomColor() : Color.white; categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eye_white); face.whiteId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.whiteBaseColor = RandomBool(5) ? RandomColor() : Color.white; face.whiteSubColor = RandomBool(5) ? RandomColor() : Color.white; categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyeline_up); face.eyelineUpId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyeline_down); face.eyelineDownId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); Color.RGBToHSV(face.pupil[0].baseColor, out float h, out float s, out float v); v = Mathf.Clamp(v - 0.3f, 0f, 1f); face.eyelineColor = Color.HSVToRGB(h, s, v); } if (etc) { Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_head); face.headId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_face_detail); face.detailId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.detailPower = RandomFloat(); face.lipGlossPower = RandomFloat(); categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_eyebrow); face.eyebrowId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); face.eyebrowColor = file.custom.hair.parts[0].baseColor; categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_nose); face.noseId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); //categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_mole); face.moleId = 0; categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_lipline); face.lipLineId = RandomBool() ? categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)) : 0; face.lipLineColor = file.custom.body.skinSubColor; //Color.RGBToHSV(file.custom.body.skinMainColor, out float h2, out float s2, out float num3); //face.lipLineColor = Color.HSVToRGB(h2, s2, Mathf.Max(num3 - 0.3f, 0f)); face.lipGlossPower = RandomFloat(); face.doubleTooth = RandomBool(5); } }
/// <summary> /// Method to copy data to/from characters. /// </summary> /// <param from>File to copy from</param> /// <param to>File to copy to</param> protected static void EyebrowWriter(ChaFileFace from, ChaFileFace to) { to.eyebrowId = from.eyebrowId; }