Decompiled source of DashMod v0.1.2

plugins/com.github.apenstad.PeakDashMod.dll

Decompiled 2 weeks ago
using System;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PeakBetterMovement.Utils;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.apenstad.PeakDashMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("com.github.apenstad.PeakDashMod")]
[assembly: AssemblyTitle("Dash")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PeakBetterMovement
{
	[BepInPlugin("com.github.apenstad.PeakDashMod", "Dash", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.github.apenstad.PeakDashMod");

		public const string Id = "com.github.apenstad.PeakDashMod";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "Dash";

		public static string Version => "0.1.0";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			DashConfig.AllConfigs(((BaseUnityPlugin)this).Config);
		}
	}
}
namespace PeakBetterMovement.Utils
{
	internal class DashConfig
	{
		public static ConfigEntry<int> DashStrength;

		public static ConfigEntry<float> DashDuration;

		public static ConfigEntry<float> DashCooldown;

		public static ConfigEntry<float> DashStaminaCost;

		public static ConfigEntry<bool> CanUseNormalStamina;

		public static ConfigEntry<bool> CanDashInAir;

		public static void AllConfigs(ConfigFile cfg)
		{
			DashStrength = cfg.Bind<int>("Dash Mod", "Dash Strength", 5, "The strength the user dashes at");
			DashDuration = cfg.Bind<float>("Dash Mod", "Dash Duration", 0.25f, "The time the dash lasts");
			DashCooldown = cfg.Bind<float>("Dash Mod", "Dash Cooldown", 1f, "The cooldown between dashes");
			DashStaminaCost = cfg.Bind<float>("Dash Mod", "Dash Stamina Cost", 0.2f, "How much stamina it costs to dash (0.2 = 20% of the stamina bar)");
			CanUseNormalStamina = cfg.Bind<bool>("Dash Mod", "Can use normal stamina to dash", false, "false = only use bonus stamina , true = can use normal stamina");
			CanDashInAir = cfg.Bind<bool>("Dash Mod", "Can dash in the air", false, "false = cant dash while in the air, true = can dash in the air");
		}
	}
}
namespace PeakBetterMovement.Patches
{
	internal class BetterMovementPatch
	{
		[HarmonyPatch(typeof(CharacterMovement))]
		internal class CharacterMovementPatch
		{
			[HarmonyPatch("Update")]
			[HarmonyPostfix]
			public static void DashPatch(CharacterMovement __instance)
			{
				//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				Character character = __instance.character;
				if (!DashActiveTime.ContainsKey(character))
				{
					DashActiveTime[character] = 0f;
				}
				if (((ButtonControl)Keyboard.current.digit5Key).wasPressedThisFrame)
				{
					character.AddExtraStamina(1f);
				}
				DashActiveTime[character] -= Time.deltaTime;
				if (character.data.isReaching && DashActiveTime[character] < 0f - DashConfig.DashCooldown.Value && character.data.isSprinting && (DashConfig.CanDashInAir.Value || character.data.isGrounded) && character.data.TotalStamina > DashConfig.DashStaminaCost.Value)
				{
					if (DashConfig.CanUseNormalStamina.Value)
					{
						character.UseStamina(DashConfig.DashStaminaCost.Value, true);
						DashActiveTime[character] = DashConfig.DashDuration.Value;
						character.data.sinceGrounded = 0f;
						DashDirection[character] = character.data.lookDirection;
					}
					else if (character.data.extraStamina > DashConfig.DashStaminaCost.Value)
					{
						character.AddExtraStamina(0f - DashConfig.DashStaminaCost.Value);
						DashActiveTime[character] = DashConfig.DashDuration.Value;
						character.data.sinceGrounded = 0f;
						DashDirection[character] = character.data.lookDirection;
					}
				}
				if (!(DashActiveTime[character] > 0f))
				{
					return;
				}
				Vector3 val = DashDirection[character];
				foreach (Bodypart part in character.refs.ragdoll.partList)
				{
					part.AddForce(val * (float)DashConfig.DashStrength.Value * (1f + DashActiveTime[character]), (ForceMode)5);
				}
			}
		}

		private static readonly Dictionary<Character, float> DashActiveTime = new Dictionary<Character, float>();

		private static readonly Dictionary<Character, Vector3> DashDirection = new Dictionary<Character, Vector3>();
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}