public static void SetUpModConfigMenu(HorseConfig config, HorseOverhaul mod)
        {
            GenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <GenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(manifest, () => config = new HorseConfig(), delegate { mod.Helper.WriteConfig(config); VerifyConfigValues(config, mod); });

            api.RegisterLabel(manifest, "General", null);

            api.RegisterSimpleOption(manifest, "Thin Horse", null, () => config.ThinHorse, (bool val) => config.ThinHorse = val);
            api.RegisterSimpleOption(manifest, "Saddle Bag", null, () => config.SaddleBag, (bool val) => config.SaddleBag = val);

            api.RegisterLabel(manifest, "Friendship", null);

            api.RegisterSimpleOption(manifest, "Movement Speed (MS)", null, () => config.MovementSpeed, (bool val) => config.MovementSpeed = val);
            api.RegisterSimpleOption(manifest, "Maximum MS Bonus", null, () => config.MaxMovementSpeedBonus, (float val) => config.MaxMovementSpeedBonus = val);
            api.RegisterSimpleOption(manifest, "Petting", null, () => config.Petting, (bool val) => config.Petting = val);
            api.RegisterSimpleOption(manifest, "Water", null, () => config.Water, (bool val) => config.Water       = val);
            api.RegisterSimpleOption(manifest, "Feeding", null, () => config.Feeding, (bool val) => config.Feeding = val);

            api.RegisterLabel(manifest, "Other", null);

            api.RegisterSimpleOption(manifest, "Disable Stable Sprites", null, () => config.DisableStableSpriteChanges, (bool val) => config.DisableStableSpriteChanges = val);
            api.RegisterSimpleOption(manifest, "Pet Feeding", null, () => config.PetFeeding, (bool val) => config.PetFeeding = val);

            api.RegisterLabel(manifest, "(Menu Key Rebinding Only Available In Config File)", null);
        }
