Exemple #1
0
        /// <summary>
        /// 將MoreAccessories飾品清空
        /// </summary>
        /// <param name="chaCtrl">清空對象</param>
        public static void ClearMoreAccessoriesData(ChaControl chaCtrl, bool force = false)
        {
            TryGetValueFromWeakKeyDict(MoreAccObj.GetField("_accessoriesByChar"), chaCtrl.chaFile, out object charAdditionalData);
            charAdditionalData.GetField("rawAccessoriesInfos").ToDictionary <ChaFileDefine.CoordinateType, List <ChaFileAccessory.PartsInfo> >()
            .TryGetValue((ChaFileDefine.CoordinateType)chaCtrl.fileStatus.coordinateType, out List <ChaFileAccessory.PartsInfo> parts);
            for (int i = 0; i < parts.Count; i++)
            {
                if (force || !(Patches.IsHairAccessory(chaCtrl, i + 20) && Patches.lockHairAcc))
                {
                    parts[i] = new ChaFileAccessory.PartsInfo();
                }
                else
                {
                    Logger.LogDebug($"Keep HairAcc{i}: {parts[i].id}");
                }
            }
            RemoveEmptyFromBackToFront(parts);
            //charAdditionalData.SetField("rawAccessoriesInfos", rawAccessoriesInfos);
            //charAdditionalData.SetField("nowAccessories", rawAccessoriesInfos[(ChaFileDefine.CoordinateType)chaCtrl.fileStatus.coordinateType]);

            //MoreAccObj.SetField("_accessoriesByChar", _accessoriesByChar);

            try {
                //MoreAccessories.InvokeMember("UpdateStudioUI", BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, MoreAccObj, null);
                Update();
                chaCtrl.ChangeAccessory(true);
            } catch { }
            Logger.LogDebug("Clear MoreAccessories Finish");
        }