示例#1
0
        public static bool MGMgr_CanMarriage_Patch_Prefix(int npcId, ref int result, ref bool __result)
        {
            if (!Main.enabled)
            {
                return(true);
            }

            result = -1;
            if (GlobleBlackBoard.Self.HasInfo("Nomarry_" + npcId))
            {
                result   = 11;
                __result = false;
                return(false);
            }
            if (!FavorRelationshipUtil.CanPropose(npcId, out result))
            {
                __result = false;
                return(false);
            }
            if (HomeModule.Self.HomeLevel < 1)
            {
                result   = 8;
                __result = false;
                return(false);
            }
            __result = true;
            return(false);
        }
            static bool Prefix(ref bool __result, ref int ___marriageID, ref bool ___isMiscarry, ref GameDateTime ___lastMiscarryTime)
            {
                if (!enabled)
                {
                    return(true);
                }

                if (!ChildrenModule.ModuleOpen)
                {
                    __result = false;
                    return(false);
                }
                ___marriageID = GetCurrentSpouse();
                if (___marriageID < 1)
                {
                    __result = false;
                    return(false);
                }

                bool attain = FavorRelationshipUtil.GetRelationShip(___marriageID) == ChildConfig.Self.RelationShip;
                bool home   = Module <HomeModule> .Self.HomeLevel >= ChildConfig.Self.HomeLevel;
                bool free   = Singleton <BedUnitMgr> .Self.HaveChildsFreePos();

                __result = attain && home && free;
                return(false);
            }
示例#3
0
        public static bool CanTeeterInteract(Actor actor)
        {
            if (actor == null)
            {
                return(false);
            }
            int relationship = FavorRelationshipUtil.GetRelationShip(actor.InstanceId);

            return((settings.HugRelationshipMin == -1 || relationship >= settings.HugRelationshipMin) &&
                   (settings.KissRelationshipMin == -1 || relationship >= settings.KissRelationshipMin) &&
                   (settings.MassageRelationshipMin == -1 || relationship >= settings.MassageRelationshipMin));
        }
示例#4
0
        private static void BringBack(int id)
        {
            Actor actor = Module <ActorMgr> .Self.Get(id);

            actor.SetBehaviorState(BehaveState.Default, true);
            Module <ActorMgr> .Self.MoveToScenario(actor, "Main", ReturnLocations[id][0]);

            FavorObject f = Module <FavorManager> .Self.GetFavorObject(id);

            FavorRelationshipId r = f.Relationship;

            f.Relationship = FavorRelationshipId.Friend;
            FavorRelationshipUtil.TryUpgradeRelationShip(f, false, false, true);
            Module <FavorInfluenceManager> .Self.OnUpdateRelation(f.ID, r, f.Relationship);

            Module <FavorManager> .Self.RemoveToBlackList(f.ID);
        }
示例#5
0
        private static void BringBack(int id)
        {
            Actor actor = Module <ActorMgr> .Self.Get(id);

            actor.SetBehaviorState(BehaveState.Default, true);
            Module <ActorMgr> .Self.MoveToScenario(actor, "Main", ReturnLocations[id][0]);

            FavorObject f = Module <FavorManager> .Self.GetFavorObject(id);

            FavorRelationshipId r = f.Relationship;

            f.Relationship = FavorRelationshipId.Friend;
            FavorRelationshipUtil.TryUpgradeRelationShip(f, false, false, true);
            Module <FavorInfluenceManager> .Self.OnUpdateRelation(f.ID, r, f.Relationship);

            if (typeof(FavorManager).GetMethod("RemoveFromBlackList") != null)
            {
                typeof(FavorManager).GetMethod("RemoveFromBlackList").Invoke(Module <FavorManager> .Self, new object[] { f.ID });
            }
            else if (typeof(FavorManager).GetMethod("RemoveToBlackList") != null)
            {
                typeof(FavorManager).GetMethod("RemoveToBlackList").Invoke(Module <FavorManager> .Self, new object[] { f.ID });
            }
        }