Example #2
0
        public static void CheckForWaterHit(ref Tool t, ref int tileX, ref int tileY)
        {
            try
            {
                if (!Context.IsWorldReady || !mod.Config.Water)
                {
                    return;
                }

                if (t is WateringCan && (t as WateringCan).WaterLeft > 0)
                {
                    foreach (Building building in Game1.getFarm().buildings)
                    {
                        if (building is Stable stable && !HorseOverhaul.IsGarage(stable) && stable.getStableHorse() != null)
                        {
                            bool doesXHit = stable.tileX.Value + 1 == tileX || stable.tileX.Value + 2 == tileX;

                            if (doesXHit && stable.tileY.Value == tileY)
                            {
                                if (!mod.Config.DisableStableSpriteChanges)
                                {
                                    stable.texture = mod.FilledTroughTexture;
                                }

                                mod.Horses.Where(x => x.Horse == stable.getStableHorse()).Do(x => x.JustGotWater());
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }
        public static void SetupSounds(HorseOverhaul mod)
        {
            var soundEffects = new List <Tuple <string, string> >
            {
                new Tuple <string, string>(HorseSnickerSound + "0", "horse-neigh-shortened.wav"),
                new Tuple <string, string>(HorseSnickerSound + "1", "horse-small-whinny.wav"),
                new Tuple <string, string>(HorseSnortSound, "horse-snort-3.wav")
            };

            foreach (var item in soundEffects)
            {
                // Creating cue and setting its name, which will be the name of the audio to play when using sound functions
                var myCueDefinition = new CueDefinition
                {
                    name = item.Item1
                };

                //// myCueDefinition.instanceLimit = 1;
                //// myCueDefinition.limitBehavior = CueDefinition.LimitBehavior.ReplaceOldest;

                // Get the audio file and add it to a SoundEffect
                SoundEffect audio;
                string      filePathCombined = Path.Combine(mod.Helper.DirectoryPath, "assets", "sounds", item.Item2);
                using (var stream = new FileStream(filePathCombined, FileMode.Open))
                {
                    audio = SoundEffect.FromStream(stream);
                }

                // Setting the sound effect to the new cue
                myCueDefinition.SetSound(audio, Game1.audioEngine.GetCategoryIndex("Sound"), false);

                // Adding the cue to the sound bank
                Game1.soundBank.AddCue(myCueDefinition);
            }
        }
Example #4
0
        public static void VerifyConfigValues(HorseConfig config, HorseOverhaul mod)
        {
            bool invalidConfig = false;

            if (config.MaxMovementSpeedBonus < 0f)
            {
                config.MaxMovementSpeedBonus = 0f;
                invalidConfig = true;
            }

            SaddleBagOption res;

            if (Enum.TryParse(config.VisibleSaddleBags, true, out res))
            {
                // reassign to ensure casing is correct
                config.VisibleSaddleBags = res.ToString();
            }
            else
            {
                config.VisibleSaddleBags = SaddleBagOption.Disabled.ToString();
                invalidConfig            = true;
            }

            if (invalidConfig)
            {
                mod.DebugLog("At least one config value was out of range and was reset.");
                mod.Helper.WriteConfig(config);
            }
        }
Example #5
0
        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);
        }
Example #6
0
        public PetMenu(HorseOverhaul mod, Pet pet)
            : base((Game1.viewport.Width / 2) - (PetMenu.width / 2), (Game1.viewport.Height / 2) - (PetMenu.height / 2), PetMenu.width, PetMenu.height, false)
        {
            this.mod = mod;
            Game1.player.Halt();
            PetMenu.width  = Game1.tileSize * 6;
            PetMenu.height = Game1.tileSize * 8;

            this.textBox        = new TextBox((Texture2D)null, (Texture2D)null, Game1.dialogueFont, Game1.textColor);
            this.textBox.X      = (Game1.viewport.Width / 2) - (Game1.tileSize * 2) - 12;
            this.textBox.Y      = this.yPositionOnScreen - 4 + (Game1.tileSize * 2);
            this.textBox.Width  = Game1.tileSize * 4;
            this.textBox.Height = Game1.tileSize * 3;

            this.textBoxCC = new ClickableComponent(new Rectangle(this.textBox.X, this.textBox.Y, this.textBox.Width, Game1.tileSize), string.Empty)
            {
                myID           = 110,
                downNeighborID = 104
            };

            this.textBox.Text = pet.displayName;

            this.textBox.Selected = false;

            var yPos1 = this.yPositionOnScreen + PetMenu.height - Game1.tileSize - IClickableMenu.borderWidth;
            var yPos2 = this.yPositionOnScreen - (Game1.tileSize / 2) + IClickableMenu.spaceToClearTopBorder + (Game1.tileSize * 4) - (Game1.tileSize / 2);

            ClickableTextureComponent textureComponent1 = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + PetMenu.width + 4, yPos1, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false)
            {
                myID         = 101,
                upNeighborID = 103
            };

            this.okayButton = textureComponent1;

            ClickableTextureComponent textureComponent5 = new ClickableTextureComponent(
                (pet.friendshipTowardFarmer.Value / 10.0).ToString() + "<",
                new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder + (Game1.tileSize / 2) + 16, yPos2, PetMenu.width - (Game1.tileSize * 2), Game1.tileSize),
                (string)null, mod.Helper.Translation.Get("Friendship"), Game1.mouseCursors, new Rectangle(172, 512, 16, 16), 4f, false)
            {
                myID = 102
            };

            this.love      = textureComponent5;
            this.loveHover = new ClickableComponent(new Rectangle(this.xPositionOnScreen + IClickableMenu.spaceToClearSideBorder, this.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + (Game1.tileSize * 3) - (Game1.tileSize / 2), PetMenu.width, Game1.tileSize), "Friendship")
            {
                myID = 109
            };

            this.pet = pet;

            if (!Game1.options.SnappyMenus)
            {
                return;
            }

            this.populateClickableComponentList();
            this.snapToDefaultClickableComponent();
        }
Example #7
0
        public HorseWrapper(Stable stable, HorseOverhaul mod, Chest saddleBag, int?stableID)
        {
            Stable = stable;

            // has to be assigned right now because the horse gets removed from the character list while it has a rider
            Horse     = stable.getStableHorse();
            this.mod  = mod;
            SaddleBag = saddleBag;
            StableID  = stableID;
        }
Example #8
0
        public static void DrawHorse(ref Horse __instance, ref SpriteBatch b, ref bool __state)
        {
            try
            {
                if (!mod.Config.ThinHorse)
                {
                    return;
                }

                if (__state)
                {
                    __instance.IsEmoting = true;
                    __state = false;

                    Vector2 emotePosition = __instance.getLocalPosition(Game1.viewport);

                    emotePosition.Y -= 96f;

                    switch (__instance.FacingDirection)
                    {
                    case 0:
                        emotePosition.Y -= 40f;
                        break;

                    case 1:
                        emotePosition.X += 40f;
                        emotePosition.Y -= 30f;
                        break;

                    case 2:
                        emotePosition.Y += 5f;
                        break;

                    case 3:
                        emotePosition.X -= 40f;
                        emotePosition.Y -= 30f;
                        break;

                    default:
                        break;
                    }

                    b.Draw(Game1.emoteSpriteSheet, emotePosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle((__instance.CurrentEmoteIndex * 16) % Game1.emoteSpriteSheet.Width, __instance.CurrentEmoteIndex * 16 / Game1.emoteSpriteSheet.Width * 16, 16, 16)), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, __instance.getStandingY() / 10000f);
                }

                if (__instance.FacingDirection == 2 && __instance.rider != null && !HorseOverhaul.IsTractor(__instance))
                {
                    b.Draw(mod.HorseSpriteWithHead, __instance.getLocalPosition(Game1.viewport) + new Vector2(16f, -24f - __instance.rider.yOffset), new Rectangle?(new Rectangle(160, 96, 9, 15)), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, (__instance.Position.Y + 64f) / 10000f);
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }
Example #9
0
        public static void PatchAll(HorseOverhaul horseOverhaul)
        {
            mod = horseOverhaul;

            var harmony = HarmonyInstance.Create(mod.ModManifest.UniqueID);

            try
            {
                harmony.Patch(
                    original: AccessTools.Method(typeof(Farm), "performToolAction"),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(CheckForWaterHit))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Farmer), "getMovementSpeed"),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(ChangeHorseMovementSpeed))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Farmer), "showRiding"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(FixRidingPosition))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "squeezeForGate"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(DoNothing))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "draw", new Type[] { typeof(SpriteBatch) }),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(PreventEmoteDraw))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "draw", new Type[] { typeof(SpriteBatch) }),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(DrawHorse))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "checkAction"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(CheckForPetting))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Stable), "performActionOnDemolition"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(SaveItemsFromDemolition))
                    );
            }
            catch (Exception e)
            {
                mod.ErrorLog("Error while trying to setup required patches:", e);
            }
        }
