示例#1
0
        public static List <CustomSelectInfo> CreateSelectList(
            ChaListDefine.CategoryNo cateNo,
            ChaListDefine.KeyType limitKey = ChaListDefine.KeyType.Unknown)
        {
            ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;
            Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(cateNo);

            int[] array = categoryInfo.Keys.ToArray <int>();
            List <CustomSelectInfo> customSelectInfoList = new List <CustomSelectInfo>();

            for (int index = 0; index < categoryInfo.Count; ++index)
            {
                if (categoryInfo[array[index]].GetInfoInt(ChaListDefine.KeyType.Possess) != 99)
                {
                    bool flag = false;
                    if (chaListCtrl.CheckItemID(categoryInfo[array[index]].Category, categoryInfo[array[index]].Id) == (byte)1)
                    {
                        flag = true;
                    }
                    customSelectInfoList.Add(new CustomSelectInfo()
                    {
                        category    = categoryInfo[array[index]].Category,
                        id          = categoryInfo[array[index]].Id,
                        limitIndex  = limitKey != ChaListDefine.KeyType.Unknown ? categoryInfo[array[index]].GetInfoInt(limitKey) : -1,
                        name        = categoryInfo[array[index]].Name,
                        assetBundle = categoryInfo[array[index]].GetInfo(ChaListDefine.KeyType.ThumbAB),
                        assetName   = categoryInfo[array[index]].GetInfo(ChaListDefine.KeyType.ThumbTex),
                        newItem     = flag
                    });
                }
            }
            return(customSelectInfoList);
        }
示例#2
0
        public CategoryProperty(CategoryNo category, string property, string prefix = "")
        {
            Category = category;
            Property = property;

            Prefix = prefix;
        }
        public Dictionary <int, ListInfoBase> GetCategoryInfo(
            ChaListDefine.CategoryNo type)
        {
            Dictionary <int, ListInfoBase> dictionary = (Dictionary <int, ListInfoBase>)null;

            return(!this.dictListInfo.TryGetValue((int)type, out dictionary) ? (Dictionary <int, ListInfoBase>)null : new Dictionary <int, ListInfoBase>((IDictionary <int, ListInfoBase>)dictionary));
        }
示例#4
0
 /// <summary>
 /// Strip the "addStr" and attempt to get the texture again. This fixes head types missing eyeliners if they don't have one defined for that specific head.
 /// </summary>
 public static void GetTexture(ChaListDefine.CategoryNo type, int id, ChaListDefine.KeyType assetBundleKey, ChaListDefine.KeyType assetKey, string addStr, ChaControl __instance, ref Texture2D __result)
 {
     if (__result == null && !addStr.IsNullOrEmpty())
     {
         __result = Traverse.Create(__instance).Method("GetTexture", type, id, assetBundleKey, assetKey, "").GetValue() as Texture2D;
     }
 }
示例#5
0
 internal MigrationInfo(MigrationType migrationType, ChaListDefine.CategoryNo category, string guidOld, string guidNew, int idOld, int idNew)
 {
     MigrationType = migrationType;
     Category      = category;
     GUIDOld       = guidOld;
     GUIDNew       = guidNew;
     IDOld         = idOld;
     IDNew         = idNew;
 }
示例#6
0
        internal static void LoadList(this ChaListControl instance, ChaListDefine.CategoryNo category, ChaListData data)
        {
            var dictListInfo = r_dictListInfo.GetValue <Dictionary <int, Dictionary <int, ListInfoBase> > >(instance);

            if (dictListInfo.TryGetValue((int)category, out Dictionary <int, ListInfoBase> dictData))
            {
                loadListInternal(instance, dictData, data);
            }
        }
