Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ItemLens v1.0.0
ItemLens.dll
Decompiled 5 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using LookingGlass.ItemStatsNameSpace; using Microsoft.CodeAnalysis; using On.RoR2.UI; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("LookingGlass")] [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Serestielle")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ItemLens")] [assembly: AssemblyTitle("ItemLens")] [assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was created with the assistance of Generative AI (code generation), directed by Serestielle.")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic (Claude Opus 5.5 via Claude Code)")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 ItemLens { [BepInPlugin("com.Serestielle.ItemLens", "ItemLens", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ItemLensPlugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_Awake <>9__8_0; public static hook_RebuildPing <>9__8_1; internal void <Awake>b__8_0(orig_Awake orig, HUD self) { orig.Invoke(self); ((Component)self).gameObject.AddComponent<ItemLensPanel>().hud = self; } internal void <Awake>b__8_1(orig_RebuildPing orig, PingIndicator self) { orig.Invoke(self); foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList) { if (Object.op_Implicit((Object)(object)self.pingOwner) && (Object)(object)readOnlyLocalUsers.cachedMasterObject == (Object)(object)self.pingOwner) { lastPing = self; lastPingTime = Time.time; } } } } internal static ConfigEntry<float> lookRange; internal static ConfigEntry<float> pingSeconds; internal static ConfigEntry<float> offsetX; internal static ConfigEntry<float> offsetY; internal static ConfigEntry<float> width; internal static ConfigEntry<float> fontSize; internal static PingIndicator lastPing; internal static float lastPingTime; private void Awake() { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_01b1: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Expected O, but got Unknown //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Expected O, but got Unknown //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown lookRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Look Range", 40f, "How far away (m) an item you aim at is shown. 0 = off."); pingSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Ping Duration", 8f, "How long (s) an item you pinged is shown. 0 = off."); offsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "Offset X", -180f, "Panel's left edge, relative to the crosshair (negative = left). HUD units: pixels at 1920x1080, scaled with your resolution. The default puts the panel over the pickup notification area."); offsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "Offset Y", -400f, "Panel's vertical middle, relative to the crosshair (negative = below). Same units as Offset X."); width = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "Width", 440f, "Panel width in HUD units."); fontSize = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "Font Size", 18f, "Text size."); ModSettingsManager.AddOption((BaseOption)new SliderOption(lookRange, new SliderConfig { min = 0f, max = 150f, FormatString = "{0:0} m" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(pingSeconds, new SliderConfig { min = 0f, max = 60f, FormatString = "{0:0} s" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(offsetX, new SliderConfig { min = -960f, max = 960f, FormatString = "{0:0}" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(offsetY, new SliderConfig { min = -540f, max = 540f, FormatString = "{0:0}" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(width, new SliderConfig { min = 200f, max = 1000f, FormatString = "{0:0}" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(fontSize, new SliderConfig { min = 8f, max = 40f, FormatString = "{0:0}" })); object obj = <>c.<>9__8_0; if (obj == null) { hook_Awake val = delegate(orig_Awake orig, HUD self) { orig.Invoke(self); ((Component)self).gameObject.AddComponent<ItemLensPanel>().hud = self; }; <>c.<>9__8_0 = val; obj = (object)val; } HUD.Awake += (hook_Awake)obj; object obj2 = <>c.<>9__8_1; if (obj2 == null) { hook_RebuildPing val2 = delegate(orig_RebuildPing orig, PingIndicator self) { orig.Invoke(self); foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList) { if (Object.op_Implicit((Object)(object)self.pingOwner) && (Object)(object)readOnlyLocalUsers.cachedMasterObject == (Object)(object)self.pingOwner) { lastPing = self; lastPingTime = Time.time; } } }; <>c.<>9__8_1 = val2; obj2 = (object)val2; } PingIndicator.RebuildPing += (hook_RebuildPing)obj2; } } internal class ItemLensPanel : MonoBehaviour { private const float RefreshInterval = 0.25f; private static readonly RaycastHit[] hits = (RaycastHit[])(object)new RaycastHit[32]; internal HUD hud; private RectTransform panel; private TextMeshProUGUI text; private PickupIndex shown = PickupIndex.none; private float refreshTimer; private void Start() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown panel = new GameObject("ItemLensPanel", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)panel).SetParent(hud.mainContainer.transform, false); RectTransform obj = panel; RectTransform obj2 = panel; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0.5f, 0.5f); obj2.anchorMax = val; obj.anchorMin = val; panel.pivot = new Vector2(0f, 0.5f); Image obj3 = ((Component)panel).gameObject.AddComponent<Image>(); ((Graphic)obj3).color = new Color(0f, 0f, 0f, 0.8f); ((Graphic)obj3).raycastTarget = false; VerticalLayoutGroup obj4 = ((Component)panel).gameObject.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)obj4).padding = new RectOffset(12, 12, 10, 10); bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true); ((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = childControlWidth; ((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false; ((Component)panel).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; GameObject val2 = new GameObject("Text", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent((Transform)(object)panel, false); text = (TextMeshProUGUI)(object)val2.AddComponent<HGTextMeshProUGUI>(); ((Graphic)text).raycastTarget = false; ((Component)panel).gameObject.SetActive(false); } private void Update() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) LocalUser localUserViewer = hud.localUserViewer; CharacterMaster val = ((localUserViewer != null) ? localUserViewer.cachedMaster : null); PickupIndex val2 = PickupIndex.none; if (Object.op_Implicit((Object)(object)val) && (!Object.op_Implicit((Object)(object)hud.scoreboardPanel) || !hud.scoreboardPanel.activeSelf)) { val2 = LookedAtPickup(localUserViewer.cachedBody); if (val2 == PickupIndex.none && Object.op_Implicit((Object)(object)ItemLensPlugin.lastPing) && (Object)(object)ItemLensPlugin.lastPing.pingOwner == (Object)(object)((Component)val).gameObject && Time.time - ItemLensPlugin.lastPingTime < ItemLensPlugin.pingSeconds.Value) { val2 = PickupOf(ItemLensPlugin.lastPing.pingTarget); } } refreshTimer -= Time.unscaledDeltaTime; if (val2 == shown && refreshTimer > 0f) { return; } refreshTimer = 0.25f; shown = val2; string text = ((val2 == PickupIndex.none) ? null : Describe(val2, val)); ((Component)panel).gameObject.SetActive(text != null); if (text != null) { panel.anchoredPosition = new Vector2(ItemLensPlugin.offsetX.Value, ItemLensPlugin.offsetY.Value); panel.sizeDelta = new Vector2(ItemLensPlugin.width.Value, panel.sizeDelta.y); ((TMP_Text)this.text).fontSize = ItemLensPlugin.fontSize.Value; if (((TMP_Text)this.text).text != text) { ((TMP_Text)this.text).text = text; } } } private static PickupIndex LookedAtPickup(CharacterBody body) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)body) || ItemLensPlugin.lookRange.Value <= 0f) { return PickupIndex.none; } InteractionDriver val = default(InteractionDriver); if (((Component)body).TryGetComponent<InteractionDriver>(ref val)) { PickupIndex val2 = PickupOf(val.currentInteractable); if (val2 != PickupIndex.none) { return val2; } } if (!Object.op_Implicit((Object)(object)body.inputBank)) { return PickupIndex.none; } float num = default(float); Ray val3 = CameraRigController.ModifyAimRayIfApplicable(body.inputBank.GetAimRay(), ((Component)body).gameObject, ref num); int num2 = Physics.RaycastNonAlloc(val3, hits, ItemLensPlugin.lookRange.Value + num, LayerMask.op_Implicit(CommonMasks.interactable), (QueryTriggerInteraction)2); PickupIndex result = PickupIndex.none; float num3 = float.MaxValue; EntityLocator val5 = default(EntityLocator); for (int i = 0; i < num2; i++) { RaycastHit val4 = hits[i]; if (((RaycastHit)(ref val4)).distance >= num3 || !EntityLocator.HasEntityLocator(((Component)((RaycastHit)(ref val4)).collider).gameObject, ref val5)) { continue; } PickupIndex val6 = PickupOf(val5.entity); if (!(val6 == PickupIndex.none)) { Vector3 origin = ((Ray)(ref val3)).origin; Vector3 point = ((RaycastHit)(ref val4)).point; LayerIndex world = LayerIndex.world; if (!Physics.Linecast(origin, point, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1)) { result = val6; num3 = ((RaycastHit)(ref val4)).distance; } } } return result; } private static PickupIndex PickupOf(GameObject target) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)target)) { return PickupIndex.none; } GenericPickupController val = default(GenericPickupController); if (target.TryGetComponent<GenericPickupController>(ref val)) { return val.pickup.pickupIndex; } ShopTerminalBehavior val2 = default(ShopTerminalBehavior); if (target.TryGetComponent<ShopTerminalBehavior>(ref val2)) { if (val2.hidden || !Object.op_Implicit((Object)(object)val2.pickupDisplay)) { return PickupIndex.none; } return val2.pickup.pickupIndex; } PickupDistributorBehavior val3 = default(PickupDistributorBehavior); if (target.TryGetComponent<PickupDistributorBehavior>(ref val3)) { if (val3.hidden) { return PickupIndex.none; } return val3.pickup.pickupIndex; } return PickupIndex.none; } private static string Describe(PickupIndex pickupIndex, CharacterMaster master) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) PickupDef pickupDef = PickupCatalog.GetPickupDef(pickupIndex); InspectInfo val = InspectInfo.op_Implicit(pickupDef); if (val == null || string.IsNullOrEmpty(val.TitleToken)) { return null; } string text = "<size=120%><color=#" + ColorUtility.ToHtmlStringRGB(val.TitleColor) + ">" + Language.GetString(val.TitleToken) + "</color></size>"; ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); if (Object.op_Implicit((Object)(object)itemDef)) { int itemCountEffective = master.inventory.GetItemCountEffective(itemDef); if (itemCountEffective > 0) { text += $" <style=cStack>(you have {itemCountEffective})</style>"; } return text + "\n" + ItemStats.GetItemDescription(itemDef, itemCountEffective, master, true, false); } EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex); if (Object.op_Implicit((Object)(object)equipmentDef)) { float num = equipmentDef.cooldown * master.inventory.CalculateEquipmentCooldownScale(); return $"{text}\n{Language.GetString(equipmentDef.descriptionToken)}\n\nCooldown: <style=cIsUtility>{num:0.##}s</style>" + ItemStats.GetEquipmentExtras(master, equipmentDef.equipmentIndex); } if (!string.IsNullOrEmpty(val.DescriptionToken)) { return text + "\n" + Language.GetString(val.DescriptionToken); } return text; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }