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 FastSwitchPlayerViewInRadar v1.3.4
LethalCompanyMonitorMod.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LethalCompanyMonitorMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A plugin that let's you fast switch to a player's cam while using the radar built in the in-game Terminal")] [assembly: AssemblyFileVersion("1.3.1.0")] [assembly: AssemblyInformationalVersion("1.3.1+117cd7e65dba02989327f3ac3116704757bb2780")] [assembly: AssemblyProduct("LethalCompanyMonitorMod")] [assembly: AssemblyTitle("LethalCompanyMonitorMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.1.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 LethalCompanyMonitorMod { public class KeyBindings : LcInputActions { [InputAction(/*Could not decode attribute arguments.*/)] public InputAction PreviousPlayerCamKey { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction NextPlayerCamKey { get; set; } } [BepInPlugin("krystall9.FastSwitchPlayerViewInRadar", "FastSwitchPlayerViewInRadar", "1.3.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("Lethal Company.exe")] public class Plugin : BaseUnityPlugin { internal static KeyBindings KeyBindingsInstance; internal static Plugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static bool ViewMonitorSubmitted { get; set; } internal static int CurrentlyViewingPlayer { get; set; } internal static ManualCameraRenderer CameraRendererInstance { get; set; } internal static bool TwoRadarMapsFound { get; set; } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; KeyBindingsInstance = new KeyBindings(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"FastSwitchPlayerViewInRadar plugin is loaded!"); } } public static class PluginStaticInfo { public const string PLUGIN_GUID = "krystall9.FastSwitchPlayerViewInRadar"; public const string PLUGIN_NAME = "FastSwitchPlayerViewInRadar"; public const string PLUGIN_VERSION = "1.3.4"; } public static class MyPluginInfo { public const string PLUGIN_GUID = "LethalCompanyMonitorMod"; public const string PLUGIN_NAME = "LethalCompanyMonitorMod"; public const string PLUGIN_VERSION = "1.3.1"; } } namespace LethalCompanyMonitorMod.Patch { [HarmonyPatch(typeof(RadarBoosterItem))] public class RadarBoosterPatch { [HarmonyPatch("RemoveBoosterFromRadar")] [HarmonyPostfix] public static void RemovingUnusedRadar(ref RadarBoosterItem __instance) { ManualCameraRenderer mapScreen = Object.FindAnyObjectByType<StartOfRound>().mapScreen; Plugin.Log.LogDebug((object)("Method - RemovingUnusedRadar | Current cam target name: " + __instance.radarBoosterName)); Plugin.Log.LogDebug((object)("Method - RemovingUnusedRadar | " + __instance.radarBoosterName + " removed")); Plugin.Log.LogDebug((object)"Method - RemovingUnusedRadar | Updating camera target"); for (int i = 0; i < mapScreen.radarTargets.Count; i++) { if (mapScreen.radarTargets.Count <= Plugin.CurrentlyViewingPlayer || mapScreen.radarTargets[Plugin.CurrentlyViewingPlayer] == null) { Plugin.CurrentlyViewingPlayer = i; continue; } mapScreen.SwitchRadarTargetAndSync(Plugin.CurrentlyViewingPlayer); Plugin.Log.LogDebug((object)("Method - RemovingUnusedRadar | Currently targeting " + mapScreen.radarTargets[Plugin.CurrentlyViewingPlayer].name)); break; } } } [HarmonyPatch(typeof(StartOfRound))] public class StartOfRoundPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void HandleStartOfRound() { Plugin.TwoRadarMapsFound = Chainloader.PluginInfos.Where((KeyValuePair<string, PluginInfo> pluginInfo) => pluginInfo.Value.Metadata.Name.Contains("tworadarmap", StringComparison.InvariantCultureIgnoreCase)).Any(); } } [HarmonyPatch(typeof(Terminal))] public class TerminalPatch { [HarmonyPatch("ParsePlayerSentence")] [HarmonyPostfix] private static void HandleSentence(Terminal __instance, TerminalNode __result) { if (!((Object)(object)__result == (Object)null) && __instance.terminalInUse && !Plugin.ViewMonitorSubmitted && string.Compare(((Object)__result).name, "ViewInsideShipCam 1", ignoreCase: true) == 0) { Plugin.ViewMonitorSubmitted = true; } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void HandleTerminalCameraNode(Terminal __instance) { if (!__instance.terminalInUse || !Plugin.ViewMonitorSubmitted) { return; } try { InputAction val = ((IEnumerable<InputAction>)((LcInputActions)Plugin.KeyBindingsInstance).Asset).Where((InputAction x) => x.triggered).FirstOrDefault(); if (val == null) { return; } if ((Object)(object)Plugin.CameraRendererInstance == (Object)null) { if (Plugin.TwoRadarMapsFound) { Plugin.Log.LogDebug((object)"Method - HandleTerminalCameraNode | TwoRadarMaps Camera Found"); Plugin.CameraRendererInstance = (from x in ((Component)__instance).GetComponents<ManualCameraRenderer>() where ((Object)x.cam).name == "TerminalMapCamera" select x).FirstOrDefault(); } else { Plugin.Log.LogDebug((object)"Method - HandleTerminalCameraNode | TwoRadarMaps Camera Not Found. Using Default Ship Camera"); Plugin.CameraRendererInstance = Object.FindAnyObjectByType<StartOfRound>().mapScreen; } } int num = Plugin.CurrentlyViewingPlayer; int count = Plugin.CameraRendererInstance.radarTargets.Count; Plugin.Log.LogDebug((object)$"Method - HandleTerminalCameraNode | Currently Max Spectable Players: {count}"); PlayerControllerB val2 = null; RadarBoosterItem val3 = null; for (int i = 0; i < count; i++) { string name = val.name; if (!(name == "PreviousPlayerCamKey")) { if (name == "NextPlayerCamKey") { num = GetRadarTargetIndex(num, count, isIndexPlusOne: true); Plugin.Log.LogDebug((object)$"Method - HandleTerminalCameraNode | Current Index: {num}"); } } else { num = GetRadarTargetIndex(num, count); Plugin.Log.LogDebug((object)$"Method - HandleTerminalCameraNode | Current Index: {num}"); } if (Plugin.CameraRendererInstance.radarTargets[num] == null) { Plugin.Log.LogDebug((object)$"Method - HandleTerminalCameraNode | The player at the Index: {num} cannot be spectated. Getting the next player"); continue; } GameObject gameObject = ((Component)Plugin.CameraRendererInstance.radarTargets[num].transform).gameObject; gameObject.TryGetComponent<PlayerControllerB>(ref val2); if ((Object)(object)val2 != (Object)null && (val2.isPlayerControlled || val2.isPlayerDead)) { break; } if ((Object)(object)val2 == (Object)null || !val2.isPlayerControlled) { gameObject.TryGetComponent<RadarBoosterItem>(ref val3); if ((Object)(object)val3 != (Object)null && val3.radarEnabled) { break; } } } if (count > num && Plugin.CameraRendererInstance.radarTargets[num] != null) { string text = ""; text = ((!((Object)(object)val3 != (Object)null)) ? val2.playerUsername : val3.radarBoosterName); Plugin.Log.LogDebug((object)("Method - HandleTerminalCameraNode | Switching cam to " + text)); Plugin.CameraRendererInstance.SwitchRadarTargetAndSync(num); } Plugin.CurrentlyViewingPlayer = num; val2 = null; val3 = null; } catch (Exception ex) { Plugin.Log.LogError((object)("Method - HandleTerminalCameraNode| Error: " + ex.Message)); } } public static int GetRadarTargetIndex(int index, int loopableItemsCount, bool isIndexPlusOne = false) { if (isIndexPlusOne) { return (index < loopableItemsCount - 1) ? (index + 1) : 0; } return (index > 0) ? (index - 1) : (loopableItemsCount - 1); } } }