示例#7
0
        /// <summary>
        /// Do not load any nip or underhair textures, always keep empty
        /// </summary>
        private static bool PreventNipAndPubes(ChaListDefine.CategoryNo type) //, ref Texture __result)
        {
            if (type == ChaListDefine.CategoryNo.mt_nip || type == ChaListDefine.CategoryNo.mt_underhair)
            {
                //__result = null;
                return(false);
            }

            return(true);
        }
        public ListInfoBase GetListInfo(ChaListDefine.CategoryNo type, int id)
        {
            Dictionary <int, ListInfoBase> dictionary = (Dictionary <int, ListInfoBase>)null;

            if (!this.dictListInfo.TryGetValue((int)type, out dictionary))
            {
                return((ListInfoBase)null);
            }
            ListInfoBase listInfoBase = (ListInfoBase)null;

            return(!dictionary.TryGetValue(id, out listInfoBase) ? (ListInfoBase)null : listInfoBase);
        }
        public static string GetAccessoryTypeName(ChaListDefine.CategoryNo cate)
        {
            switch (cate)
            {
            case ChaListDefine.CategoryNo.ao_none:
                return(ChaAccessoryDefine.AccessoryTypeName[0]);

            case ChaListDefine.CategoryNo.ao_head:
                return(ChaAccessoryDefine.AccessoryTypeName[1]);

            case ChaListDefine.CategoryNo.ao_ear:
                return(ChaAccessoryDefine.AccessoryTypeName[2]);

            case ChaListDefine.CategoryNo.ao_glasses:
                return(ChaAccessoryDefine.AccessoryTypeName[3]);

            case ChaListDefine.CategoryNo.ao_face:
                return(ChaAccessoryDefine.AccessoryTypeName[4]);

            case ChaListDefine.CategoryNo.ao_neck:
                return(ChaAccessoryDefine.AccessoryTypeName[5]);

            case ChaListDefine.CategoryNo.ao_shoulder:
                return(ChaAccessoryDefine.AccessoryTypeName[6]);

            case ChaListDefine.CategoryNo.ao_chest:
                return(ChaAccessoryDefine.AccessoryTypeName[7]);

            case ChaListDefine.CategoryNo.ao_waist:
                return(ChaAccessoryDefine.AccessoryTypeName[8]);

            case ChaListDefine.CategoryNo.ao_back:
                return(ChaAccessoryDefine.AccessoryTypeName[9]);

            case ChaListDefine.CategoryNo.ao_arm:
                return(ChaAccessoryDefine.AccessoryTypeName[10]);

            case ChaListDefine.CategoryNo.ao_hand:
                return(ChaAccessoryDefine.AccessoryTypeName[11]);

            case ChaListDefine.CategoryNo.ao_leg:
                return(ChaAccessoryDefine.AccessoryTypeName[12]);

            case ChaListDefine.CategoryNo.ao_kokan:
                return(ChaAccessoryDefine.AccessoryTypeName[13]);

            default:
                return("不明");
            }
        }
示例#10
0
        public static List <CustomPushInfo> CreatePushList(
            ChaListDefine.CategoryNo cateNo)
        {
            Dictionary <int, ListInfoBase> categoryInfo = Singleton <Character> .Instance.chaListCtrl.GetCategoryInfo(cateNo);

            int[] array = categoryInfo.Keys.ToArray <int>();
            List <CustomPushInfo> customPushInfoList = new List <CustomPushInfo>();

            for (int index = 0; index < categoryInfo.Count; ++index)
            {
                customPushInfoList.Add(new CustomPushInfo()
                {
                    category    = categoryInfo[array[index]].Category,
                    id          = categoryInfo[array[index]].Id,
                    name        = categoryInfo[array[index]].Name,
                    assetBundle = categoryInfo[array[index]].GetInfo(ChaListDefine.KeyType.ThumbAB),
                    assetName   = categoryInfo[array[index]].GetInfo(ChaListDefine.KeyType.ThumbTex)
                });
            }
            return(customPushInfoList);
        }
示例#11
0
            internal static void MigrateData(ref ResolveInfo extResolve)
            {
                if (extResolve.GUID.IsNullOrWhiteSpace())
                {
                    return;
                }

                List <MigrationInfo> migrationInfoList = UniversalAutoResolver.GetMigrationInfo(extResolve.GUID);

                if (migrationInfoList.Any(x => x.MigrationType == MigrationType.StripAll))
                {
                    extResolve.GUID = "";
                    return;
                }

                int slot = extResolve.Slot;

                ChaListDefine.CategoryNo categoryNo = extResolve.CategoryNo;
                foreach (MigrationInfo migrationInfo in migrationInfoList.Where(x => x.IDOld == slot && x.Category == categoryNo))
                {
                    if (Sideloader.Sideloader.GetManifest(migrationInfo.GUIDNew) != null)
                    {
                        extResolve.GUID = migrationInfo.GUIDNew;
                        extResolve.Slot = migrationInfo.IDNew;
                        return;
                    }
                }

                foreach (MigrationInfo migrationInfo in migrationInfoList.Where(x => x.MigrationType == MigrationType.MigrateAll))
                {
                    if (Sideloader.Sideloader.GetManifest(migrationInfo.GUIDNew) != null)
                    {
                        extResolve.GUID = migrationInfo.GUIDNew;
                    }
                }
            }
