using 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(); 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(); 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(); 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 d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public RoundManager rm; private GrabbableObject[] 5__1; private int 5__2; private int 5__3; private int 5__4; private List 5__5; private string 5__6; private string 5__7; private GrabbableObject[] <>s__8; private int <>s__9; private GrabbableObject 5__10; private int <>s__11; private Exception 5__12; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__5 = null; 5__6 = null; 5__7 = null; <>s__8 = null; 5__10 = null; 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; } 5__1 = Object.FindObjectsOfType(); 5__2 = 0; 5__3 = 0; 5__4 = 0; 5__5 = new List(); <>s__8 = 5__1; for (<>s__9 = 0; <>s__9 < <>s__8.Length; <>s__9++) { 5__10 = <>s__8[<>s__9]; if ((Object)(object)5__10.itemProperties != (Object)null && 5__10.itemProperties.isScrap && !5__10.scrapPersistedThroughRounds && !5__10.isInShipRoom) { 5__5.Add(5__10); } if (!5__10.isInShipRoom && ((Object)5__10).name.Contains("Hive", StringComparison.OrdinalIgnoreCase)) { 5__3++; } if (!5__10.isInShipRoom && ((Object)5__10).name.Contains("KiwiBabyItem", StringComparison.OrdinalIgnoreCase)) { 5__4++; } 5__10 = null; } <>s__8 = null; 5__2 = 5__5.Count - 5__3 - 5__4; if (5__2 < 0) { 5__2 = 0; } AutoTerminalScan.Logger.LogInfo((object)$"[AutoScan] Scrap: {5__2}, Beehives: {5__3}, Eggs: {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) { } 5__6 = text; if (5__4 == 3) { SendChatMessage1($"{5__6} {5__2} {5__3} Bird"); return false; } 5__7 = $"{5__6} {5__2} {5__3}"; SendChatMessage1(5__7); 5__1 = null; 5__5 = null; 5__6 = null; 5__7 = null; } catch (Exception ex) { 5__12 = ex; AutoTerminalScan.Logger.LogError((object)("[AutoScan] Error while counting or sending: " + 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(d__4))] private static IEnumerator CountScrapAndBeehives(RoundManager rm) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new 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)); } } } }