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: AssemblyDescription("Template")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CancelAbility")]
[assembly: AssemblyTitle("CancelAbility")]
[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 CancelAbility
{
internal static class MyPluginInfo
{
internal const string PLUGIN_GUID = "id107.cancelability";
internal const string PLUGIN_NAME = "CancelAbility";
internal const string PLUGIN_VERSION = "0.0.0";
}
[BepInPlugin("id107.cancelability", "CancelAbility", "0.0.0")]
[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(), "id107.cancelability");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin id107.cancelability is loaded!");
}
}
[HarmonyPatch(typeof(ClassAbility))]
internal class ClassAbilityPatch
{
[HarmonyPrefix]
[HarmonyPatch("ActivationKeyPressed")]
private static void ActivationKeyPressed(ClassAbility __instance)
{
FiniteDurationClassAbility val = (FiniteDurationClassAbility)(object)((__instance is FiniteDurationClassAbility) ? __instance : null);
if (val != null && !(val is ChannelGrapplingHook))
{
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);
}
else
{
float currentCooldown = ((ClassAbility)val).CurrentCooldown;
((ClassAbility)val).CurrentCooldown = 0f;
((Ability)val).StartAbility();
val.CurrentActiveDuration = (1f - currentCooldown / ((ModifiablePrimitive<float, FloatModifier>)(object)((ClassAbility)val).CooldownSeconds).Value) * ((ModifiablePrimitive<float, FloatModifier>)(object)val.FiniteTimeDuration).Value;
}
}
}
}
public class VoidManagerPlugin : VoidPlugin
{
public override MultiplayerType MPType => (MultiplayerType)3;
public override string Author => "18107";
public override string Description => "Allows abilities to be cancelled early for faster recharge";
}
}