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 AutoTerminalScan v1.0.8
Happyness.Autoscan.dll
Decompiled 3 weeks agousing System; using System.Collections; using System.Collections.Generic; 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.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Happyness.Autoscan")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.8.0")] [assembly: AssemblyInformationalVersion("1.0.8")] [assembly: AssemblyProduct("Autoscan")] [assembly: AssemblyTitle("Happyness.Autoscan")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.8.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace AutoScan { public static class MyPluginInfo { public const string PLUGIN_GUID = "Happyness.Autoscan"; public const string PLUGIN_NAME = "Autoscan"; public const string PLUGIN_VERSION = "1.0.8"; } } namespace AutoTerminalScan { [BepInPlugin("Happyness.Autoscan", "Autoscan", "1.0.8")] public class AutoTerminalScan : BaseUnityPlugin { public class MonoBehaviourProxy : MonoBehaviour { } private static MonoBehaviourProxy coroutineProxy; private static bool harmonyPatched; public StartOfRound playersManager; internal static ManualLogSource Logger { get; private set; } private void Awake() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; playersManager = Object.FindObjectOfType<StartOfRound>(); SetupCoroutineRunner01(); if (!harmonyPatched) { Harmony val = new Harmony("com.happyness.autoscan"); val.PatchAll(); harmonyPatched = true; } } private void SetupCoroutineRunner01() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown if (!((Object)(object)coroutineProxy != (Object)null) || !((Object)(object)((Component)coroutineProxy).gameObject != (Object)null)) { GameObject val = new GameObject("AutoScan_CoroutineRunner"); coroutineProxy = val.AddComponent<MonoBehaviourProxy>(); Object.DontDestroyOnLoad((Object)(object)val); Logger.LogInfo((object)"[AutoScan] Coroutine runner initialized"); } } public static void StartSafeCoroutine01(IEnumerator routine) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if ((Object)(object)coroutineProxy == (Object)null || (Object)(object)((Component)coroutineProxy).gameObject == (Object)null) { GameObject val = new GameObject("AutoScan_CoroutineRunner"); coroutineProxy = val.AddComponent<MonoBehaviourProxy>(); Object.DontDestroyOnLoad((Object)(object)val); Logger.LogInfo((object)"[AutoScan] Coroutine runner recreated (was destroyed)"); } try { ((MonoBehaviour)coroutineProxy).StartCoroutine(routine); } catch (Exception ex) { Logger.LogError((object)("[AutoScan] Failed to start coroutine: " + ex)); } } } [HarmonyPatch(typeof(RoundManager), "PredictAllOutsideEnemies")] public static class WaitForScrapToSpawnToSyncPatch01 { public static class AutoScanChatCache { public static string lastReceivedChatMessage1 = ""; } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] public static class CaptureIncomingChatPatch1 { [HarmonyPostfix] public static void PostfixAM(string chatMessage) { if (!string.IsNullOrWhiteSpace(chatMessage)) { AutoScanChatCache.lastReceivedChatMessage1 = chatMessage; } } } [CompilerGenerated] private sealed class <CountScrapAndBeehives>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RoundManager rm; private GrabbableObject[] <allObjects01>5__1; private int <scrapCount1>5__2; private int <beehiveCount1>5__3; private int <eggCount1>5__4; private List<GrabbableObject> <outsideScrap>5__5; private string <dungeonName>5__6; private string <message>5__7; private GrabbableObject[] <>s__8; private int <>s__9; private GrabbableObject <obj>5__10; private int <>s__11; private Exception <ex>5__12; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CountScrapAndBeehives>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <allObjects01>5__1 = null; <outsideScrap>5__5 = null; <dungeonName>5__6 = null; <message>5__7 = null; <>s__8 = null; <obj>5__10 = null; <ex>5__12 = null; <>1__state = -2; } private bool MoveNext() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; gamelevel111 = ((object)RoundManager.Instance.currentLevel).ToString(); AutoTerminalScan.Logger.LogInfo((object)gamelevel111); if (Time.time - lastCleanupTime1 < 10f) { return false; } if (gamelevel111 == "CompanyBuildingLevel (SelectableLevel)") { return false; } lastCleanupTime1 = Time.time; <>2__current = (object)new WaitForSeconds(5f); <>1__state = 1; return true; case 1: <>1__state = -1; try { if ((Object)(object)rm == (Object)null) { return false; } <allObjects01>5__1 = Object.FindObjectsOfType<GrabbableObject>(); <scrapCount1>5__2 = 0; <beehiveCount1>5__3 = 0; <eggCount1>5__4 = 0; <outsideScrap>5__5 = new List<GrabbableObject>(); <>s__8 = <allObjects01>5__1; for (<>s__9 = 0; <>s__9 < <>s__8.Length; <>s__9++) { <obj>5__10 = <>s__8[<>s__9]; if ((Object)(object)<obj>5__10.itemProperties != (Object)null && <obj>5__10.itemProperties.isScrap && !<obj>5__10.scrapPersistedThroughRounds && !<obj>5__10.isInShipRoom) { <outsideScrap>5__5.Add(<obj>5__10); } if (!<obj>5__10.isInShipRoom && ((Object)<obj>5__10).name.Contains("Hive", StringComparison.OrdinalIgnoreCase)) { <beehiveCount1>5__3++; } if (!<obj>5__10.isInShipRoom && ((Object)<obj>5__10).name.Contains("KiwiBabyItem", StringComparison.OrdinalIgnoreCase)) { <eggCount1>5__4++; } <obj>5__10 = null; } <>s__8 = null; <scrapCount1>5__2 = <outsideScrap>5__5.Count - <beehiveCount1>5__3 - <eggCount1>5__4; if (<scrapCount1>5__2 < 0) { <scrapCount1>5__2 = 0; } AutoTerminalScan.Logger.LogInfo((object)$"[AutoScan] Scrap: {<scrapCount1>5__2}, Beehives: {<beehiveCount1>5__3}, Eggs: {<eggCount1>5__4}"); <>s__11 = rm.currentDungeonType; if (1 == 0) { } string text = <>s__11 switch { 1 => "Mansion", 3 => "Factory", 4 => "Mineshaft", 0 => "Factory", _ => "Unknown", }; if (1 == 0) { } <dungeonName>5__6 = text; if (<eggCount1>5__4 == 3) { SendChatMessage1($"{<dungeonName>5__6} {<scrapCount1>5__2} {<beehiveCount1>5__3} Bird"); return false; } <message>5__7 = $"{<dungeonName>5__6} {<scrapCount1>5__2} {<beehiveCount1>5__3}"; SendChatMessage1(<message>5__7); <allObjects01>5__1 = null; <outsideScrap>5__5 = null; <dungeonName>5__6 = null; <message>5__7 = null; } catch (Exception ex) { <ex>5__12 = ex; AutoTerminalScan.Logger.LogError((object)("[AutoScan] Error while counting or sending: " + <ex>5__12)); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static float lastCleanupTime1 = -999f; public const float CleanupCooldown1 = 10f; public static string gamelevel111 = ""; [HarmonyPostfix] public static void BeforeWait(RoundManager __instance) { AutoTerminalScan.StartSafeCoroutine01(CountScrapAndBeehives(__instance)); } [IteratorStateMachine(typeof(<CountScrapAndBeehives>d__4))] private static IEnumerator CountScrapAndBeehives(RoundManager rm) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CountScrapAndBeehives>d__4(0) { rm = rm }; } private static void SendChatMessage1(string message) { try { string text = message ?? string.Empty; if (text.Length > 50) { text = text.Substring(0, 50); } if (AutoScanChatCache.lastReceivedChatMessage1 == text) { AutoTerminalScan.Logger.LogInfo((object)"[AutoScan] Duplicate. Not sending message."); return; } HUDManager instance = HUDManager.Instance; PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!((Object)(object)instance == (Object)null) && !((Object)(object)localPlayerController == (Object)null)) { if (text.Length > 50) { text = text.Substring(0, 50); } MethodInfo method = ((object)instance).GetType().GetMethod("AddTextToChatOnServer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { int num = (int)localPlayerController.playerClientId; method.Invoke(instance, new object[2] { text, num }); AutoTerminalScan.Logger.LogInfo((object)("[AutoScan] Chat message '" + text + "'")); } } } catch (Exception ex) { AutoTerminalScan.Logger.LogError((object)("[AutoScan] Error sending chat message: " + ex)); } } } }