Esempio n. 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");
        }
Esempio n. 2
0
        /// <summary>
        /// 拷貝整個髮飾品資料
        /// </summary>
        /// <param name="sourceCtrl">來源ChaControl</param>
        /// <param name="targetCtrl">目標ChaControl</param>
        /// <returns>拷貝成功</returns>
        public static bool CopyAllHairAcc(ChaControl sourceCtrl, ChaControl targetCtrl)
        {
            if (sourceCtrl == null || targetCtrl == null)
            {
                Logger.LogError($"CopyAllHairAcc input not correct!");
                return(false);
            }

            if (null != GetDataFromExtData(sourceCtrl, out Dictionary <int, object> dict) && null != dict)
            {
                for (int i = 0; i < dict.Count; i++)
                {
                    dict[dict.Keys.ElementAt(i)] = CopyHairAccInfoObject(dict.Values.ElementAt(i));
                    //dict[dict.Keys.ElementAt(i)] = (dict.Values.ElementAt(i));
                }
                SetToExtData(targetCtrl, dict);

                targetCtrl.ChangeAccessory(true);
                Logger.LogDebug($"Copy all HairAcc ({dict.Count}): {sourceCtrl.fileParam.fullname} -> {targetCtrl.fileParam.fullname} ");
                return(true);
            }
            else
            {
                Logger.LogDebug($"CopyAllHairAcc input not found!");
                return(false);
            }
        }
Esempio n. 3
0
        public static bool Prefix_ChaControl_ChangeNowCoordinate(ChaControl __instance, ChaFileCoordinate srcCoorde, bool reload = false, bool forceChange = true)
        {
            if (!Map.IsInstance())
            {
                return(true);
            }

            if (partners.Contains(__instance))
            {
                if (Map.Instance.Player.CameraControl.Mode != CameraMode.H)
                {
                    partners.Remove(__instance);

                    if (srcCoorde == __instance.chaFile.coordinate &&
                        Random.Range(0, 100) < KeepHOutfit.Value)
                    {
                        __instance.SetClothesStateAll(0);
                        __instance.ChangeAccessory();

                        return(false);
                    }
                }
            }
            else
            {
                AgentActor actor = null;

                foreach (KeyValuePair <int, AgentActor> agent in Map.Instance.AgentTable)
                {
                    if (agent.Value.ChaControl == __instance)
                    {
                        actor = agent.Value;
                        break;
                    }
                }

                if (actor != null &&
                    actor.Mode == ActionType.EndTaskDressOut &&
                    Random.Range(0, 100) < KeepOutfit.Value)
                {
                    return(false);
                }
            }

            return(true);
        }