示例#12
0
        internal static void MigrateData(ResolveInfo extResolve, ChaListDefine.CategoryNo categoryNo)
        {
            if (extResolve.GUID.IsNullOrWhiteSpace())
            {
                return;
            }

            var migrationInfoList = GetMigrationInfo(extResolve.GUID);

            if (migrationInfoList.Any(x => x.MigrationType == MigrationType.StripAll))
            {
                extResolve.GUID = "";
                return;
            }

            foreach (var migrationInfo in migrationInfoList.Where(x => x.MigrationType == MigrationType.MigrateAll))
            {
                if (Sideloader.GetManifest(migrationInfo.GUIDNew) != null)
                {
                    Sideloader.Logger.LogInfo($"Migrating GUID {migrationInfo.GUIDOld} -> {migrationInfo.GUIDNew}");
                    extResolve.GUID = migrationInfo.GUIDNew;
                    return;
                }
            }

            foreach (var migrationInfo in migrationInfoList.Where(x => x.IDOld == extResolve.Slot && categoryNo == extResolve.CategoryNo))
            {
                if (Sideloader.GetManifest(migrationInfo.GUIDNew) != null)
                {
                    Sideloader.Logger.LogInfo($"Migrating {migrationInfo.GUIDOld}:{migrationInfo.IDOld} -> {migrationInfo.GUIDNew}:{migrationInfo.IDNew}");
                    extResolve.GUID = migrationInfo.GUIDNew;
                    extResolve.Slot = migrationInfo.IDNew;
                    return;
                }
            }
        }
