using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("PassivePowersTooltipFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PassivePowersTooltipFix")] [assembly: AssemblyTitle("PassivePowersTooltipFix")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PassivePowersTooltipFix { [BepInPlugin("com.caleb.passivepowerstooltipfix", "PassivePowers Tooltip Fix", "1.0.5")] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Hud), "UpdateCrosshair")] private static class HudUpdateCrosshairPatch { private static void Postfix(Hud __instance) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) if (!Enabled.Value) { return; } try { TMP_Text hoverLabel = GetHoverLabel(__instance); if ((Object)(object)hoverLabel == (Object)null || !((Component)hoverLabel).gameObject.activeInHierarchy || !LooksLikePassivePowersTooltip(hoverLabel.text)) { return; } RectTransform rectTransform = hoverLabel.rectTransform; if (!((Object)(object)rectTransform == (Object)null)) { if (TooltipWidth.Value > 0f) { rectTransform.SetSizeWithCurrentAnchors((Axis)0, TooltipWidth.Value); } if (ChangeFontSize.Value && FontSize.Value > 0f) { hoverLabel.fontSize = FontSize.Value; } Vector2 anchoredPosition = rectTransform.anchoredPosition + new Vector2(ExtraX.Value, ExtraY.Value); rectTransform.anchoredPosition = anchoredPosition; if (KeepInsideScreen.Value) { ClampRectToScreen(rectTransform); } } } catch (Exception arg) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogDebug((object)$"Tooltip adjustment failed: {arg}"); } } } } public const string Guid = "com.caleb.passivepowerstooltipfix"; public const string Name = "PassivePowers Tooltip Fix"; public const string Version = "1.0.5"; internal static Plugin Instance; private Harmony _harmony; internal static ConfigEntry Enabled; internal static ConfigEntry KeepInsideScreen; internal static ConfigEntry TooltipWidth; internal static ConfigEntry ScreenPadding; internal static ConfigEntry ExtraX; internal static ConfigEntry ExtraY; internal static ConfigEntry ChangeFontSize; internal static ConfigEntry FontSize; private static FieldInfo _hoverNameField; private void Awake() { //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown Instance = this; Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Enable the PassivePowers tooltip fix."); KeepInsideScreen = ((BaseUnityPlugin)this).Config.Bind("Position", "KeepInsideScreen", true, "Automatically keep the PassivePowers tooltip inside the visible screen."); TooltipWidth = ((BaseUnityPlugin)this).Config.Bind("Position", "TooltipWidth", 600f, "Width of the PassivePowers tooltip in pixels. Set to 0 to leave its width unchanged."); ScreenPadding = ((BaseUnityPlugin)this).Config.Bind("Position", "ScreenPadding", 20f, "Minimum distance from the screen edge in pixels."); ExtraX = ((BaseUnityPlugin)this).Config.Bind("Position", "ExtraX", 0f, "Additional horizontal offset in pixels."); ExtraY = ((BaseUnityPlugin)this).Config.Bind("Position", "ExtraY", 0f, "Additional vertical offset in pixels."); ChangeFontSize = ((BaseUnityPlugin)this).Config.Bind("Display", "ChangeFontSize", false, "Override the tooltip font size."); FontSize = ((BaseUnityPlugin)this).Config.Bind("Display", "FontSize", 18f, "Font size used when ChangeFontSize is enabled."); _harmony = new Harmony("com.caleb.passivepowerstooltipfix"); _harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"PassivePowers Tooltip Fix 1.0.5 loaded."); } internal static TMP_Text GetHoverLabel(Hud hud) { if ((Object)(object)hud == (Object)null) { return null; } try { if (_hoverNameField == null) { _hoverNameField = typeof(Hud).GetField("m_hoverName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (_hoverNameField == null) { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)"Could not find Hud.m_hoverName."); } return null; } object? value = _hoverNameField.GetValue(hud); return (TMP_Text)((value is TMP_Text) ? value : null); } catch (Exception ex) { Plugin instance2 = Instance; if (instance2 != null) { ((BaseUnityPlugin)instance2).Logger.LogWarning((object)("Could not read Hud.m_hoverName: " + ex.Message)); } return null; } } private static bool LooksLikePassivePowersTooltip(string text) { if (string.IsNullOrEmpty(text)) { return false; } bool num = text.IndexOf("You need to kill the boss", StringComparison.OrdinalIgnoreCase) >= 0; bool flag = text.IndexOf("Passive:", StringComparison.OrdinalIgnoreCase) >= 0; bool flag2 = text.IndexOf("Active:", StringComparison.OrdinalIgnoreCase) >= 0; if (!num) { return flag && flag2; } return true; } private static void ClampRectToScreen(RectTransform rect) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) Canvas componentInParent = ((Component)rect).GetComponentInParent(); Transform parent = ((Transform)rect).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)componentInParent == (Object)null || (Object)(object)val == (Object)null) { return; } Camera val2 = (((int)componentInParent.renderMode == 0) ? null : componentInParent.worldCamera); Vector3[] array = (Vector3[])(object)new Vector3[4]; rect.GetWorldCorners(array); float num = float.MaxValue; float num2 = float.MinValue; float num3 = float.MaxValue; float num4 = float.MinValue; for (int i = 0; i < array.Length; i++) { Vector2 val3 = RectTransformUtility.WorldToScreenPoint(val2, array[i]); num = Mathf.Min(num, val3.x); num2 = Mathf.Max(num2, val3.x); num3 = Mathf.Min(num3, val3.y); num4 = Mathf.Max(num4, val3.y); } float num5 = 0f; float num6 = 0f; if (num < ScreenPadding.Value) { num5 = ScreenPadding.Value - num; } else if (num2 > (float)Screen.width - ScreenPadding.Value) { num5 = (float)Screen.width - ScreenPadding.Value - num2; } if (num3 < ScreenPadding.Value) { num6 = ScreenPadding.Value - num3; } else if (num4 > (float)Screen.height - ScreenPadding.Value) { num6 = (float)Screen.height - ScreenPadding.Value - num4; } if (!(Mathf.Abs(num5) < 0.01f) || !(Mathf.Abs(num6) < 0.01f)) { Vector2 val4 = RectTransformUtility.WorldToScreenPoint(val2, ((Transform)rect).position) + new Vector2(num5, num6); Vector2 val5 = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(val, val4, val2, ref val5)) { rect.anchoredPosition += val5 - rect.anchoredPosition; } } } } }