From 6c14d040be49bc71cc8daa57b343c3f7a53861ec Mon Sep 17 00:00:00 2001 From: Mohammad Shoaib Khan Date: Mon, 10 Apr 2023 19:56:42 +0530 Subject: [PATCH] Patched draw method of TrashBear.cs to speak the wanted item --- stardew-access/HarmonyPatches.cs | 6 +++++ .../Patches/MiscPatches/TrashBearPatch.cs | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 stardew-access/Patches/MiscPatches/TrashBearPatch.cs diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs index c3567c9..4a4ffbd 100644 --- a/stardew-access/HarmonyPatches.cs +++ b/stardew-access/HarmonyPatches.cs @@ -4,6 +4,7 @@ using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using stardew_access.Patches; using StardewValley; +using StardewValley.Characters; using StardewValley.Menus; using StardewValley.Minigames; @@ -306,6 +307,11 @@ namespace stardew_access original: AccessTools.Method(typeof(Game1), nameof(Game1.closeTextEntry)), prefix: new HarmonyMethod(typeof(Game1Patch), nameof(Game1Patch.CloseTextEntryPatch)) ); + + harmony.Patch( + original: AccessTools.Method(typeof(TrashBear), nameof(TrashBear.draw), new Type[] { typeof(SpriteBatch) }), + prefix: new HarmonyMethod(typeof(TrashBearPatch), nameof(TrashBearPatch.DrawPatch)) + ); } } } diff --git a/stardew-access/Patches/MiscPatches/TrashBearPatch.cs b/stardew-access/Patches/MiscPatches/TrashBearPatch.cs new file mode 100644 index 0000000..ad2592a --- /dev/null +++ b/stardew-access/Patches/MiscPatches/TrashBearPatch.cs @@ -0,0 +1,23 @@ +using StardewValley; + +namespace stardew_access.Patches +{ + internal class TrashBearPatch + { + internal static void DrawPatch(int ___itemWantedIndex, int ___showWantBubbleTimer) + { + try + { + if (___showWantBubbleTimer >= 2900) + { + string itemName = Game1.objectInformation[___itemWantedIndex].Split('/')[4]; + MainClass.ScreenReader.Say($"Trash Bear wants {itemName}!", true); + } + } + catch (Exception e) + { + MainClass.ErrorLog($"An error occured TrashBearPatch::DrawPatch():\n{e.Message}\n{e.StackTrace}"); + } + } + } +}