Example #10
0
        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);
        }
Example #11
0
        public static void DrawEmote(ref Horse __instance, ref SpriteBatch b, ref bool __state)
        {
            try
            {
                if (!mod.Config.ThinHorse || HorseOverhaul.IsTractor(__instance))
                {
                    return;
                }

                __instance.IsEmoting = __state;

                Horse horse = __instance;

                if (horse.IsEmoting)
                {
                    Vector2 emotePosition = horse.getLocalPosition(Game1.viewport);

                    emotePosition.Y -= 96f;

                    switch (horse.FacingDirection)
                    {
                    case 0:
                        emotePosition.Y -= 40f;
                        break;

                    case 1:
                        emotePosition.X += 40f;
                        emotePosition.Y -= 30f;
                        break;

                    case 2:
                        emotePosition.Y += 5f;
                        break;

                    case 3:
                        emotePosition.X -= 40f;
                        emotePosition.Y -= 30f;
                        break;

                    default:
                        break;
                    }

                    b.Draw(Game1.emoteSpriteSheet, emotePosition, new Microsoft.Xna.Framework.Rectangle?(new Rectangle((horse.CurrentEmoteIndex * 16) % Game1.emoteSpriteSheet.Width, horse.CurrentEmoteIndex * 16 / Game1.emoteSpriteSheet.Width * 16, 16, 16)), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, horse.getStandingY() / 10000f);
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }
        public static void VerifyConfigValues(HorseConfig config, HorseOverhaul mod)
        {
            bool invalidConfig = false;

            if (config.MaxMovementSpeedBonus < 0f)
            {
                config.MaxMovementSpeedBonus = 0f;
                invalidConfig = true;
            }

            if (invalidConfig)
            {
                mod.DebugLog("At least one config value was out of range and was reset.");
                mod.Helper.WriteConfig(config);
            }
        }
        public static void SetUpModConfigMenu(HorseConfig config, HorseOverhaul mod)
        {
            IGenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(
                manifest,
                () => config = new HorseConfig(),
                delegate
            {
                mod.Helper.WriteConfig(config);
                VerifyConfigValues(config, mod);
            });

            api.RegisterLabel(manifest, "General", null);

            api.RegisterSimpleOption(manifest, "Thin Horse", null, () => config.ThinHorse, (bool val) => config.ThinHorse  = val);
            api.RegisterSimpleOption(manifest, "Saddle Bags", null, () => config.SaddleBag, (bool val) => config.SaddleBag = val);
            api.RegisterChoiceOption(manifest, "Visible Saddle Bags", null, () => config.VisibleSaddleBags.ToString(), (string val) => config.VisibleSaddleBags = val, Enum.GetNames(typeof(SaddleBagOption)));

            api.RegisterLabel(manifest, "Friendship", null);

            api.RegisterSimpleOption(manifest, "Movement Speed (MS)", null, () => config.MovementSpeed, (bool val) => config.MovementSpeed = val);
            api.RegisterSimpleOption(manifest, "Maximum MS Bonus", null, () => config.MaxMovementSpeedBonus, (float val) => config.MaxMovementSpeedBonus = val);
            api.RegisterSimpleOption(manifest, "Petting", null, () => config.Petting, (bool val) => config.Petting = val);
            api.RegisterSimpleOption(manifest, "Water", null, () => config.Water, (bool val) => config.Water       = val);
            api.RegisterSimpleOption(manifest, "Feeding", null, () => config.Feeding, (bool val) => config.Feeding = val);

            api.RegisterLabel(manifest, "Other", null);

            api.RegisterSimpleOption(manifest, "Pet Feeding", null, () => config.PetFeeding, (bool val) => config.PetFeeding = val);
            api.RegisterSimpleOption(manifest, "Allow Multiple Feedings A Day", null, () => config.AllowMultipleFeedingsADay, (bool val) => config.AllowMultipleFeedingsADay   = val);
            api.RegisterSimpleOption(manifest, "Disable Stable Sprite Changes", null, () => config.DisableStableSpriteChanges, (bool val) => config.DisableStableSpriteChanges = val);

            // this is a spacer
            api.RegisterLabel(manifest, string.Empty, null);
            api.RegisterLabel(manifest, "(Menu Key Rebinding Only Available In Config File)", null);
        }
Example #14
0
        public static bool CheckForPetting(ref Horse __instance, ref bool __result, ref Farmer who)
        {
            try
            {
                if (!mod.Config.Petting || HorseOverhaul.IsTractor(__instance))
                {
                    return(true);
                }

                HorseWrapper horseW = null;

                foreach (var item in mod.Horses)
                {
                    if (item.Horse == __instance)
                    {
                        horseW = item;
                        break;
                    }
                }

                if (__instance.getOwner() == who && horseW != null && !horseW.WasPet)
                {
                    horseW.JustGotPetted();

                    if (mod.Config.ThinHorse)
                    {
                        __instance.doEmote(Character.heartEmote);
                    }

                    __result = true;
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
                return(true);
            }
        }
Example #15
0
        public static void FeedPet(HorseOverhaul mod, Pet pet, Item currentItem, int friendship)
        {
            if (pet?.modData?.ContainsKey($"{mod.ModManifest.UniqueID}/gotFed") == true && !mod.Config.AllowMultipleFeedingsADay)
            {
                Game1.drawObjectDialogue(mod.Helper.Translation.Get("AteEnough", new { name = pet.displayName }));
            }
            else
            {
                pet.modData.Add($"{mod.ModManifest.UniqueID}/gotFed", "fed");

                Game1.drawObjectDialogue(mod.Helper.Translation.Get("AteFood", new { name = pet.displayName, foodName = currentItem.DisplayName }));

                pet.doEmote(Character.happyEmote);

                Game1.player.reduceActiveItemByOne();

                pet.friendshipTowardFarmer.Value = Math.Min(1000, pet.friendshipTowardFarmer.Value + friendship);
            }
        }
Example #16
0
        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);
            }
        }
