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 FarSightSpyglass v1.1.0
FarSightSpyglass.dll
Decompiled a month agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("FarSightSpyglass")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FarSightSpyglass")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("47f3bb4a-5ef4-435e-a981-04a768c765fe")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace FarSightSpyglass; [BepInPlugin("com.shaya.farsightspyglass", "Far Sight Spyglass", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class FarSightSpyglassMod : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__14_0; public static UnityAction <>9__17_0; internal void <InjectHudToggle>b__14_0() { IsSpyglassToggled = !IsSpyglassToggled; UpdateToggleTextUI(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, IsSpyglassToggled ? "Far Sight: ON" : "Far Sight: OFF", 0, (Sprite)null, false); } } internal void <ShowChangelog>b__17_0() { changelogUI.SetActive(false); } } public const string PluginGUID = "com.shaya.farsightspyglass"; public const string PluginName = "Far Sight Spyglass"; public const string PluginVersion = "1.1.0"; private static GameObject spyglassUI; private static Text topText; private static RectTransform healthBarFill; private static Text healthBarText; private static Text bottomText; private static GameObject iconContainer; public static bool IsSpyglassToggled = true; private static Text toggleButtonText; private static ConfigEntry<string> LastSeenVersion; private static GameObject changelogUI; private void Awake() { LastSeenVersion = ((BaseUnityPlugin)this).Config.Bind<string>("Hidden", "LastSeenVersion", "", "Tracks the last version the changelog was shown for."); Harmony.CreateAndPatchAll(typeof(FarSightSpyglassMod), (string)null); GUIManager.OnCustomGUIAvailable += CreateCustomUI; } [HarmonyPatch(typeof(Hud), "Awake")] [HarmonyPostfix] public static void InjectHudToggle(Hud __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown if ((Object)(object)toggleButtonText != (Object)null) { return; } GameObject val = new GameObject("SpyglassToggleButton"); val.transform.SetParent(__instance.m_rootObject.transform, false); RectTransform obj = val.AddComponent<RectTransform>(); obj.anchorMin = new Vector2(1f, 1f); obj.anchorMax = new Vector2(1f, 1f); obj.pivot = new Vector2(1f, 1f); obj.anchoredPosition = new Vector2(-260f, -20f); obj.sizeDelta = new Vector2(300f, 30f); toggleButtonText = val.AddComponent<Text>(); toggleButtonText.font = GUIManager.Instance.AveriaSerifBold; toggleButtonText.fontSize = 14; toggleButtonText.alignment = (TextAnchor)5; UpdateToggleTextUI(); ButtonClickedEvent onClick = val.AddComponent<Button>().onClick; object obj2 = <>c.<>9__14_0; if (obj2 == null) { UnityAction val2 = delegate { IsSpyglassToggled = !IsSpyglassToggled; UpdateToggleTextUI(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, IsSpyglassToggled ? "Far Sight: ON" : "Far Sight: OFF", 0, (Sprite)null, false); } }; <>c.<>9__14_0 = val2; obj2 = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj2); } private static void UpdateToggleTextUI() { if (!((Object)(object)toggleButtonText == (Object)null)) { if (IsSpyglassToggled) { toggleButtonText.text = "Far Sight Spyglass: <color=#00FF00>ACTIVE (on)</color>"; } else { toggleButtonText.text = "Far Sight Spyglass: <color=#FF0000>INACTIVE (off)</color>"; } } } [HarmonyPatch(typeof(Player), "OnSpawned")] [HarmonyPostfix] public static void PlayerOnSpawnedPatch(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && LastSeenVersion.Value != "1.1.0") { ShowChangelog(); LastSeenVersion.Value = "1.1.0"; } } private static void ShowChangelog() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Expected O, but got Unknown if ((Object)(object)changelogUI != (Object)null) { changelogUI.SetActive(true); return; } GameObject customGUIFront = GUIManager.CustomGUIFront; changelogUI = new GameObject("SpyglassChangelogPanel"); changelogUI.transform.SetParent(customGUIFront.transform, false); ((Graphic)changelogUI.AddComponent<Image>()).color = new Color(0.05f, 0.05f, 0.05f, 0.95f); RectTransform component = changelogUI.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(500f, 300f); component.anchoredPosition = Vector2.zero; GameObject val = new GameObject("Title"); val.transform.SetParent(changelogUI.transform, false); Text obj = val.AddComponent<Text>(); obj.font = GUIManager.Instance.AveriaSerifBold; obj.fontSize = 24; ((Graphic)obj).color = Color.yellow; obj.alignment = (TextAnchor)4; obj.text = "Far Sight Spyglass v1.1.0 Update"; RectTransform component2 = val.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 1f); component2.anchorMax = new Vector2(1f, 1f); component2.pivot = new Vector2(0.5f, 1f); component2.sizeDelta = new Vector2(0f, 50f); component2.anchoredPosition = new Vector2(0f, -10f); GameObject val2 = new GameObject("Body"); val2.transform.SetParent(changelogUI.transform, false); Text obj2 = val2.AddComponent<Text>(); obj2.font = GUIManager.Instance.AveriaSerifBold; obj2.fontSize = 16; ((Graphic)obj2).color = Color.white; obj2.alignment = (TextAnchor)0; obj2.text = "• The craftable Spyglass item has been completely removed from the game.\n\n• Far Sight is now a fully passive system and is turned <color=#00FF00>ON</color> by default.\n\n• You can easily disable or re-enable it at any time by opening up your inventory and then click the new 'Far Sight Spyglass' text button located next to your minimap in the top right corner of the screen."; RectTransform component3 = val2.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 0f); component3.anchorMax = new Vector2(1f, 1f); component3.offsetMin = new Vector2(20f, 60f); component3.offsetMax = new Vector2(-20f, -60f); GameObject obj3 = GUIManager.Instance.CreateButton("Close", changelogUI.transform, new Vector2(0.5f, 0f), new Vector2(0.5f, 0f), new Vector2(0f, 20f), 120f, 40f); obj3.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0f); ButtonClickedEvent onClick = obj3.GetComponent<Button>().onClick; object obj4 = <>c.<>9__17_0; if (obj4 == null) { UnityAction val3 = delegate { changelogUI.SetActive(false); }; <>c.<>9__17_0 = val3; obj4 = (object)val3; } ((UnityEvent)onClick).AddListener((UnityAction)obj4); } private void CreateCustomUI() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_0108: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0244: 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_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: 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_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Expected O, but got Unknown //IL_03be: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)spyglassUI != (Object)null)) { GameObject customGUIFront = GUIManager.CustomGUIFront; spyglassUI = new GameObject("SpyglassPanel"); spyglassUI.transform.SetParent(customGUIFront.transform, false); ((Graphic)spyglassUI.AddComponent<Image>()).color = new Color(0.05f, 0.05f, 0.05f, 0.85f); RectTransform component = spyglassUI.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.anchoredPosition = new Vector2(200f, 0f); component.sizeDelta = new Vector2(250f, 0f); VerticalLayoutGroup obj = spyglassUI.AddComponent<VerticalLayoutGroup>(); ((LayoutGroup)obj).padding = new RectOffset(10, 10, 10, 10); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false; spyglassUI.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; GameObject val = new GameObject("TopText"); val.transform.SetParent(spyglassUI.transform, false); topText = val.AddComponent<Text>(); topText.font = GUIManager.Instance.AveriaSerifBold; topText.fontSize = 16; ((Graphic)topText).color = Color.white; topText.alignment = (TextAnchor)0; val.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; GameObject val2 = new GameObject("HealthBarBG"); val2.transform.SetParent(spyglassUI.transform, false); ((Graphic)val2.AddComponent<Image>()).color = new Color(0.15f, 0.05f, 0.05f, 1f); val2.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 20f); GameObject val3 = new GameObject("HealthBarFill"); val3.transform.SetParent(val2.transform, false); ((Graphic)val3.AddComponent<Image>()).color = new Color(0.8f, 0.1f, 0.1f, 1f); healthBarFill = val3.GetComponent<RectTransform>(); healthBarFill.anchorMin = new Vector2(0f, 0f); healthBarFill.anchorMax = new Vector2(1f, 1f); healthBarFill.sizeDelta = Vector2.zero; healthBarFill.anchoredPosition = Vector2.zero; GameObject val4 = new GameObject("HealthBarText"); val4.transform.SetParent(val2.transform, false); healthBarText = val4.AddComponent<Text>(); healthBarText.font = GUIManager.Instance.AveriaSerifBold; healthBarText.fontSize = 14; ((Graphic)healthBarText).color = Color.white; healthBarText.alignment = (TextAnchor)4; RectTransform component2 = val4.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0f, 0f); component2.anchorMax = new Vector2(1f, 1f); component2.sizeDelta = Vector2.zero; component2.anchoredPosition = Vector2.zero; GameObject val5 = new GameObject("BottomText"); val5.transform.SetParent(spyglassUI.transform, false); bottomText = val5.AddComponent<Text>(); bottomText.font = GUIManager.Instance.AveriaSerifBold; bottomText.fontSize = 14; ((Graphic)bottomText).color = Color.white; bottomText.alignment = (TextAnchor)0; val5.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; iconContainer = new GameObject("IconContainer"); iconContainer.transform.SetParent(spyglassUI.transform, false); iconContainer.AddComponent<RectTransform>().sizeDelta = new Vector2(0f, 30f); HorizontalLayoutGroup obj2 = iconContainer.AddComponent<HorizontalLayoutGroup>(); ((LayoutGroup)obj2).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 8f; spyglassUI.SetActive(false); } } private void Update() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)spyglassUI == (Object)null) { return; } if (!IsSpyglassToggled) { spyglassUI.SetActive(false); return; } GameCamera instance = GameCamera.instance; Camera val = ((instance != null) ? ((Component)((Component)instance).transform).GetComponent<Camera>() : null); if ((Object)(object)val == (Object)null) { return; } Ray val2 = default(Ray); ((Ray)(ref val2))..ctor(((Component)val).transform.position, ((Component)val).transform.forward); int mask = LayerMask.GetMask(new string[3] { "character", "character_net", "character_ghost" }); RaycastHit val3 = default(RaycastHit); if (Physics.Raycast(val2, ref val3, 150f, mask)) { Character componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<Character>(); if ((Object)(object)componentInParent != (Object)null && !componentInParent.IsPlayer()) { UpdateUI(componentInParent); spyglassUI.SetActive(true); return; } } spyglassUI.SetActive(false); } private void UpdateUI(Character character) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) string text = Localization.instance.Localize(character.m_name); int level = character.GetLevel(); float health = character.GetHealth(); float maxHealth = character.GetMaxHealth(); string text2 = ((object)Unsafe.As<Faction, Faction>(ref character.m_faction)/*cast due to .constrained prefix*/).ToString(); string text3 = ""; if (level > 1) { text3 = new string('★', level - 1); text3 = "<color=#FFFF00>" + text3 + "</color> "; } topText.text = "<b><color=#00FF00>" + text + "</color></b> " + text3 + "\nFaction: " + text2; health = Mathf.Clamp(health, 0f, maxHealth); float num = ((maxHealth > 0f) ? (health / maxHealth) : 0f); healthBarFill.anchorMax = new Vector2(num, 1f); healthBarText.text = $"{Mathf.RoundToInt(health)} / {Mathf.RoundToInt(maxHealth)}"; foreach (Transform item in iconContainer.transform) { Object.Destroy((Object)(object)((Component)item).gameObject); } string text4 = ""; bool active = false; SEMan sEMan = character.GetSEMan(); if (sEMan != null) { foreach (StatusEffect statusEffect in sEMan.GetStatusEffects()) { string text5 = Localization.instance.Localize(statusEffect.m_name); text4 = text4 + "<color=#FF8800>• " + text5 + "</color>\n"; if ((Object)(object)statusEffect.m_icon != (Object)null) { active = true; GameObject val = new GameObject("StatusIcon"); val.transform.SetParent(iconContainer.transform, false); val.AddComponent<Image>().sprite = statusEffect.m_icon; val.GetComponent<RectTransform>().sizeDelta = new Vector2(24f, 24f); } } } string text6 = ""; Tameable component = ((Component)character).GetComponent<Tameable>(); if ((Object)(object)component != (Object)null) { text6 = ((!component.IsTamed()) ? "<color=#FFA500>Status: Wild / Tameable</color>\n" : "<color=#00FFFF>Status: Tamed</color>\n"); } bottomText.text = text6 + text4.TrimEnd(new char[1] { '\n' }); ((Component)bottomText).gameObject.SetActive(!string.IsNullOrEmpty(bottomText.text)); iconContainer.gameObject.SetActive(active); } }