Esempio n. 1
0
        private static void ReplaceIfOldItem(IList <Item> items, int i)
        {
            Item item = items[i];

            if (item?.Name != null)
            {
                if (item.Name.Contains("ButcherMod.MeatCleaver") || item.Name.Contains("AnimalHusbandryMod.tools.MeatCleaver"))
                {
                    items[i] = ToolsFactory.GetMeatCleaver();
                    AnimalHusbandryModEntry.monitor.Log($"An older version of the MeatCleaver found. Replacing it with the new one.", LogLevel.Debug);
                }
                else if (item.Name.Contains("ButcherMod.tools.InseminationSyringe") || item.Name.Contains("AnimalHusbandryMod.tools.InseminationSyringe"))
                {
                    items[i] = ToolsFactory.GetInseminationSyringe();
                    AnimalHusbandryModEntry.monitor.Log($"An older version of the InseminationSyringe found. Replacing it with the new one.", LogLevel.Debug);
                }
                else if (item.Name.Contains("AnimalHusbandryMod.tools.FeedingBasket"))
                {
                    items[i] = ToolsFactory.GetFeedingBasket();
                    AnimalHusbandryModEntry.monitor.Log($"An older version of the FeedingBasket found. Replacing it with the new one.", LogLevel.Debug);
                }
                else if (item.Name.Contains("AnimalHusbandryMod.tools.ParticipantRibbon"))
                {
                    items[i] = ToolsFactory.GetParticipantRibbon();
                    AnimalHusbandryModEntry.monitor.Log($"An older version of the ParticipantRibbon found. Replacing it with the new one.", LogLevel.Debug);
                }
            }
        }
Esempio n. 2
0
        public static bool getOne(MilkPail __instance, ref Item __result)
        {
            if (!IsInseminationSyringe(__instance))
            {
                return(true);
            }

            __result = (Item)ToolsFactory.GetInseminationSyringe();
            return(false);
        }
Esempio n. 3
0
        public static bool getOne(Axe __instance, ref Item __result)
        {
            if (!IsMeatCleaver(__instance))
            {
                return(true);
            }

            __result = (Item)ToolsFactory.GetMeatCleaver();
            return(false);
        }
        public static bool getOne(MilkPail __instance, ref Item __result)
        {
            if (!IsFeedingBasket(__instance))
            {
                return(true);
            }

            __result = (Item)ToolsFactory.GetFeedingBasket();
            return(false);
        }
        public static bool getOne(MilkPail __instance, ref Item __result)
        {
            if (!IsParticipantRibbon(__instance))
            {
                return(true);
            }

            __result = (Item)ToolsFactory.GetParticipantRibbon();
            return(false);
        }