Example #17
0
        public static void ChangeHorseMovementSpeed(ref Farmer __instance, ref float __result)
        {
            try
            {
                if (mod.Config.MovementSpeed)
                {
                    Horse horse = __instance.mount;

                    if (horse != null && !HorseOverhaul.IsTractor(horse))
                    {
                        float addedMovementSpeed = 0f;
                        mod.Horses.Where(x => x.Horse == horse).Do(x => addedMovementSpeed = x.GetMovementSpeedBonus());

                        __result += addedMovementSpeed;
                    }
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }
Example #18
0
        public static bool SaveItemsFromDemolition(Stable __instance)
        {
            try
            {
                if (HorseOverhaul.IsGarage(__instance))
                {
                    return(true);
                }

                HorseWrapper horseW = null;

                mod.Horses.Where(x => x.Horse == __instance.getStableHorse()).Do(x => horseW = x);

                if (horseW != null && horseW.SaddleBag != null)
                {
                    if (horseW.SaddleBag.items.Count > 0)
                    {
                        foreach (var item in horseW.SaddleBag.items)
                        {
                            Game1.player.team.returnedDonations.Add(item);
                            Game1.player.team.newLostAndFoundItems.Value = true;
                        }

                        horseW.SaddleBag.items.Clear();
                    }

                    horseW.SaddleBag = null;
                }

                return(true);
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
                return(true);
            }
        }
Example #19
0
        public PetMenu(HorseOverhaul mod, Pet pet)
            : base((Game1.viewport.Width / 2) - (PetMenu.width / 2), (Game1.viewport.Height / 2) - (PetMenu.height / 2), PetMenu.width, PetMenu.height, false)
        {
            this.mod = mod;
            this.pet = pet;

            Game1.player.Halt();

            PetMenu.width  = Game1.tileSize * 6;
            PetMenu.height = Game1.tileSize * 8;

            this.textBox        = new TextBox(null, null, Game1.dialogueFont, Game1.textColor);
            this.textBox.X      = (Game1.viewport.Width / 2) - (Game1.tileSize * 2) - 12;
            this.textBox.Y      = this.yPositionOnScreen - 4 + (Game1.tileSize * 2);
            this.textBox.Width  = Game1.tileSize * 4;
            this.textBox.Height = Game1.tileSize * 3;

            this.textBox.Text = pet.displayName;

            this.textBox.Selected = false;

            var yPos = this.yPositionOnScreen + PetMenu.height - Game1.tileSize - IClickableMenu.borderWidth;

            this.okayButton = new ClickableTextureComponent(new Rectangle(this.xPositionOnScreen + PetMenu.width + 4, yPos, Game1.tileSize, Game1.tileSize), Game1.mouseCursors, Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46, -1, -1), 1f, false)
            {
                myID = okButtonID
            };

            if (!Game1.options.SnappyMenus)
            {
                return;
            }

            this.populateClickableComponentList();
            this.snapToDefaultClickableComponent();
        }
Example #20
0
 public PetMenu(HorseOverhaul mod, Pet pet) : base(pet.displayName)
 {
     this.mod = mod;
     this.pet = pet;
 }
Example #21
0
 public HorseMenu(HorseOverhaul mod, HorseWrapper horse)
     : base(Game1.player.horseName.Value)
 {
     this.mod   = mod;
     this.horse = horse;
 }
Example #22
0
        public static void PatchAll(HorseOverhaul horseOverhaul)
        {
            mod = horseOverhaul;

            var harmony = new Harmony(mod.ModManifest.UniqueID);

            try
            {
                harmony.Patch(
                    original: AccessTools.Method(typeof(Desert), "playerReachedBusDoor", new Type[] { typeof(Character), typeof(GameLocation) }),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(PreventSoftlock)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Chest), "draw", new Type[] { typeof(SpriteBatch), typeof(int), typeof(int), typeof(float) }),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(DoNothingIfSaddleBag)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Chest), "draw", new Type[] { typeof(SpriteBatch), typeof(int), typeof(int), typeof(float), typeof(bool) }),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(DoNothingIfSaddleBag)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Chest), "performToolAction"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(DoNothingIfSaddleBag)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Farm), "performToolAction"),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(CheckForWaterHit)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Farmer), "getMovementSpeed"),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(ChangeHorseMovementSpeed)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "checkAction"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(CheckForPetting)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Stable), "performActionOnDemolition"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(SaveItemsFromDemolition)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Utility), nameof(Utility.iterateChestsAndStorage)),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(IterateOverSaddles)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Building), "resetTexture"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(ResetStableTexture)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), nameof(Horse.PerformDefaultHorseFootstep)),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(PerformDefaultHorseFootstep)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(FarmerSprite), "checkForFootstep"),
                    transpiler: new HarmonyMethod(typeof(Patcher), nameof(FixMultiplayerFootstepDisplay)));

                //// thin horse patches

                harmony.Patch(
                    original: AccessTools.Method(typeof(Character), nameof(Character.GetSpriteWidthForPositioning)),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(SetOneTileWide)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Farmer), "showRiding"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(FixRidingPosition)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), nameof(Horse.squeezeForGate)),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(DoNothing)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "draw", new Type[] { typeof(SpriteBatch) }),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(PreventBaseEmoteDraw)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "draw", new Type[] { typeof(SpriteBatch) }),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(DrawEmoteAndSaddleBags)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "draw", new Type[] { typeof(SpriteBatch) }),
                    transpiler: new HarmonyMethod(typeof(Patcher), nameof(FixHeadAndHatPosition)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "update", new Type[] { typeof(GameTime), typeof(GameLocation) }),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(DoMountingAnimation)));

                harmony.Patch(
                    original: AccessTools.Method(typeof(Farmer), "setMount"),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(FixSetMount)));
            }
            catch (Exception e)
            {
                mod.ErrorLog("Error while trying to setup required patches:", e);
            }
        }
