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.7
Happyness.Autoscan.dll
Decompiled 2 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.6.0")] [assembly: AssemblyInformationalVersion("1.0.6")] [assembly: AssemblyProduct("Autoscan")] [assembly: AssemblyTitle("Happyness.Autoscan")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.6.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.6"; } } namespace AutoTerminalScan { [BepInPlugin("Happyness.Autoscan", "Autoscan", "1.0.6")] public class AutoTerminalScan : BaseUnityPlugin { public class MonoBehaviourProxy : MonoBehaviour { } private static MonoBehaviourProxy coroutineProxy; public StartOfRound playersManager; internal static ManualLogSource Logger { get; private set; } private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; playersManager = Object.FindObjectOfType<StartOfRound>(); SetupCoroutineRunner01(); Harmony val = new Harmony("com.happyness.autoscan"); val.PatchAll(); } private void SetupCoroutineRunner01() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (!((Object)(object)coroutineProxy != (Object)null)) { GameObject val = new GameObject("AutoScan_CoroutineRunner"); coroutineProxy = val.AddComponent<MonoBehaviourProxy>(); Object.DontDestroyOnLoad((Object)(object)val); } } public static void StartSafeCoroutine01(IEnumerator routine) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)coroutineProxy == (Object)null) { GameObject val = new GameObject("AutoScan_CoroutineRunner"); coroutineProxy = val.AddComponent<MonoBehaviourProxy>(); Object.DontDestroyOnLoad((Object)(object)val); } ((MonoBehaviour)coroutineProxy).StartCoroutine(routine); } } [HarmonyPatch(typeof(RoundManager), "FinishGeneratingNewLevelClientRpc")] public static class WaitForScrapToSpawnToSyncPatch01 { [HarmonyPostfix] public static void Postfix(RoundManager __instance) { string text = ((object)RoundManager.Instance.currentLevel).ToString(); if (!(text == "AssuranceLevel (SelectableLevel)") && !share.sentToday) { share.sentToday = true; AutoTerminalScan.StartSafeCoroutine01(share.CountScrapAndBeehives(__instance)); } } } [HarmonyPatch(typeof(RoundManager), "SyncScrapValuesClientRpc")] public static class WaitForScrapToSpawnToSyncPatch02 { [HarmonyPostfix] public static void Postfix(RoundManager __instance) { string text = ((object)RoundManager.Instance.currentLevel).ToString(); if (!(text != "AssuranceLevel (SelectableLevel)") && !share.sentToday) { share.sentToday = true; AutoTerminalScan.StartSafeCoroutine01(share.CountScrapAndBeehives(__instance)); } } } public static class share { [CompilerGenerated] private sealed class <CountScrapAndBeehives>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RoundManager rm; private string <gamelevel>5__1; private GrabbableObject[] <allObjects>5__2; private int <scrapCount>5__3; private int <beehiveCount>5__4; private int <eggCount>5__5; private List<GrabbableObject> <outsideScrap>5__6; private string <dungeonName>5__7; private string <message>5__8; private GrabbableObject[] <>s__9; private int <>s__10; private GrabbableObject <obj>5__11; private int <>s__12; private Exception <ex>5__13; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CountScrapAndBeehives>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <gamelevel>5__1 = null; <allObjects>5__2 = null; <outsideScrap>5__6 = null; <dungeonName>5__7 = null; <message>5__8 = null; <>s__9 = null; <obj>5__11 = null; <ex>5__13 = null; <>1__state = -2; } private bool MoveNext() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <gamelevel>5__1 = ((object)RoundManager.Instance.currentLevel).ToString(); AutoTerminalScan.Logger.LogInfo((object)<gamelevel>5__1); if (Time.time - lastCleanupTime < 10f) { return false; } if (<gamelevel>5__1 == "CompanyBuildingLevel (SelectableLevel)") { return false; } lastCleanupTime = 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; } <allObjects>5__2 = Object.FindObjectsOfType<GrabbableObject>(); <scrapCount>5__3 = 0; <beehiveCount>5__4 = 0; <eggCount>5__5 = 0; <outsideScrap>5__6 = new List<GrabbableObject>(); <>s__9 = <allObjects>5__2; for (<>s__10 = 0; <>s__10 < <>s__9.Length; <>s__10++) { <obj>5__11 = <>s__9[<>s__10]; if ((Object)(object)<obj>5__11.itemProperties != (Object)null && <obj>5__11.itemProperties.isScrap && !<obj>5__11.scrapPersistedThroughRounds && !<obj>5__11.isInShipRoom) { <outsideScrap>5__6.Add(<obj>5__11); } if (!<obj>5__11.isInShipRoom && ((Object)<obj>5__11).name.Contains("Hive", StringComparison.OrdinalIgnoreCase)) { <beehiveCount>5__4++; } if (!<obj>5__11.isInShipRoom && ((Object)<obj>5__11).name.Contains("KiwiBabyItem", StringComparison.OrdinalIgnoreCase)) { <eggCount>5__5++; } <obj>5__11 = null; } <>s__9 = null; <scrapCount>5__3 = <outsideScrap>5__6.Count - <beehiveCount>5__4 - <eggCount>5__5; if (<scrapCount>5__3 < 0) { <scrapCount>5__3 = 0; } AutoTerminalScan.Logger.LogInfo((object)$"[AutoScan] Scrap: {<scrapCount>5__3}, Beehives: {<beehiveCount>5__4}, Eggs: {<eggCount>5__5}"); <>s__12 = rm.currentDungeonType; if (1 == 0) { } string text = <>s__12 switch { 1 => "Mansion", 3 => "Factory (march)", 4 => "Mineshaft", 0 => "Factory", _ => "Unknown", }; if (1 == 0) { } <dungeonName>5__7 = text; <message>5__8 = ((<eggCount>5__5 == 3) ? $"{<dungeonName>5__7} {<scrapCount>5__3} {<beehiveCount>5__4} Bird" : $"{<dungeonName>5__7} {<scrapCount>5__3} {<beehiveCount>5__4}"); SendChatMessage(<message>5__8); <allObjects>5__2 = null; <outsideScrap>5__6 = null; <dungeonName>5__7 = null; <message>5__8 = null; } catch (Exception ex) { <ex>5__13 = ex; AutoTerminalScan.Logger.LogError((object)("[AutoScan] Error while counting or sending: " + <ex>5__13)); } 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 lastCleanupTime = -999f; public const float CleanupCooldown = 10f; public static bool sentToday = false; [IteratorStateMachine(typeof(<CountScrapAndBeehives>d__3))] public static IEnumerator CountScrapAndBeehives(RoundManager rm) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CountScrapAndBeehives>d__3(0) { rm = rm }; } public static void SendChatMessage(string message) { try { string text = message ?? string.Empty; if (text.Length > 50) { text = text.Substring(0, 50); } if (AutoScanChatCache.lastReceivedChatMessage == 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)) { 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 + "'")); sentToday = false; } } } catch (Exception ex) { AutoTerminalScan.Logger.LogError((object)("[AutoScan] Error sending chat message: " + ex)); } } } public static class AutoScanChatCache { public static string lastReceivedChatMessage = ""; } [HarmonyPatch(typeof(HUDManager), "AddChatMessage")] public static class CaptureIncomingChatPatch1 { [HarmonyPostfix] public static void PostfixAM(string chatMessage) { if (!string.IsNullOrWhiteSpace(chatMessage)) { AutoScanChatCache.lastReceivedChatMessage = chatMessage; } } } }