Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions ImmersiveHud/Hud_Update_Patch.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using UnityEngine;
using HarmonyLib;

using System;
using System.Reflection;

namespace ImmersiveHud
{
[HarmonyPatch(typeof(Hud), "Update")]
public class Hud_Update_Patch : ImmersiveHud
{
{
private static MethodInfo _GetRightItemMethod = AccessTools.Method(typeof(Humanoid), "GetRightItem");
private static MethodInfo _GetLeftItemMethod = AccessTools.Method(typeof(Humanoid), "GetLeftItem");
public static void updateHudElementTransparency(HudElement hudElement)
{
float lerpedAlpha;
Expand Down Expand Up @@ -33,8 +37,8 @@ public static void getPlayerData(Transform hud, Player player)

getPlayerTotalFoodValue(player);

ItemDrop.ItemData playerItemEquippedLeft = player.GetLeftItem();
ItemDrop.ItemData playerItemEquippedRight = player.GetRightItem();
ItemDrop.ItemData playerItemEquippedLeft = _GetLeftItemMethod.Invoke(player, Array.Empty<object>()) as ItemDrop.ItemData;
ItemDrop.ItemData playerItemEquippedRight = _GetRightItemMethod.Invoke(player, Array.Empty<object>()) as ItemDrop.ItemData;

if (playerItemEquippedLeft != null || playerItemEquippedRight != null)
playerHasItemEquipped = true;
Expand Down
11 changes: 7 additions & 4 deletions ImmersiveHud/Player_Update_Patch.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
using UnityEngine;
using HarmonyLib;
using System.Reflection;

using System;

namespace ImmersiveHud
{
[HarmonyPatch(typeof(Player), "Update")]
public class Player_Update_Patch : ImmersiveHud
{
{
private static MethodInfo _GetRightItemMethod = AccessTools.Method(typeof(Humanoid), "GetRightItem");
private static MethodInfo _GetLeftItemMethod = AccessTools.Method(typeof(Humanoid), "GetLeftItem");
private static void Prefix(Player __instance)
{
if (!__instance) return;

ItemDrop.ItemData playerItemEquippedLeft = __instance.GetLeftItem();
ItemDrop.ItemData playerItemEquippedRight = __instance.GetRightItem();
ItemDrop.ItemData playerItemEquippedLeft = _GetLeftItemMethod.Invoke(__instance, Array.Empty<object>()) as ItemDrop.ItemData;
ItemDrop.ItemData playerItemEquippedRight = _GetRightItemMethod.Invoke(__instance, Array.Empty<object>()) as ItemDrop.ItemData;

if (playerItemEquippedLeft != null && (playerItemEquippedLeft.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Bow))
{
Expand Down