Esempio n. 6
0
        public void LoadMail()
        {
            string meatCleaverText  = DataLoader.i18n.Get(DataLoader.ModConfig.Softmode ? "Tool.MeatCleaver.Letter.Soft" : "Tool.MeatCleaver.Letter");
            string meatCleaverTitle = DataLoader.i18n.Get(DataLoader.ModConfig.Softmode ? "Tool.MeatCleaver.Letter.Soft.Title" : "Tool.MeatCleaver.Letter.Title");

            bool HasAnimal()
            {
                return(Game1.locations.Any((location) =>
                {
                    if (location is Farm farm)
                    {
                        return farm.buildings
                        .Any((b => (b.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Count > 0));
                    }
                    return false;
                }));
            }

            bool MeatCleaverCondition(Letter l)
            {
                return(!DataLoader.ModConfig.DisableMeatToolLetter && HasAnimal() && (!ItemUtility.HasModdedItem(MeatCleaverOverrides.MeatCleaverKey) || !Game1.player.mailReceived.Contains(l.Id)));
            }

            List <string> validBuildingsForInsemination = new List <string>(new string[] { "Deluxe Barn", "Big Barn", "Deluxe Coop" });

            bool InseminationSyringeCondition(Letter l)
            {
                bool hasAnimalInValidBuildings = Game1.locations.Any((location) =>
                {
                    if (location is Farm farm)
                    {
                        return(farm.buildings
                               .Any((b) => (b.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Count > 0 && validBuildingsForInsemination.Contains(((AnimalHouse)b.indoors.Value)?.Name)));
                    }
                    return(false);
                });

                return(hasAnimalInValidBuildings && (!ItemUtility.HasModdedItem(InseminationSyringeOverrides.InseminationSyringeKey) || !Game1.player.mailReceived.Contains(l.Id)));
            }

            bool FeedingBasketCondition(Letter l)
            {
                return(!Game1.player.mailReceived.Contains(l.Id) && Game1.player.getFriendshipHeartLevelForNPC("Marnie") >= 2 && (Game1.player.hasPet() || HasAnimal()));
            }

            bool FeedingBasketRedeliveryCondition(Letter l)
            {
                return(Game1.player.mailReceived.Contains("feedingBasket") && !ItemUtility.HasModdedItem(FeedingBasketOverrides.FeedingBasketKey) && Game1.player.getFriendshipHeartLevelForNPC("Marnie") >= 6);
            }

            if (!DataLoader.ModConfig.DisableMeat)
            {
                Letter meatCleaverLetter = new Letter("meatCleaver", meatCleaverText, new List <Item> {
                    ToolsFactory.GetMeatCleaver()
                }, MeatCleaverCondition, (l) => { if (!Game1.player.mailReceived.Contains(l.Id))
                                                  {
                                                      Game1.player.mailReceived.Add(l.Id);
                                                  }
                    })
                {
                    GroupId = "AHM.InterdimentionalFriend",
                    Title   = meatCleaverTitle
                };
                meatCleaverLetter.LetterTexture = _customLetterBG;
                meatCleaverLetter.TextColor     = 4;
                MailDao.SaveLetter(meatCleaverLetter);
            }

            if (!DataLoader.ModConfig.DisablePregnancy)
            {
                Letter inseminationSyringeLetter = new Letter("inseminationSyringe", DataLoader.i18n.Get("Tool.InseminationSyringe.Letter"), new List <Item> {
                    ToolsFactory.GetInseminationSyringe()
                }, InseminationSyringeCondition, (l) => { if (!Game1.player.mailReceived.Contains(l.Id))
                                                          {
                                                              Game1.player.mailReceived.Add(l.Id);
                                                          }
                    })
                {
                    GroupId = "AHM.InterdimentionalFriend",
                    Title   = DataLoader.i18n.Get("Tool.InseminationSyringe.Letter.Title")
                };
                inseminationSyringeLetter.LetterTexture = _customLetterBG;
                inseminationSyringeLetter.TextColor     = 4;
                MailDao.SaveLetter(inseminationSyringeLetter);
            }

            if (!DataLoader.ModConfig.DisableAnimalContest)
            {
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "participantRibbon"
                        , DataLoader.i18n.Get("Tool.ParticipantRibbon.Letter")
                        , new List <Item> {
                    ToolsFactory.GetParticipantRibbon()
                }
                        , (l) => SDate.Now().AddDays(1).Equals(AnimalContestController.GetNextContestDate()) && AnimalContestController.GetContestCount() == 0 && !Game1.player.mailReceived.Contains(l.Id + AnimalContestController.GetNextContestDateKey())
                        , (l) =>
                {
                    Game1.player.mailReceived.Add(l.Id + AnimalContestController.GetNextContestDateKey());
                    if (!Game1.player.mailReceived.Contains(l.Id))
                    {
                        Game1.player.mailReceived.Add(l.Id);
                    }
                })
                {
                    Title = DataLoader.i18n.Get("Tool.ParticipantRibbon.Letter.Title")
                }
                );
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "participantRibbonRedelivery"
                        , DataLoader.i18n.Get("Tool.ParticipantRibbon.LetterRedelivery")
                        , new List <Item> {
                    ToolsFactory.GetParticipantRibbon()
                }
                        , (l) => SDate.Now().AddDays(1).Equals(AnimalContestController.GetNextContestDate()) && AnimalContestController.GetContestCount() > 0 && !Game1.player.mailReceived.Contains(l.Id + AnimalContestController.GetNextContestDateKey())
                        , (l) =>
                {
                    Game1.player.mailReceived.Add(l.Id + AnimalContestController.GetNextContestDateKey());
                    if (!Game1.player.mailReceived.Contains(l.Id))
                    {
                        Game1.player.mailReceived.Add(l.Id);
                    }
                })
                {
                    Title = DataLoader.i18n.Get("Tool.ParticipantRibbon.LetterRedelivery.Title")
                }
                );
            }

            if (!DataLoader.ModConfig.DisableTreats)
            {
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "feedingBasket",
                        DataLoader.i18n.Get("Tool.FeedingBasket.Letter"),
                        new List <Item> {
                    ToolsFactory.GetFeedingBasket()
                },
                        FeedingBasketCondition,
                        (l) => { if (!Game1.player.mailReceived.Contains(l.Id))
                                 {
                                     Game1.player.mailReceived.Add(l.Id);
                                 }
                        }
                    )
                {
                    Title = DataLoader.i18n.Get("Tool.FeedingBasket.Letter.Title")
                }
                );
                MailDao.SaveLetter
                (
                    new Letter
                    (
                        "feedingBasketRedelivery",
                        DataLoader.i18n.Get("Tool.FeedingBasket.LetterRedelivery"),
                        new List <Item> {
                    ToolsFactory.GetFeedingBasket()
                },
                        FeedingBasketRedeliveryCondition,
                        (l) => { if (!Game1.player.mailReceived.Contains(l.Id))
                                 {
                                     Game1.player.mailReceived.Add(l.Id);
                                 }
                        }
                    )
                {
                    Title = DataLoader.i18n.Get("Tool.FeedingBasket.LetterRedelivery.Title")
                }
                );
            }
        }