Decompiled source of Mloks REPOdash v1.0.6

BepInEx/plugins/RepoDash.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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("RepoDash")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RepoDash")]
[assembly: AssemblyTitle("RepoDash")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 RepoDash
{
	[BepInPlugin("mloks.repodash", "REPOdash", "1.0.6")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "mloks.repodash";

		public const string PluginName = "REPOdash";

		public const string PluginVersion = "1.0.6";

		private ConfigEntry<KeyboardShortcut> _dashKey;

		private ConfigEntry<float> _staminaCost;

		private ConfigEntry<float> _dashForce;

		private ConfigEntry<float> _cooldown;

		private float _nextDashTime;

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			_dashKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Dash", "Key", new KeyboardShortcut((KeyCode)102, Array.Empty<KeyCode>()), "Key used to dash.");
			_staminaCost = ((BaseUnityPlugin)this).Config.Bind<float>("Dash", "Stamina cost", 20f, "Energy spent per dash.");
			_dashForce = ((BaseUnityPlugin)this).Config.Bind<float>("Dash", "Force", 50f, "Dash strength.");
			_cooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Dash", "Cooldown", 0.65f, "Delay between dashes in seconds.");
			bool flag = false;
			if (Mathf.Approximately(_staminaCost.Value, 25f))
			{
				_staminaCost.Value = 20f;
				flag = true;
			}
			if (Mathf.Approximately(_dashForce.Value, 14f) || Mathf.Approximately(_dashForce.Value, 18f) || Mathf.Approximately(_dashForce.Value, 22f))
			{
				_dashForce.Value = 50f;
				flag = true;
			}
			if (flag)
			{
				((BaseUnityPlugin)this).Config.Save();
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"REPOdash loaded. Press F to dash; default force is 50 and each dash costs 20 energy.");
		}

		private void Update()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_00ac: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.RunIsLevel())
			{
				return;
			}
			KeyboardShortcut value = _dashKey.Value;
			if (!((KeyboardShortcut)(ref value)).IsDown() && !Input.GetKeyDown((KeyCode)102))
			{
				return;
			}
			PlayerController instance = PlayerController.instance;
			if ((Object)(object)instance == (Object)null || Time.time < _nextDashTime)
			{
				return;
			}
			float num = Mathf.Max(0f, _staminaCost.Value);
			if (!(instance.EnergyCurrent < num))
			{
				Vector3 inputDirectionRaw = instance.InputDirectionRaw;
				Vector3 val = ((((Vector3)(ref inputDirectionRaw)).sqrMagnitude >= 0.01f) ? ((Component)instance).transform.TransformDirection(new Vector3(inputDirectionRaw.x, 0f, inputDirectionRaw.z)) : (((Object)(object)instance.playerAvatarScript != (Object)null) ? instance.playerAvatarScript.playerTransform.forward : ((Component)instance).transform.forward));
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
				{
					val = Vector3.forward;
				}
				((Vector3)(ref val)).Normalize();
				instance.EnergyCurrent = Mathf.Max(0f, instance.EnergyCurrent - num);
				instance.ForceImpulse(val * Mathf.Max(0f, _dashForce.Value));
				_nextDashTime = Time.time + Mathf.Max(0f, _cooldown.Value);
			}
		}
	}
}