public static void FeedHorse(HorseOverhaul mod, HorseWrapper horseW, Item currentItem, int friendship) { if (horseW.GotFed && !mod.Config.AllowMultipleFeedingsADay) { Game1.drawObjectDialogue(mod.Helper.Translation.Get("AteEnough", new { name = horseW.Horse.displayName })); } else { string translation = mod.Helper.Translation.Get("AteFood", new { name = horseW.Horse.displayName, foodName = currentItem.DisplayName }); if (mod.Config.NewFoodSystem) { string translationKey; if (friendship <= 5) { translationKey = "AteFoodDislike"; } else if (friendship >= 15) { translationKey = "AteFoodLove"; } else { translationKey = "AteFoodLike"; } translation += " " + mod.Helper.Translation.Get(translationKey); } Game1.drawObjectDialogue(translation); if (mod.Config.ThinHorse) { horseW.Horse.doEmote(Character.happyEmote); } Game1.player.reduceActiveItemByOne(); horseW.JustGotFood(friendship); } }
private bool CheckHorseInteraction(GameLocation currentLocation, int x, int y, bool wasController) { // Find if click was on Horse foreach (Horse horse in currentLocation.characters.OfType <Horse>()) { // Can only feed your own horse if (horse.getOwner() != Game1.player || IsTractor(horse)) { continue; } HorseWrapper horseW = null; Horses.Where(h => h.Horse == horse).Do(h => horseW = h); if (horseW == null) { continue; } if (IsInRange(horse, x, y, wasController)) { if (Game1.player.CurrentItem != null && Config.Feeding) { // Holding food Item currentItem = Game1.player.CurrentItem; if (IsEdible(currentItem)) { if (horseW.GotFed) { Game1.drawObjectDialogue(Helper.Translation.Get("AteEnough", new { name = horse.displayName })); } else { Game1.drawObjectDialogue(Helper.Translation.Get("AteFood", new { name = horse.displayName, foodName = currentItem.DisplayName })); if (Config.ThinHorse) { horse.doEmote(Character.happyEmote); } Game1.player.reduceActiveItemByOne(); horseW.JustGotFood(CalculateExpGain(currentItem, horseW.Friendship)); } return(true); } } if (Context.IsWorldReady && Context.CanPlayerMove && Context.IsPlayerFree && Config.SaddleBag) { if (horseW.SaddleBag != null) { horseW.SaddleBag.ShowMenu(); return(true); } } } } return(false); }
private void CheckHorseInteraction(GameLocation currentLocation, int x, int y, bool wasController) { // Find if click was on Horse foreach (Horse horse in currentLocation.characters.OfType <Horse>()) { // Can only feed your own horse if (horse.getOwner() != Game1.player || IsTractor(horse)) { continue; } HorseWrapper horseW = null; Horses.Where(h => h.Horse == horse).Do(h => horseW = h); if (horseW == null) { continue; } if (IsInRange(horse, x, y, wasController)) { if (Game1.player.CurrentItem != null && Config.Feeding) { // Holding food Item currentItem = Game1.player.CurrentItem; if (IsEdible(currentItem)) { Item food = Game1.player.CurrentItem; if (horseW.GotFed) { Game1.drawObjectDialogue(Helper.Translation.Get("AteEnough", new { name = horse.displayName })); } else { Game1.drawObjectDialogue(Helper.Translation.Get("AteFood", new { name = horse.displayName, foodName = food.DisplayName })); if (Config.ThinHorse) { horse.doEmote(Character.happyEmote); } Game1.player.reduceActiveItemByOne(); horseW.JustGotFood(CalculateExpGain(currentItem, horseW.Friendship)); } return; } } if (Context.IsWorldReady && Context.CanPlayerMove && Context.IsPlayerFree && Config.SaddleBag) { if (horseW.SaddleBag != null) { horseW.SaddleBag.ShowMenu(); return; } } } } if (Config.PetFeeding && Game1.player.hasPet()) { Pet pet = Game1.player.getPet(); if (pet != null) { if (IsInRange(pet, x, y, wasController)) { if (Game1.player.CurrentItem != null) { // Holding food Item currentItem = Game1.player.CurrentItem; if (IsEdible(currentItem)) { Item food = Game1.player.CurrentItem; if (pet?.modData?.TryGetValue($"{ModManifest.UniqueID}/gotFed", out _) == true) { Game1.drawObjectDialogue(Helper.Translation.Get("AteEnough", new { name = pet.displayName })); } else { pet.modData.Add($"{ModManifest.UniqueID}/gotFed", "fed"); Game1.drawObjectDialogue(Helper.Translation.Get("AteFood", new { name = pet.displayName, foodName = food.DisplayName })); pet.doEmote(Character.happyEmote); Game1.player.reduceActiveItemByOne(); pet.friendshipTowardFarmer.Set(Math.Min(1000, pet.friendshipTowardFarmer.Value + CalculateExpGain(currentItem, pet.friendshipTowardFarmer.Value))); } return; } } } } } }