Patched the checkAction method instead to avoid the patch from executing multiple times
parent
6c14d040be
commit
5f612a20c1
|
@ -309,8 +309,8 @@ namespace stardew_access
|
||||||
);
|
);
|
||||||
|
|
||||||
harmony.Patch(
|
harmony.Patch(
|
||||||
original: AccessTools.Method(typeof(TrashBear), nameof(TrashBear.draw), new Type[] { typeof(SpriteBatch) }),
|
original: AccessTools.Method(typeof(TrashBear), nameof(TrashBear.checkAction)),
|
||||||
prefix: new HarmonyMethod(typeof(TrashBearPatch), nameof(TrashBearPatch.DrawPatch))
|
postfix: new HarmonyMethod(typeof(TrashBearPatch), nameof(TrashBearPatch.CheckActionPatch))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
using StardewValley;
|
using StardewValley;
|
||||||
|
using StardewValley.Characters;
|
||||||
|
|
||||||
namespace stardew_access.Patches
|
namespace stardew_access.Patches
|
||||||
{
|
{
|
||||||
internal class TrashBearPatch
|
internal class TrashBearPatch
|
||||||
{
|
{
|
||||||
internal static void DrawPatch(int ___itemWantedIndex, int ___showWantBubbleTimer)
|
internal static void CheckActionPatch(TrashBear __instance, bool __result, int ___itemWantedIndex, int ___showWantBubbleTimer)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (___showWantBubbleTimer >= 2900)
|
if (__result) return; // The true `true` value of __result indicates the bear is interactable i.e. when giving the bear the wanted item
|
||||||
{
|
if (__instance.sprite.Value.CurrentAnimation != null) return;
|
||||||
|
|
||||||
string itemName = Game1.objectInformation[___itemWantedIndex].Split('/')[4];
|
string itemName = Game1.objectInformation[___itemWantedIndex].Split('/')[4];
|
||||||
MainClass.ScreenReader.Say($"Trash Bear wants {itemName}!", true);
|
MainClass.ScreenReader.Say($"Trash Bear wants {itemName}!", true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
MainClass.ErrorLog($"An error occured TrashBearPatch::DrawPatch():\n{e.Message}\n{e.StackTrace}");
|
MainClass.ErrorLog($"An error occured TrashBearPatch::CheckActionPatch():\n{e.Message}\n{e.StackTrace}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue