Patched draw method of TrashBear.cs to speak the wanted item

master^2
Mohammad Shoaib Khan 2023-04-10 19:56:42 +05:30
parent ca249644dd
commit 6c14d040be
2 changed files with 29 additions and 0 deletions

View File

@ -4,6 +4,7 @@ using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using stardew_access.Patches; using stardew_access.Patches;
using StardewValley; using StardewValley;
using StardewValley.Characters;
using StardewValley.Menus; using StardewValley.Menus;
using StardewValley.Minigames; using StardewValley.Minigames;
@ -306,6 +307,11 @@ namespace stardew_access
original: AccessTools.Method(typeof(Game1), nameof(Game1.closeTextEntry)), original: AccessTools.Method(typeof(Game1), nameof(Game1.closeTextEntry)),
prefix: new HarmonyMethod(typeof(Game1Patch), nameof(Game1Patch.CloseTextEntryPatch)) 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))
);
} }
} }
} }

View File

@ -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}");
}
}
}
}