using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2.UI;
using RoR2.UI;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RoR2_ImmersiveHUD")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RoR2_ImmersiveHUD")]
[assembly: AssemblyTitle("RoR2_ImmersiveHUD")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace RoR2_ImmersiveHUD
{
public static class BetterHudLiteCompat
{
private const string PluginGUID = "com.TheTimeSweeper.BetterHudLite";
public static bool IsLoaded { get; private set; }
static BetterHudLiteCompat()
{
IsLoaded = Chainloader.PluginInfos.ContainsKey("com.TheTimeSweeper.BetterHudLite");
}
public static GameObject GetHealthObject(Transform springCanvas)
{
if (!IsLoaded || (Object)(object)springCanvas == (Object)null)
{
return null;
}
Transform val = springCanvas.Find("BottomCenterCluster/BarRoots");
if (!Object.op_Implicit((Object)(object)val))
{
return null;
}
return ((Component)val).gameObject;
}
public static GameObject GetSkillsObject(Transform springCanvas)
{
if (!IsLoaded || (Object)(object)springCanvas == (Object)null)
{
return null;
}
Transform val = springCanvas.Find("BottomCenterCluster/Scaler");
if (!Object.op_Implicit((Object)(object)val))
{
return null;
}
return ((Component)val).gameObject;
}
}
public static class ChatTooltipsCompat
{
public enum TooltipType
{
Pickup,
Achievement,
Ping
}
private const string GUID = "bulletbot.chattooltips";
public static bool IsLoaded { get; private set; }
static ChatTooltipsCompat()
{
IsLoaded = Chainloader.PluginInfos.ContainsKey("bulletbot.chattooltips");
}
public static string GenerateTooltipString(string visibleText, string token, int type = 0, int quantity = 1)
{
if (!IsLoaded)
{
return visibleText;
}
string text = $"{type}|{token}|{quantity}";
return "<link=\"" + text + "\">" + visibleText + "</link>";
}
}
public static class HunkHudCompat
{
private const string BaseTypeName = "HunkHud.Components.DisplayMover";
private static Type _displayMoverType;
private static MethodInfo _setActiveMethod;
private static bool _initialized;
private static bool _isHunkHudLoaded;
public static void Init()
{
if (_initialized)
{
return;
}
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < assemblies.Length; i++)
{
_displayMoverType = assemblies[i].GetType("HunkHud.Components.DisplayMover");
if (_displayMoverType != null)
{
_setActiveMethod = _displayMoverType.GetMethod("SetActive", new Type[0]);
_isHunkHudLoaded = true;
break;
}
}
_initialized = true;
}
public static List<MonoBehaviour> FindMovers(Transform root)
{
List<MonoBehaviour> list = new List<MonoBehaviour>();
if (!_isHunkHudLoaded || (Object)(object)root == (Object)null)
{
return list;
}
Component[] componentsInChildren = ((Component)root).GetComponentsInChildren(_displayMoverType, true);
foreach (Component obj in componentsInChildren)
{
MonoBehaviour val = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
if (val != null)
{
list.Add(val);
}
}
return list;
}
public static void ForceActive(MonoBehaviour mover)
{
if ((Object)(object)mover != (Object)null && _setActiveMethod != null)
{
_setActiveMethod.Invoke(mover, null);
}
}
public static string GetMoverType(MonoBehaviour mover)
{
if ((Object)(object)mover == (Object)null)
{
return "";
}
return ((object)mover).GetType().Name;
}
}
[BepInPlugin("Cyphers.ImmersiveHUD", "Immersive HUD", "2.0.0")]
public class ImmersiveHUD : BaseUnityPlugin
{
public static ConfigEntry<KeyboardShortcut> ToggleKey;
public static ConfigEntry<KeyboardShortcut> DebugKey;
public static ConfigEntry<float> FadeInDuration;
public static ConfigEntry<float> FadeOutDuration;
public static ConfigEntry<bool> ShowHealth;
public static ConfigEntry<bool> ShowSkills;
public static ConfigEntry<bool> ShowMoney;
public static ConfigEntry<bool> ShowTopRight;
public static ConfigEntry<bool> ShowBoss;
public static ConfigEntry<bool> ShowReticle;
public static ConfigEntry<bool> ShowAllies;
public static ConfigEntry<bool> ShowNotifications;
public static ConfigEntry<bool> ShowStatsDisplay;
public static ConfigEntry<bool> ShowBHLHealth;
public static ConfigEntry<bool> ShowBHLSkills;
public static ConfigEntry<bool> ForceHunkHealth;
public static ConfigEntry<bool> ForceHunkSkills;
public static ConfigEntry<bool> ForceHunkMoney;
public static ConfigEntry<bool> ForceHunkAllies;
public static ConfigEntry<bool> ForceHunkItems;
public static ConfigEntry<bool> ForceHunkObjectives;
public void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Expected O, but got Unknown
HunkHudCompat.Init();
ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "Toggle HUD Key", new KeyboardShortcut((KeyCode)112, Array.Empty<KeyCode>()), "Key to fade the HUD in/out.");
DebugKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "Debug Hierarchy Key", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Press to print UI names.");
FadeInDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Fade In Duration", 0.5f, "Seconds it takes for the HUD to appear.");
FadeOutDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Fade Out Duration", 1.5f, "Seconds it takes for the HUD to disappear.");
ShowHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Health", false, "Keep Health/Level bar visible?");
ShowSkills = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Skills", false, "Keep Skills/Items visible?");
ShowMoney = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Money", false, "Keep Money/Lunar Coins visible?");
ShowTopRight = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Difficulty and Timer", false, "Keep Difficulty/Timer/Stage visible?");
ShowBoss = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Boss Health", false, "Keep Boss Health visible?");
ShowReticle = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Reticle", true, "Keep Crosshair visible?");
ShowAllies = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Ally Cards", false, "Keep Ally/Drone list visible?");
ShowNotifications = ((BaseUnityPlugin)this).Config.Bind<bool>("Visibility", "Show Notifications", true, "If true, pickups behave normally. If false, hidden until P is pressed.");
ShowStatsDisplay = ((BaseUnityPlugin)this).Config.Bind<bool>("Mod Compatibility", "Show LookingGlass Stats", false, "Keep the LookingGlass Stats Display visible? (Only applies if Stats are Detached).");
ShowBHLHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("BetterHudLite Compatibility", "Show Health Bar", false, "Keep BetterHudLite Health/Level bar visible?");
ShowBHLSkills = ((BaseUnityPlugin)this).Config.Bind<bool>("BetterHudLite Compatibility", "Show Skills", false, "Keep BetterHudLite Skills visible?");
ForceHunkHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("HunkHUD Compatibility", "Force Health Bar", true, "Force HunkHUD Health Bar to stay on screen when HUD is toggled ON.");
ForceHunkSkills = ((BaseUnityPlugin)this).Config.Bind<bool>("HunkHUD Compatibility", "Force Skills", true, "Force HunkHUD Skills to stay on screen when HUD is toggled ON.");
ForceHunkMoney = ((BaseUnityPlugin)this).Config.Bind<bool>("HunkHUD Compatibility", "Force Money", true, "Force HunkHUD Money to stay on screen when HUD is toggled ON.");
ForceHunkAllies = ((BaseUnityPlugin)this).Config.Bind<bool>("HunkHUD Compatibility", "Force Ally Cards", true, "Force HunkHUD Ally Cards to stay on screen when HUD is toggled ON.");
ForceHunkItems = ((BaseUnityPlugin)this).Config.Bind<bool>("HunkHUD Compatibility", "Force Items", true, "Force HunkHUD Item Bar (Top Center) to stay on screen when HUD is toggled ON.");
ForceHunkObjectives = ((BaseUnityPlugin)this).Config.Bind<bool>("HunkHUD Compatibility", "Force Objectives", true, "Force HunkHUD Objectives/Timer to stay on screen when HUD is toggled ON.");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Immersive HUD 2.8 Loaded (Separate BHL Configs).");
HUD.Awake += new hook_Awake(HUD_Awake);
}
private void HUD_Awake(orig_Awake orig, HUD self)
{
orig.Invoke(self);
((Component)self).gameObject.AddComponent<ImmersiveHUDController>();
}
}
public class ImmersiveHUDController : MonoBehaviour
{
private class HUDElement
{
public GameObject GameObject;
public CanvasGroup CanvasGroup;
public ConfigEntry<bool> Config;
public bool IsDynamic;
public HUDElement(GameObject obj, ConfigEntry<bool> cfg, bool isDynamic = false)
{
GameObject = obj;
Config = cfg;
IsDynamic = isDynamic;
CanvasGroup = obj.GetComponent<CanvasGroup>();
if (!Object.op_Implicit((Object)(object)CanvasGroup))
{
CanvasGroup = obj.AddComponent<CanvasGroup>();
}
}
}
private List<HUDElement> _elements = new List<HUDElement>();
private HashSet<GameObject> _trackedObjects = new HashSet<GameObject>();
private List<MonoBehaviour> _hunkHudMovers = new List<MonoBehaviour>();
private float _scanTimer;
private bool _tempShowAll;
private Transform _springCanvas;
private Transform _mainUiArea;
public IEnumerator Start()
{
yield return (object)new WaitForSeconds(0.2f);
FindUIElements();
RefreshDynamicElements();
}
private void FindUIElements()
{
_mainUiArea = ((Component)this).transform.Find("MainContainer/MainUIArea");
_springCanvas = (Object.op_Implicit((Object)(object)_mainUiArea) ? _mainUiArea.Find("SpringCanvas") : null);
if (Object.op_Implicit((Object)(object)_springCanvas))
{
if (BetterHudLiteCompat.IsLoaded)
{
GameObject healthObject = BetterHudLiteCompat.GetHealthObject(_springCanvas);
if (Object.op_Implicit((Object)(object)healthObject))
{
AddDirect(healthObject, ImmersiveHUD.ShowBHLHealth);
}
else
{
Add(_springCanvas, "BottomLeftCluster", null, ImmersiveHUD.ShowHealth);
}
}
else
{
Add(_springCanvas, "BottomLeftCluster", null, ImmersiveHUD.ShowHealth);
}
if (BetterHudLiteCompat.IsLoaded)
{
GameObject skillsObject = BetterHudLiteCompat.GetSkillsObject(_springCanvas);
if (Object.op_Implicit((Object)(object)skillsObject))
{
AddDirect(skillsObject, ImmersiveHUD.ShowBHLSkills);
}
Add(_springCanvas, "BottomRightCluster", null, ImmersiveHUD.ShowBHLSkills);
}
else
{
Add(_springCanvas, "BottomRightCluster", null, ImmersiveHUD.ShowSkills);
}
Add(_springCanvas, "UpperLeftCluster", "TopLeftCluster", ImmersiveHUD.ShowMoney);
Add(_springCanvas, "UpperRightCluster", "TopRightCluster", ImmersiveHUD.ShowTopRight);
Add(_springCanvas, "TopCenterCluster", "BossHealth", ImmersiveHUD.ShowBoss);
Add(_springCanvas, "LeftCluster", null, ImmersiveHUD.ShowAllies);
Add(_springCanvas, "NotificationArea", "NotificationPanel", ImmersiveHUD.ShowNotifications, isDynamic: true);
}
if (Object.op_Implicit((Object)(object)_mainUiArea))
{
GameObject val = FindChild(_mainUiArea, "CrosshairCanvas");
if (!Object.op_Implicit((Object)(object)val))
{
val = FindChildRecursive(_mainUiArea, "Crosshair");
}
AddDirect(val, ImmersiveHUD.ShowReticle);
Add(_mainUiArea, "PlayerStats", null, ImmersiveHUD.ShowStatsDisplay);
}
void Add(Transform root, string name, string altName, ConfigEntry<bool> config, bool isDynamic = false)
{
if (Object.op_Implicit((Object)(object)root))
{
GameObject val2 = FindChild(root, name);
if (!Object.op_Implicit((Object)(object)val2) && !string.IsNullOrEmpty(altName))
{
val2 = FindChild(root, altName);
}
if (!Object.op_Implicit((Object)(object)val2))
{
val2 = FindChildRecursive(root, name);
}
AddDirect(val2, config);
}
}
void AddDirect(GameObject obj, ConfigEntry<bool> config)
{
if (Object.op_Implicit((Object)(object)obj) && !_trackedObjects.Contains(obj))
{
_elements.Add(new HUDElement(obj, config));
_trackedObjects.Add(obj);
}
}
}
public void Update()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = ImmersiveHUD.ToggleKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
_tempShowAll = !_tempShowAll;
if (_tempShowAll)
{
RefreshDynamicElements();
}
}
value = ImmersiveHUD.DebugKey.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
DumpHierarchy();
}
if (_tempShowAll)
{
_scanTimer += Time.deltaTime;
if (_scanTimer > 1f)
{
RefreshDynamicElements();
_scanTimer = 0f;
}
}
UpdateFades();
UpdateHunkHud();
}
private void RefreshDynamicElements()
{
if (Object.op_Implicit((Object)(object)_springCanvas))
{
_hunkHudMovers = HunkHudCompat.FindMovers(_springCanvas);
}
if (Object.op_Implicit((Object)(object)_mainUiArea))
{
GameObject val = FindChild(_mainUiArea, "PlayerStats");
if (Object.op_Implicit((Object)(object)val) && !_trackedObjects.Contains(val))
{
_elements.Add(new HUDElement(val, ImmersiveHUD.ShowStatsDisplay));
_trackedObjects.Add(val);
}
}
}
private void UpdateHunkHud()
{
if (!_tempShowAll || _hunkHudMovers.Count == 0)
{
return;
}
foreach (MonoBehaviour hunkHudMover in _hunkHudMovers)
{
string moverType = HunkHudCompat.GetMoverType(hunkHudMover);
bool flag = false;
if (moverType.Contains("HealthBarMover") && ImmersiveHUD.ForceHunkHealth.Value)
{
flag = true;
}
else if (moverType.Contains("SkillIconMover") && ImmersiveHUD.ForceHunkSkills.Value)
{
flag = true;
}
else if (moverType.Contains("MoneyDisplayMover") && ImmersiveHUD.ForceHunkMoney.Value)
{
flag = true;
}
else if (moverType.Contains("AllyHealthBarMover") && ImmersiveHUD.ForceHunkAllies.Value)
{
flag = true;
}
else if (moverType.Contains("ItemDisplayMover") && ImmersiveHUD.ForceHunkItems.Value)
{
flag = true;
}
else if (moverType.Contains("ObjectiveDisplayMover") && ImmersiveHUD.ForceHunkObjectives.Value)
{
flag = true;
}
if (flag)
{
HunkHudCompat.ForceActive(hunkHudMover);
}
}
}
private void UpdateFades()
{
float deltaTime = Time.deltaTime;
foreach (HUDElement element in _elements)
{
if (element.IsDynamic && element.Config.Value && !_tempShowAll)
{
if (!element.CanvasGroup.blocksRaycasts && element.CanvasGroup.alpha > 0.1f)
{
element.CanvasGroup.blocksRaycasts = true;
}
continue;
}
float num = ((_tempShowAll || element.Config.Value) ? 1f : 0f);
float alpha = element.CanvasGroup.alpha;
float num2 = ((num > alpha) ? ImmersiveHUD.FadeInDuration.Value : ImmersiveHUD.FadeOutDuration.Value);
float num3 = 1f / Mathf.Max(0.001f, num2);
float num4 = Mathf.MoveTowards(alpha, num, num3 * deltaTime);
element.CanvasGroup.alpha = num4;
element.CanvasGroup.blocksRaycasts = num4 > 0.1f;
}
}
private GameObject FindChild(Transform parent, string name)
{
Transform val = parent.Find(name);
if (!Object.op_Implicit((Object)(object)val))
{
return null;
}
return ((Component)val).gameObject;
}
private GameObject FindChildRecursive(Transform parent, string nameFragment)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
foreach (Transform item in parent)
{
Transform val = item;
if (((Object)val).name.Contains(nameFragment))
{
return ((Component)val).gameObject;
}
GameObject val2 = FindChildRecursive(val, nameFragment);
if ((Object)(object)val2 != (Object)null)
{
return val2;
}
}
return null;
}
private void DumpHierarchy()
{
Debug.Log((object)"--- ImmersiveHUD Full Dump ---");
Dump(((Component)this).transform, ">");
static void Dump(Transform t, string prefix)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
Debug.Log((object)$"{prefix}{((Object)t).name} [Active: {((Component)t).gameObject.activeInHierarchy}]");
foreach (Transform item in t)
{
Dump(item, prefix + "-");
}
}
}
}
}