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 LCTweaks v1.0.3
BepInEx/plugins/LCTweaks.dll
Decompiled a week agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.UI; [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("LCTweaks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Tweaks a number of Lethal Company features.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+10574bbd80e92f99ae21242b8919e48ba3071c00")] [assembly: AssemblyProduct("LCTweaks")] [assembly: AssemblyTitle("LCTweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 LCTweaks { public class DotColorController : MonoBehaviour { public PlayerControllerB player; private Material dotMat; private Material viewMat; private static Color FULL_HEALTH = new Color(0f, 1f, 0f); private static Color LITTLE_HURT = new Color(1f, 0.75f, 0f); private static Color FAIRLY_HURT = new Color(1f, 0.65f, 0f); private static Color PRETTY_HURT = new Color(1f, 0.58f, 0f); private static Color VERY_HURT = new Color(1f, 0.48f, 0f); private static Color CRITICALLY_HURT = new Color(1f, 0.33f, 0f); private static Color DEAD = new Color(1f, 0f, 0f); private static Color col = FULL_HEALTH; private void Awake() { if ((Object)(object)((Component)this).GetComponent<Animator>() != (Object)null) { ((Behaviour)((Component)this).GetComponent<Animator>()).enabled = false; } } private void Update() { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player != (Object)null) { if (player.isPlayerDead) { col = DEAD; } else if (player.health >= 100) { col = FULL_HEALTH; } else if (player.health >= 80) { col = LITTLE_HURT; } else if (player.health >= 60) { col = FAIRLY_HURT; } else if (player.health >= 40) { col = PRETTY_HURT; } else if (player.health >= 20) { col = VERY_HURT; } else if (player.health >= 0) { col = CRITICALLY_HURT; } else { col = DEAD; } } else { col = DEAD; } if ((Object)(object)dotMat == (Object)null) { dotMat = ((Component)this).GetComponent<Renderer>().material; viewMat = ((Component)((Component)this).transform.Find("MapDirectionIndicator")).GetComponent<Renderer>().material; if ((Object)(object)player != (Object)null) { LCTweaks.DebugLog("Storing instanced material for player " + ((Object)player).name); } else { LCTweaks.DebugLog("Storing instanced material for nonplayer object"); } } viewMat.color = col; viewMat.SetColor("_EmissiveColor", col); dotMat.color = col; dotMat.SetColor("_EmissiveColor", col); } } public class LCTConfig { public ConfigEntry<float> DropAllDelay { get; private set; } public ConfigEntry<int> MaxScannables { get; private set; } public ConfigEntry<bool> ScanInShip { get; private set; } public ConfigEntry<bool> TerminalBoom { get; private set; } public ConfigEntry<bool> MuteNearTerm { get; private set; } public ConfigEntry<bool> HealthOnTerm { get; private set; } public LCTConfig(ConfigFile cfg) { DropAllDelay = cfg.Bind<float>("Input", "DropAllDelay", 1f, "How many seconds drop must be held to drop all items.\nMust be greater than or equal to the drop scrap delay"); MaxScannables = cfg.Bind<int>("Scanner", "MaxScannableObjects", 13, "Sets how many items the scanner can pick up at once.\nMust be at least 13."); ScanInShip = cfg.Bind<bool>("Scanner", "ScanThroughWallsInShip", false, "If true, scrap in the ship can be scanned through walls."); TerminalBoom = cfg.Bind<bool>("Terminal", "TerminalMineExplosion", false, "If true, disabling mines from the terminal will trigger them to explode."); MuteNearTerm = cfg.Bind<bool>("Terminal", "MuteNearTerminal", false, "Makes it so that eyeless dogs cannot hear noises that come from within 5 meters of the terminal."); HealthOnTerm = cfg.Bind<bool>("Terminal", "ShowHealthOnRadar", false, "If true, player indicators on radar will change with health."); DropAllDelay.Value = Mathf.Max(DropAllDelay.Value, 0.1f); MaxScannables.Value = Math.Max(MaxScannables.Value, 13); } } public class LCTCustomInputs : LcInputActions { public static PlayerControllerB clientPlayer; public static LCTCustomInputs instance { get; private set; } [InputAction("<Keyboard>/c", Name = "Auto-Walk")] public InputAction AutoWalkButton { get; private set; } public LCTCustomInputs() { instance = this; } public static void ToggleAutoWalk(CallbackContext context) { if ((Object)(object)clientPlayer != (Object)null && clientPlayer.isPlayerControlled && !clientPlayer.isTypingChat && !clientPlayer.inTerminalMenu && !clientPlayer.quickMenuManager.isMenuOpen) { Patches.autoWalk = !Patches.autoWalk; } } public static void DiscardPerformed(CallbackContext context) { Patches.dropAllTime = Time.time + LCTweaks.config.DropAllDelay.Value; } public static void DiscardCanceled(CallbackContext context) { LCTweaks.DebugLog("Drop canceled"); Patches.dropAllTime = -1f; } } [BepInPlugin("coderCleric.LCTweaks", "LCTweaks", "1.0.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class LCTweaks : BaseUnityPlugin { public const string MOD_GUID = "coderCleric.LCTweaks"; public const string MOD_NAME = "LCTweaks"; public const string MOD_VERSION = "1.0.3"; public int c; private static LCTweaks instance; public static LCTConfig config; private void Awake() { instance = this; config = new LCTConfig(((BaseUnityPlugin)this).Config); new LCTCustomInputs(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin coderCleric.LCTweaks is loaded!"); } public static void DebugLog(string msg) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)msg); } } [HarmonyPatch] public static class Patches { [CompilerGenerated] private sealed class <>c__DisplayClass19_0 { public PlayerControllerB __instance; } public static bool sHeld = false; public static bool sNew = false; public static bool autoWalk = false; public static float dropAllTime = -1f; private static Terminal term = null; private static bool bindingsBound = false; [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "MeetsScanNodeRequirements")] public static void ScanThroughWallsInShip(ScanNodeProperties node) { if (LCTweaks.config.ScanInShip.Value && !((Object)(object)((Component)node).transform.parent == (Object)null) && !((Object)(object)((Component)((Component)node).transform.parent).gameObject.GetComponent<PhysicsProp>() == (Object)null)) { GrabbableObject component = (GrabbableObject)(object)((Component)((Component)node).transform.parent).gameObject.GetComponent<PhysicsProp>(); if ((Object)(object)component != (Object)null && component.isInShipRoom) { node.requiresLineOfSight = false; } else if (LCTweaks.config.ScanInShip.Value && (Object)(object)component != (Object)null) { node.requiresLineOfSight = true; } } } [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "Awake")] public static void OverridePingNumber(HUDManager __instance) { __instance.scanNodesHit = (RaycastHit[])(object)new RaycastHit[LCTweaks.config.MaxScannables.Value]; if (LCTweaks.config.MaxScannables.Value - 13 > 0) { RectTransform[] array = (RectTransform[])(object)new RectTransform[LCTweaks.config.MaxScannables.Value]; for (int i = 0; i < __instance.scanElements.Length; i++) { array[i] = __instance.scanElements[i]; } Transform parent = ((Transform)array[0]).parent; for (int j = 13; j < LCTweaks.config.MaxScannables.Value; j++) { array[j] = Object.Instantiate<RectTransform>(array[0], parent); } __instance.scanElements = array; } } [HarmonyPrefix] [HarmonyPatch(typeof(TerminalAccessibleObject), "CallFunctionFromTerminal")] public static bool ExplodeFromTerminal(TerminalAccessibleObject __instance) { Landmine component = ((Component)__instance).gameObject.GetComponent<Landmine>(); if ((Object)(object)component == (Object)null || !LCTweaks.config.TerminalBoom.Value) { return true; } typeof(Landmine).GetMethod("TriggerMineOnLocalClientByExiting", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(component, new object[0]); return false; } [HarmonyPostfix] [HarmonyPatch(typeof(Landmine), "Detonate")] public static void ClearMineFromTerm(Landmine __instance) { Image mapRadarBox = ((Component)__instance).gameObject.GetComponent<TerminalAccessibleObject>().mapRadarBox; if ((Object)(object)mapRadarBox != (Object)null) { ((Component)((Component)mapRadarBox).transform.parent).gameObject.SetActive(false); } } [HarmonyPostfix] [HarmonyPatch(typeof(Terminal), "Awake")] public static void GrabTerminal(Terminal __instance) { term = __instance; } [HarmonyPrefix] [HarmonyPatch(typeof(MouthDogAI), "DetectNoise")] public static bool MuteNearTerm(Vector3 noisePosition) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)term == (Object)null || !LCTweaks.config.MuteNearTerm.Value) { return true; } bool num = Vector3.Distance(noisePosition, ((Component)term).transform.position) > 5f; if (!num) { LCTweaks.DebugLog("Dog had a noise detection event cancelled!"); } return num; } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "Awake")] public static void CreateRecolorComp(PlayerControllerB __instance) { if (LCTweaks.config.HealthOnTerm.Value) { ((Component)((Component)__instance).transform.Find("Misc/MapDot")).gameObject.AddComponent<DotColorController>().player = __instance; } } [HarmonyPostfix] [HarmonyPatch(typeof(DeadBodyInfo), "Start")] public static void CreateRecolorCompDead(DeadBodyInfo __instance) { if (LCTweaks.config.HealthOnTerm.Value) { ((Component)((Component)__instance).transform.Find("MapDot")).gameObject.AddComponent<DotColorController>(); } } [HarmonyPostfix] [HarmonyPatch(typeof(MaskedPlayerEnemy), "Awake")] public static void CreateRecolorCompMasked(DeadBodyInfo __instance) { if (LCTweaks.config.HealthOnTerm.Value) { ((Component)((Component)__instance).transform.Find("Misc/MapDot")).gameObject.AddComponent<DotColorController>(); } } [HarmonyTranspiler] [HarmonyPatch(typeof(PlayerControllerB), "Update")] public static IEnumerable<CodeInstruction> OverrideWalkInput(IEnumerable<CodeInstruction> instructions, ILGenerator il) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = -1; Label label = il.DefineLabel(); for (int i = 0; i < list.Count; i++) { if (list[i].opcode == OpCodes.Stfld && (FieldInfo)list[i].operand == AccessTools.Field(typeof(PlayerControllerB), "moveInputVector")) { LCTweaks.DebugLog("Found expected structure for walk transpiler"); num = i + 1; list[i + 1].labels.Add(label); break; } } List<CodeInstruction> list2 = new List<CodeInstruction>(); list2.Add(new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(Patches), "autoWalk"))); list2.Add(new CodeInstruction(OpCodes.Brfalse_S, (object)label)); list2.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null)); list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Vector2), "get_up", (Type[])null, (Type[])null))); list2.Add(new CodeInstruction(OpCodes.Stfld, (object)AccessTools.Field(typeof(PlayerControllerB), "moveInputVector"))); if (num != -1) { list.InsertRange(num, list2); } return list; } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "Start")] public static void BindInput() { if (!bindingsBound) { bindingsBound = true; InputActionAsset actions = IngamePlayerSettings.Instance.playerInput.actions; LCTweaks.DebugLog("Binding controls"); LCTCustomInputs.instance.AutoWalkButton.performed += LCTCustomInputs.ToggleAutoWalk; actions.FindAction("Discard", false).performed += LCTCustomInputs.DiscardPerformed; actions.FindAction("Discard", false).canceled += LCTCustomInputs.DiscardCanceled; } } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "Disconnect")] public static void UnbindInput() { if (bindingsBound) { bindingsBound = false; InputActionAsset actions = IngamePlayerSettings.Instance.playerInput.actions; LCTweaks.DebugLog("Unbinding controls"); LCTCustomInputs.instance.AutoWalkButton.performed -= LCTCustomInputs.ToggleAutoWalk; actions.FindAction("Discard", false).performed -= LCTCustomInputs.DiscardPerformed; actions.FindAction("Discard", false).canceled -= LCTCustomInputs.DiscardCanceled; } } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] public static void DetectClientPlayer(PlayerControllerB __instance) { LCTCustomInputs.clientPlayer = __instance; LCTweaks.DebugLog("Found the client player!"); } [HarmonyPostfix] [HarmonyPatch(typeof(PlayerControllerB), "Update")] public static void DiscardAllItems(PlayerControllerB __instance) { <>c__DisplayClass19_0 CS$<>8__locals0 = new <>c__DisplayClass19_0(); CS$<>8__locals0.__instance = __instance; if (!((Object)(object)CS$<>8__locals0.__instance != (Object)(object)LCTCustomInputs.clientPlayer) && dropAllTime >= 0f && Time.time > dropAllTime) { ((MonoBehaviour)CS$<>8__locals0.__instance).StartCoroutine(DiscardAtEndOfFrame()); dropAllTime = -1f; } [IteratorStateMachine(typeof(<>c__DisplayClass19_0.<<DiscardAllItems>g__DiscardAtEndOfFrame|0>d))] IEnumerator DiscardAtEndOfFrame() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <>c__DisplayClass19_0.<<DiscardAllItems>g__DiscardAtEndOfFrame|0>d(0) { <>4__this = CS$<>8__locals0 }; } } [HarmonyPrefix] [HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")] public static bool CancelItemSwitch() { return dropAllTime < 0f; } } }