using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ImmersiveHud")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ImmersiveHud")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6a171b4f-ba83-4d4f-a1e3-7f0d52a965fa")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
internal sealed class ConfigurationManagerAttributes
{
public bool? ShowRangeAsPercent;
public Action<ConfigEntryBase> CustomDrawer;
public bool? Browsable;
public string Category;
public object DefaultValue;
public bool? HideDefaultButton;
public bool? HideSettingName;
public string Description;
public string DispName;
public int? Order;
public bool? ReadOnly;
public bool? IsAdvanced;
public Func<object, string> ObjToStr;
public Func<string, object> StrToObj;
}
namespace ImmersiveHud;
[HarmonyPatch(typeof(Player), "Update")]
public class Player_Update_Patch : ImmersiveHud
{
private static void Prefix(Player __instance)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
if (Object.op_Implicit((Object)(object)__instance))
{
ItemData currentWeapon = ((Humanoid)__instance).GetCurrentWeapon();
if (currentWeapon != null && (int)currentWeapon.m_shared.m_itemType == 4)
{
ImmersiveHud.characterEquippedBow = true;
ImmersiveHud.characterEquippedItem = false;
}
else if (currentWeapon != null)
{
ImmersiveHud.characterEquippedBow = false;
ImmersiveHud.characterEquippedItem = true;
}
else
{
ImmersiveHud.characterEquippedItem = false;
ImmersiveHud.characterEquippedBow = false;
}
}
}
}
[HarmonyPatch(typeof(Player), "UseStamina")]
public class Player_UseStamina_Patch : ImmersiveHud
{
private static void Postfix(ref float v)
{
if ((double)v != 0.0)
{
ImmersiveHud.playerUsedStamina = true;
}
}
}
[HarmonyPatch(typeof(Player), "UseHotbarItem")]
public class Player_UseHotbarItem_Patch : ImmersiveHud
{
private static void Postfix(int index)
{
Player localPlayer = Player.m_localPlayer;
ItemData itemAt = ((Humanoid)localPlayer).GetInventory().GetItemAt(index - 1, 0);
if (itemAt != null)
{
ImmersiveHud.playerUsedHotBarItem = true;
}
}
}
[HarmonyPatch]
public class Player_UpdateFood_Patch : ImmersiveHud
{
private static MethodBase TargetMethod()
{
return typeof(Player).GetMethod("UpdateFood", BindingFlags.Instance | BindingFlags.NonPublic);
}
private static void Postfix(ref float dt, ref bool forceUpdate)
{
if ((dt == 0f) & forceUpdate)
{
ImmersiveHud.playerAteFood = true;
}
else
{
ImmersiveHud.playerAteFood = false;
}
}
}
[HarmonyPatch(typeof(Hud), "UpdateCrosshair")]
public class Hud_UpdateCrosshair_Patch : ImmersiveHud
{
public static void updateCrosshairHudElement(float bowDrawPercentage)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
((Graphic)ImmersiveHud.playerCrosshair).CrossFadeAlpha(ImmersiveHud.targetCrosshairAlpha, ImmersiveHud.fadeDuration, false);
if ((double)bowDrawPercentage > 0.0)
{
if (ImmersiveHud.useCustomBowCrosshair.Value)
{
float num = Mathf.Lerp(0.75f, 0.25f, bowDrawPercentage);
((Component)ImmersiveHud.playerBowCrosshair).transform.localScale = new Vector3(num, num, num);
}
if (ImmersiveHud.displayBowDrawCrosshair.Value)
{
((Graphic)ImmersiveHud.playerBowCrosshair).color = Color.Lerp(new Color(1f, 1f, 1f, 0f), ImmersiveHud.crosshairBowDrawColor.Value, bowDrawPercentage);
}
else
{
((Graphic)ImmersiveHud.playerBowCrosshair).color = new Color(0f, 0f, 0f, 0f);
}
}
}
public static void updateStealthHudElement()
{
((Component)ImmersiveHud.playerStealthBar).GetComponent<CanvasGroup>().alpha = ImmersiveHud.targetStealthHudAlpha;
ImmersiveHud.playerStealthIndicator.GetComponent<CanvasGroup>().alpha = ImmersiveHud.targetStealthHudAlpha;
ImmersiveHud.playerStealthIndicatorTargeted.GetComponent<CanvasGroup>().alpha = ImmersiveHud.targetStealthHudAlpha;
ImmersiveHud.playerStealthIndicatorAlert.GetComponent<CanvasGroup>().alpha = ImmersiveHud.targetStealthHudAlpha;
}
public static void setCrosshairValues(Player player)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
GameObject hoverObject = ((Humanoid)player).GetHoverObject();
Hoverable val = (Object.op_Implicit((Object)(object)hoverObject) ? hoverObject.GetComponentInParent<Hoverable>() : null);
if (val != null && !TextViewer.instance.IsVisible())
{
ImmersiveHud.isLookingAtActivatable = true;
}
else
{
ImmersiveHud.isLookingAtActivatable = false;
}
if (ImmersiveHud.displayCrosshairAlways.Value)
{
ImmersiveHud.targetCrosshairAlpha = ImmersiveHud.crosshairColor.Value.a;
}
else if (ImmersiveHud.displayCrosshairWhenBuilding.Value && ((Character)player).InPlaceMode())
{
ImmersiveHud.targetCrosshairAlpha = ImmersiveHud.crosshairColor.Value.a;
}
else if (ImmersiveHud.displayCrosshairOnActivation.Value && ImmersiveHud.isLookingAtActivatable)
{
ImmersiveHud.targetCrosshairAlpha = ImmersiveHud.crosshairColor.Value.a;
}
else if (ImmersiveHud.displayCrosshairOnEquipped.Value && ImmersiveHud.characterEquippedItem)
{
ImmersiveHud.targetCrosshairAlpha = ImmersiveHud.crosshairColor.Value.a;
}
else if (ImmersiveHud.displayCrosshairOnBowEquipped.Value && ImmersiveHud.characterEquippedBow)
{
ImmersiveHud.targetCrosshairAlpha = ImmersiveHud.crosshairColor.Value.a;
}
else
{
ImmersiveHud.targetCrosshairAlpha = 0f;
}
}
public static void setStealthHudValues()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
if (ImmersiveHud.disableStealthHud.Value || ImmersiveHud.hudHidden)
{
ImmersiveHud.targetStealthHudAlpha = 0f;
}
else
{
ImmersiveHud.targetStealthHudAlpha = ImmersiveHud.crosshairColor.Value.a;
}
}
private static void Postfix(Player player, float bowDrawPercentage)
{
setCrosshairValues(player);
setStealthHudValues();
updateCrosshairHudElement(bowDrawPercentage);
updateStealthHudElement();
}
}
[HarmonyPatch(typeof(Hud), "Update")]
public class Hud_Update_Patch : ImmersiveHud
{
public static void updateHudElementTransparency(HudElement hudElement)
{
float num = Mathf.Lerp(hudElement.lastSetAlpha, hudElement.targetAlpha, hudElement.timeFade / ImmersiveHud.hudFadeDuration.Value);
if (hudElement.elementName == "MiniMap")
{
((Graphic)((Component)hudElement.element).GetComponent<Minimap>().m_mapImageSmall).CrossFadeAlpha(hudElement.targetAlpha, hudElement.timeFade, false);
}
hudElement.lastSetAlpha = num;
((Component)hudElement.element).GetComponent<CanvasGroup>().alpha = num;
}
public static void getPlayerData(Transform hud, Player player)
{
Minimap component = ((Component)hud.Find("MiniMap")).GetComponent<Minimap>();
bool flag = ImmersiveHud.isMiniMapActive;
ImmersiveHud.isMiniMapActive = component.m_smallRoot.activeSelf;
if (flag != ImmersiveHud.isMiniMapActive)
{
ImmersiveHud.hudElements["MiniMap"].timeFade = 0f;
}
getPlayerTotalFoodValue(player);
ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon();
if (currentWeapon != null)
{
ImmersiveHud.playerHasItemEquipped = true;
}
else
{
ImmersiveHud.playerHasItemEquipped = false;
}
}
public static void getPlayerTotalFoodValue(Player player)
{
ImmersiveHud.playerTotalFoodValue = (ImmersiveHud.playerCurrentFoodValue = (ImmersiveHud.playerHungerCount = 0));
foreach (Food food in player.GetFoods())
{
ImmersiveHud.playerTotalFoodValue += food.m_item.m_shared.m_food;
ImmersiveHud.playerCurrentFoodValue += food.m_health;
if (food.CanEatAgain())
{
ImmersiveHud.playerHungerCount++;
}
}
ImmersiveHud.playerFoodPercentage = ImmersiveHud.playerCurrentFoodValue / ImmersiveHud.playerTotalFoodValue;
}
public static void setValuesBasedOnHud(bool pressedHideKey, bool pressedShowKey)
{
Player localPlayer = Player.m_localPlayer;
string[] array = ImmersiveHud.hudElementNames;
foreach (string key in array)
{
if ((Object)(object)ImmersiveHud.hudElements[key].element != (Object)null)
{
ImmersiveHud.hudElements[key].targetAlphaPrev = ImmersiveHud.hudElements[key].targetAlpha;
}
}
if (pressedHideKey)
{
ImmersiveHud.hudHidden = !ImmersiveHud.hudHidden;
if (ImmersiveHud.hudHiddenNotification.Value)
{
if (ImmersiveHud.hudHidden)
{
MessageHud.instance.ShowMessage((MessageType)1, "Hud is hidden.", 0, (Sprite)null);
}
else
{
MessageHud.instance.ShowMessage((MessageType)1, "Hud is visible.", 0, (Sprite)null);
}
}
string[] array2 = ImmersiveHud.hudElementNames;
foreach (string key2 in array2)
{
ImmersiveHud.hudElements[key2].resetTimers();
}
}
if (ImmersiveHud.hungerNotification.Value && ((ImmersiveHud.hungerNotificationOption.Value == hungerNotificationOptions.FoodHungerAmount && ImmersiveHud.playerHungerCount >= ImmersiveHud.foodHungerAmount.Value) || (ImmersiveHud.hungerNotificationOption.Value == hungerNotificationOptions.FoodPercentage && ImmersiveHud.playerFoodPercentage <= ImmersiveHud.foodPercentage.Value)))
{
ImmersiveHud.notificationTimer += Time.deltaTime;
if ((int)ImmersiveHud.notificationTimer % ImmersiveHud.hungerNotificationInterval.Value == 0)
{
switch (ImmersiveHud.hungerNotificationType.Value)
{
case notificationTypes.SmallTopLeft:
MessageHud.instance.ShowMessage((MessageType)1, ImmersiveHud.hungerNotificationText.Value, 0, (Sprite)null);
break;
case notificationTypes.LargeCenter:
MessageHud.instance.ShowMessage((MessageType)2, ImmersiveHud.hungerNotificationText.Value, 0, (Sprite)null);
break;
}
ImmersiveHud.notificationTimer = 1f;
}
}
if (ImmersiveHud.hudHidden)
{
string[] array3 = ImmersiveHud.hudElementNames;
foreach (string key3 in array3)
{
ImmersiveHud.hudElements[key3].targetAlpha = 0f;
}
if (ImmersiveHud.isMiniMapActive)
{
ImmersiveHud.hudElements["MiniMap"].targetAlpha = 0f;
}
else
{
ImmersiveHud.hudElements["MiniMap"].targetAlpha = 1f;
}
}
else if (pressedShowKey)
{
if (ImmersiveHud.showHealthOnKeyPressed.Value)
{
ImmersiveHud.hudElements["healthpanel"].showHudForDuration();
ImmersiveHud.hudElements["BetterUI_HPBar"].showHudForDuration();
}
if (ImmersiveHud.showFoodBarOnKeyPressed.Value)
{
ImmersiveHud.hudElements["BetterUI_FoodBar"].showHudForDuration();
}
if (ImmersiveHud.showStaminaBarOnKeyPressed.Value)
{
ImmersiveHud.hudElements["staminapanel"].showHudForDuration();
ImmersiveHud.hudElements["BetterUI_StaminaBar"].showHudForDuration();
}
if (ImmersiveHud.showPowerOnKeyPressed.Value)
{
ImmersiveHud.hudElements["GuardianPower"].showHudForDuration();
}
if (ImmersiveHud.showHotKeyBarOnKeyPressed.Value)
{
ImmersiveHud.hudElements["HotKeyBar"].showHudForDuration();
}
if (ImmersiveHud.showStatusEffectsOnKeyPressed.Value)
{
ImmersiveHud.hudElements["StatusEffects"].showHudForDuration();
}
if (ImmersiveHud.showMiniMapOnKeyPressed.Value)
{
ImmersiveHud.hudElements["MiniMap"].showHudForDuration();
}
if (ImmersiveHud.showCompassOnKeyPressed.Value)
{
ImmersiveHud.hudElements["Compass"].showHudForDuration();
}
if (ImmersiveHud.showTimeOnKeyPressed.Value && ImmersiveHud.oryxenTimeEnabled.Value)
{
ImmersiveHud.hudElements["DayTimePanel"].showHudForDuration();
}
if (ImmersiveHud.showQuickSlotsOnKeyPressed.Value)
{
ImmersiveHud.hudElements["QuickSlotsHotkeyBar"].showHudForDuration();
}
}
else
{
if (ImmersiveHud.displayHealthAlways.Value || (ImmersiveHud.displayHealthInInventory.Value && InventoryGui.IsVisible()))
{
ImmersiveHud.hudElements["healthpanel"].targetAlpha = 1f;
ImmersiveHud.hudElements["BetterUI_HPBar"].targetAlpha = 1f;
if (!ImmersiveHud.displayHealthInInventory.Value && InventoryGui.IsVisible())
{
ImmersiveHud.hudElements["healthpanel"].hudSetTargetAlpha(0f);
ImmersiveHud.hudElements["BetterUI_HPBar"].hudSetTargetAlpha(0f);
}
}
else
{
if (ImmersiveHud.displayHealthWhenEating.Value && ImmersiveHud.playerAteFood)
{
ImmersiveHud.hudElements["healthpanel"].showHudForDuration();
ImmersiveHud.hudElements["BetterUI_HPBar"].showHudForDuration();
}
if (ImmersiveHud.displayHealthWhenBelow.Value && ((Character)localPlayer).GetHealthPercentage() <= ImmersiveHud.healthPercentage.Value)
{
ImmersiveHud.hudElements["healthpanel"].hudSetTargetAlpha(1f);
ImmersiveHud.hudElements["BetterUI_HPBar"].hudSetTargetAlpha(1f);
}
else if (ImmersiveHud.displayHealthWhenFoodBelow.Value && ImmersiveHud.playerFoodPercentage <= ImmersiveHud.foodPercentage.Value)
{
ImmersiveHud.hudElements["healthpanel"].hudSetTargetAlpha(1f);
ImmersiveHud.hudElements["BetterUI_HPBar"].hudSetTargetAlpha(1f);
}
else if (ImmersiveHud.displayHealthWhenHungry.Value && ImmersiveHud.playerHungerCount >= ImmersiveHud.foodHungerAmount.Value)
{
ImmersiveHud.hudElements["healthpanel"].hudSetTargetAlpha(1f);
ImmersiveHud.hudElements["BetterUI_HPBar"].hudSetTargetAlpha(1f);
}
else
{
ImmersiveHud.hudElements["healthpanel"].hudSetTargetAlpha(0f);
ImmersiveHud.hudElements["BetterUI_HPBar"].hudSetTargetAlpha(0f);
}
}
if (ImmersiveHud.displayBetterUIFoodAlways.Value || (ImmersiveHud.displayFoodBarInInventory.Value && InventoryGui.IsVisible()))
{
ImmersiveHud.hudElements["BetterUI_FoodBar"].targetAlpha = 1f;
if (!ImmersiveHud.displayFoodBarInInventory.Value && InventoryGui.IsVisible())
{
ImmersiveHud.hudElements["BetterUI_FoodBar"].hudSetTargetAlpha(0f);
}
}
else if (ImmersiveHud.betterUIFoodEnabled.Value && ImmersiveHud.hudElements["BetterUI_FoodBar"].doesExist)
{
if (ImmersiveHud.displayFoodBarWhenEating.Value && ImmersiveHud.playerAteFood)
{
ImmersiveHud.hudElements["BetterUI_FoodBar"].showHudForDuration();
}
if (ImmersiveHud.displayFoodBarWhenBelow.Value && ImmersiveHud.playerFoodPercentage <= ImmersiveHud.foodPercentage.Value)
{
ImmersiveHud.hudElements["BetterUI_FoodBar"].hudSetTargetAlpha(1f);
}
else if (ImmersiveHud.displayFoodBarWhenHungry.Value && ImmersiveHud.playerHungerCount >= ImmersiveHud.foodHungerAmount.Value)
{
ImmersiveHud.hudElements["BetterUI_FoodBar"].hudSetTargetAlpha(1f);
}
else
{
ImmersiveHud.hudElements["BetterUI_FoodBar"].hudSetTargetAlpha(0f);
}
}
if (ImmersiveHud.displayStaminaBarAlways.Value || (ImmersiveHud.displayStaminaBarInInventory.Value && InventoryGui.IsVisible()))
{
ImmersiveHud.hudElements["staminapanel"].targetAlpha = 1f;
ImmersiveHud.hudElements["BetterUI_StaminaBar"].targetAlpha = 1f;
if (!ImmersiveHud.displayStaminaBarInInventory.Value && InventoryGui.IsVisible())
{
ImmersiveHud.hudElements["staminapanel"].hudSetTargetAlpha(0f);
ImmersiveHud.hudElements["BetterUI_StaminaBar"].hudSetTargetAlpha(0f);
}
}
else
{
if (ImmersiveHud.displayStaminaBarOnUse.Value && ImmersiveHud.playerUsedStamina)
{
ImmersiveHud.hudElements["staminapanel"].showHudForDuration();
ImmersiveHud.hudElements["BetterUI_StaminaBar"].showHudForDuration();
}
if (ImmersiveHud.displayStaminaBarWhenEating.Value && ImmersiveHud.playerAteFood)
{
ImmersiveHud.hudElements["staminapanel"].showHudForDuration();
ImmersiveHud.hudElements["BetterUI_StaminaBar"].showHudForDuration();
}
if (ImmersiveHud.displayStaminaBarWhenBelow.Value && ((Character)localPlayer).GetStaminaPercentage() <= ImmersiveHud.staminaPercentage.Value)
{
ImmersiveHud.hudElements["staminapanel"].hudSetTargetAlpha(1f);
ImmersiveHud.hudElements["BetterUI_StaminaBar"].hudSetTargetAlpha(1f);
}
else if (ImmersiveHud.displayStaminaBarWhenFoodBelow.Value && ImmersiveHud.playerFoodPercentage <= ImmersiveHud.foodPercentage.Value)
{
ImmersiveHud.hudElements["staminapanel"].hudSetTargetAlpha(1f);
ImmersiveHud.hudElements["BetterUI_StaminaBar"].hudSetTargetAlpha(1f);
}
else if (ImmersiveHud.displayStaminaBarWhenHungry.Value && ImmersiveHud.playerHungerCount >= ImmersiveHud.foodHungerAmount.Value)
{
ImmersiveHud.hudElements["staminapanel"].hudSetTargetAlpha(1f);
ImmersiveHud.hudElements["BetterUI_StaminaBar"].hudSetTargetAlpha(1f);
}
else
{
ImmersiveHud.hudElements["staminapanel"].hudSetTargetAlpha(0f);
ImmersiveHud.hudElements["BetterUI_StaminaBar"].hudSetTargetAlpha(0f);
}
}
if (ImmersiveHud.displayForsakenPowerAlways.Value || (ImmersiveHud.displayPowerInInventory.Value && InventoryGui.IsVisible()))
{
ImmersiveHud.hudElements["GuardianPower"].targetAlpha = 1f;
if (!ImmersiveHud.displayPowerInInventory.Value && InventoryGui.IsVisible())
{
ImmersiveHud.hudElements["GuardianPower"].hudSetTargetAlpha(0f);
}
}
else
{
if (ImmersiveHud.displayPowerOnActivation.Value && (ZInput.GetButtonDown("GPower") || ZInput.GetButtonDown("JoyGPower")))
{
ImmersiveHud.hudElements["GuardianPower"].showHudForDuration();
}
ImmersiveHud.hudElements["GuardianPower"].hudSetTargetAlpha(0f);
}
if (ImmersiveHud.displayHotKeyBarAlways.Value || (ImmersiveHud.displayHotKeyBarInInventory.Value && InventoryGui.IsVisible()))
{
ImmersiveHud.hudElements["HotKeyBar"].targetAlpha = 1f;
if (!ImmersiveHud.displayHotKeyBarInInventory.Value && InventoryGui.IsVisible())
{
ImmersiveHud.hudElements["HotKeyBar"].hudSetTargetAlpha(0f);
}
}
else if (ImmersiveHud.displayHotKeyBarOnItemSwitch.Value && ImmersiveHud.playerUsedHotBarItem)
{
ImmersiveHud.hudElements["HotKeyBar"].showHudForDuration();
}
else if (ImmersiveHud.displayHotKeyBarWhenItemEquipped.Value && ImmersiveHud.playerHasItemEquipped)
{
ImmersiveHud.hudElements["HotKeyBar"].hudSetTargetAlpha(1f);
}
else
{
ImmersiveHud.hudElements["HotKeyBar"].hudSetTargetAlpha(0f);
}
if (ImmersiveHud.displayStatusEffectsAlways.Value || (ImmersiveHud.displayStatusEffectsInInventory.Value && InventoryGui.IsVisible()))
{
ImmersiveHud.hudElements["StatusEffects"].targetAlpha = 1f;
if (!ImmersiveHud.displayStatusEffectsInInventory.Value && InventoryGui.IsVisible())
{
ImmersiveHud.hudElements["StatusEffects"].hudSetTargetAlpha(0f);
}
}
else
{
ImmersiveHud.hudElements["StatusEffects"].hudSetTargetAlpha(0f);
}
if (ImmersiveHud.displayMiniMapAlways.Value || (ImmersiveHud.displayMiniMapInInventory.Value && InventoryGui.IsVisible()) || !ImmersiveHud.isMiniMapActive)
{
ImmersiveHud.hudElements["MiniMap"].targetAlpha = 1f;
if (!ImmersiveHud.displayMiniMapInInventory.Value && InventoryGui.IsVisible())
{
ImmersiveHud.hudElements["MiniMap"].hudSetTargetAlpha(0f);
}
}
else
{
ImmersiveHud.hudElements["MiniMap"].hudSetTargetAlpha(0f);
}
if (ImmersiveHud.aedenCompassEnabled.Value && ImmersiveHud.hudElements["Compass"].doesExist)
{
if (ImmersiveHud.displayCompassAlways.Value || (ImmersiveHud.displayCompassInInventory.Value && InventoryGui.IsVisible()))
{
ImmersiveHud.hudElements["Compass"].targetAlpha = 1f;
if (!ImmersiveHud.displayCompassInInventory.Value && InventoryGui.IsVisible())
{
ImmersiveHud.hudElements["Compass"].hudSetTargetAlpha(0f);
}
}
else
{
ImmersiveHud.hudElements["Compass"].hudSetTargetAlpha(0f);
}
}
if (ImmersiveHud.oryxenTimeEnabled.Value && ImmersiveHud.hudElements["DayTimePanel"].doesExist)
{
if (ImmersiveHud.displayTimeAlways.Value || (ImmersiveHud.displayTimeInInventory.Value && InventoryGui.IsVisible()))
{
ImmersiveHud.hudElements["DayTimePanel"].targetAlpha = 1f;
if (!ImmersiveHud.displayTimeInInventory.Value && InventoryGui.IsVisible())
{
ImmersiveHud.hudElements["DayTimePanel"].hudSetTargetAlpha(0f);
}
}
else
{
ImmersiveHud.hudElements["DayTimePanel"].hudSetTargetAlpha(0f);
}
}
if (ImmersiveHud.quickSlotsEnabled.Value && ImmersiveHud.hudElements["QuickSlotsHotkeyBar"].doesExist)
{
if (ImmersiveHud.displayQuickSlotsAlways.Value || (ImmersiveHud.displayQuickSlotsInInventory.Value && InventoryGui.IsVisible()))
{
ImmersiveHud.hudElements["QuickSlotsHotkeyBar"].targetAlpha = 1f;
if (!ImmersiveHud.displayQuickSlotsInInventory.Value && InventoryGui.IsVisible())
{
ImmersiveHud.hudElements["QuickSlotsHotkeyBar"].hudSetTargetAlpha(0f);
}
}
else
{
ImmersiveHud.hudElements["QuickSlotsHotkeyBar"].hudSetTargetAlpha(0f);
}
}
if (ImmersiveHud.displayKeyHintsAlways.Value && ImmersiveHud.hudElements["KeyHints"].doesExist)
{
ImmersiveHud.hudElements["KeyHints"].targetAlpha = 1f;
}
else
{
ImmersiveHud.hudElements["KeyHints"].hudSetTargetAlpha(0f);
}
}
string[] array4 = ImmersiveHud.hudElementNames;
foreach (string key4 in array4)
{
ImmersiveHud.hudElements[key4].hudCheckDisplayTimer();
if (ImmersiveHud.hudElements[key4].doesExist && !((Object)(object)ImmersiveHud.hudElements[key4].element == (Object)null) && ImmersiveHud.hudElements[key4].targetAlphaPrev != ImmersiveHud.hudElements[key4].targetAlpha)
{
ImmersiveHud.hudElements[key4].timeFade = 0f;
}
}
ImmersiveHud.playerUsedHotBarItem = false;
ImmersiveHud.playerUsedStamina = false;
ImmersiveHud.playerAteFood = false;
}
private static void Postfix(Hud __instance)
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
Player localPlayer = Player.m_localPlayer;
if (!ImmersiveHud.isEnabled.Value || !Object.op_Implicit((Object)(object)localPlayer) || !Object.op_Implicit((Object)(object)__instance))
{
return;
}
Transform val = ((Component)__instance).transform.Find("hudroot");
getPlayerData(val, localPlayer);
ImmersiveHud.setCompatibility(val);
KeyboardShortcut value = ImmersiveHud.hideHudKey.Value;
bool keyDown = Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey);
value = ImmersiveHud.showHudKey.Value;
setValuesBasedOnHud(keyDown, Input.GetKey(((KeyboardShortcut)(ref value)).MainKey));
if (!ImmersiveHud.hudElements["BetterUI_StaminaBar"].doesExist)
{
((Component)ImmersiveHud.hudElements["staminapanel"].element).gameObject.SetActive(true);
__instance.m_staminaAnimator.SetBool("Visible", true);
}
string[] array = ImmersiveHud.hudElementNames;
foreach (string key in array)
{
if (ImmersiveHud.hudElements[key].doesExist && !((Object)(object)ImmersiveHud.hudElements[key].element == (Object)null))
{
ImmersiveHud.hudElements[key].hudCheckLerpDuration();
if (!ImmersiveHud.hudElements[key].targetAlphaReached)
{
ImmersiveHud.hudElements[key].timeFade += Time.deltaTime;
updateHudElementTransparency(ImmersiveHud.hudElements[key]);
}
else
{
ImmersiveHud.hudElements[key].timeDisplay += Time.deltaTime;
}
}
}
}
}
[BepInPlugin("jwlei.ImmersiveHud", "Immersive Hud", "1.1.0")]
[BepInProcess("valheim.exe")]
public class ImmersiveHud : BaseUnityPlugin
{
public enum notificationTypes
{
SmallTopLeft,
LargeCenter
}
public enum hungerNotificationOptions
{
FoodHungerAmount,
FoodPercentage
}
public class HudElement
{
public Transform element;
public string elementName;
public float targetAlphaPrev;
public float targetAlpha;
public float lastSetAlpha;
public float timeFade = 0f;
public float timeDisplay = 0f;
public bool targetAlphaReached;
public bool isDisplaying;
public bool doesExist;
public HudElement(string name)
{
element = null;
elementName = name;
}
public void setElement(Transform e)
{
if ((Object)(object)e != (Object)null)
{
element = e;
doesExist = true;
}
}
public void hudSetTargetAlpha(float alpha)
{
if (!isDisplaying)
{
targetAlpha = alpha;
}
}
public void hudCheckDisplayTimer()
{
if (timeDisplay >= showHudDuration.Value && isDisplaying)
{
targetAlpha = 0f;
isDisplaying = false;
}
}
public void hudCheckLerpDuration()
{
if (timeFade >= hudFadeDuration.Value)
{
targetAlphaReached = true;
}
else
{
targetAlphaReached = false;
}
}
public void showHudForDuration()
{
if (doesExist)
{
targetAlpha = 1f;
timeDisplay = 0f;
isDisplaying = true;
}
}
public void resetTimers()
{
timeFade = 0f;
timeDisplay = 0f;
}
}
[HarmonyPatch(typeof(Hud), "Awake")]
public class Hud_Awake_Patch
{
private static void Postfix(Hud __instance)
{
if (!isEnabled.Value)
{
return;
}
Transform val = ((Component)__instance).transform.Find("hudroot");
hudElements = new Dictionary<string, HudElement>();
string[] hudElementNames = ImmersiveHud.hudElementNames;
foreach (string text in hudElementNames)
{
hudElements.Add(text, new HudElement(text));
if (!((Object)(object)val.Find(text) == (Object)null))
{
hudElements[text].setElement(val.Find(text));
((Component)((Component)hudElements[text].element).GetComponent<RectTransform>()).gameObject.AddComponent<CanvasGroup>();
}
}
hudHidden = hudHiddenOnStart.Value;
playerCrosshair = __instance.m_crosshair;
playerBowCrosshair = __instance.m_crosshairBow;
playerStealthBar = __instance.m_stealthBar;
playerStealthIndicator = __instance.m_hidden;
playerStealthIndicatorTargeted = __instance.m_targeted;
playerStealthIndicatorAlert = __instance.m_targetedAlert;
((Component)((Component)playerStealthBar).transform).gameObject.AddComponent<CanvasGroup>();
((Component)playerStealthIndicator.transform).gameObject.AddComponent<CanvasGroup>();
((Component)playerStealthIndicatorTargeted.transform).gameObject.AddComponent<CanvasGroup>();
((Component)playerStealthIndicatorAlert.transform).gameObject.AddComponent<CanvasGroup>();
crosshairSpriteOriginal = playerCrosshair.sprite;
crosshairBowSpriteOriginal = playerBowCrosshair.sprite;
if (useCustomCrosshair.Value && (Object)(object)crosshairSprite != (Object)null)
{
playerCrosshair.sprite = crosshairSprite;
}
if (useCustomBowCrosshair.Value && (Object)(object)crosshairBowSprite != (Object)null)
{
playerBowCrosshair.sprite = crosshairBowSprite;
}
setCompatibilityInit();
setCompatibility(val);
}
}
public static ConfigEntry<bool> isEnabled;
public static ConfigEntry<int> nexusID;
public static ConfigEntry<KeyboardShortcut> hideHudKey;
public static ConfigEntry<KeyboardShortcut> showHudKey;
public static ConfigEntry<bool> hudHiddenNotification;
public static ConfigEntry<bool> hudHiddenOnStart;
public static ConfigEntry<float> hudFadeDuration;
public static ConfigEntry<float> showHudDuration;
public static ConfigEntry<bool> useCustomCrosshair;
public static ConfigEntry<bool> useCustomBowCrosshair;
public static ConfigEntry<Color> crosshairColor;
public static ConfigEntry<Color> crosshairBowDrawColor;
public static ConfigEntry<bool> disableStealthHud;
public static ConfigEntry<bool> displayCrosshairAlways;
public static ConfigEntry<bool> displayCrosshairWhenBuilding;
public static ConfigEntry<bool> displayCrosshairOnActivation;
public static ConfigEntry<bool> displayCrosshairOnEquipped;
public static ConfigEntry<bool> displayCrosshairOnBowEquipped;
public static ConfigEntry<bool> displayBowDrawCrosshair;
public static float targetCrosshairAlpha;
public static float targetBowDrawCrosshairAlpha;
public static Image playerCrosshair;
public static Image playerBowCrosshair;
public static Sprite crosshairSprite;
public static Sprite crosshairBowSprite;
public static Sprite crosshairSpriteOriginal;
public static Sprite crosshairBowSpriteOriginal;
public static float targetStealthHudAlpha;
public static GuiBar playerStealthBar;
public static GameObject playerStealthIndicator;
public static GameObject playerStealthIndicatorTargeted;
public static GameObject playerStealthIndicatorAlert;
public static ConfigEntry<bool> displayHealthAlways;
public static ConfigEntry<bool> displayKeyHintsAlways;
public static ConfigEntry<bool> displayHotKeyBarAlways;
public static ConfigEntry<bool> displayForsakenPowerAlways;
public static ConfigEntry<bool> displayStatusEffectsAlways;
public static ConfigEntry<bool> displayStaminaBarAlways;
public static ConfigEntry<bool> displayMiniMapAlways;
public static ConfigEntry<bool> displayQuickSlotsAlways;
public static ConfigEntry<bool> displayBetterUIFoodAlways;
public static ConfigEntry<bool> displayCompassAlways;
public static ConfigEntry<bool> displayTimeAlways;
public static ConfigEntry<bool> quickSlotsEnabled;
public static ConfigEntry<bool> betterUIHPEnabled;
public static ConfigEntry<bool> betterUIFoodEnabled;
public static ConfigEntry<bool> betterUIStamEnabled;
public static ConfigEntry<bool> aedenCompassEnabled;
public static ConfigEntry<bool> oryxenTimeEnabled;
public static bool hudHidden;
public static ConfigEntry<bool> displayHealthInInventory;
public static ConfigEntry<bool> displayHealthWhenHungry;
public static ConfigEntry<bool> displayHealthWhenEating;
public static ConfigEntry<bool> displayHealthWhenBelow;
public static ConfigEntry<bool> displayHealthWhenFoodBelow;
public static ConfigEntry<float> healthPercentage;
public static ConfigEntry<bool> showHealthOnKeyPressed;
public static ConfigEntry<int> foodHungerAmount;
public static ConfigEntry<float> foodPercentage;
public static ConfigEntry<bool> hungerNotification;
public static ConfigEntry<int> hungerNotificationInterval;
public static ConfigEntry<hungerNotificationOptions> hungerNotificationOption;
public static ConfigEntry<string> hungerNotificationText;
public static ConfigEntry<notificationTypes> hungerNotificationType;
public static ConfigEntry<bool> displayFoodBarInInventory;
public static ConfigEntry<bool> displayFoodBarWhenHungry;
public static ConfigEntry<bool> displayFoodBarWhenEating;
public static ConfigEntry<bool> displayFoodBarWhenBelow;
public static ConfigEntry<bool> showFoodBarOnKeyPressed;
public static ConfigEntry<bool> displayStaminaBarInInventory;
public static ConfigEntry<bool> displayStaminaBarOnUse;
public static ConfigEntry<bool> displayStaminaBarWhenHungry;
public static ConfigEntry<bool> displayStaminaBarWhenEating;
public static ConfigEntry<bool> displayStaminaBarWhenBelow;
public static ConfigEntry<bool> displayStaminaBarWhenFoodBelow;
public static ConfigEntry<float> staminaPercentage;
public static ConfigEntry<bool> showStaminaBarOnKeyPressed;
public static ConfigEntry<bool> displayPowerInInventory;
public static ConfigEntry<bool> displayPowerOnActivation;
public static ConfigEntry<bool> displayPowerWhenTimeChanges;
public static ConfigEntry<bool> displayPowerOnReady;
public static ConfigEntry<float> powerTimeChangeInterval;
public static ConfigEntry<bool> showPowerOnKeyPressed;
public static ConfigEntry<bool> displayHotKeyBarInInventory;
public static ConfigEntry<bool> displayHotKeyBarOnItemSwitch;
public static ConfigEntry<bool> displayHotKeyBarWhenItemEquipped;
public static ConfigEntry<bool> showHotKeyBarOnKeyPressed;
public static ConfigEntry<bool> displayStatusEffectsInInventory;
public static ConfigEntry<bool> showStatusEffectsOnKeyPressed;
public static ConfigEntry<bool> displayMiniMapInInventory;
public static ConfigEntry<bool> showMiniMapOnKeyPressed;
public static bool isMiniMapActive;
public static ConfigEntry<bool> displayCompassInInventory;
public static ConfigEntry<bool> showCompassOnKeyPressed;
public static ConfigEntry<bool> displayTimeInInventory;
public static ConfigEntry<bool> showTimeOnKeyPressed;
public static ConfigEntry<bool> displayQuickSlotsInInventory;
public static ConfigEntry<bool> showQuickSlotsOnKeyPressed;
public static float playerTotalFoodValue;
public static float playerCurrentFoodValue;
public static float playerFoodPercentage;
public static int playerHungerCount;
public static bool characterEquippedItem;
public static bool characterEquippedBow;
public static bool isLookingAtActivatable;
public static bool playerUsedStamina;
public static bool playerAteFood;
public static bool playerUsedHotBarItem;
public static bool playerUsedQuickSlotsItem;
public static bool playerHasItemEquipped;
public static float fadeDuration = 0.5f;
public static float notificationTimer = 0f;
public static string[] hudElementNames = new string[13]
{
"healthpanel", "staminapanel", "GuardianPower", "HotKeyBar", "StatusEffects", "MiniMap", "QuickSlotsHotkeyBar", "BetterUI_HPBar", "BetterUI_FoodBar", "BetterUI_StaminaBar",
"Compass", "DayTimePanel", "KeyHints"
};
public static Dictionary<string, HudElement> hudElements;
public static Sprite LoadCrosshairTexture(string filename)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
string path = Path.Combine(Paths.PluginPath, filename);
if (File.Exists(path))
{
Texture2D val = new Texture2D(0, 0);
ImageConversion.LoadImage(val, File.ReadAllBytes(path));
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
}
Debug.Log((object)"ImmersiveHud: Error. Couldn't load provided crosshair image. Check if the folder ImmersiveHud in the plugins folder has a file named crosshair.png or bowcrosshair.png");
return null;
}
private void Awake()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Expected O, but got Unknown
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Expected O, but got Unknown
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
//IL_05c3: Expected O, but got Unknown
//IL_060a: Unknown result type (might be due to invalid IL or missing references)
//IL_0614: Expected O, but got Unknown
//IL_0647: Unknown result type (might be due to invalid IL or missing references)
//IL_0651: Expected O, but got Unknown
//IL_069d: Unknown result type (might be due to invalid IL or missing references)
//IL_06a7: Expected O, but got Unknown
//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
//IL_06d2: Expected O, but got Unknown
//IL_0717: Unknown result type (might be due to invalid IL or missing references)
//IL_0721: Expected O, but got Unknown
//IL_08b4: Unknown result type (might be due to invalid IL or missing references)
//IL_08be: Expected O, but got Unknown
isEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("- General -", "Enable Mod", true, "Enable or disable the mod");
nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("- General -", "NexusID", 790, "Nexus mod ID for updates");
hideHudKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("- Main Settings -", "hideHudKey", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), "Keyboard shortcut or mouse button to hide the hud permanently.");
hudHiddenOnStart = ((BaseUnityPlugin)this).Config.Bind<bool>("- Main Settings -", "hudHiddenOnStart", false, "Hide the hud when the game is started.");
hudHiddenNotification = ((BaseUnityPlugin)this).Config.Bind<bool>("- Main Settings -", "hudHiddenNotification", true, "Enable notifications in the top left corner for hiding the hud.");
hudFadeDuration = ((BaseUnityPlugin)this).Config.Bind<float>("- Main Settings -", "hudFadeDuration", 1f, "How quickly the hud fades in or out.");
showHudDuration = ((BaseUnityPlugin)this).Config.Bind<float>("- Main Settings -", "showHudDuration", 1f, "How long a hud element should stay up for when it is activated for certain conditions.");
showHudKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("- Main Settings -", "showHudKey", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), "Keyboard shortcut or mouse button to display the hud for a duration.");
quickSlotsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("- Mod Compatibility -", "quickSlotsEnabled", false, "Enable compatibility for quickslots mod.");
betterUIHPEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("- Mod Compatibility -", "betterUIHPEnabled", false, "Enable compatibility for Better UI's custom HP bar.");
betterUIFoodEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("- Mod Compatibility -", "betterUIFoodEnabled", false, "Enable compatibility for Better UI's custom food bar.");
betterUIStamEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("- Mod Compatibility -", "betterUIStamEnabled", false, "Enable compatibility for Better UI's custom stamina bar.");
aedenCompassEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("- Mod Compatibility -", "aedenCompassEnabled", false, "Enable compatibility for aedenthorn's compass mod.");
oryxenTimeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("- Mod Compatibility -", "oryxenTimeEnabled", false, "Enable compatibility for oryxen's display day and time mod.");
useCustomCrosshair = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Crosshair -", "useCustomCrosshair", false, new ConfigDescription("Enable or disable the new crosshair.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 1
}
}));
useCustomBowCrosshair = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Crosshair -", "useCustomBowCrosshair", false, new ConfigDescription("Enable or disable the new crosshair for the bow draw.", (AcceptableValueBase)null, new object[1]
{
new ConfigurationManagerAttributes
{
Order = 2
}
}));
crosshairColor = ((BaseUnityPlugin)this).Config.Bind<Color>("- Settings: Crosshair -", "crosshairColor", Color.white, "Color and transparency of the crosshair.");
crosshairBowDrawColor = ((BaseUnityPlugin)this).Config.Bind<Color>("- Settings: Crosshair -", "crosshairBowDrawColor", Color.yellow, "Color and transparency of the bow draw crosshair.");
disableStealthHud = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Crosshair -", "disableStealthHud", false, "Disable the stealth bar and indicator so it doesn't display.");
displayCrosshairAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Crosshair -", "displayCrosshairAlways", true, "Always display the crosshair, overriding other display crosshair settings.");
displayBowDrawCrosshair = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Crosshair -", "displayBowDrawCrosshair", true, "Display the bow draw crosshair.");
displayCrosshairWhenBuilding = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Crosshair -", "displayCrosshairWhenBuilding", true, "Display the crosshair when you have the hammer equipped.");
displayCrosshairOnActivation = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Crosshair -", "displayCrosshairOnActivation", false, "Display crosshair when hovering over an activatable object.");
displayCrosshairOnEquipped = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Crosshair -", "displayCrosshairOnEquipped", false, "Display crosshair when an item is equipped in either hand.");
displayCrosshairOnBowEquipped = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Crosshair -", "displayCrosshairOnBowEquipped", false, "Display crosshair when the bow is equipped.");
displayHealthAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayHealthAlways", false, "Always display the health panel.");
displayHotKeyBarAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayHotbarAlways", false, "Always display the hotbar.");
displayForsakenPowerAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayForsakenPowerAlways", false, "Always display the forsaken power.");
displayStatusEffectsAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayStatusEffectsAlways", false, "Always display status effects.");
displayStaminaBarAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayStaminaBarAlways", false, "Always display the stamina bar.");
displayMiniMapAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayMiniMapAlways", false, "Always display the minimap.");
displayQuickSlotsAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayQuickSlotsAlways", false, "Always display the quick slots (Requires quick slots mod).");
displayBetterUIFoodAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayBetterUIFoodAlways", false, "Always display the food bar (Requires Better UI).");
displayCompassAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayCompassAlways", false, "Always display the compass (Requires aedenthorn's compass).");
displayTimeAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayTimeAlways", false, "Always display the time or clock (Requires oryxen's display day and time mod).");
displayKeyHintsAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("- Settings: Display -", "displayKeyHintsAlways", false, "Always display the key hints.");
displayHealthInInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Health", "displayHealthInInventory", true, "Display your health when in the inventory.");
displayHealthWhenHungry = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Health", "displayHealthWhenHungry", false, "Display the health panel when you are hungry.");
displayHealthWhenEating = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Health", "displayHealthWhenEating", false, "Display the health panel when you eat food.");
displayHealthWhenBelow = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Health", "displayHealthWhenBelow", true, "When you are at or below a certain health percentage, display the health panel.");
displayHealthWhenFoodBelow = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Health", "displayHealthWhenFoodBelow", true, "When you are at or below a certain food percentage, display the health panel.");
healthPercentage = ((BaseUnityPlugin)this).Config.Bind<float>("Display - Health", "healthPercentage", 0.75f, new ConfigDescription("Health percentage at which the health panel should be displayed", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
showHealthOnKeyPressed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Health", "showHealthOnKeyPressed", true, "Show the health panel when the show hud key is pressed.");
foodHungerAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Display - Food", "foodHungerAmount", 3, new ConfigDescription("The minimum amount of food icons that need to be flashing to be considered hungry.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>()));
foodPercentage = ((BaseUnityPlugin)this).Config.Bind<float>("Display - Food", "foodPercentage", 0.35f, new ConfigDescription("Food percentage at which the food bar, health, or stamina should be displayed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
hungerNotification = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Food", "hungerNotification", false, "Enable notifications for when you are hungry.");
hungerNotificationInterval = ((BaseUnityPlugin)this).Config.Bind<int>("Display - Food", "hungerNotificationInterval", 25, new ConfigDescription("How often the notification should display in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 180), Array.Empty<object>()));
hungerNotificationOption = ((BaseUnityPlugin)this).Config.Bind<hungerNotificationOptions>("Display - Food", "hungerNotificationOption", hungerNotificationOptions.FoodPercentage, new ConfigDescription("Option to be used for notifications.", (AcceptableValueBase)null, Array.Empty<object>()));
hungerNotificationText = ((BaseUnityPlugin)this).Config.Bind<string>("Display - Food", "hungerNotificationText", "I'm feeling a bit peckish.", "Message for hunger notification.");
hungerNotificationType = ((BaseUnityPlugin)this).Config.Bind<notificationTypes>("Display - Food", "hungerNotificationType", notificationTypes.SmallTopLeft, new ConfigDescription("Notification types for the hunger notification.", (AcceptableValueBase)null, Array.Empty<object>()));
displayFoodBarInInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Food Bar (Better UI)", "displayBetterUIFoodBarInInventory", true, "Display the food bar when in the inventory.");
displayFoodBarWhenHungry = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Food Bar (Better UI)", "displayFoodBarWhenHungry", true, "Display the food bar when you are hungry.");
displayFoodBarWhenEating = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Food Bar (Better UI)", "displayFoodBarWhenEating", true, "Display the food bar when you eat food.");
displayFoodBarWhenBelow = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Food Bar (Better UI)", "displayFoodBarWhenBelow", true, "When you are at or below a certain food percentage, display the food bar.");
showFoodBarOnKeyPressed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Food Bar (Better UI)", "showFoodBarOnKeyPressed", true, "Display the food bar when the show hud key is pressed.");
displayStaminaBarInInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Stamina Bar", "displayStaminaBarInInventory", true, "Display the stamina bar when in the inventory.");
displayStaminaBarOnUse = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Stamina Bar", "displayStaminaBarOnUse", true, "Display the stamina bar when stamina is used.");
displayStaminaBarWhenHungry = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Stamina Bar", "displayStaminaBarWhenHungry", false, "Display the stamina bar when you are hungry.");
displayStaminaBarWhenEating = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Stamina Bar", "displayStaminaBarWhenEating", true, "Display the stamina bar when you eat food.");
displayStaminaBarWhenBelow = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Stamina Bar", "displayStaminaBarWhenBelow", true, "When you are at or below a certain stamina percentage, display the stamina bar.");
displayStaminaBarWhenFoodBelow = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Stamina Bar", "displayStaminaBarWhenFoodBelow", false, "When you are at or below a certain food percentage, display the stamina bar.");
staminaPercentage = ((BaseUnityPlugin)this).Config.Bind<float>("Display - Stamina Bar", "staminaPercentage", 0.99f, new ConfigDescription("Stamina percentage at which the stamina bar should be displayed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
showStaminaBarOnKeyPressed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Stamina Bar", "showStaminaBarOnKeyPressed", true, "Show the stamina bar when the show hud key is pressed.");
displayPowerInInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Forsaken Power", "displayPowerInInventory", true, "Display the forsaken power when in the inventory.");
displayPowerOnActivation = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Forsaken Power", "displayPowerOnActivation", false, "Display the forsaken power when the key to use it is pressed.");
showPowerOnKeyPressed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Forsaken Power", "showPowerOnKeyPressed", true, "Show the forsaken power when the show hud key is pressed.");
displayHotKeyBarInInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Hot Key Bar", "displayHotKeyBarInInventory", true, "Display the hot key bar when in the inventory.");
displayHotKeyBarOnItemSwitch = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Hot Key Bar", "displayHotKeyBarOnItemSwitch", false, "Display the hot key bar when you press any key for your hot bar items.");
displayHotKeyBarWhenItemEquipped = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Hot Key Bar", "displayHotKeyBarWhenItemEquipped", false, "Display the hot key bar when you have an item equipped in either hand.");
showHotKeyBarOnKeyPressed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Hot Key Bar", "showHotKeyBarOnKeyPressed", true, "Show the hot key bar when the show hud key is pressed.");
displayStatusEffectsInInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Status Effects", "displayStatusEffectsInInventory", true, "Display status effects when in the inventory.");
showStatusEffectsOnKeyPressed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Status Effects", "showStatusEffectsOnKeyPressed", true, "Show the status effects when the show hud key is pressed.");
displayMiniMapInInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - MiniMap", "displayMiniMapInInventory", true, "Display the minimap when in the inventory.");
showMiniMapOnKeyPressed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - MiniMap", "showMiniMapOnKeyPressed", true, "Show the minimap when the show hud key is pressed.");
displayCompassInInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Compass", "displayCompassInInventory", false, "Display the compass when in the inventory.");
showCompassOnKeyPressed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Compass", "showCompassOnKeyPressed", false, "Show the compass when the show hud key is pressed.");
displayTimeInInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Day and Time", "displayTimeInInventory", false, "Display the time when in the inventory.");
showTimeOnKeyPressed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Day and Time", "showTimeOnKeyPressed", false, "Show the time when the show hud key is pressed.");
displayQuickSlotsInInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Quick Slots", "displayQuickSlotsInInventory", false, "Display quick slots when in the inventory.");
showQuickSlotsOnKeyPressed = ((BaseUnityPlugin)this).Config.Bind<bool>("Display - Quick Slots", "showQuickSlotsOnKeyPressed", false, "Show the quick slots when the show hud key is pressed.");
crosshairSprite = LoadCrosshairTexture("ImmersiveHud/crosshair.png");
crosshairBowSprite = LoadCrosshairTexture("ImmersiveHud/bowcrosshair.png");
DoPatching();
}
public static void DoPatching()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("ImmersiveHud").PatchAll();
}
public static void DebugListOfHudElements(Transform hud)
{
Transform[] componentsInChildren = ((Component)hud).GetComponentsInChildren<Transform>(true);
foreach (Transform val in componentsInChildren)
{
Debug.Log((object)((Object)val).name);
}
}
public static void setCompatibilityInit()
{
hudElements["BetterUI_HPBar"].doesExist = false;
hudElements["BetterUI_FoodBar"].doesExist = false;
hudElements["BetterUI_StaminaBar"].doesExist = false;
hudElements["Compass"].doesExist = false;
hudElements["QuickSlotsHotkeyBar"].doesExist = false;
}
public static void setCompatibility(Transform hud)
{
if (betterUIHPEnabled.Value && !hudElements["BetterUI_HPBar"].doesExist && Object.op_Implicit((Object)(object)hud.Find("BetterUI_HPBar")))
{
hudElements["BetterUI_HPBar"].setElement(hud.Find("BetterUI_HPBar"));
((Component)((Component)hudElements["BetterUI_HPBar"].element).GetComponent<RectTransform>()).gameObject.AddComponent<CanvasGroup>();
}
if (betterUIFoodEnabled.Value && !hudElements["BetterUI_FoodBar"].doesExist && Object.op_Implicit((Object)(object)hud.Find("BetterUI_FoodBar")))
{
hudElements["BetterUI_FoodBar"].setElement(hud.Find("BetterUI_FoodBar"));
((Component)((Component)hudElements["BetterUI_FoodBar"].element).GetComponent<RectTransform>()).gameObject.AddComponent<CanvasGroup>();
}
if (betterUIStamEnabled.Value && !hudElements["BetterUI_StaminaBar"].doesExist && Object.op_Implicit((Object)(object)hud.Find("BetterUI_StaminaBar")))
{
hudElements["BetterUI_StaminaBar"].setElement(hud.Find("BetterUI_StaminaBar"));
((Component)((Component)hudElements["BetterUI_StaminaBar"].element).GetComponent<RectTransform>()).gameObject.AddComponent<CanvasGroup>();
}
if (aedenCompassEnabled.Value && !hudElements["Compass"].doesExist && Object.op_Implicit((Object)(object)hud.Find("Compass")))
{
hudElements["Compass"].setElement(hud.Find("Compass"));
((Component)((Component)hudElements["Compass"].element).GetComponent<RectTransform>()).gameObject.AddComponent<CanvasGroup>();
}
if (oryxenTimeEnabled.Value && !hudElements["DayTimePanel"].doesExist && Object.op_Implicit((Object)(object)hud.Find("DayTimePanel")))
{
hudElements["DayTimePanel"].setElement(hud.Find("DayTimePanel"));
((Component)((Component)hudElements["DayTimePanel"].element).GetComponent<RectTransform>()).gameObject.AddComponent<CanvasGroup>();
}
if (quickSlotsEnabled.Value && !hudElements["QuickSlotsHotkeyBar"].doesExist && Object.op_Implicit((Object)(object)hud.Find("QuickSlotsHotkeyBar")))
{
hudElements["QuickSlotsHotkeyBar"].setElement(hud.Find("QuickSlotsHotkeyBar"));
((Component)((Component)hudElements["QuickSlotsHotkeyBar"].element).GetComponent<RectTransform>()).gameObject.AddComponent<CanvasGroup>();
}
}
}