Please disclose if your mod was created primarily 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 AgeSignals v1.0.1
AgeSignals.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using AgeSignals.Patches; using AgeSignals.Utils; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("AgeSignals")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("AgeSignals")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("8fac9c89-67c2-42cb-a63b-6f5a1e873fae")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace AgeSignals { [BepInPlugin("AgeCo.Signals", "AgeSignals", "1.0.1")] public class Plugin : BaseUnityPlugin { private static Plugin Instance; private const string GUID = "AgeCo.Signals"; public static ManualLogSource _logger; private readonly Harmony harmony = new Harmony("AgeCo.Signals"); internal static List<AudioClip> SoundFX; internal static AssetBundle Bundle; internal static ConfigEntry<bool> canSendTime; internal static ConfigEntry<bool> canSendScan; internal static ConfigEntry<bool> canSendAlive; internal static ConfigEntry<bool> canSendStock; internal static ConfigEntry<bool> canUseTx; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } _logger = Logger.CreateLogSource("AgeCo.Signals"); _logger.LogInfo((object)"The AgeCo mod has been loaded."); canSendTime = ((BaseUnityPlugin)this).Config.Bind<bool>("Commands", "CanSendTime", true, "Can send the transmit time command."); canSendScan = ((BaseUnityPlugin)this).Config.Bind<bool>("Commands", "CanSendScan", true, "Can send the transmit scan command."); canSendAlive = ((BaseUnityPlugin)this).Config.Bind<bool>("Commands", "CanSendAlive", true, "Can send the transmit alive command."); canSendStock = ((BaseUnityPlugin)this).Config.Bind<bool>("Commands", "CanSendStock", true, "Can send the transmit stock command."); canUseTx = ((BaseUnityPlugin)this).Config.Bind<bool>("Rules", "CanUseTx", true, "Can use tx or xmt to transmit messages."); harmony.PatchAll(typeof(Plugin)); harmony.PatchAll(typeof(ParsePlayerSentencePatch)); harmony.PatchAll(typeof(HUDManagerPatch)); } } } namespace AgeSignals.Utils { internal static class Util { public static bool CompareStrings(string main, string compareTo) { return main.Trim().Equals(compareTo.Trim(), StringComparison.OrdinalIgnoreCase); } } } namespace AgeSignals.Patches { [HarmonyPatch(typeof(HUDManager), "UseSignalTranslatorServerRpc")] internal class HUDManagerPatch { private static bool Prefix(ref string signalMessage) { if (Util.CompareStrings(signalMessage, "TIME") && Plugin.canSendTime.Value) { if (!StartOfRound.Instance.currentLevel.planetHasTime || !StartOfRound.Instance.shipDoorsEnabled) { return true; } signalMessage = ((TMP_Text)HUDManager.Instance.clockNumber).text.Replace('\n', ' '); } if (Util.CompareStrings(signalMessage, "SCAN") && Plugin.canSendScan.Value) { int num = (from s in Object.FindObjectsOfType<GrabbableObject>().ToList() where s.itemProperties.isScrap && !s.isInShipRoom && !s.isInElevator select s).Count(); signalMessage = ((num > 0) ? $"{num} Loot" : "No Loot"); } if (Util.CompareStrings(signalMessage, "ALIVE") && Plugin.canSendAlive.Value) { int livingPlayers = StartOfRound.Instance.livingPlayers; signalMessage = $"{livingPlayers} Alive"; } if (Util.CompareStrings(signalMessage, "STOCK") && Plugin.canSendStock.Value) { int num2 = (from s in Object.FindObjectsOfType<GrabbableObject>().ToList() where s.itemProperties.isScrap && s.isInShipRoom select s.scrapValue).Sum(); signalMessage = $"{num2} Stock"; } return true; } } [HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")] internal class ParsePlayerSentencePatch { private static bool Prefix(Terminal __instance, ref TerminalNode __result) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown string text = __instance.screenText.text; char[] separator = " ".ToCharArray(); string text2 = text.Substring(text.Length - __instance.textAdded); text2 = Traverse.Create((object)__instance).Method("RemovePunctuation", new object[1] { text2 }).GetValue<string>(); string[] array = text2.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (Util.CompareStrings(text2, "AgeSignals") || Util.CompareStrings(text2, "AgeHelp")) { TerminalNode val = new TerminalNode(); val.displayText = "Commands:\n\nTIME: Will print the current time in 00:00 AM/PM format.\nSCAN: Will print the current count of scrap outside the ship.\nALIVE: Will print the current number of players still alive.\nSTOCK: Will print how much the scrap in the ship is worth.\n"; val.clearPreviousText = true; __result = val; return false; } if (array.Length <= 1) { return true; } string main = array[0]; if ((Util.CompareStrings(main, "TX") || Util.CompareStrings(main, "XMT")) && Plugin.canUseTx.Value) { SignalTranslator val2 = Object.FindObjectOfType<SignalTranslator>(); if (!((Object)(object)val2 != (Object)null) || !(Time.realtimeSinceStartup - val2.timeLastUsingSignalTranslator > 8f) || array.Length < 2) { return true; } string text3 = text2.Substring(Util.CompareStrings(main, "TX") ? 2 : 3); if (string.IsNullOrEmpty(text3)) { return true; } if (!((NetworkBehaviour)__instance).IsServer) { val2.timeLastUsingSignalTranslator = Time.realtimeSinceStartup; } string text4 = text3.Substring(0, Mathf.Min(text3.Length, 10)); HUDManager.Instance.UseSignalTranslatorServerRpc(text4); __result = __instance.terminalNodes.specialNodes[22]; return false; } return true; } } }