示例#6
0
        public static bool FavorUtility_GetGiftGainInfo_Patch_Prefix(NpcData npcData, FavorManagerConfInfo favorConf, ItemBaseConfData itemBaseConf, ref int gainValue, ref FeeLevelEnum feeLevel, ref string replyText, ref GiftType gType)
        {
            if (!Main.enabled)
            {
                return(true);
            }

            if (itemBaseConf.NameID == 271422) //heart knot
            {
                gainValue = 0;
                replyText = string.Empty;
                gType     = GiftType.Normal;
                feeLevel  = FeeLevelEnum.Refuse;
                int failIndex = -1;
                int id        = npcData.id;

                Dbgl("Giving heart knot to :" + npcData.Name + " " + npcData.id + " " + npcData.factionId);

                if (Module <Player> .Self.CanExpress(id, out failIndex) && FavorRelationshipUtil.CheckExpress(id, ref failIndex))
                {
                    gainValue = FavorUtility.GetGiftGainValue(favorConf.FavorValues_Confession, itemBaseConf);
                    feeLevel  = FeeLevelEnum.Confession;
                    gType     = GiftType.Relation;
                }
                else
                {
                    gainValue = 0;
                    feeLevel  = FeeLevelEnum.Refuse;
                    gType     = GiftType.Relation;
                }

                replyText = FavorUtility.GetGiveGiftDialog(npcData, favorConf, itemBaseConf, feeLevel, failIndex);
                return(false);
            }
            else if (itemBaseConf.NameID == 270956) // wedding ring
            {
                gainValue = 0;
                replyText = string.Empty;
                gType     = GiftType.Normal;
                feeLevel  = FeeLevelEnum.Refuse;
                int failIndex = -1;
                int id        = npcData.id;

                if (Module <MGMgr> .Self.CanMarriage(id, out failIndex) && FavorRelationshipUtil.CheckPropose(id, ref failIndex))
                {
                    gainValue = FavorUtility.GetGiftGainValue(favorConf.FavorValues_Propose, itemBaseConf);
                    feeLevel  = FeeLevelEnum.Propose;
                    gType     = GiftType.Relation;
                }
                else
                {
                    gainValue = 0;
                    feeLevel  = FeeLevelEnum.Refuse;
                    gType     = GiftType.Relation;
                }

                replyText = FavorUtility.GetGiveGiftDialog(npcData, favorConf, itemBaseConf, feeLevel, failIndex);
                return(false);
            }

            return(true);
        }