示例#13
0
 /// <summary>
 /// Get the ResolveInfo for an item. Used for compatibility resolving in cases where GUID is not known (hard mods).
 /// </summary>
 /// <param name="slot">Original ID as defined in the list file</param>
 /// <param name="property">Property as defined in StructReference</param>
 /// <param name="categoryNo">Category number of the item</param>
 /// <returns>ResolveInfo</returns>
 public static ResolveInfo TryGetResolutionInfo(int slot, string property, ChaListDefine.CategoryNo categoryNo) =>
 _resolveInfoLookupSlot?[slot].FirstOrDefault(x => x.Property == property && x.CategoryNo == categoryNo);
        internal void LoadMigrationInfo()
        {
            if (manifestDocument.Root?.Element("migrationInfo") == null)
            {
                return;
            }

            foreach (var info in manifestDocument.Root.Element("migrationInfo").Elements("info"))
            {
                try
                {
                    MigrationType migrationType;
                    if (info.Attribute("migrationType")?.Value == null || info.Attribute("migrationType").Value.IsNullOrWhiteSpace())
                    {
                        migrationType = MigrationType.Migrate;
                    }
                    else
                    {
                        migrationType = (MigrationType)Enum.Parse(typeof(MigrationType), info.Attribute("migrationType").Value);
                    }

                    string guidOld = info.Attribute("guidOld")?.Value;
                    string guidNew = info.Attribute("guidNew")?.Value;
                    if (guidNew.IsNullOrWhiteSpace())
                    {
                        guidNew = GUID;
                    }

                    if (guidOld.IsNullOrEmpty())
                    {
                        throw new Exception("guidOld must be specified for migration.");
                    }
                    if (guidNew.IsNullOrEmpty() && migrationType == MigrationType.Migrate)
                    {
                        throw new Exception("guidNew must be specified for migration.");
                    }

                    if (migrationType == MigrationType.MigrateAll || migrationType == MigrationType.StripAll)
                    {
                        MigrationList.Add(new MigrationInfo(migrationType, guidOld, guidNew));
                        continue;
                    }

                    if (info.Attribute("category")?.Value == null)
                    {
                        throw new Exception("Category must be specified for migration.");
                    }

                    ChaListDefine.CategoryNo category = (ChaListDefine.CategoryNo)Enum.Parse(typeof(ChaListDefine.CategoryNo), info.Attribute("category").Value);

                    if (!int.TryParse(info.Attribute("idOld").Value, out int idOld) && migrationType == MigrationType.Migrate)
                    {
                        throw new Exception("ID must be specified for migration.");
                    }
                    if (!int.TryParse(info.Attribute("idNew").Value, out int idNew) && migrationType == MigrationType.Migrate)
                    {
                        throw new Exception("ID must be specified for migration.");
                    }

                    MigrationList.Add(new MigrationInfo(migrationType, category, guidOld, guidNew, idOld, idNew));
                }
                catch (Exception ex)
                {
                    Sideloader.Logger.LogError($"Could not load migration data for {GUID}, skipping line.");
                    Sideloader.Logger.LogError(ex);
                }
            }
        }
        public void Initialize(ChaControl owner, ChaClothesComponent clothesComponent, ChaAccessoryComponent accessoryComponent, ListInfoBase listInfoBase, ChaListDefine.CategoryNo kind)
        {
            if (owner == null)
            {
                throw new ArgumentNullException(nameof(owner));
            }
            if (clothesComponent == null)
            {
                throw new ArgumentNullException(nameof(clothesComponent));
            }
            if (accessoryComponent == null)
            {
                throw new ArgumentNullException(nameof(accessoryComponent));
            }
            if (listInfoBase == null)
            {
                throw new ArgumentNullException(nameof(listInfoBase));
            }
            ClothesComponent   = clothesComponent;
            AccessoryComponent = accessoryComponent;
            Owner    = owner;
            InfoBase = listInfoBase;
            _kind    = kind;

            // Treat top parts as normal tops
            if (kind >= ChaListDefine.CategoryNo.cpo_sailor_a)
            {
                _clothingKind = 0;
            }
            else
            {
                _clothingKind = kind - ChaListDefine.CategoryNo.co_top;
            }

            var firstInstanceForCharacter = false;

            AllInstances.TryGetValue(owner, out var instances);
            if (instances == null)
            {
                // + 1 for inner shoes. Only outer / index 7 are used, but some hooks can look for index 8
                instances                 = Enumerable.Range(0, 8 /*+ 1*/).Select(i => new List <ClothesToAccessoriesAdapter>()).ToArray();
                AllInstances[Owner]       = instances;
                firstInstanceForCharacter = true;
            }
            instances[_clothingKind].Add(this);

            Reference = gameObject.AddComponent <ChaReference>();
            Reference.CreateReferenceInfo((ulong)(_clothingKind + 5), gameObject);

            if (_kind == ChaListDefine.CategoryNo.co_gloves || _kind == ChaListDefine.CategoryNo.co_shoes || _kind == ChaListDefine.CategoryNo.co_socks)
            {
                AllObjects = AccessoryComponent.rendNormal.Select(x => x.transform.parent.gameObject).Distinct().ToArray();
            }

            _colorRend = AccessoryComponent.rendNormal.FirstOrDefault(x => x != null) ?? AccessoryComponent.rendAlpha.FirstOrDefault(x => x != null) ?? AccessoryComponent.rendHair.FirstOrDefault(x => x != null);

            if (!InitializeCreateTextures())
            {
                ClothesToAccessoriesPlugin.Logger.LogWarning($"InitializeCreateTextures failed for kind={kind} id={listInfoBase.Id}");
            }

            // If there's already a bra mask active it needs to be applied again to a newly loaded accessory bra
            if (_kind == ChaListDefine.CategoryNo.co_bra)
            {
                // If this bra is the first clothing accessory added to the character, LastTopState needs to be calculated by UpdateVisibleAccessoryClothes before it can be used below
                if (firstInstanceForCharacter)
                {
                    ClothesToAccessoriesPlugin.UpdateVisibleAccessoryClothes(Owner);
                }

                if (ClothesToAccessoriesPlugin.LastTopState.TryGetValue(Owner, out var topState))
                {
                    ChangeAlphaMask(ClothesToAccessoriesPlugin.alphaState[topState, 0], ClothesToAccessoriesPlugin.alphaState[topState, 1]);
                }
            }

            // bug: if multipe clothes with skirt dynamic bones are spawned then their dynamic bone components all work at the same time on the same body bones, which can cause some weird physics effects
        }
