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 ScanShipEverywhere v2.0.2
ScanShipEverywhere.dll
Decompiled a year ago#define DEBUG using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using BetterItemScan.Patches; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using ScanShipEverywhere.Patches; using ScanTweaks; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TestAccount666.ScanShipEverywhere")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Improves scan nodes for you")] [assembly: AssemblyFileVersion("2.0.2.0")] [assembly: AssemblyInformationalVersion("2.0.2+d1ad36e6fc03052269f3fb2b8de5e508f4935af6")] [assembly: AssemblyProduct("ScanShipEverywhere")] [assembly: AssemblyTitle("TestAccount666.ScanShipEverywhere")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 ScanShipEverywhere { public static class BetterItemScanSupport { private static FieldInfo? _maxRangeField; public static void Initialize() { SetValue(); ScanShipEverywhere.configManager.SubscribeToMaxScanDistanceHardLimit(OnValueChanged); } public static void Uninitialize() { ScanShipEverywhere.configManager.UnsubscribeFromMaxScanDistanceHardLimit(OnValueChanged); } private static void OnValueChanged(object sender, EventArgs e) { SetValue(); } private static void SetValue() { if ((object)_maxRangeField == null) { _maxRangeField = AccessTools.DeclaredField(typeof(PlayerControllerBPatch_A), "maxDistance"); } if ((object)_maxRangeField == null) { ScanShipEverywhere.Logger.LogFatal((object)"Couldn't find \"_maxRangeField\" field in BetterItemScan's \"PingScan\" PlayerControllerBPatch_A!'"); } else { _maxRangeField.SetValue(null, ScanShipEverywhere.configManager.GetMaxScanDistanceHardLimit()); } } } internal sealed class ConfigManager { private ConfigEntry<bool> _addDropShipScanNode = null; private ConfigEntry<string> _dropShipScanNodeHeaderText = null; private ConfigEntry<string> _dropShipScanNodeSubText = null; private ConfigEntry<int> _maxDropShipDistance = null; private ConfigEntry<int> _maxEntranceDistance = null; private ConfigEntry<float> _maxScanDistanceHardLimit = null; private ConfigEntry<int> _maxShipDistance = null; private ConfigEntry<bool> _addLightSwitchScanNode = null; private ConfigEntry<string> _lightSwitchScanNodeHeaderText = null; private ConfigEntry<string> _lightSwitchScanNodeSubText = null; public void Initialize(ConfigFile configFile) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown _maxDropShipDistance = configFile.Bind<int>("1. Distance", "1. Max Drop Ship Distance", 2147482647, new ConfigDescription("Defines the maximum scan distance for the drop ship", (AcceptableValueBase)(object)new AcceptableValueRange<int>(13, 2147482647), Array.Empty<object>())); _maxEntranceDistance = configFile.Bind<int>("1. Distance", "2. Max Entrance Distance", 2147482647, new ConfigDescription("Defines the maximum scan distance for the entrance", (AcceptableValueBase)(object)new AcceptableValueRange<int>(13, 2147482647), Array.Empty<object>())); _maxShipDistance = configFile.Bind<int>("1. Distance", "3. Max Ship Distance", 2147482647, new ConfigDescription("Defines the maximum scan distance for the ship", (AcceptableValueBase)(object)new AcceptableValueRange<int>(13, 2147482647), Array.Empty<object>())); _addDropShipScanNode = configFile.Bind<bool>("2. Drop Ship Scan Node", "Add Drop Ship Scan Node", true, "If true, will add a scan node to the drop ship (Will not add a node if there already is one)"); _dropShipScanNodeHeaderText = configFile.Bind<string>("2. Drop Ship Scan Node", "Scan Node Header Text", "Drop Ship", "Defines the header text for the drop ship scan node"); _dropShipScanNodeSubText = configFile.Bind<string>("2. Drop Ship Scan Node", "Scan Node Sub Text", "Get your items :>", "Defines the sub text for the drop ship scan node"); _maxScanDistanceHardLimit = configFile.Bind<float>("3. Extra", "1. Scan Distance Hard Limit", 1600f, new ConfigDescription("If you encounter lags, try lowering this. This is the hard limit for the scan node distance", (AcceptableValueBase)(object)new AcceptableValueRange<float>(36f, float.MaxValue), Array.Empty<object>())); _addLightSwitchScanNode = configFile.Bind<bool>("4. Light Switch Scan Node", "Add Light Switch Scan Node", true, "If true, will add a scan node to the light switch (Will not add a node if there already is one)"); _lightSwitchScanNodeHeaderText = configFile.Bind<string>("4. Light Switch Scan Node", "Scan Node Header Text", "Light Switch", "Defines the header text for the light switch scan node"); _lightSwitchScanNodeSubText = configFile.Bind<string>("4. Light Switch Scan Node", "Scan Node Sub Text", "Toggles the light :3", "Defines the sub text for the light switch scan node"); } public int GetMaxDropShipDistance() { return _maxDropShipDistance.Value; } public int GetMaxEntranceDistance() { return _maxEntranceDistance.Value; } public int GetMaxShipDistance() { return _maxShipDistance.Value; } public bool AddDropShipScanNode() { return _addDropShipScanNode.Value; } public string GetDropShipScanNodeHeaderText() { return _dropShipScanNodeHeaderText.Value; } public string GetDropShipScanNodeSubText() { return _dropShipScanNodeSubText.Value; } public float GetMaxScanDistanceHardLimit() { return _maxScanDistanceHardLimit.Value; } public void SubscribeToMaxScanDistanceHardLimit(EventHandler eventHandler) { _maxScanDistanceHardLimit.SettingChanged += eventHandler; } public void UnsubscribeFromMaxScanDistanceHardLimit(EventHandler eventHandler) { _maxScanDistanceHardLimit.SettingChanged -= eventHandler; } public bool AddLightSwitchScanNode() { return _addLightSwitchScanNode.Value; } public string GetLightSwitchScanNodeHeaderText() { return _lightSwitchScanNodeHeaderText.Value; } public string GetLightSwitchScanNodeSubText() { return _lightSwitchScanNodeSubText.Value; } } public static class DependencyChecker { public static bool IsBetterItemScanModInstalled() { return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.Equals("PopleZoo.BetterItemScan")); } public static bool IsScanTweaksModInstalled() { return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.Equals("Saradora.ScanTweaks")); } } public class LightSwitchUpdater : MonoBehaviour { private ScanNodeProperties? _scanNodeProperties; private void Awake() { if (_scanNodeProperties == null) { _scanNodeProperties = ((Component)this).GetComponentInChildren<ScanNodeProperties>(); } } private void LateUpdate() { if (_scanNodeProperties == null) { return; } PlayerControllerB val = StartOfRound.Instance?.localPlayerController ?? null; if (val != null) { if (((Behaviour)_scanNodeProperties).enabled && !ScanShipEverywhere.configManager.AddLightSwitchScanNode()) { ((Behaviour)_scanNodeProperties).enabled = false; } else if (((Behaviour)_scanNodeProperties).enabled != val.isInHangarShipRoom) { ((Behaviour)_scanNodeProperties).enabled = val.isInHangarShipRoom; } } } } public class ScanNodeUpdater : MonoBehaviour { private ScanNodeProperties? _scanNodeProperties; private GameObject _parent = null; private Component? _component; private float _nextUpdate = 0.5f; private bool _parentIsScanNodes; internal bool IsValid(ScanNodeProperties scanNodeProperties) { if (!Object.op_Implicit((Object)(object)scanNodeProperties)) { return false; } _scanNodeProperties = scanNodeProperties; _parent = ((Component)((Component)scanNodeProperties).gameObject.transform.parent).gameObject; _component = (Component?)(object)_parent.GetComponent<Terminal>(); if (Object.op_Implicit((Object)(object)_component)) { return true; } if (((Object)_parent).name.Equals("ScanNodes")) { _parentIsScanNodes = true; return true; } _component = (Component?)(object)_parent.GetComponent<ItemDropship>(); if (Object.op_Implicit((Object)(object)_component)) { return true; } _component = (Component?)(object)_parent.GetComponent<EntranceTeleport>(); return Object.op_Implicit((Object)(object)_component) || scanNodeProperties.headerText.ToLower().Contains("entrance"); } private void Update() { if (_scanNodeProperties != null && Object.op_Implicit((Object)(object)_scanNodeProperties)) { _nextUpdate -= Time.deltaTime; if (!(_nextUpdate > 0f)) { _nextUpdate = 0.5f; PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController; HandleDropShip(localPlayerController, _scanNodeProperties); HandleEntrance(localPlayerController, _scanNodeProperties); HandleSpaceShip(localPlayerController, _scanNodeProperties); } } } private void HandleEntrance(PlayerControllerB playerControllerB, ScanNodeProperties scanNodeProperties) { int maxRange = ScanShipEverywhere.configManager.GetMaxEntranceDistance(); Component? component = _component; EntranceTeleport val = (EntranceTeleport)(object)((component is EntranceTeleport) ? component : null); if (val == null) { if (scanNodeProperties.headerText.ToLower().Contains("entrance")) { if (playerControllerB.isInsideFactory) { maxRange = 2; } UpdateScanNode(scanNodeProperties, requiresLineOfSight: false, 1, maxRange); } } else if (val.isEntranceToBuilding) { maxRange = ScanShipEverywhere.configManager.GetMaxEntranceDistance(); if (playerControllerB.isInsideFactory) { maxRange = 2; } UpdateScanNode(scanNodeProperties, requiresLineOfSight: false, 1, maxRange); } } private void HandleDropShip(PlayerControllerB playerControllerB, ScanNodeProperties scanNodeProperties) { Component? component = _component; ItemDropship val = (ItemDropship)(object)((component is ItemDropship) ? component : null); if (val != null) { int maxRange = (val.deliveringOrder ? ScanShipEverywhere.configManager.GetMaxDropShipDistance() : 2); if (playerControllerB.isInsideFactory) { maxRange = 2; } UpdateScanNode(scanNodeProperties, requiresLineOfSight: false, 1, maxRange); } } private void HandleSpaceShip(PlayerControllerB playerControllerB, ScanNodeProperties scanNodeProperties) { if (_parentIsScanNodes || _component is Terminal) { int maxRange = ScanShipEverywhere.configManager.GetMaxShipDistance(); if (playerControllerB.isInsideFactory || playerControllerB.isInHangarShipRoom) { maxRange = 2; } UpdateScanNode(scanNodeProperties, requiresLineOfSight: false, 1, maxRange); } } private static void UpdateScanNode(ScanNodeProperties scanNodeProperties, bool requiresLineOfSight, int minRange, int maxRange) { scanNodeProperties.requiresLineOfSight = requiresLineOfSight; scanNodeProperties.minRange = minRange; scanNodeProperties.maxRange = maxRange; } } [BepInPlugin("TestAccount666.ScanShipEverywhere", "ScanShipEverywhere", "2.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ScanShipEverywhere : BaseUnityPlugin { internal static ConfigManager configManager; public static ScanShipEverywhere Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Logger.LogInfo((object)"Scan Ship Everywhere has started scanning!"); configManager = new ConfigManager(); configManager.Initialize(((BaseUnityPlugin)this).Config); Patch(); if (DependencyChecker.IsBetterItemScanModInstalled()) { Logger.LogInfo((object)"Found BetterItemScan... Doing some extra work for you :)"); BetterItemScanSupport.Initialize(); } if (DependencyChecker.IsScanTweaksModInstalled()) { Logger.LogInfo((object)"Found ScanTweaks... Doing some extra work for you :)"); Harmony? harmony = Harmony; if (harmony != null) { harmony.PatchAll(typeof(ScanTweaksPingScanPatch)); } } Logger.LogInfo((object)"TestAccount666.ScanShipEverywhere v2.0.2 has loaded!"); } internal static void Patch() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("TestAccount666.ScanShipEverywhere"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(typeof(HUDManagerPatch)); Harmony.PatchAll(typeof(RoundManagerPatch)); Harmony.PatchAll(typeof(ItemDropShipPatch)); Harmony.PatchAll(typeof(LightSwitchPatch)); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "TestAccount666.ScanShipEverywhere"; public const string PLUGIN_NAME = "ScanShipEverywhere"; public const string PLUGIN_VERSION = "2.0.2"; } } namespace ScanShipEverywhere.Patches { [HarmonyPatch(typeof(HUDManager))] public static class HUDManagerPatch { [HarmonyPatch("AssignNewNodes")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> AssignNewNodesTranspiler(IEnumerable<CodeInstruction> instructions) { int skipped = 0; foreach (CodeInstruction codeInstruction in instructions) { if (codeInstruction.opcode != OpCodes.Ldc_R4) { yield return codeInstruction; } else if (!(codeInstruction.operand is float)) { yield return codeInstruction; } else if (skipped < 2) { skipped++; yield return codeInstruction; } else { yield return new CodeInstruction(OpCodes.Ldc_R4, (object)ScanShipEverywhere.configManager.GetMaxScanDistanceHardLimit()); ScanShipEverywhere.Logger.LogDebug((object)"Found max scan range!"); } } } } [HarmonyPatch(typeof(ItemDropship))] public static class ItemDropShipPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPostfix(ItemDropship __instance) { if (ScanShipEverywhere.configManager.AddDropShipScanNode()) { GameObject gameObject = ((Component)__instance).gameObject; if ((Object)(object)gameObject.transform.Find("ScanNode") != (Object)null) { ScanShipEverywhere.Logger.LogDebug((object)"Found a ScanNode already attached to dropship!"); return; } ScanShipEverywhere.Logger.LogDebug((object)"Adding ScanNode to dropship!"); string dropShipScanNodeHeaderText = ScanShipEverywhere.configManager.GetDropShipScanNodeHeaderText(); string dropShipScanNodeSubText = ScanShipEverywhere.configManager.GetDropShipScanNodeSubText(); CreateScanNodeOnObject(gameObject, dropShipScanNodeHeaderText, dropShipScanNodeSubText, ScanShipEverywhere.configManager.GetMaxDropShipDistance()); } } private static void CreateScanNodeOnObject(GameObject gameObject, string headerText, string? subText, int maxRange) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //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) GameObject val = new GameObject("ScanNode", new Type[2] { typeof(ScanNodeProperties), typeof(BoxCollider) }) { layer = LayerMask.NameToLayer("ScanNode") }; val.transform.localScale = Vector3.one * 4f; val.transform.parent = gameObject.transform; GameObject val2 = val; val2.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); ScanNodeProperties component = val2.GetComponent<ScanNodeProperties>(); component.scrapValue = 0; component.creatureScanID = -1; component.nodeType = 0; component.minRange = 1; component.maxRange = maxRange; component.requiresLineOfSight = false; component.headerText = headerText; if (subText != null) { component.subText = subText; } } } [HarmonyPatch(typeof(AutoParentToShip))] public static class LightSwitchPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void ConstructorPostfix(AutoParentToShip __instance) { string text = ((__instance != null) ? ((Object)__instance).name : null) ?? ""; if (text.Equals("LightSwitchContainer")) { Debug.Assert((Object)(object)__instance != (Object)null, "__instance != null"); if ((Object)(object)((Component)__instance).transform.Find("ScanNode") != (Object)null) { ScanShipEverywhere.Logger.LogDebug((object)"Found a ScanNode already attached to LightSwitchContainer!"); return; } CreateScanNodeOnObject(((Component)__instance).gameObject, ScanShipEverywhere.configManager.GetLightSwitchScanNodeHeaderText(), ScanShipEverywhere.configManager.GetLightSwitchScanNodeSubText()); ScanShipEverywhere.Logger.LogInfo((object)"Added ScanNode to Light Switch!"); } } private static void CreateScanNodeOnObject(GameObject gameObject, string headerText, string? subText) { //IL_0033: 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_0049: 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) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ScanNode", new Type[3] { typeof(ScanNodeProperties), typeof(BoxCollider), typeof(LightSwitchUpdater) }) { layer = LayerMask.NameToLayer("ScanNode") }; val.transform.localScale = Vector3.one * 1f; val.transform.parent = gameObject.transform; GameObject val2 = val; val2.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); ScanNodeProperties component = val2.GetComponent<ScanNodeProperties>(); component.scrapValue = 0; component.creatureScanID = -1; component.nodeType = 0; component.minRange = 0; component.maxRange = 6; component.requiresLineOfSight = false; component.headerText = headerText; if (subText != null) { component.subText = subText; } } } [HarmonyPatch(typeof(RoundManager))] public static class RoundManagerPatch { [HarmonyPatch("FinishGeneratingLevel")] [HarmonyPostfix] private static void AttachUpdaterToScanNodes() { ScanNodeProperties[] array = Object.FindObjectsByType<ScanNodeProperties>((FindObjectsInactive)1, (FindObjectsSortMode)0); if (array == null) { array = Array.Empty<ScanNodeProperties>(); } ScanNodeProperties[] array2 = array; foreach (ScanNodeProperties val in array2) { if (Object.op_Implicit((Object)(object)val)) { ScanNodeUpdater scanNodeUpdater = ((Component)val).gameObject.AddComponent<ScanNodeUpdater>(); if (!scanNodeUpdater.IsValid(val)) { Object.Destroy((Object)(object)scanNodeUpdater); } } } } } [HarmonyPatch(typeof(PingScan))] public static class ScanTweaksPingScanPatch { private static FieldInfo? _rangeField; private static PingScan? _pingScan; [HarmonyPatch("OnEnable")] [HarmonyPostfix] private static void OnEnablePostfix(PingScan __instance) { _pingScan = __instance; SetValue(); ScanShipEverywhere.configManager.SubscribeToMaxScanDistanceHardLimit(OnValueChanged); } [HarmonyPatch("OnDisable")] [HarmonyPostfix] private static void OnDisablePostfix() { ScanShipEverywhere.configManager.UnsubscribeFromMaxScanDistanceHardLimit(OnValueChanged); } private static void OnValueChanged(object sender, EventArgs e) { SetValue(); } private static void SetValue() { if (_pingScan != null) { if ((object)_rangeField == null) { _rangeField = AccessTools.DeclaredField(typeof(PingScan), "_range"); } if ((object)_rangeField == null) { ScanShipEverywhere.Logger.LogFatal((object)"Couldn't find \"_range\" field in ScanTweaks' \"PingScan\" type!'"); } else { _rangeField.SetValue(_pingScan, ScanShipEverywhere.configManager.GetMaxScanDistanceHardLimit()); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }