Пример #1
0
        public static bool FarmHouse_getSpouseBedSpot_Prefix(FarmHouse __instance, string spouseName, ref Point __result)
        {
            try
            {
                if (spouseName == null || !Config.EnableMod)
                {
                    return(true);
                }
                var spouses = ModEntry.GetSpouses(__instance.owner, true);

                if (!spouses.TryGetValue(spouseName, out NPC spouse) || spouse is null || spouse.isMoving() || !ModEntry.IsInBed(__instance, spouse.GetBoundingBox()))
                {
                    return(true);
                }

                __result = spouse.getTileLocationPoint();
                return(false);
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(FarmHouse_GetSpouseBed_Postfix)}:\n{ex}", LogLevel.Error);
            }
            return(true);
        }
Пример #2
0
 public Dictionary <string, NPC> GetSpouses(Farmer farmer, int all = -1)
 {
     return(ModEntry.GetSpouses(farmer, all != 0));
 }
Пример #3
0
 public void PlaceSpousesInFarmhouse(FarmHouse farmHouse)
 {
     ModEntry.PlaceSpousesInFarmhouse(farmHouse);
 }
Пример #4
0
 public Dictionary <string, NPC> GetSpouses(Farmer farmer, bool all = true)
 {
     return(ModEntry.GetSpouses(farmer, all));
 }
Пример #5
0
        public static void afterDialogueBehavior(Farmer who, string whichAnswer)
        {
            Monitor.Log("answer " + whichAnswer);

            if (ModEntry.GetSpouses(who, true).ContainsKey(whichAnswer))
            {
                Monitor.Log("divorcing " + whichAnswer);
                string s2 = Game1.content.LoadString("Strings\\Locations:ManorHouse_DivorceBook_Question_" + whichAnswer, whichAnswer);
                if (s2 == null || s2 == "Strings\\Locations:ManorHouse_DivorceBook_Question_" + whichAnswer)
                {
                    s2 = Game1.content.LoadStringReturnNullIfNotFound("Strings\\Locations:ManorHouse_DivorceBook_Question");
                }
                List <Response> responses = new List <Response>();
                responses.Add(new Response($"divorce_Yes_{whichAnswer}", Game1.content.LoadString("Strings\\Lexicon:QuestionDialogue_Yes")));
                if (Config.ComplexDivorce)
                {
                    responses.Add(new Response($"divorce_complex_{whichAnswer}", Helper.Translation.Get("divorce_complex")));
                }
                responses.Add(new Response("No", Game1.content.LoadString("Strings\\Lexicon:QuestionDialogue_No")));
                (Game1.activeClickableMenu as DialogueBox)?.closeDialogue();
                Game1.currentLocation.createQuestionDialogue(s2, responses.ToArray(), afterDialogueBehavior);
            }
            else if (whichAnswer.StartsWith("divorce_Yes_"))
            {
                Monitor.Log("confirmed " + whichAnswer);
                string spouse = whichAnswer.Split('_')[2];
                if (Game1.player.Money >= 50000 || spouse == "Krobus")
                {
                    Monitor.Log("divorce initiated successfully");
                    if (!Game1.player.isRoommate(spouse))
                    {
                        Game1.player.Money        -= 50000;
                        ModEntry.divorceHeartsLost = Config.PreventHostileDivorces ? 0 : -1;
                    }
                    else
                    {
                        ModEntry.divorceHeartsLost = 0;
                    }
                    ModEntry.spouseToDivorce          = spouse;
                    Game1.player.divorceTonight.Value = true;
                    string s = Game1.content.LoadString("Strings\\Locations:ManorHouse_DivorceBook_Filed_" + spouse, spouse);
                    if (s == null)
                    {
                        s = Game1.content.LoadStringReturnNullIfNotFound("Strings\\Locations:ManorHouse_DivorceBook_Filed");
                    }
                    Game1.drawObjectDialogue(s);
                    if (!Game1.player.isRoommate(spouse))
                    {
                        ModEntry.mp.globalChatInfoMessage("Divorce", new string[]
                        {
                            Game1.player.Name
                        });
                    }
                }
                else
                {
                    Monitor.Log("not enough money to divorce");
                    Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\UI:NotEnoughMoney1"));
                }
            }
            else if (whichAnswer.StartsWith("divorce_complex_"))
            {
                complexDivorceSpouse       = whichAnswer.Replace("divorce_complex_", "");
                ModEntry.divorceHeartsLost = 1;
                ShowNextDialogue("divorce_fault_", Game1.currentLocation);
            }
            else if (whichAnswer.StartsWith("divorce_fault_"))
            {
                Monitor.Log("divorce fault");
                string r = Helper.Translation.Get(whichAnswer);
                if (r != null)
                {
                    if (int.TryParse(r.Split('#')[r.Split('#').Length - 1], out int lost))
                    {
                        ModEntry.divorceHeartsLost += lost;
                    }
                }
                string      nextKey = $"divorce_{r.Split('#')[r.Split('#').Length - 2]}reason_";
                Translation test    = Helper.Translation.Get(nextKey + "q");
                if (!test.HasValue())
                {
                    ShowNextDialogue($"divorce_method_", Game1.currentLocation);
                    return;
                }
                ShowNextDialogue($"divorce_{r.Split('#')[r.Split('#').Length - 2]}reason_", Game1.currentLocation);
            }
            else if (whichAnswer.Contains("reason_"))
            {
                Monitor.Log("divorce reason");
                string r = Helper.Translation.Get(whichAnswer);
                if (r != null)
                {
                    if (int.TryParse(r.Split('#')[r.Split('#').Length - 1], out int lost))
                    {
                        ModEntry.divorceHeartsLost += lost;
                    }
                }

                ShowNextDialogue($"divorce_method_", Game1.currentLocation);
            }
            else if (whichAnswer.StartsWith("divorce_method_"))
            {
                Monitor.Log("divorce method");
                ModEntry.spouseToDivorce = complexDivorceSpouse;
                string r = Helper.Translation.Get(whichAnswer);
                if (r != null)
                {
                    if (int.TryParse(r.Split('#')[r.Split('#').Length - 1], out int lost))
                    {
                        ModEntry.divorceHeartsLost += lost;
                    }
                }

                if (Game1.player.Money >= 50000 || complexDivorceSpouse == "Krobus")
                {
                    if (!Game1.player.isRoommate(complexDivorceSpouse))
                    {
                        int money = 50000;
                        if (int.TryParse(r.Split('#')[r.Split('#').Length - 2], out int mult))
                        {
                            money = (int)Math.Round(money * mult / 100f);
                        }
                        Monitor.Log($"money cost {money}");
                        Game1.player.Money -= money;
                    }
                    Game1.player.divorceTonight.Value = true;
                    string s = Game1.content.LoadString("Strings\\Locations:ManorHouse_DivorceBook_Filed_" + complexDivorceSpouse, complexDivorceSpouse);
                    if (s == null || s == "Strings\\Locations:ManorHouse_DivorceBook_Filed_" + complexDivorceSpouse)
                    {
                        s = Game1.content.LoadStringReturnNullIfNotFound("Strings\\Locations:ManorHouse_DivorceBook_Filed");
                    }
                    Game1.drawObjectDialogue(s);
                    if (!Game1.player.isRoommate(complexDivorceSpouse))
                    {
                        ModEntry.mp.globalChatInfoMessage("Divorce", new string[]
                        {
                            Game1.player.Name
                        });
                    }
                    Monitor.Log($"hearts lost {ModEntry.divorceHeartsLost}");
                }
                else
                {
                    Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\UI:NotEnoughMoney1"));
                }
            }
        }