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 BetterLaddersFixed v2.2.0
BepInEx/plugins/BetterLadders.dll
Decompiled 2 days agousing System; using System.Collections; 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.Cryptography; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using BetterLadders.NetcodePatcher; using BetterLadders.Networking; using BetterLadders.Patches; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BetterLadders")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Configurable climbing speed, extension ladder time, and climbing with two-handed items.")] [assembly: AssemblyFileVersion("2.1.0.0")] [assembly: AssemblyInformationalVersion("2.1.0+6cae662c86c90ee432a92735c0251cc577c2776e")] [assembly: AssemblyProduct("BetterLadders")] [assembly: AssemblyTitle("BetterLadders")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 BetterLadders { [BepInPlugin("e3s1.BetterLadders", "BetterLadders", "2.0.2")] public class BetterLadders : BaseUnityPlugin { public const string PLUGIN_GUID = "e3s1.BetterLadders"; public const string PLUGIN_NAME = "BetterLadders"; public const string PLUGIN_VERSION = "2.0.2"; internal static ManualLogSource StaticLogger { get; private set; } internal static Config Settings { get; private set; } internal static Harmony Harmony { get; private set; } private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown StaticLogger = ((BaseUnityPlugin)this).Logger; try { Settings = new Config(((BaseUnityPlugin)this).Config); Harmony = new Harmony("e3s1.BetterLadders"); NetcodePatcher(); Harmony.PatchAll(typeof(NetworkingInitPatches)); Harmony.PatchAll(typeof(AllowTwoHandedPatch)); Harmony.PatchAll(typeof(AnimationSpeedPatch)); Harmony.PatchAll(typeof(ClimbSpeedPatch)); Harmony.PatchAll(typeof(ExtLadderKillTriggerPatch)); Harmony.PatchAll(typeof(ExtLadderTimerPatch)); Harmony.PatchAll(typeof(HideItemsPatches)); StaticLogger.LogInfo((object)"BetterLadders v2.0.2 loaded!"); } catch (Exception arg) { StaticLogger.LogError((object)string.Format("Error while initializing '{0}': {1}", "BetterLadders", arg)); } } private static void NetcodePatcher() { Type[] array; try { array = Assembly.GetExecutingAssembly().GetTypes(); } catch (ReflectionTypeLoadException ex) { array = ex.Types.Where((Type type) => type != null).ToArray(); } Type[] array2 = array; foreach (Type type2 in array2) { MethodInfo[] methods = type2.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } } public class Config { public static BetterLaddersData LocalData { get; internal set; } public ConfigEntry<float> ClimbSpeedMultiplier { get; private set; } public ConfigEntry<float> ClimbSprintSpeedMultiplier { get; private set; } public ConfigEntry<bool> AllowTwoHanded { get; private set; } public ConfigEntry<bool> ScaleAnimationSpeed { get; private set; } public ConfigEntry<bool> HideOneHanded { get; private set; } public ConfigEntry<bool> HideTwoHanded { get; private set; } public ConfigEntry<float> ExtensionTimer { get; private set; } public ConfigEntry<bool> EnableKillTrigger { get; private set; } public Config(ConfigFile cfg) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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 cfg.SaveOnConfigSet = false; ClimbSpeedMultiplier = cfg.Bind<float>("Speed", "climbSpeedMultiplier", 1f, new ConfigDescription("Ladder climb speed multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), Array.Empty<object>())); ClimbSprintSpeedMultiplier = cfg.Bind<float>("Speed", "sprintingClimbSpeedMultiplier", 1.5f, new ConfigDescription("Ladder climb speed multiplier while sprinting, stacks with climbSpeedMultiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 10f), Array.Empty<object>())); ScaleAnimationSpeed = cfg.Bind<bool>("Speed", "scaleAnimationSpeed", true, "Whether to scale the speed of the climbing animation to the climbing speed."); AllowTwoHanded = cfg.Bind<bool>("Items", "allowTwoHanded", true, "Whether to allow using ladders while carrying a two-handed object."); HideOneHanded = cfg.Bind<bool>("Items", "hideOneHanded", true, "Whether to hide one-handed items while climbing a ladder."); HideTwoHanded = cfg.Bind<bool>("Items", "hideTwoHanded", true, "Whether to hide two-handed items while climbing a ladder."); ExtensionTimer = cfg.Bind<float>("Extension Ladder", "extensionTimer", 20f, new ConfigDescription("How long (in seconds) extension ladders remain deployed. Set to 0 for permanent.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 700f), Array.Empty<object>())); EnableKillTrigger = cfg.Bind<bool>("Extension Ladder", "enableKillTrigger", true, "Whether extension ladders should kill players they land on."); ClimbSpeedMultiplier.SettingChanged += OnSettingChanged; ClimbSprintSpeedMultiplier.SettingChanged += OnSettingChanged; AllowTwoHanded.SettingChanged += OnSettingChanged; ScaleAnimationSpeed.SettingChanged += OnSettingChanged; HideOneHanded.SettingChanged += OnSettingChanged; HideTwoHanded.SettingChanged += OnSettingChanged; ExtensionTimer.SettingChanged += OnSettingChanged; EnableKillTrigger.SettingChanged += OnSettingChanged; ClearOrphanedEntries(cfg); cfg.SaveOnConfigSet = true; cfg.Save(); } private void OnSettingChanged(object sender, EventArgs args) { if ((Object)(object)BetterLaddersNetworker.Instance != (Object)null && ((NetworkBehaviour)BetterLaddersNetworker.Instance).IsSpawned && ((NetworkBehaviour)BetterLaddersNetworker.Instance).IsHost) { BetterLaddersNetworker.Instance.RefreshSyncedData(); } } private static void ClearOrphanedEntries(ConfigFile config) { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); ((Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(config))?.Clear(); } } } namespace BetterLadders.Patches { [HarmonyPatch] internal sealed class AllowTwoHandedPatch { [HarmonyPatch(typeof(InteractTrigger), "Start")] [HarmonyPostfix] private static void LadderStart_Post(InteractTrigger __instance) { if (__instance.isLadder) { ModifyLadder(__instance, Config.LocalData.allowTwoHanded); } } internal static void RefreshAllLadders(bool allowTwoHanded) { InteractTrigger[] array = Object.FindObjectsByType<InteractTrigger>((FindObjectsInactive)0, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { if (array[i].isLadder) { ModifyLadder(array[i], allowTwoHanded); } } } private static void ModifyLadder(InteractTrigger ladderTrigger, bool allowTwoHanded) { ladderTrigger.twoHandedItemAllowed = allowTwoHanded; ladderTrigger.specialCharacterAnimation = !allowTwoHanded; } } [HarmonyPatch] internal sealed class AnimationSpeedPatch { [CompilerGenerated] private sealed class <>c__DisplayClass2_0 { public PlayerControllerB player; public float startTime; public bool isLocalPlayer; internal bool <ScalePlayerAnimationSpeed>b__0() { return ((Object)(object)player != (Object)null && player.isClimbingLadder) || Time.realtimeSinceStartup - startTime > 5f; } internal bool <ScalePlayerAnimationSpeed>b__1() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)player.playerBodyAnimator == (Object)null) { return false; } float @float = player.playerBodyAnimator.GetFloat(animationSpeedID); if (@float != 0f) { bool num; if (!isLocalPlayer) { AnimatorStateInfo currentAnimatorStateInfo = player.playerBodyAnimator.GetCurrentAnimatorStateInfo(0); num = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsTag("Sprinting"); } else { num = player.isSprinting; } bool flag = num; @float = Config.LocalData.climbSpeedMultiplier * (flag ? Config.LocalData.climbSprintSpeedMultiplier : 1f); player.playerBodyAnimator.SetFloat(animationSpeedID, @float); } return player.isClimbingLadder; } } [CompilerGenerated] private sealed class <ScalePlayerAnimationSpeed>d__2 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlayerControllerB player; private <>c__DisplayClass2_0 <>8__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ScalePlayerAnimationSpeed>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass2_0(); <>8__1.player = player; <>8__1.isLocalPlayer = <>8__1.player.actualClientId == GameNetworkManager.Instance.localPlayerController.actualClientId; <>8__1.startTime = Time.realtimeSinceStartup; <>2__current = (object)new WaitUntil((Func<bool>)(() => ((Object)(object)<>8__1.player != (Object)null && <>8__1.player.isClimbingLadder) || Time.realtimeSinceStartup - <>8__1.startTime > 5f)); <>1__state = 1; return true; case 1: <>1__state = -1; if ((Object)(object)<>8__1.player == (Object)null || !<>8__1.player.isClimbingLadder) { BetterLadders.StaticLogger.LogWarning((object)"Timed out when syncing ladder animation speed."); return false; } <>2__current = (object)new WaitWhile((Func<bool>)delegate { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)<>8__1.player == (Object)null || (Object)(object)<>8__1.player.playerBodyAnimator == (Object)null) { return false; } float @float = <>8__1.player.playerBodyAnimator.GetFloat(animationSpeedID); if (@float != 0f) { bool num; if (!<>8__1.isLocalPlayer) { AnimatorStateInfo currentAnimatorStateInfo = <>8__1.player.playerBodyAnimator.GetCurrentAnimatorStateInfo(0); num = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsTag("Sprinting"); } else { num = <>8__1.player.isSprinting; } bool flag = num; @float = Config.LocalData.climbSpeedMultiplier * (flag ? Config.LocalData.climbSprintSpeedMultiplier : 1f); <>8__1.player.playerBodyAnimator.SetFloat(animationSpeedID, @float); } return <>8__1.player.isClimbingLadder; }); <>1__state = 2; return true; case 2: <>1__state = -1; 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(); } } private static readonly int animationSpeedID = Animator.StringToHash("animationSpeed"); [HarmonyPatch(typeof(InteractTrigger), "SetUsingLadderOnLocalClient")] [HarmonyPriority(300)] [HarmonyPostfix] private static void SetUsingLadderOnLocalClient_Post(bool isUsing) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; ((MonoBehaviour)localPlayerController).StopCoroutine(ScalePlayerAnimationSpeed(localPlayerController)); if (!isUsing) { if ((Object)(object)BetterLaddersNetworker.Instance != (Object)null && ((NetworkBehaviour)BetterLaddersNetworker.Instance).IsSpawned) { BetterLaddersNetworker.Instance.SetAnimationSpeedServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)localPlayerController), stop: true); } return; } ((MonoBehaviour)localPlayerController).StartCoroutine(ScalePlayerAnimationSpeed(localPlayerController)); if ((Object)(object)BetterLaddersNetworker.Instance != (Object)null && ((NetworkBehaviour)BetterLaddersNetworker.Instance).IsSpawned) { BetterLaddersNetworker.Instance.SetAnimationSpeedServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)localPlayerController), stop: false); } } [IteratorStateMachine(typeof(<ScalePlayerAnimationSpeed>d__2))] internal static IEnumerator ScalePlayerAnimationSpeed(PlayerControllerB player) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ScalePlayerAnimationSpeed>d__2(0) { player = player }; } } [HarmonyPatch] internal sealed class ClimbSpeedPatch { internal static float initialClimbSpeed = 4f; [HarmonyPatch(typeof(InteractTrigger), "SetUsingLadderOnLocalClient")] [HarmonyPostfix] private static void SetUsingLadderOnLocalClient_Post(bool isUsing) { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (!isUsing) { ResetPlayerClimbSpeed(localPlayerController); return; } initialClimbSpeed = localPlayerController.climbSpeed; InputAction movement_Sprint = localPlayerController.playerActions.m_Movement_Sprint; movement_Sprint.started += OnPlayerBeginSprint; movement_Sprint.canceled += OnPlayerStopSprint; SetPlayerClimbSpeed(localPlayerController, localPlayerController.isSprinting); } [HarmonyPatch(typeof(InteractTrigger), "CancelLadderAnimation")] [HarmonyPostfix] private static void CancelLadderAnimation_Post() { ResetPlayerClimbSpeed(GameNetworkManager.Instance.localPlayerController); } private static void OnPlayerBeginSprint(CallbackContext context) { SetPlayerClimbSpeed(GameNetworkManager.Instance.localPlayerController, isSprinting: true); } private static void OnPlayerStopSprint(CallbackContext context) { SetPlayerClimbSpeed(GameNetworkManager.Instance.localPlayerController, isSprinting: false); } private static void SetPlayerClimbSpeed(PlayerControllerB player, bool isSprinting) { player.climbSpeed = initialClimbSpeed * Config.LocalData.climbSpeedMultiplier * (isSprinting ? Config.LocalData.climbSprintSpeedMultiplier : 1f); } private static void ResetPlayerClimbSpeed(PlayerControllerB player) { player.climbSpeed = initialClimbSpeed; InputAction movement_Sprint = player.playerActions.m_Movement_Sprint; movement_Sprint.started -= OnPlayerBeginSprint; movement_Sprint.canceled -= OnPlayerStopSprint; } } [HarmonyPatch] internal sealed class ExtLadderKillTriggerPatch { [HarmonyPatch(typeof(ExtensionLadderItem), "StartLadderAnimation")] [HarmonyPrefix] private static void StartLadderAnimation_Pre(Collider ___killTrigger) { if ((Object)(object)___killTrigger != (Object)null && Config.LocalData.enableKillTrigger != ((Component)___killTrigger).gameObject.activeInHierarchy) { ((Component)___killTrigger).gameObject.SetActive(Config.LocalData.enableKillTrigger); } } } [HarmonyPatch] internal sealed class ExtLadderTimerPatch { [HarmonyPatch(typeof(ExtensionLadderItem), "StartLadderAnimation")] [HarmonyPostfix] private static void StartLadderAnimation_Post(ref float ___ladderTimer) { ___ladderTimer = ((Config.LocalData.extensionTimer > 0f) ? (20f - Config.LocalData.extensionTimer) : (-2.1474836E+09f)); } } [HarmonyPatch] internal sealed class HideItemsPatches { [HarmonyPatch(typeof(InteractTrigger), "SetUsingLadderOnLocalClient")] [HarmonyPostfix] private static void LadderHeldItemVisibilityPatch(bool isUsing) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if (localPlayerController.isHoldingObject && (Object)(object)localPlayerController.currentlyHeldObjectServer != (Object)null && ((Config.LocalData.hideOneHanded && !localPlayerController.twoHanded) || (Config.LocalData.allowTwoHanded && Config.LocalData.hideTwoHanded && localPlayerController.twoHanded))) { localPlayerController.currentlyHeldObjectServer.EnableItemMeshes(!isUsing); if ((Object)(object)BetterLaddersNetworker.Instance != (Object)null && ((NetworkBehaviour)BetterLaddersNetworker.Instance).IsSpawned) { BetterLaddersNetworker.Instance.HideItemServerRpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)localPlayerController.currentlyHeldObjectServer), !isUsing); } } } [HarmonyPatch(typeof(InteractTrigger), "Start")] [HarmonyPostfix] private static void LadderStart_Post(InteractTrigger __instance) { if (__instance.isLadder) { __instance.hidePlayerItem = Config.LocalData.hideOneHanded && Config.LocalData.hideTwoHanded; } } internal static void RefreshAllLadders(bool hideItem) { InteractTrigger[] array = Object.FindObjectsByType<InteractTrigger>((FindObjectsInactive)0, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { if (array[i].isLadder) { array[i].hidePlayerItem = hideItem; } } } } [HarmonyPatch] internal sealed class NetworkingInitPatches { [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private static GameObject? <NetworkerPrefab>k__BackingField; public static GameObject? NetworkerPrefab { get { //IL_0019: 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_002c: Expected O, but got Unknown if ((Object)(object)<NetworkerPrefab>k__BackingField == (Object)null) { <NetworkerPrefab>k__BackingField = new GameObject("BetterLaddersNetworker") { hideFlags = (HideFlags)61 }; NetworkObject val = <NetworkerPrefab>k__BackingField.AddComponent<NetworkObject>(); try { byte[] value = SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(Assembly.GetExecutingAssembly().GetName().Name)); val.GlobalObjectIdHash = BitConverter.ToUInt32(value, 0); } catch (Exception arg) { BetterLadders.StaticLogger.LogError((object)$"Could not override default networker hash: {arg}"); } <NetworkerPrefab>k__BackingField.AddComponent<BetterLaddersNetworker>(); } return <NetworkerPrefab>k__BackingField; } [CompilerGenerated] private set { <NetworkerPrefab>k__BackingField = value; } } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPrefix] private static void StartOfRoundAwake_Pre() { if (NetworkManager.Singleton.IsHost) { if ((Object)(object)NetworkerPrefab == (Object)null) { BetterLadders.StaticLogger.LogWarning((object)"Networker prefab is missing and could not be created; mod won't be able to do anything."); return; } GameObject val = Object.Instantiate<GameObject>(NetworkerPrefab); ((Object)val).hideFlags = (HideFlags)0; val.GetComponent<NetworkObject>().Spawn(true); } } [HarmonyPatch(typeof(GameNetworkManager), "Start")] [HarmonyPrefix] private static void GameNetworkManagerStart_Pre() { if ((Object)(object)NetworkerPrefab == (Object)null) { BetterLadders.StaticLogger.LogWarning((object)"Networker prefab is missing and could not be created; mod won't be able to do anything."); } else if (!NetworkManager.Singleton.NetworkConfig.Prefabs.Contains(NetworkerPrefab)) { NetworkManager.Singleton.AddNetworkPrefab(NetworkerPrefab); } } } } namespace BetterLadders.Networking { public struct BetterLaddersData : INetworkSerializable { public float climbSpeedMultiplier; public float climbSprintSpeedMultiplier; public float extensionTimer; public bool allowTwoHanded; public bool scaleAnimationSpeed; public bool hideOneHanded; public bool hideTwoHanded; public bool enableKillTrigger; public BetterLaddersData() { allowTwoHanded = false; scaleAnimationSpeed = false; hideOneHanded = false; hideTwoHanded = false; climbSpeedMultiplier = 1f; climbSprintSpeedMultiplier = 1f; extensionTimer = 20f; enableKillTrigger = true; } public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0056: 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) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref climbSpeedMultiplier, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref climbSprintSpeedMultiplier, default(ForPrimitives)); ((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref extensionTimer, default(ForPrimitives)); ((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref allowTwoHanded, default(ForPrimitives)); ((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref scaleAnimationSpeed, default(ForPrimitives)); ((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref hideOneHanded, default(ForPrimitives)); ((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref hideTwoHanded, default(ForPrimitives)); ((BufferSerializer<bool>*)(&serializer))->SerializeValue<bool>(ref enableKillTrigger, default(ForPrimitives)); } } public sealed class BetterLaddersNetworker : NetworkBehaviour { public static BetterLaddersNetworker? Instance { get; private set; } public NetworkVariable<BetterLaddersData> SyncedData { get; private set; } = new NetworkVariable<BetterLaddersData>(default(BetterLaddersData), (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); Instance = this; NetworkVariable<BetterLaddersData> syncedData = SyncedData; syncedData.OnValueChanged = (OnValueChangedDelegate<BetterLaddersData>)(object)Delegate.Combine((Delegate?)(object)syncedData.OnValueChanged, (Delegate?)(object)(OnValueChangedDelegate<BetterLaddersData>)delegate(BetterLaddersData previousData, BetterLaddersData newData) { Config.LocalData = newData; if (previousData.allowTwoHanded != newData.allowTwoHanded) { AllowTwoHandedPatch.RefreshAllLadders(newData.allowTwoHanded); } if (previousData.hideOneHanded != newData.hideOneHanded || previousData.hideTwoHanded != newData.hideTwoHanded) { HideItemsPatches.RefreshAllLadders(newData.hideOneHanded && newData.hideTwoHanded); } }); RefreshSyncedData(); Config.LocalData = SyncedData.Value; } public override void OnNetworkDespawn() { Instance = null; ((NetworkBehaviour)this).OnNetworkDespawn(); } public void RefreshSyncedData() { if (((NetworkBehaviour)this).IsSpawned && ((NetworkBehaviour)this).IsHost) { SyncedData.Value = new BetterLaddersData { climbSpeedMultiplier = BetterLadders.Settings.ClimbSpeedMultiplier.Value, climbSprintSpeedMultiplier = BetterLadders.Settings.ClimbSprintSpeedMultiplier.Value, extensionTimer = BetterLadders.Settings.ExtensionTimer.Value, allowTwoHanded = BetterLadders.Settings.AllowTwoHanded.Value, scaleAnimationSpeed = BetterLadders.Settings.ScaleAnimationSpeed.Value, hideOneHanded = BetterLadders.Settings.HideOneHanded.Value, hideTwoHanded = BetterLadders.Settings.HideTwoHanded.Value, enableKillTrigger = BetterLadders.Settings.EnableKillTrigger.Value }; } } [Rpc(/*Could not decode attribute arguments.*/)] public void HideItemServerRpc(NetworkBehaviourReference itemReference, bool hide) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Invalid comparison between Unknown and I4 //IL_0043: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val2 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(2373942706u, val2, val, (SendTo)5, (RpcDelivery)0); ((FastBufferWriter)(ref val3)).WriteValueSafe<NetworkBehaviourReference>(ref itemReference, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val3)).WriteValueSafe<bool>(ref hide, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 2373942706u, val2, val, (SendTo)5, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1) { base.__rpc_exec_stage = (__RpcExecStage)0; GrabbableObject val4 = default(GrabbableObject); if (((NetworkBehaviourReference)(ref itemReference)).TryGet<GrabbableObject>(ref val4, (NetworkManager)null) && (Object)(object)val4.playerHeldBy != (Object)null) { val4.EnableItemMeshes(hide); } } } [Rpc(/*Could not decode attribute arguments.*/)] public void SetAnimationSpeedServerRpc(NetworkBehaviourReference playerReference, bool stop) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Invalid comparison between Unknown and I4 //IL_0043: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)base.__rpc_exec_stage != 1) { RpcAttributeParams val = new RpcAttributeParams { RequireOwnership = false }; RpcParams val2 = default(RpcParams); FastBufferWriter val3 = ((NetworkBehaviour)this).__beginSendRpc(1125511430u, val2, val, (SendTo)5, (RpcDelivery)0); ((FastBufferWriter)(ref val3)).WriteValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable)); ((FastBufferWriter)(ref val3)).WriteValueSafe<bool>(ref stop, default(ForPrimitives)); ((NetworkBehaviour)this).__endSendRpc(ref val3, 1125511430u, val2, val, (SendTo)5, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage != 1) { return; } base.__rpc_exec_stage = (__RpcExecStage)0; PlayerControllerB val4 = default(PlayerControllerB); if (((NetworkBehaviourReference)(ref playerReference)).TryGet<PlayerControllerB>(ref val4, (NetworkManager)null)) { ((MonoBehaviour)val4).StopCoroutine(AnimationSpeedPatch.ScalePlayerAnimationSpeed(val4)); if (!stop) { ((MonoBehaviour)val4).StartCoroutine(AnimationSpeedPatch.ScalePlayerAnimationSpeed(val4)); } } } protected override void __initializeVariables() { if (SyncedData == null) { throw new Exception("BetterLaddersNetworker.<SyncedData>k__BackingField cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)SyncedData).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)SyncedData, "SyncedData"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)SyncedData); ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown ((NetworkBehaviour)this).__registerRpc(2373942706u, new RpcReceiveHandler(__rpc_handler_2373942706), "HideItemServerRpc"); ((NetworkBehaviour)this).__registerRpc(1125511430u, new RpcReceiveHandler(__rpc_handler_1125511430), "SetAnimationSpeedServerRpc"); ((NetworkBehaviour)this).__initializeRpcs(); } private static void __rpc_handler_2373942706(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkBehaviourReference itemReference = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref itemReference, default(ForNetworkSerializable)); bool hide = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref hide, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((BetterLaddersNetworker)(object)target).HideItemServerRpc(itemReference, hide); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1125511430(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkBehaviourReference playerReference = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref playerReference, default(ForNetworkSerializable)); bool stop = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref stop, default(ForPrimitives)); target.__rpc_exec_stage = (__RpcExecStage)1; ((BetterLaddersNetworker)(object)target).SetAnimationSpeedServerRpc(playerReference, stop); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "BetterLaddersNetworker"; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<BetterLaddersData>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<BetterLaddersData>(); } } } namespace BetterLadders.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }