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 HalfLifeLadders v1.0.0
HalfLifeLadders.dll
Decompiled a day agousing System; 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.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HalfLifeLadders.Patches; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [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("Khameli0n")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Standalone Two-Handed Ladder & Half-Life Auto-Climbing mod for Lethal Company.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("HalfLifeLadders")] [assembly: AssemblyTitle("HalfLifeLadders")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 HalfLifeLadders { public static class Configuration { public static ConfigEntry<bool> EnableTwoHandedLadders { get; private set; } public static ConfigEntry<bool> EnableAutoLadderClimb { get; private set; } public static ConfigEntry<float> LadderBoostForce { get; private set; } public static void Init(ConfigFile cfg) { EnableTwoHandedLadders = cfg.Bind<bool>("Ladders", "EnableTwoHandedLadders", true, "Enables climbing all ladders while carrying two-handed scrap."); EnableAutoLadderClimb = cfg.Bind<bool>("Ladders", "EnableAutoLadderClimb", true, "Enables Half-Life 1 style ladder climbing: walking into a ladder climbs automatically."); LadderBoostForce = cfg.Bind<float>("Ladders", "LadderBoostForce", 4.5f, "Horizontal push force when jumping off a ladder with Space."); } } [BepInPlugin("com.khameli0n.halflifeladders", "HalfLifeLadders", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.khameli0n.halflifeladders"; public const string PLUGIN_NAME = "HalfLifeLadders"; public const string PLUGIN_VERSION = "1.0.0"; public static Plugin Instance { get; private set; } public static ManualLogSource Log { get; private set; } public static Harmony HarmonyInstance { get; private set; } private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Configuration.Init(((BaseUnityPlugin)this).Config); HarmonyInstance = new Harmony("com.khameli0n.halflifeladders"); try { HarmonyInstance.CreateClassProcessor(typeof(LadderPatches)).Patch(); Log.LogInfo((object)string.Format("{0} v{1} loaded (TwoHanded={2}, AutoClimb={3}).", "HalfLifeLadders", "1.0.0", Configuration.EnableTwoHandedLadders.Value, Configuration.EnableAutoLadderClimb.Value)); } catch (Exception arg) { Log.LogError((object)string.Format("Failed to apply patches for {0}: {1}", "HalfLifeLadders", arg)); } } } } namespace HalfLifeLadders.Patches { [HarmonyPatch] public static class LadderPatches { private static float jumpCooldownTime; private static float lastMountTime; private static float nextLadderScanTime; private static bool loggedHeartbeat; private static bool IsLadderTrigger(InteractTrigger trig) { if ((Object)(object)trig == (Object)null) { return false; } if (trig.isLadder) { return true; } if (((Object)trig).name != null && ((Object)trig).name.IndexOf("ladder", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } if (trig.hoverTip != null) { return trig.hoverTip.IndexOf("Climb", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private static void ConfigureLadderTrigger(InteractTrigger trig) { if (!((Object)(object)trig == (Object)null)) { trig.isLadder = true; trig.twoHandedItemAllowed = true; trig.oneHandedItemAllowed = true; trig.specialCharacterAnimation = false; trig.holdInteraction = false; trig.interactable = true; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPrefix] public static void PlayerUpdate_Prefix(PlayerControllerB __instance) { try { if (!Configuration.EnableTwoHandedLadders.Value || (Object)(object)__instance == (Object)null || !((NetworkBehaviour)__instance).IsOwner) { return; } if (!loggedHeartbeat && __instance.isPlayerControlled) { loggedHeartbeat = true; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[Ladders] PlayerControllerB.Update hook verified active on local player!"); } } if ((Object)(object)__instance.hoveringOverTrigger != (Object)null && IsLadderTrigger(__instance.hoveringOverTrigger)) { ConfigureLadderTrigger(__instance.hoveringOverTrigger); } if (Time.time < nextLadderScanTime) { return; } nextLadderScanTime = Time.time + 1.5f; InteractTrigger[] array = Object.FindObjectsOfType<InteractTrigger>(); if (array == null) { return; } for (int i = 0; i < array.Length; i++) { if (IsLadderTrigger(array[i])) { ConfigureLadderTrigger(array[i]); } } } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; if (log2 != null) { log2.LogWarning((object)("[Ladders] Prefix error: " + ex.Message)); } } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] public static void PlayerUpdate_Postfix(PlayerControllerB __instance) { try { if (!Configuration.EnableTwoHandedLadders.Value || (Object)(object)__instance == (Object)null || !((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled || __instance.isPlayerDead) { return; } TryUpdateHoverLadderPrompt(__instance); if (__instance.isClimbingLadder) { if (IsJumpOffRequested(__instance)) { HandleLadderJumpOff(__instance); } } else if (CanAutoMount(__instance) && IsForwardMoveRequested(__instance)) { InteractTrigger val = FindWalkUpLadderTrigger(__instance); if ((Object)(object)val != (Object)null && !val.isPlayingSpecialAnimation && (Object)(object)__instance.thisPlayerBody != (Object)null) { MountLadder(__instance, val); } } } catch (Exception ex) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("[Ladders] Postfix error: " + ex.Message)); } } } [HarmonyPatch(typeof(PlayerControllerB), "SetHoverTipAndCurrentInteractTrigger")] [HarmonyPrefix] public static void SetHoverTip_Prefix(PlayerControllerB __instance) { if (Configuration.EnableTwoHandedLadders.Value && (Object)(object)__instance != (Object)null && (Object)(object)__instance.hoveringOverTrigger != (Object)null && IsLadderTrigger(__instance.hoveringOverTrigger)) { ConfigureLadderTrigger(__instance.hoveringOverTrigger); } } [HarmonyPatch(typeof(PlayerControllerB), "SetHoverTipAndCurrentInteractTrigger")] [HarmonyPostfix] public static void SetHoverTip_Postfix(PlayerControllerB __instance) { if (Configuration.EnableTwoHandedLadders.Value && (Object)(object)__instance != (Object)null) { TryUpdateHoverLadderPrompt(__instance); } } private static void TryUpdateHoverLadderPrompt(PlayerControllerB player) { if (!((Object)(object)player.hoveringOverTrigger == (Object)null) && IsLadderTrigger(player.hoveringOverTrigger)) { ConfigureLadderTrigger(player.hoveringOverTrigger); if ((Object)(object)player.cursorTip != (Object)null) { ((TMP_Text)player.cursorTip).text = "Climb : [Walk / W] or [E]"; } } } private static bool CanAutoMount(PlayerControllerB player) { if (Configuration.EnableAutoLadderClimb.Value && !player.isClimbingLadder && !player.inSpecialInteractAnimation && !player.inTerminalMenu && !player.isTypingChat && Time.time > jumpCooldownTime) { return Time.time - lastMountTime > 0.4f; } return false; } private static bool IsJumpOffRequested(PlayerControllerB player) { //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) try { if (Keyboard.current != null && ((ButtonControl)Keyboard.current.spaceKey).wasPressedThisFrame) { return true; } if (UnityInput.Current.GetKeyDown((KeyCode)32)) { return true; } if (player.playerActions != null) { MovementActions movement = player.playerActions.Movement; if (((MovementActions)(ref movement)).Jump.triggered) { return true; } } } catch { } return false; } private static bool IsForwardMoveRequested(PlayerControllerB player) { if (player.moveInputVector.y > 0.1f) { return true; } try { if (Keyboard.current != null && ((ButtonControl)Keyboard.current.wKey).isPressed) { return true; } if (UnityInput.Current.GetKey((KeyCode)119)) { return true; } } catch { } return false; } private static void HandleLadderJumpOff(PlayerControllerB player) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) player.CancelSpecialTriggerAnimations(); if ((Object)(object)player.thisController != (Object)null) { ((Collider)player.thisController).enabled = true; float value = Configuration.LadderBoostForce.Value; Vector3 val = -((Component)player).transform.forward * value + Vector3.up * 3.5f; player.thisController.Move(val * Time.deltaTime); } jumpCooldownTime = Time.time + 0.55f; ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)"[Ladders] HL1: Jumped off ladder with Space."); } } private static InteractTrigger FindWalkUpLadderTrigger(PlayerControllerB player) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player.hoveringOverTrigger != (Object)null && IsLadderTrigger(player.hoveringOverTrigger) && Vector3.Distance(((Component)player).transform.position, ((Component)player.hoveringOverTrigger).transform.position) < 2.2f) { return player.hoveringOverTrigger; } Vector3 val; Bounds bounds; if (!((Object)(object)player.thisController != (Object)null)) { val = ((Component)player).transform.position + Vector3.up * 1f; } else { bounds = ((Collider)player.thisController).bounds; val = ((Bounds)(ref bounds)).center; } Vector3 val2 = val; Collider[] array = Physics.OverlapSphere(val2, 1.35f, -1, (QueryTriggerInteraction)2); if (array == null) { return null; } Vector3 forward = ((Component)player).transform.forward; forward.y = 0f; Vector3 normalized = ((Vector3)(ref forward)).normalized; Collider[] array2 = array; foreach (Collider val3 in array2) { if ((Object)(object)val3 == (Object)null || (Object)(object)val3 == (Object)(object)player.thisController) { continue; } InteractTrigger val4 = ((Component)val3).GetComponent<InteractTrigger>() ?? ((Component)val3).GetComponentInParent<InteractTrigger>() ?? ((Component)val3).GetComponentInChildren<InteractTrigger>(); if (!((Object)(object)val4 == (Object)null) && IsLadderTrigger(val4)) { bounds = val3.bounds; Vector3 val5 = ((Bounds)(ref bounds)).center - val2; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude < 0.05f || Vector3.Dot(normalized, ((Vector3)(ref val5)).normalized) > 0.15f) { return val4; } } } return null; } private static void MountLadder(PlayerControllerB player, InteractTrigger ladderTrigger) { lastMountTime = Time.time; ConfigureLadderTrigger(ladderTrigger); bool twoHanded = player.twoHanded; bool isInHangarShipRoom = player.isInHangarShipRoom; player.twoHanded = false; player.isInHangarShipRoom = false; try { ladderTrigger.Interact(player.thisPlayerBody); } finally { player.twoHanded = twoHanded; player.isInHangarShipRoom = isInHangarShipRoom; } ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)("[Ladders] HL1: Auto-mounted ladder '" + ((Object)ladderTrigger).name + "' via walk-up!")); } } } }