Example #23
0
        public static void SetUpModConfigMenu(HorseConfig config, HorseOverhaul mod)
        {
            IGenericModConfigMenuAPI api = mod.Helper.ModRegistry.GetApi <IGenericModConfigMenuAPI>("spacechase0.GenericModConfigMenu");

            if (api == null)
            {
                return;
            }

            var manifest = mod.ModManifest;

            api.RegisterModConfig(
                manifest,
                delegate
            {
                // if the world is ready, then we are not in the main menu, so reset should only reset the keybindings
                if (Context.IsWorldReady)
                {
                    config.HorseMenuKey = HorseMenuKeyDefault;
                    config.PetMenuKey   = PetMenuKeyDefault;
                    config.AlternateSaddleBagAndFeedKey   = AlternateSaddleBagAndFeedKeyDefault;
                    config.DisableMainSaddleBagAndFeedKey = false;
                }
                else
                {
                    config = new HorseConfig();
                }
            },
                delegate
            {
                mod.Helper.WriteConfig(config);
                VerifyConfigValues(config, mod);
            }
                );

            api.SetTitleScreenOnlyForNextOptions(manifest, true);

            api.RegisterLabel(manifest, "General", null);

            api.RegisterSimpleOption(manifest, "Thin Horse", null, () => config.ThinHorse, (bool val) => config.ThinHorse  = val);
            api.RegisterSimpleOption(manifest, "Saddle Bags", null, () => config.SaddleBag, (bool val) => config.SaddleBag = val);
            api.RegisterChoiceOption(manifest, "Visible Saddle Bags", null, () => config.VisibleSaddleBags.ToString(), (string val) => config.VisibleSaddleBags = val, Enum.GetNames(typeof(SaddleBagOption)));

            api.RegisterLabel(manifest, "Friendship", null);

            api.RegisterSimpleOption(manifest, "Movement Speed (MS)", null, () => config.MovementSpeed, (bool val) => config.MovementSpeed = val);
            api.RegisterSimpleOption(manifest, "Maximum MS Bonus", null, () => config.MaxMovementSpeedBonus, (float val) => config.MaxMovementSpeedBonus = val);
            api.RegisterSimpleOption(manifest, "Petting", null, () => config.Petting, (bool val) => config.Petting        = val);
            api.RegisterSimpleOption(manifest, "Water", null, () => config.Water, (bool val) => config.Water              = val);
            api.RegisterSimpleOption(manifest, "Feeding", null, () => config.Feeding, (bool val) => config.Feeding        = val);
            api.RegisterSimpleOption(manifest, "Heater", null, () => config.HorseHeater, (bool val) => config.HorseHeater = val);

            api.RegisterLabel(manifest, "Other", null);

            api.RegisterSimpleOption(manifest, "Horse Hoofstep Effects", null, () => config.HorseHoofstepEffects, (bool val) => config.HorseHoofstepEffects = val);
            api.RegisterSimpleOption(manifest, "Disable Horse Sounds", null, () => config.DisableHorseSounds, (bool val) => config.DisableHorseSounds       = val);
            api.RegisterSimpleOption(manifest, "New Food System", null, () => config.NewFoodSystem, (bool val) => config.NewFoodSystem = val);
            api.RegisterSimpleOption(manifest, "Pet Feeding", null, () => config.PetFeeding, (bool val) => config.PetFeeding           = val);
            api.RegisterSimpleOption(manifest, "Allow Multiple Feedings A Day", null, () => config.AllowMultipleFeedingsADay, (bool val) => config.AllowMultipleFeedingsADay   = val);
            api.RegisterSimpleOption(manifest, "Disable Stable Sprite Changes", null, () => config.DisableStableSpriteChanges, (bool val) => config.DisableStableSpriteChanges = val);

            api.SetTitleScreenOnlyForNextOptions(manifest, false);

            api.RegisterLabel(manifest, "Keybindings", null);

            api.AddKeybindList(manifest, () => config.HorseMenuKey, (KeybindList keybindList) => config.HorseMenuKey = keybindList, () => "Horse Menu Key");
            api.AddKeybindList(manifest, () => config.PetMenuKey, (KeybindList keybindList) => config.PetMenuKey     = keybindList, () => "Pet Menu Key");
            api.AddKeybindList(manifest, () => config.AlternateSaddleBagAndFeedKey, (KeybindList keybindList) => config.AlternateSaddleBagAndFeedKey = keybindList, () => "Alternate Saddle Bag\nAnd Feed Key");
            api.RegisterSimpleOption(manifest, "Disable Main Saddle Bag\nAnd Feed Key", null, () => config.DisableMainSaddleBagAndFeedKey, (bool val) => config.DisableMainSaddleBagAndFeedKey = val);
        }
 public HorseWrapper(Horse horse, HorseOverhaul mod, Chest saddleBag)
 {
     Horse     = horse;
     this.mod  = mod;
     SaddleBag = saddleBag;
 }