示例#16
0
        public static bool CheckDataRangeCoordinate(
            ChaFileCoordinate coorde,
            int sex,
            List <string> checkInfo = null)
        {
            ChaListControl chaListCtrl = Singleton <Character> .Instance.chaListCtrl;
            bool           flag        = false;

            string[] strArray = new string[8]
            {
                "トップス",
                "ボトムス",
                "インナー上",
                "インナー下",
                "手袋",
                "パンスト",
                "靴下",
                "靴"
            };
            ChaListDefine.CategoryNo[] categoryNoArray = new ChaListDefine.CategoryNo[8]
            {
                sex != 0 ? ChaListDefine.CategoryNo.fo_top : ChaListDefine.CategoryNo.mo_top,
                sex != 0 ? ChaListDefine.CategoryNo.fo_bot : ChaListDefine.CategoryNo.mo_bot,
                sex != 0 ? ChaListDefine.CategoryNo.fo_inner_t : ChaListDefine.CategoryNo.unknown,
                sex != 0 ? ChaListDefine.CategoryNo.fo_inner_b : ChaListDefine.CategoryNo.unknown,
                sex != 0 ? ChaListDefine.CategoryNo.fo_gloves : ChaListDefine.CategoryNo.mo_gloves,
                sex != 0 ? ChaListDefine.CategoryNo.fo_panst : ChaListDefine.CategoryNo.unknown,
                sex != 0 ? ChaListDefine.CategoryNo.fo_socks : ChaListDefine.CategoryNo.unknown,
                sex != 0 ? ChaListDefine.CategoryNo.fo_shoes : ChaListDefine.CategoryNo.mo_shoes
            };
            int[] numArray1 = new int[8] {
                0, 1, 2, 3, 4, 5, 6, 7
            };
            int[] numArray2 = new int[8]
            {
                sex != 0 ? 0 : 0,
                sex != 0 ? 0 : 0,
                sex != 0 ? 0 : -1,
                sex != 0 ? 0 : -1,
                sex != 0 ? 0 : 0,
                sex != 0 ? 0 : -1,
                sex != 0 ? 0 : -1,
                sex != 0 ? 0 : 0
            };
            ChaFileClothes clothes = coorde.clothes;

            for (int index1 = 0; index1 < numArray1.Length; ++index1)
            {
                if (categoryNoArray[index1] != ChaListDefine.CategoryNo.unknown)
                {
                    if (!chaListCtrl.GetCategoryInfo(categoryNoArray[index1]).ContainsKey(clothes.parts[numArray1[index1]].id))
                    {
                        checkInfo?.Add(string.Format("【{0}】値:{1}", (object)strArray[index1], (object)clothes.parts[numArray1[index1]].id));
                        flag = true;
                        clothes.parts[numArray1[index1]].id = numArray2[index1];
                    }
                    Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo(ChaListDefine.CategoryNo.st_pattern);
                    for (int index2 = 0; index2 < clothes.parts[numArray1[index1]].colorInfo.Length; ++index2)
                    {
                        if (!categoryInfo.ContainsKey(clothes.parts[numArray1[index1]].colorInfo[index2].pattern))
                        {
                            checkInfo?.Add(string.Format("【柄】値:{0}", (object)clothes.parts[numArray1[index1]].colorInfo[index2].pattern));
                            flag = true;
                            clothes.parts[numArray1[index1]].colorInfo[index2].pattern = 0;
                        }
                    }
                }
            }
            ChaFileAccessory accessory = coorde.accessory;

            for (int index = 0; index < accessory.parts.Length; ++index)
            {
                int type = accessory.parts[index].type;
                int id   = accessory.parts[index].id;
                Dictionary <int, ListInfoBase> categoryInfo = chaListCtrl.GetCategoryInfo((ChaListDefine.CategoryNo)type);
                if (categoryInfo != null && !categoryInfo.ContainsKey(accessory.parts[index].id))
                {
                    checkInfo?.Add(string.Format("【{0}】値:{1}", (object)ChaAccessoryDefine.GetAccessoryTypeName((ChaListDefine.CategoryNo)type), (object)accessory.parts[index].id));
                    flag = true;
                    accessory.parts[index].MemberInit();
                }
            }
            return(flag);
        }
示例#17
0
 public static ResolveInfo TryGetResolutionInfo(int slot, string property, ChaListDefine.CategoryNo categoryNo, string guid)
 {
     return(_resolveInfoLookupSlot?[slot].FirstOrDefault(x => x.Property == property && x.CategoryNo == categoryNo && x.GUID == guid));
 }
示例#18
0
 /// <summary>
 /// Get the ResolveInfo for an item
 /// </summary>
 /// <param name="slot">Original ID as defined in the list file</param>
 /// <param name="categoryNo">Category number of the item</param>
 /// <param name="guid"></param>
 /// <returns>ResolveInfo</returns>
 public static ResolveInfo TryGetResolutionInfo(int slot, ChaListDefine.CategoryNo categoryNo, string guid) =>
 _resolveInfoLookupSlot?[slot].FirstOrDefault(x => x.CategoryNo == categoryNo && x.GUID == guid);
示例#19
0
 /// <summary>
 /// Get the ResolveInfo for an item
 /// </summary>
 /// <param name="categoryNo">Category number of the item</param>
 /// <param name="localSlot">Current (resolved) ID of the item</param>
 /// <returns>ResolveInfo</returns>
 public static ResolveInfo TryGetResolutionInfo(ChaListDefine.CategoryNo categoryNo, int localSlot) =>
 _resolveInfoLookupLocalSlot?[localSlot].FirstOrDefault(x => x.CategoryNo == categoryNo);