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 Dash v1.1.1
Dash.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalCompanyInputUtils.Api; using Microsoft.CodeAnalysis; using Unity.Collections; 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: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Dash")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A Dash mod for Lethal Company")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+3421b26455eed0caf2df65dccf377dc2ba0344bb")] [assembly: AssemblyProduct("Dash")] [assembly: AssemblyTitle("Dash")] [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 Dash { public sealed class Config : LcInputActions { [HarmonyPatch] public class SyncLimitations { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static HandleNamedMessageDelegate <>9__2_0; internal void <Initialize>b__2_0(ulong clientId, FastBufferReader reader) { Instance.Enabled.Value = false; Plugin.mls.LogMessage((object)"Disabled by host."); } } private const string DISABLED_RECEIVE = "Niro.Dash_DisabledReceive"; private const string DISABLED_REQUEST = "Niro.Dash_DisabledRequest"; [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] public static void Initialize() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0080: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("Niro.Dash_DisabledRequest", new HandleNamedMessageDelegate(DisabledRequest)); return; } CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; object obj = <>c.<>9__2_0; if (obj == null) { HandleNamedMessageDelegate val = delegate { Instance.Enabled.Value = false; Plugin.mls.LogMessage((object)"Disabled by host."); }; <>c.<>9__2_0 = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("Niro.Dash_DisabledReceive", (HandleNamedMessageDelegate)obj); NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Niro.Dash_DisabledRequest", 0uL, new FastBufferWriter(0, (Allocator)2, -1), (NetworkDelivery)3); } public static void DisabledRequest(ulong clientId, FastBufferReader reader) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (!Instance.Enabled.Value) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("Niro.Dash_DisabledReceive", clientId, new FastBufferWriter(0, (Allocator)2, -1), (NetworkDelivery)3); } } } private static Config instance; public ConfigEntry<bool> Enabled { get; set; } public ConfigEntry<float> StaminaCost { get; set; } public ConfigEntry<float> Cooldown { get; set; } public ConfigEntry<float> Precision { get; set; } public ConfigEntry<float> Power { get; set; } public ConfigEntry<float> Speed { get; set; } public ConfigEntry<float> FromSize { get; set; } public ConfigEntry<float> ToSize { get; set; } public InputAction DashKey => ((LcInputActions)this).Asset["dashkey"]; public ConfigEntry<bool> UseDashKey { get; set; } public static Config Instance { get { if (instance == null) { instance = new Config(); } return instance; } } public void Setup() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown Enabled = Plugin.BepInExConfig().Bind<bool>("General", "Enabled", true, "Enable / Disable this mod (Syncing with host!)"); StaminaCost = Plugin.BepInExConfig().Bind<float>("General", "StaminaCost", 0.15f, new ConfigDescription("Stamina cost for one dash.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); Cooldown = Plugin.BepInExConfig().Bind<float>("General", "Cooldown", 0.75f, new ConfigDescription("Cooldown in seconds.", (AcceptableValueBase)null, Array.Empty<object>())); Precision = Plugin.BepInExConfig().Bind<float>("General", "Precision", 0.2f, new ConfigDescription("Time in which a key of the double-tap has to follow to the previous one. Higher = Easier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 0.5f), Array.Empty<object>())); Power = Plugin.BepInExConfig().Bind<float>("General", "Power", 15f, new ConfigDescription("The power of a dash.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>())); Speed = Plugin.BepInExConfig().Bind<float>("General", "Speed", 0.4f, new ConfigDescription("The duration / speed of the dash.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); FromSize = Plugin.BepInExConfig().Bind<float>("General", "FromSize", 0f, "Player minimum size to be able to dash (value included). Default player size is 1."); ToSize = Plugin.BepInExConfig().Bind<float>("General", "ToSize", 0f, "Player maximum size to be able to dash (value included). Default player size is 1. Use 0 to enable dashing for any size."); UseDashKey = Plugin.BepInExConfig().Bind<bool>("SeperateKey", "UseDashKey", false, "Use a seperate key for dashing."); } public override void CreateInputActions(in InputActionMapBuilder builder) { string value = Plugin.BepInExConfig().Bind<string>("SeperateKey", "DashKeyKeyboard", "<Keyboard>/f", "Seperate keyboard key for dashing. Requires a restart after changing.").Value; Plugin.mls.LogInfo((object)("CreateInputActions -> " + value)); string value2 = Plugin.BepInExConfig().Bind<string>("SeperateKey", "DashKeyGamepad", "<Gamepad>/rightShoulder", "Seperate gamepad key for dashing. Requires a restart after changing.").Value; Plugin.mls.LogInfo((object)("CreateInputActions -> " + value2)); builder.NewActionBinding().WithActionId("dashkey").WithActionType((InputActionType)1) .WithBindingName("DashKey") .WithKbmPath(value) .WithGamepadPath(value2) .Finish(); } } internal class DashHandler { public enum Direction { Forward, Backward, Left, Right } public float lastDashedAt; private bool DashKeyRegistered; internal Dictionary<Direction, int> dashProgressMap = new Dictionary<Direction, int> { { Direction.Forward, 0 }, { Direction.Backward, 0 }, { Direction.Left, 0 }, { Direction.Right, 0 } }; internal Dictionary<Direction, float> lastKeyChangeMap = new Dictionary<Direction, float> { { Direction.Forward, 0f }, { Direction.Backward, 0f }, { Direction.Left, 0f }, { Direction.Right, 0f } }; public void RegisterDashKey() { if (DashKeyRegistered) { if (!InputUtilsCompat.Enabled || !InputUtilsCompat.UseDashKey) { InputUtilsCompat.DashKey.performed -= OnDashKeyPressed; DashKeyRegistered = false; } } else if (InputUtilsCompat.Enabled && InputUtilsCompat.UseDashKey) { InputUtilsCompat.DashKey.performed += OnDashKeyPressed; DashKeyRegistered = true; } } internal void OnUpdate() { if (FulfillsDashConditions()) { if (((ButtonControl)Keyboard.current.wKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.wKey).wasReleasedThisFrame) { HandleDashInDirection(Direction.Forward); } else if (((ButtonControl)Keyboard.current.sKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.sKey).wasReleasedThisFrame) { HandleDashInDirection(Direction.Backward); } else if (((ButtonControl)Keyboard.current.aKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.aKey).wasReleasedThisFrame) { HandleDashInDirection(Direction.Left); } else if (((ButtonControl)Keyboard.current.dKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.dKey).wasReleasedThisFrame) { HandleDashInDirection(Direction.Right); } } } internal void OnDashKeyPressed(CallbackContext dashContext) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (FulfillsDashConditions()) { PerformDash(((Component)StartOfRound.Instance.localPlayerController.gameplayCamera).transform.forward); } } internal bool FulfillsDashConditions() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)StartOfRound.Instance.localPlayerController == (Object)null) { return false; } if (!Config.Instance.Enabled.Value) { return false; } if (Config.Instance.ToSize.Value > 0f) { float y = ((Component)StartOfRound.Instance.localPlayerController).gameObject.transform.localScale.y; if (y < Config.Instance.FromSize.Value || y > Config.Instance.ToSize.Value) { return false; } } if (StartOfRound.Instance.localPlayerController.sprintMeter < Config.Instance.StaminaCost.Value) { return false; } if (Time.time - lastDashedAt < Config.Instance.Cooldown.Value) { return false; } return true; } internal void HandleDashInDirection(Direction direction) { float num = Time.time - lastKeyChangeMap[direction]; lastKeyChangeMap[direction] = Time.time; if (num < Config.Instance.Precision.Value) { dashProgressMap[direction]++; if (dashProgressMap[direction] >= 3) { PerformDash(direction); dashProgressMap[direction] = 0; } } else { dashProgressMap[direction] = 0; } } internal void PerformDash(Direction direction) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)StartOfRound.Instance.localPlayerController.gameplayCamera).transform.forward; switch (direction) { case Direction.Backward: val *= -1f; break; case Direction.Left: val = Quaternion.Euler(0f, -90f, 0f) * val; break; case Direction.Right: val = Quaternion.Euler(0f, 90f, 0f) * val; break; } PerformDash(val); } internal void PerformDash(Vector3 direction) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) direction.y = 0f; DashRoutine.StartRoutine(StartOfRound.Instance.localPlayerController, direction, Config.Instance.Power.Value, Config.Instance.Speed.Value); StartOfRound.Instance.localPlayerController.sprintMeter = Mathf.Clamp(StartOfRound.Instance.localPlayerController.sprintMeter - Config.Instance.StaminaCost.Value, 0f, 1f); lastDashedAt = Time.time; } } internal class DashRoutine : MonoBehaviour { public static void StartRoutine(PlayerControllerB targetPlayer, Vector3 direction, float force, float duration = 0.5f, Action onComplete = null) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)((targetPlayer != null) ? ((Component)targetPlayer).gameObject : null) == (Object)null)) { DashRoutine dashRoutine = ((Component)targetPlayer).gameObject.AddComponent<DashRoutine>(); ((MonoBehaviour)dashRoutine).StartCoroutine(dashRoutine.Run(targetPlayer, direction, force, duration)); } } private IEnumerator Run(PlayerControllerB targetPlayer, Vector3 direction, float force, float duration) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) float time = 0f; Vector3 startForce = direction * force; while (time < duration) { float num = Mathf.Lerp(MathF.PI / 2f, 0f, time / duration); Vector3 externalForces = startForce * num; targetPlayer.externalForces = externalForces; time += Time.deltaTime; yield return null; } targetPlayer.externalForces = Vector3.zero; } } internal static class InputUtilsCompat { public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.LethalCompanyInputUtils"); public static bool UseDashKey => Config.Instance.UseDashKey.Value; public static InputAction DashKey => Config.Instance.DashKey; } [HarmonyPatch] internal class PlayerControllerBPatch { [HarmonyPatch(typeof(PlayerControllerB), "Update")] [HarmonyPostfix] public static void OnUpdate(PlayerControllerB __instance) { if ((!InputUtilsCompat.Enabled || !InputUtilsCompat.UseDashKey) && !((Object)(object)StartOfRound.Instance.localPlayerController == (Object)null) && StartOfRound.Instance.localPlayerController.playerClientId == __instance.playerClientId) { Plugin.dashHandler.OnUpdate(); } } [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] public static void ConnectClientToPlayerObject() { Plugin.dashHandler.RegisterDashKey(); } } [BepInPlugin("Niro.Dash", "Dash", "1.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string modGUID = "Niro.Dash"; public const string modName = "Dash"; public const string modVersion = "1.1.1"; private readonly Harmony harmony = new Harmony("Niro.Dash"); private static Plugin instance; internal static ManualLogSource mls; internal static DashHandler dashHandler = new DashHandler(); public static ConfigFile BepInExConfig() { return ((BaseUnityPlugin)instance).Config; } public void Awake() { if ((Object)(object)instance == (Object)null) { instance = this; } mls = Logger.CreateLogSource("Niro.Dash"); Config.Instance.Setup(); mls.LogMessage((object)"Plugin Dash loaded!"); harmony.PatchAll(typeof(Config.SyncLimitations)); harmony.PatchAll(typeof(PlayerControllerBPatch)); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }