internal static bool CheckItemIDHook(int category, int id, ref byte __result, ChaListControl __instance) { int pid = Lists.CalculateGlobalID(category, id); byte result = __instance.CheckItemID(pid); if (result > 0) { __result = result; return(false); } return(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); } }
public static void LoadList(this ChaListControl instance, ChaListData data) { LoadList(instance, (ChaListDefine.CategoryNo)data.categoryNo, data); }
/// <summary> /// Randomize the hair /// </summary> private static void RandomHair(ChaFileControl file, bool type, bool color, bool etc) { ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl; ChaFileHair hair = file.custom.hair; if (type) { Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_b); hair.parts[0].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_f); hair.parts[1].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); //Side hair if (RandomBool(10)) { hair.parts[2].id = 0; } else { categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_s); hair.parts[2].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); } //Ahoge if (RandomBool(10)) { hair.parts[3].id = 0; } else { categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.bo_hair_o); hair.parts[3].id = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); } } if (color) { Color baseColor = RandomColor(); Color.RGBToHSV(baseColor, out float h, out float s, out float v); Color startColor = Color.HSVToRGB(h, s, Mathf.Max(v - 0.3f, 0f)); Color endColor = Color.HSVToRGB(h, s, Mathf.Min(v + 0.15f, 1f)); hair.parts[0].baseColor = baseColor; hair.parts[0].startColor = startColor; hair.parts[0].endColor = endColor; hair.parts[1].baseColor = baseColor; hair.parts[1].startColor = startColor; hair.parts[1].endColor = endColor; hair.parts[2].baseColor = baseColor; hair.parts[2].startColor = startColor; hair.parts[2].endColor = endColor; hair.parts[3].baseColor = baseColor; hair.parts[3].startColor = startColor; hair.parts[3].endColor = endColor; file.custom.face.eyebrowColor = hair.parts[0].baseColor; file.custom.body.underhairColor = hair.parts[0].baseColor; } if (etc) { for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { hair.parts[i].acsColor[j] = RandomColor(); } } Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.mt_hairgloss); hair.glossId = categoryInfo.Keys.ElementAt(Rand.Next(categoryInfo.Keys.Count)); } }
private static void LoadListInfoAllPostfix(ChaListControl __instance) { if (!Directory.Exists(ListOverrideFolder)) { return; } int counter = 0; Dictionary <ChaListDefine.CategoryNo, Dictionary <int, ListInfoBase> > dictListInfo = Traverse.Create(__instance).Field("dictListInfo").GetValue() as Dictionary <ChaListDefine.CategoryNo, Dictionary <int, ListInfoBase> >; var files = Directory.GetFiles(ListOverrideFolder); for (var i = 0; i < files.Length; i++) { var fileName = files[i]; try { XDocument doc = XDocument.Load(fileName); foreach (var overrideElement in doc.Root.Elements()) { ChaListDefine.CategoryNo categoryNo; if (int.TryParse(overrideElement.Attribute("Category").Value, out int category)) { categoryNo = (ChaListDefine.CategoryNo)category; } else { categoryNo = (ChaListDefine.CategoryNo)Enum.Parse(typeof(ChaListDefine.CategoryNo), overrideElement.Attribute("Category").Value); } ChaListDefine.KeyType keyType; if (int.TryParse(overrideElement.Attribute("KeyType").Value, out int key)) { keyType = (ChaListDefine.KeyType)key; } else { keyType = (ChaListDefine.KeyType)Enum.Parse(typeof(ChaListDefine.KeyType), overrideElement.Attribute("KeyType").Value); } int id = int.Parse(overrideElement.Attribute("ID").Value); string value = overrideElement.Attribute("Value").Value; //Don't allow people to change IDs, that's sure to break everything. if (keyType == ChaListDefine.KeyType.ID) { continue; } dictListInfo[categoryNo][id].dictInfo[(int)keyType] = value; counter++; } } catch (Exception ex) { Logger.Log(LogLevel.Error, $"Failed to load {PluginNameInternal} xml file."); Logger.Log(LogLevel.Error, ex); } } Logger.Log(LogLevel.Debug, $"[{PluginNameInternal}] Loaded {counter} overrides"); }