Exemplo n.º 1
0
 public static void LoadSpouseAreaData()
 {
     if (!Config.EnableMod)
     {
         return;
     }
     if (!Context.IsMainPlayer)
     {
         SMonitor.Log($"Not the host player, this copy of the mod will not do anything.", LogLevel.Warn);
         return;
     }
     outdoorAreas = SHelper.Data.ReadSaveData <OutdoorAreaData>(saveKey) ?? new OutdoorAreaData();
     if (outdoorAreas.areas != null)
     {
         foreach (var area in outdoorAreas.areas)
         {
             outdoorAreas.dict.Add(area.Key, new OutdoorArea()
             {
                 location = Game1.getFarm().Name, corner = area.Value
             });
         }
     }
     foreach (var area in outdoorAreas.dict)
     {
         CacheOffBasePatioArea(area.Key);
     }
     SMonitor.Log($"Total outdoor spouse areas: {outdoorAreas.dict.Count}", LogLevel.Debug);
 }
Exemplo n.º 2
0
 private void GameLoop_ReturnedToTitle(object sender, ReturnedToTitleEventArgs e)
 {
     spousePositions.Clear();
     outdoorAreas = new OutdoorAreaData();
 }
Exemplo n.º 3
0
        public void CSPWizardDialogue(string whichQuestion, string whichAnswer, int page = 0)
        {
            Monitor.Log($"question: {whichQuestion}, answer: {whichAnswer}");
            if (whichAnswer == "cancel")
            {
                return;
            }

            List <Response> responses   = new List <Response>();
            string          header      = "";
            string          newQuestion = whichAnswer;

            switch (whichQuestion)
            {
            case "CSP_Wizard_Questions":
                switch (whichAnswer)
                {
                case "CSP_Wizard_Questions_AddPatio":
                    if (cursorLoc.X > Game1.player.currentLocation.map.Layers[0].LayerWidth - 4 || cursorLoc.Y > Game1.player.currentLocation.map.Layers[0].LayerWidth - 4)
                    {
                        Game1.drawObjectDialogue(string.Format(Helper.Translation.Get("cursor-out-of-bounds"), cursorLoc.X, cursorLoc.Y));
                        return;
                    }
                    header = Helper.Translation.Get("new-patio-which");
                    if (page > 0)
                    {
                        responses.Add(new Response("last", "..."));
                    }
                    foreach (string spouse in noCustomAreaSpouses.Skip(page * Config.MaxSpousesPerPage).Take(Config.MaxSpousesPerPage))
                    {
                        responses.Add(new Response(spouse, spouse));
                    }
                    if (noCustomAreaSpouses.Count > (page + 1) * Config.MaxSpousesPerPage)
                    {
                        responses.Add(new Response("next", "..."));
                    }
                    break;

                case "CSP_Wizard_Questions_MovePatio":
                    header = Helper.Translation.Get("move-patio-which");
                    if (page > 0)
                    {
                        responses.Add(new Response("last", "..."));
                    }
                    foreach (string spouse in outdoorAreas.dict.Keys.Skip(page * Config.MaxSpousesPerPage).Take(Config.MaxSpousesPerPage))
                    {
                        responses.Add(new Response(spouse, spouse));
                    }
                    if (outdoorAreas.dict.Keys.Count > (page + 1) * Config.MaxSpousesPerPage)
                    {
                        responses.Add(new Response("next", "..."));
                    }
                    break;

                case "CSP_Wizard_Questions_RemovePatio":
                    header = Helper.Translation.Get("remove-patio-which");
                    if (page > 0)
                    {
                        responses.Add(new Response("last", "..."));
                    }
                    foreach (string spouse in outdoorAreas.dict.Keys.Skip(page * Config.MaxSpousesPerPage).Take(Config.MaxSpousesPerPage))
                    {
                        responses.Add(new Response(spouse, spouse));
                    }
                    if (outdoorAreas.dict.Keys.Count > (page + 1) * Config.MaxSpousesPerPage)
                    {
                        responses.Add(new Response("next", "..."));
                    }
                    break;

                case "CSP_Wizard_Questions_ListPatios":
                    Game1.drawObjectDialogue(string.Format(Helper.Translation.Get("patios-exist-for"), string.Join(", ", outdoorAreas.dict.Keys)));
                    return;

                case "CSP_Wizard_Questions_ReloadPatios":
                    outdoorAreas = Helper.Data.ReadSaveData <OutdoorAreaData>(saveKey);
                    Game1.getFarm().UpdatePatio();
                    Game1.drawObjectDialogue(string.Format(Helper.Translation.Get("reloaded-patios"), outdoorAreas.dict.Count));
                    return;
                }
                break;

            case "CSP_Wizard_Questions_AddPatio":
                if (whichAnswer == "next")
                {
                    CSPWizardDialogue("CSP_Wizard_Questions", "CSP_Wizard_Questions_AddPatio", page + 1);
                    return;
                }
                if (whichAnswer == "last")
                {
                    CSPWizardDialogue("CSP_Wizard_Questions", "CSP_Wizard_Questions_AddPatio", page - 1);
                    return;
                }
                if (cursorLoc.X > Game1.player.currentLocation.map.Layers[0].LayerWidth - 4 || cursorLoc.Y > Game1.player.currentLocation.map.Layers[0].LayerWidth - 4)
                {
                    Game1.drawObjectDialogue(string.Format(Helper.Translation.Get("cursor-out-of-bounds"), cursorLoc.X, cursorLoc.Y));
                    return;
                }
                ReapplyBasePatioArea();
                if (AccessTools.FieldRefAccess <GameLocation, HashSet <string> >(Game1.getFarm(), "_appliedMapOverrides").Contains("spouse_patio"))
                {
                    AccessTools.FieldRefAccess <GameLocation, HashSet <string> >(Game1.getFarm(), "_appliedMapOverrides").Remove("spouse_patio");
                }
                if (AccessTools.FieldRefAccess <GameLocation, HashSet <string> >(Game1.getFarm(), "_appliedMapOverrides").Contains(whichAnswer + "_spouse_patio"))
                {
                    AccessTools.FieldRefAccess <GameLocation, HashSet <string> >(Game1.getFarm(), "_appliedMapOverrides").Remove(whichAnswer + "_spouse_patio");
                }
                outdoorAreas.dict[whichAnswer] = new OutdoorArea()
                {
                    location = Game1.player.currentLocation.Name, corner = cursorLoc.ToVector2()
                };
                CacheOffBasePatioArea(whichAnswer);
                Game1.getFarm().UpdatePatio();
                if (Game1.getCharacterFromName(whichAnswer)?.shouldPlaySpousePatioAnimation.Value == true)
                {
                    Game1.getCharacterFromName(whichAnswer).setUpForOutdoorPatioActivity();
                }

                Game1.drawObjectDialogue(string.Format(Helper.Translation.Get("created-patio"), cursorLoc.X, cursorLoc.Y));
                return;

            case "CSP_Wizard_Questions_MovePatio":
                if (whichAnswer == "next")
                {
                    CSPWizardDialogue("CSP_Wizard_Questions", "CSP_Wizard_Questions_MovePatio", page + 1);
                    return;
                }
                if (whichAnswer == "last")
                {
                    CSPWizardDialogue("CSP_Wizard_Questions", "CSP_Wizard_Questions_MovePatio", page - 1);
                    return;
                }
                header      = Helper.Translation.Get("move-patio-which-way");
                newQuestion = "CSP_Wizard_Questions_MovePatio_2";
                responses.Add(new Response($"{whichAnswer}_cursorLoc", string.Format(Helper.Translation.Get("cursor-location"), cursorLoc.X, cursorLoc.Y)));
                responses.Add(new Response($"{whichAnswer}_up", Helper.Translation.Get("up")));
                responses.Add(new Response($"{whichAnswer}_down", Helper.Translation.Get("down")));
                responses.Add(new Response($"{whichAnswer}_left", Helper.Translation.Get("left")));
                responses.Add(new Response($"{whichAnswer}_right", Helper.Translation.Get("right")));
                break;

            case "CSP_Wizard_Questions_MovePatio_2":
                if (MoveSpousePatio(whichAnswer, cursorLoc))
                {
                    Game1.drawObjectDialogue(string.Format(Helper.Translation.Get("moved-patio"), whichAnswer.Split('_')[0]));
                }
                else
                {
                    Game1.drawObjectDialogue(string.Format(Helper.Translation.Get("not-moved-patio"), whichAnswer.Split('_')[0]));
                }
                return;

            case "CSP_Wizard_Questions_RemovePatio":
                if (whichAnswer == "next")
                {
                    CSPWizardDialogue("CSP_Wizard_Questions", "CSP_Wizard_Questions_RemovePatio", page + 1);
                    return;
                }
                if (whichAnswer == "last")
                {
                    CSPWizardDialogue("CSP_Wizard_Questions", "CSP_Wizard_Questions_RemovePatio", page - 1);
                    return;
                }
                if (outdoorAreas.dict.ContainsKey(whichAnswer))
                {
                    ReapplyBasePatioArea(whichAnswer);
                    outdoorAreas.dict.Remove(whichAnswer);
                    baseSpouseAreaTiles.Remove(whichAnswer);
                    Game1.getFarm().UpdatePatio();
                    Game1.drawObjectDialogue(string.Format(Helper.Translation.Get("removed-patio"), whichAnswer));
                }
                else
                {
                    Game1.drawObjectDialogue(string.Format(Helper.Translation.Get("not-removed-patio"), whichAnswer));
                }
                return;

            default:
                return;
            }
            responses.Add(new Response("cancel", Helper.Translation.Get("cancel")));
            Game1.player.currentLocation.createQuestionDialogue($"{header}", responses.ToArray(), newQuestion);
        }