public static bool CheckHorseInteraction(HorseOverhaul mod, GameLocation currentLocation, int mouseX, int mouseY, bool ignoreMousePosition) { foreach (Horse horse in currentLocation.characters.OfType <Horse>()) { // check if the interaction was a mouse click on a horse or a button press near a horse if (horse != null && !horse.IsTractor() && IsInRange(horse, mouseX, mouseY, ignoreMousePosition)) { HorseWrapper horseW = null; mod.Horses.Where(h => h?.Horse?.HorseId == horse.HorseId).Do(h => horseW = h); if (Game1.player.CurrentItem != null && mod.Config.Feeding) { Item currentItem = Game1.player.CurrentItem; if (mod.Config.NewFoodSystem) { var potentialhorseFood = HorseFoodData.ClassifyHorseFood(currentItem); if (potentialhorseFood.IsHorseFood) { int friendship = potentialhorseFood.FriendshipOnFeed; FeedHorse(mod, horseW, currentItem, friendship); return(true); } else if (potentialhorseFood.ReplyOnFeed != null) { Game1.drawObjectDialogue(mod.Helper.Translation.Get(potentialhorseFood.ReplyOnFeed)); return(false); } // don't return here so we can fall into the saddle bag case } else if (FoodData.IsGenericEdible(currentItem)) { int friendship = FoodData.CalculateGenericFriendshipGain(currentItem, horseW.Friendship); FeedHorse(mod, horseW, currentItem, friendship); return(true); } } if (Context.IsWorldReady && Context.CanPlayerMove && Context.IsPlayerFree && mod.Config.SaddleBag) { if (horseW.SaddleBag != null) { horseW.SaddleBag.ShowMenu(); return(true); } } } } return(false); }
public static bool CheckPetInteraction(HorseOverhaul mod, int mouseX, int mouseY, bool ignoreMousePosition) { if (!mod.Config.PetFeeding || !Game1.player.hasPet()) { return(false); } Pet pet = Game1.player.getPet(); if (pet != null && IsInRange(pet, mouseX, mouseY, ignoreMousePosition)) { if (Game1.player.CurrentItem != null) { Item currentItem = Game1.player.CurrentItem; if (mod.Config.NewFoodSystem) { if (FoodData.IsDairyProduct(currentItem)) { Game1.drawObjectDialogue(mod.Helper.Translation.Get("LactoseIntolerantPets")); return(false); } else if (FoodData.IsChocolate(currentItem)) { Game1.drawObjectDialogue(mod.Helper.Translation.Get("DontFeedChocolate")); return(false); } else if (PetFoodData.IsPetFood(currentItem)) { int friendship = PetFoodData.CalculatePetFriendshipGain(currentItem); FeedPet(mod, pet, currentItem, friendship); return(true); } } else if (FoodData.IsGenericEdible(currentItem)) { int friendship = FoodData.CalculateGenericFriendshipGain(currentItem, pet.friendshipTowardFarmer.Value); FeedPet(mod, pet, currentItem, friendship); return(true); } } } return(false); }