示例#7
0
        private static void OnGUI(UnityModManager.ModEntry modEntry)
        {
            float infoBoxWidth = (typeof(UnityModManager).GetProperty("Params", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null, new object[] { }) as UnityModManager.Param).WindowWidth * 0.9f;

            if (infoBoxWidth == 0)
            {
                infoBoxWidth = 960;
            }

            float buttonWidthShort = infoBoxWidth / 7f;

            float buttonWidthMedium = infoBoxWidth / 2f;


            if (Module <FavorManager> .Self?.GetAllShowFavorObjects() == null)
            {
                npcContent = null;
                return;
            }
            if (npcContent == null || npcContent.Length != Module <FavorManager> .Self.GetAllShowFavorObjects().Length + 1)
            {
                npcContent = new string[Module <FavorManager> .Self.GetAllShowFavorObjects().Length + 1];
            }

            string[] tempNPC = new string[Module <FavorManager> .Self.GetAllShowFavorObjects().Length];

            for (int i = 0; i < Module <FavorManager> .Self.GetAllShowFavorObjects().Length; i++)
            {
                FavorObject favorObject = Module <FavorManager> .Self.GetAllShowFavorObjects()[i];

                NpcData npcData = Module <FavorManager> .Self.npcData[i];
                string  text    = (npcData == null) ? favorObject.ID.ToString() : npcData.Name;
                string  text2   = (!favorObject.IsDebut) ? string.Empty : "(?) ";
                tempNPC[i] = string.Concat(new object[]
                {
                    text,
                    " ",
                    text2,
                    favorObject.ID,
                    " ",
                    FavorRelationshipUtil.GetGenderRelation(npcData.gender, favorObject.Relationship),
                    " ",
                    favorObject.FavorValue
                });
            }
            tempNPC.CopyTo(npcContent, 0);
            string[] sortedNPC = new string[Module <FavorManager> .Self.GetAllShowFavorObjects().Length + 1];
            Array.Sort(tempNPC);
            tempNPC.CopyTo(sortedNPC, 0);
            npcContent[npcContent.Length - 1] = "All NPCs";
            sortedNPC[sortedNPC.Length - 1]   = "All NPCs";

            GUILayout.Box("NPC Count:" + Module <FavorManager> .Self.GetAllShowFavorObjects().Length, new GUILayoutOption[0]);
            realSelectIndex = GUILayout.SelectionGrid(realSelectIndex, sortedNPC, 2, new GUILayoutOption[]
            {
                GUILayout.Width((float)infoBoxWidth)
            });
            selectIndex = npcContent.IndexOf(sortedNPC[realSelectIndex]);
            GUILayout.Space(10);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (GUILayout.Button("Talk", new GUILayoutOption[]
            {
                GUILayout.Width((float)buttonWidthShort)
            }))
            {
                if (selectIndex < npcContent.Length - 1)
                {
                    FavorObject favorObject2 = Module <FavorManager> .Self.GetAllShowFavorObjects()[selectIndex];

                    IFavorBehavior favorBehavior = favorObject2.FavorBehaviorList.Find((IFavorBehavior it) => it is FavorBehavior_Dialog);
                    favorBehavior.Execute(favorObject2, null);
                    favorObject2.IsDebut = false;
                }
                else
                {
                    foreach (FavorObject favorObject3 in Module <FavorManager> .Self.GetAllShowFavorObjects())
                    {
                        IFavorBehavior favorBehavior2 = favorObject3.FavorBehaviorList.Find((IFavorBehavior it) => it is FavorBehavior_Dialog);
                        favorBehavior2.Execute(favorObject3, null);
                        favorObject3.IsDebut = false;
                    }
                }
            }
            giftIdStr = GUILayout.TextField(giftIdStr, new GUILayoutOption[]
            {
                GUILayout.Width(58f)
            });
            if (GUILayout.Button("Gift", new GUILayoutOption[]
            {
                GUILayout.Width((float)buttonWidthShort)
            }))
            {
                int num;
                int.TryParse(giftIdStr, out num);
                if (selectIndex < npcContent.Length - 1)
                {
                    FavorObject favorObject4 = Module <FavorManager> .Self.GetAllShowFavorObjects()[selectIndex];

                    IFavorBehavior favorBehavior3 = favorObject4.FavorBehaviorList.Find((IFavorBehavior it) => it is FavorBehavior_GiveGift);
                    favorBehavior3.Execute(favorObject4, new object[]
                    {
                        num
                    });
                    favorObject4.IsDebut = false;
                }
                else
                {
                    foreach (FavorObject favorObject5 in Module <FavorManager> .Self.GetAllShowFavorObjects())
                    {
                        IFavorBehavior favorBehavior4 = favorObject5.FavorBehaviorList.Find((IFavorBehavior it) => it is FavorBehavior_GiveGift);
                        favorBehavior4.Execute(favorObject5, new object[]
                        {
                            num
                        });
                        favorObject5.IsDebut = false;
                    }
                }
            }
            addFavor = GUILayout.TextField(addFavor, new GUILayoutOption[]
            {
                GUILayout.Width(40f)
            });
            if (GUILayout.Button("Add", new GUILayoutOption[]
            {
                GUILayout.Width((float)buttonWidthShort)
            }))
            {
                int gainFavorValue;
                int.TryParse(addFavor, out gainFavorValue);
                if (selectIndex < npcContent.Length - 1)
                {
                    FavorObject favorObject6 = Module <FavorManager> .Self.GetAllShowFavorObjects()[selectIndex];

                    favorObject6.GainFavorValue(-1, gainFavorValue, true, true, true);
                    favorObject6.IsDebut = false;
                }
                else
                {
                    foreach (FavorObject favorObject7 in Module <FavorManager> .Self.GetAllShowFavorObjects())
                    {
                        Actor actor = Module <ActorMgr> .Self.Get(favorObject7.ID);

                        if (!(actor == null) && (!(actor != null) || !actor.InFarAwayScene()))
                        {
                            favorObject7.GainFavorValue(-1, gainFavorValue, true, true, true);
                            favorObject7.IsDebut = false;
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10);

            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            if (GUILayout.Button("Love", new GUILayoutOption[]
            {
                GUILayout.Width((float)buttonWidthShort)
            }))
            {
                if (selectIndex < npcContent.Length - 1)
                {
                    FavorObject favorObject10 = Module <FavorManager> .Self.GetAllShowFavorObjects()[selectIndex];

                    FavorUtility.SetNpcRelation(favorObject10.ID, FavorRelationshipId.NormalLover, 0);
                    favorObject10.IsDebut = false;
                }
                else
                {
                    foreach (FavorObject favorObject11 in Module <FavorManager> .Self.GetAllShowFavorObjects())
                    {
                        FavorUtility.SetNpcRelation(favorObject11.ID, FavorRelationshipId.NormalLover, 0);
                        favorObject11.IsDebut = false;
                    }
                }
            }
            if (GUILayout.Button("BreakUp", new GUILayoutOption[]
            {
                GUILayout.Width((float)buttonWidthShort)
            }))
            {
                if (selectIndex < npcContent.Length - 1)
                {
                    FavorObject favorObject12 = Module <FavorManager> .Self.GetAllShowFavorObjects()[selectIndex];

                    FavorRelationLover.Breakup(favorObject12);
                    favorObject12.IsDebut = false;
                }
                else
                {
                    foreach (FavorObject favorObject13 in Module <FavorManager> .Self.GetAllShowFavorObjects())
                    {
                        FavorRelationLover.Breakup(favorObject13);
                        favorObject13.IsDebut = false;
                    }
                }
            }
            if (GUILayout.Button("Marry", new GUILayoutOption[]
            {
                GUILayout.Width((float)buttonWidthShort)
            }))
            {
                if (selectIndex < npcContent.Length - 1)
                {
                    FavorObject favorObject14 = Module <FavorManager> .Self.GetAllShowFavorObjects()[selectIndex];

                    FavorUtility.SetNpcRelation(favorObject14.ID, FavorRelationshipId.NormalCouple, 0);
                    favorObject14.IsDebut = false;
                }
                else
                {
                    foreach (FavorObject favorObject15 in Module <FavorManager> .Self.GetAllShowFavorObjects())
                    {
                        favorObject15.IsDebut = false;
                        FavorUtility.SetNpcRelation(favorObject15.ID, FavorRelationshipId.NormalCouple, 0);
                    }
                }
            }
            if (GUILayout.Button("Divorce", new GUILayoutOption[]
            {
                GUILayout.Width((float)buttonWidthShort)
            }))
            {
                if (selectIndex < npcContent.Length - 1)
                {
                    FavorObject favorObject16 = Module <FavorManager> .Self.GetAllShowFavorObjects()[selectIndex];

                    FavorRelationMarriage.DoDivorce(favorObject16);
                    favorObject16.IsDebut = false;
                }
                else
                {
                    foreach (FavorObject favorObject17 in Module <FavorManager> .Self.GetAllShowFavorObjects())
                    {
                        FavorRelationMarriage.DoDivorce(favorObject17);
                        favorObject17.IsDebut = false;
                    }
                }
            }
            if (GUILayout.Button("Move", new GUILayoutOption[]
            {
                GUILayout.Width((float)buttonWidthShort)
            }))
            {
                if (selectIndex < npcContent.Length - 1)
                {
                    FavorObject favorObject18 = Module <FavorManager> .Self.GetAllShowFavorObjects()[selectIndex];

                    if (favorObject18 != null)
                    {
                        Actor actor2 = StoryHelper.GetActor(favorObject18.ID, string.Empty);
                        if (actor2 == null)
                        {
                            actor2 = Module <NpcRepository> .Self.CreateNpc(favorObject18.ID);

                            Debug.Log(string.Concat(new object[]
                            {
                                "创建NPC->",
                                favorObject18.ID,
                                " Name:",
                                (!actor2) ? "Null" : actor2.ActorName,
                                " 于地点:",
                                Module <Player> .Self.actor.gamePos,
                                new Vector3(0f, 2f, 0f)
                            }));
                        }
                        if (actor2 != null)
                        {
                            actor2.ClearActionQueue();
                            actor2.DoCommand(ACType.Transfer, ACTransferPara.Construct(Module <ScenarioModule> .Self.CurrentScenarioName, Module <Player> .Self.actor.gamePos + new Vector3(0f, 2f, 0f), Vector3.zero));
                        }
                    }
                }
                else
                {
                    foreach (FavorObject favorObject19 in Module <FavorManager> .Self.GetAllShowFavorObjects())
                    {
                        if (favorObject19 != null)
                        {
                            Actor actor3 = StoryHelper.GetActor(favorObject19.ID, string.Empty);
                            if (actor3 == null)
                            {
                                actor3 = Module <NpcRepository> .Self.CreateNpc(favorObject19.ID);

                                Debug.Log(string.Concat(new object[]
                                {
                                    "创建NPC->",
                                    favorObject19.ID,
                                    " Name:",
                                    (!actor3) ? "Null" : actor3.ActorName,
                                    " 于地点:",
                                    Module <Player> .Self.actor.gamePos,
                                    new Vector3(0f, 2f, 0f)
                                }));
                            }
                            if (actor3 != null)
                            {
                                actor3.ClearActionQueue();
                                actor3.DoCommand(ACType.Transfer, ACTransferPara.Construct(Module <ScenarioModule> .Self.CurrentScenarioName, Module <Player> .Self.actor.gamePos + new Vector3(0f, 2f, 0f), Vector3.zero));
                            }
                        }
                    }
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label($"Relation: {Enum.GetName(typeof(FavorRelationshipId), relationEnum[relationId])}", new GUILayoutOption[] { GUILayout.Width(150) });
            relationId = (int)GUILayout.HorizontalSlider(relationId, 0, relationEnum.Length - 1, new GUILayoutOption[0]);
            if (GUILayout.Button("Set", new GUILayoutOption[]
            {
                GUILayout.Width(150)
            }))
            {
                try
                {
                    int relationIdEnum = relationEnum[relationId];
                    if (selectIndex < npcContent.Length - 1)
                    {
                        FavorObject favorObject8 = Module <FavorManager> .Self.GetAllShowFavorObjects()[selectIndex];

                        FavorUtility.SetNpcRelation(favorObject8.ID, (FavorRelationshipId)relationIdEnum, 0);
                        favorObject8.IsDebut = false;
                    }
                    else
                    {
                        foreach (FavorObject favorObject9 in Module <FavorManager> .Self.GetAllShowFavorObjects())
                        {
                            FavorUtility.SetNpcRelation(favorObject9.ID, (FavorRelationshipId)relationIdEnum, 0);
                            favorObject9.IsDebut = false;
                        }
                    }
                }
                catch { }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(20);
        }
示例#8
0
            static void Postfix()
            {
                if (isHugging)
                {
                    //Dbgl($"is hugging: {targetTime}");
                    targetTime -= Time.deltaTime;

                    if (targetTime <= 0.0f)
                    {
                        Dbgl("done hugging");
                        isHugging = false;
                        foreach (Actor a in hugTargets)
                        {
                            ResetOneAnimation(a);
                        }
                        hugTargets.Clear();
                        return;
                    }
                }
                if (!Singleton <GameFlag> .Self.Gaming || (!Input.GetKeyDown(settings.KissKey) && !Input.GetKeyDown(settings.MassageKey) &&
                                                           !Input.GetKeyDown(settings.HugKey)) || UIStateMgr.Instance.currentState.type != UIStateMgr.StateType.Play || Player.Self.actor == null)
                {
                    return;
                }

                Transform pt = Player.Self.actor.transform;

                Vector3 forward = pt.TransformDirection(Vector3.forward);

                List <NpcData> npcs = FieldRefAccess <NpcRepository, List <NpcData> >(NpcRepository.Self, "mNpcInstanceDatas");

                float minDistance = settings.MaxInteractDistance;
                Actor actor       = null;

                foreach (NpcData npcData in npcs)
                {
                    int npc = npcData.id;
                    Dbgl($"Checking for {NpcRepository.Self.GetNpcName(npc)}");
                    Actor other = ActorMgr.Self.Get(npc);
                    if (other == null || !other.InActiveScene)
                    {
                        //Dbgl($"{NpcRepository.Self.GetNpcName(npc)} is not in scene!");
                        continue;
                    }
                    Transform ot      = other.transform;
                    Vector3   toOther = ot.position - pt.position;
                    float     dot     = Vector3.Dot(forward, toOther);
                    if (dot < 0) // behind us
                    {
                        //Dbgl($"{NpcRepository.Self.GetNpcName(npc)} is behind us: {dot}");
                        continue;
                    }

                    float distance = Vector3.Distance(pt.position, ot.position);
                    if (distance < minDistance)
                    {
                        Dbgl($"{NpcRepository.Self.GetNpcName(npc)} is near ({distance}) and in front of us ({dot})");
                        minDistance = distance;
                        actor       = other;
                    }
                }

                if (actor == null)
                {
                    Dbgl("no actor near and in front of us");
                    return;
                }
                int relationship = FavorRelationshipUtil.GetRelationShip(actor.InstanceId);

                Dbgl($"Relationship for {actor.ActorName}: {relationship}");

                if (Input.GetKeyDown(settings.KissKey))
                {
                    Dbgl("kissing");
                    if (settings.KissRelationshipMin > -1 && relationship < settings.KissRelationshipMin)
                    {
                        Singleton <TipsMgr> .Instance.SendSystemTip($"Your relationship with {actor.ActorName} is not high enough to kiss them!", SystemTipType.warning);

                        return;
                    }
                    string modelType = Module <ActorMgr> .Self.GetActorInfo(actor.TmpltId).modelType;

                    DoInteract(Player.Self.actor, actor, 1);
                }
                else if (Input.GetKeyDown(settings.HugKey))
                {
                    Dbgl("hugging");
                    if (settings.HugRelationshipMin > -1 && relationship < settings.HugRelationshipMin)
                    {
                        Singleton <TipsMgr> .Instance.SendSystemTip($"Your relationship with {actor.ActorName} is not high enough to hug them!", SystemTipType.warning);

                        return;
                    }

                    DoInteract(Player.Self.actor, actor, 0);
                }
                else if (Input.GetKeyDown(settings.MassageKey))
                {
                    Dbgl("getting massaged");
                    if (settings.MassageRelationshipMin > -1 && relationship < settings.MassageRelationshipMin)
                    {
                        Singleton <TipsMgr> .Instance.SendSystemTip($"Your relationship with {actor.ActorName} is not high enough to get a massage from them!", SystemTipType.warning);

                        return;
                    }

                    DoInteract(Player.Self.actor, actor, 2);
                }
            }