Example #25
0
        public static void PatchAll(HorseOverhaul horseOverhaul)
        {
            mod = horseOverhaul;

            var harmony = HarmonyInstance.Create(mod.ModManifest.UniqueID);

            try
            {
                harmony.Patch(
                    original: AccessTools.Method(typeof(Farm), "performToolAction"),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(CheckForWaterHit))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Farmer), "getMovementSpeed"),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(ChangeHorseMovementSpeed))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "checkAction"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(CheckForPetting))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Stable), "performActionOnDemolition"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(SaveItemsFromDemolition))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Farmer), "setMount"),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(FixSetMount))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Utility), "iterateChestsAndStorage"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(IterateOverSaddles))
                    );

                // thin horse patches

                harmony.Patch(
                    original: AccessTools.Method(typeof(Farmer), "showRiding"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(FixRidingPosition))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "squeezeForGate"),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(DoNothing))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "draw", new Type[] { typeof(SpriteBatch) }),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(PreventBaseEmoteDraw))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "draw", new Type[] { typeof(SpriteBatch) }),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(DrawEmote))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "draw", new Type[] { typeof(SpriteBatch) }),
                    transpiler: new HarmonyMethod(typeof(Patcher), nameof(FixHeadAndHatPosition))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Horse), "update", new Type[] { typeof(GameTime), typeof(GameLocation) }),
                    prefix: new HarmonyMethod(typeof(Patcher), nameof(DoMountingAnimation))
                    );

                harmony.Patch(
                    original: AccessTools.Method(typeof(Farmer), "setMount"),
                    postfix: new HarmonyMethod(typeof(Patcher), nameof(FixSetMount))
                    );
            }
            catch (Exception e)
            {
                mod.ErrorLog("Error while trying to setup required patches:", e);
            }
        }