Decompiled source of Cancel Ability v0.0.1

CancelAbility.dll

Decompiled 2 months ago
using 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.Logging;
using Gameplay.Utilities;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Opsive.UltimateCharacterController.Character.Abilities;
using VoidManager;
using VoidManager.MPModChecks;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("CancelAbility")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+3e9aff5c50253de3cf09b6fc7cb95e266f54143f")]
[assembly: AssemblyProduct("CancelAbility")]
[assembly: AssemblyTitle("Allows abilities to be cancelled early for faster recharge. Client side.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 CancelAbility
{
	[BepInPlugin("18107.CancelAbility", "Cancel Ability", "0.0.1")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "18107.CancelAbility");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 18107.CancelAbility is loaded!");
		}
	}
	[HarmonyPatch(typeof(ClassAbility))]
	internal class ClassAbilityPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("ActivationKeyPressed")]
		private static void ActivationKeyPressed(ClassAbility __instance)
		{
			if (!VoidManagerPlugin.SessionFeaturesEnabled)
			{
				return;
			}
			FiniteDurationClassAbility val = (FiniteDurationClassAbility)(object)((__instance is FiniteDurationClassAbility) ? __instance : null);
			if (val == null || val is ChannelGrapplingHook)
			{
				return;
			}
			if (val.IsOngoing())
			{
				float num = (1f - val.CurrentActiveDuration / ((ModifiablePrimitive<float, FloatModifier>)(object)val.FiniteTimeDuration).Value) * ((ModifiablePrimitive<float, FloatModifier>)(object)((ClassAbility)val).CooldownSeconds).Value;
				((Ability)val).StopAbility();
				((ClassAbility)val).RefundCooldown(num);
				return;
			}
			float currentCooldown = ((ClassAbility)val).CurrentCooldown;
			((ClassAbility)val).CurrentCooldown = 0f;
			if (((Ability)val).StartAbility())
			{
				val.CurrentActiveDuration = (1f - currentCooldown / ((ModifiablePrimitive<float, FloatModifier>)(object)((ClassAbility)val).CooldownSeconds).Value) * ((ModifiablePrimitive<float, FloatModifier>)(object)val.FiniteTimeDuration).Value;
			}
			else
			{
				((ClassAbility)val).CurrentCooldown = currentCooldown;
			}
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "18107.CancelAbility";

		public const string PLUGIN_NAME = "CancelAbility";

		public const string USERS_PLUGIN_NAME = "Cancel Ability";

		public const string PLUGIN_VERSION = "0.0.1";

		public const string PLUGIN_DESCRIPTION = "Allows abilities to be cancelled early for faster recharge. Client side.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107, Dragon";

		public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Cancel_Ability";
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		internal static bool SessionFeaturesEnabled;

		public override MultiplayerType MPType => (MultiplayerType)8;

		public override string Author => "18107, Dragon";

		public override string Description => "Allows abilities to be cancelled early for faster recharge. Client side.";

		public override string ThunderstoreID => "VoidCrewModdingTeam/Cancel_Ability";

		public override SessionChangedReturn OnSessionChange(SessionChangedInput input)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (input.IsMod_Session)
			{
				SessionFeaturesEnabled = true;
			}
			else
			{
				SessionFeaturesEnabled = false;
			}
			SessionChangedReturn result = default(SessionChangedReturn);
			result.SetMod_Session = true;
			return result;
		}
	}
}