using System;
using System.Collections;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon.Movement;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("EnhancedCooldowns")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0.6+268249c05ee0dccf3acb65882e20f2e18137e5e3")]
[assembly: AssemblyProduct("EnhancedCooldowns")]
[assembly: AssemblyTitle("EnhancedCooldowns")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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;
}
}
}
[BepInPlugin("sparroh.enhancedcooldowns", "EnhancedCooldowns", "1.0.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class SparrohPlugin : BaseUnityPlugin
{
public enum ActivationMode
{
None,
Hold,
Toggle
}
public const string PluginGUID = "sparroh.enhancedcooldowns";
public const string PluginName = "EnhancedCooldowns";
public const string PluginVersion = "1.0.0";
internal static ManualLogSource Logger;
public static ConfigEntry<ActivationMode> incendiaryMode;
public static ConfigEntry<ActivationMode> voltaicMode;
public static ConfigEntry<ActivationMode> acidMode;
public static ConfigEntry<ActivationMode> salvoMode;
public static ConfigEntry<bool> suppressSalvoModelAlways;
private void Awake()
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
incendiaryMode = ((BaseUnityPlugin)this).Config.Bind<ActivationMode>("General", "IncendiaryGrenadeActivationMode", ActivationMode.Toggle, "Activation mode for incendiary grenades. Hold: prevent auto-activation, Toggle: toggle on/off, None: default");
voltaicMode = ((BaseUnityPlugin)this).Config.Bind<ActivationMode>("General", "VoltaicGrenadeActivationMode", ActivationMode.Toggle, "Activation mode for voltaic (shock) grenades. Hold: prevent auto-activation, Toggle: toggle on/off, None: default");
acidMode = ((BaseUnityPlugin)this).Config.Bind<ActivationMode>("General", "AcidGrenadeActivationMode", ActivationMode.Toggle, "Activation mode for acid grenades. Hold: prevent auto-activation, Toggle: toggle on/off, None: default");
salvoMode = ((BaseUnityPlugin)this).Config.Bind<ActivationMode>("General", "SalvoActivationMode", ActivationMode.Toggle, "Activation mode for glider salvo. Toggle: tap to toggle on/off, then auto-fires upon recharge, None: default behavior");
suppressSalvoModelAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SuppressSalvoModelAlways", false, "Always hide the 3D salvo launcher model to save screen space. Manual salvo will not show targeting model when enabled.");
try
{
Harmony val = new Harmony("sparroh.enhancedcooldowns");
val.PatchAll(typeof(ThrowablePatches));
val.PatchAll(typeof(WingsuitPatches));
Logger.LogInfo((object)"EnhancedCooldowns loaded");
}
catch (Exception ex)
{
Logger.LogError((object)("Failed to patch methods: " + ex.Message));
}
try
{
string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath;
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Path.GetDirectoryName(configFilePath), Path.GetFileName(configFilePath));
fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
fileSystemWatcher.Changed += OnConfigFileChanged;
fileSystemWatcher.EnableRaisingEvents = true;
}
catch (Exception ex2)
{
Logger.LogError((object)("Failed to set up config file watcher: " + ex2.Message));
}
}
private void OnConfigFileChanged(object sender, FileSystemEventArgs e)
{
try
{
Thread.Sleep(100);
((BaseUnityPlugin)this).Config.Reload();
ResetToggles();
}
catch (Exception ex)
{
Logger.LogError((object)("Failed to reload config: " + ex.Message));
}
}
private void ResetToggles()
{
ThrowablePatches.incendiaryToggle = false;
ThrowablePatches.voltaicToggle = false;
ThrowablePatches.acidToggle = false;
WingsuitPatches.salvoAutoEnabled = false;
}
}
public static class ThrowablePatches
{
public static bool incendiaryToggle;
public static bool voltaicToggle;
public static bool acidToggle;
private static bool isAutoThrow;
[HarmonyPatch(typeof(Player), "TryThrow")]
[HarmonyPrefix]
private static bool TryThrowPrefix(Player __instance)
{
try
{
if (isAutoThrow)
{
return true;
}
if (((object)__instance).GetType().GetProperty("Gear")?.GetValue(__instance) is IList list && list.Count > 3)
{
object obj = list[3];
if (obj != null)
{
if (obj.GetType().Name == "IncendiaryGrenade")
{
switch (SparrohPlugin.incendiaryMode.Value)
{
case SparrohPlugin.ActivationMode.Toggle:
incendiaryToggle = !incendiaryToggle;
return false;
case SparrohPlugin.ActivationMode.Hold:
return false;
}
}
else if (obj.GetType().Name == "VoltaicGrenade")
{
switch (SparrohPlugin.voltaicMode.Value)
{
case SparrohPlugin.ActivationMode.Toggle:
voltaicToggle = !voltaicToggle;
return false;
case SparrohPlugin.ActivationMode.Hold:
return false;
}
}
else if (obj.GetType().Name == "AcidGrenade")
{
switch (SparrohPlugin.acidMode.Value)
{
case SparrohPlugin.ActivationMode.Toggle:
acidToggle = !acidToggle;
return false;
case SparrohPlugin.ActivationMode.Hold:
return false;
}
}
}
}
return true;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in TryThrowPrefix: " + ex.Message));
return true;
}
}
[HarmonyPatch(typeof(Player), "Update")]
[HarmonyPostfix]
private static void PlayerUpdatePostfix(Player __instance)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
try
{
PlayerActions player = PlayerInput.Controls.Player;
if (!((PlayerActions)(ref player)).Throw.IsPressed() || !(((object)__instance).GetType().GetProperty("Gear")?.GetValue(__instance) is IList list) || list.Count <= 3)
{
return;
}
object obj = list[3];
if (obj == null)
{
return;
}
SparrohPlugin.ActivationMode value;
if (obj.GetType().Name == "IncendiaryGrenade")
{
value = SparrohPlugin.incendiaryMode.Value;
}
else if (obj.GetType().Name == "VoltaicGrenade")
{
value = SparrohPlugin.voltaicMode.Value;
}
else
{
if (!(obj.GetType().Name == "AcidGrenade"))
{
return;
}
value = SparrohPlugin.acidMode.Value;
}
if (value != SparrohPlugin.ActivationMode.Hold)
{
return;
}
Throwable val = (Throwable)((obj is Throwable) ? obj : null);
if (val != null)
{
CooldownData val2 = (CooldownData)AccessTools.Field(typeof(Throwable), "cooldownData").GetValue(val);
if (((CooldownData)(ref val2)).IsCharged)
{
((CooldownData)(ref val2)).UseCharge();
isAutoThrow = true;
AccessTools.Method(typeof(Player), "TryThrow", (Type[])null, (Type[])null).Invoke(__instance, new object[0]);
isAutoThrow = false;
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in PlayerUpdatePostfix: " + ex.Message));
}
}
[HarmonyPatch(typeof(Throwable), "HandleCooldown")]
[HarmonyPrefix]
private static bool HandleCooldownPrefix(Throwable __instance, float charge)
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
try
{
SparrohPlugin.ActivationMode value;
bool flag;
switch (((object)__instance).GetType().Name)
{
case "IncendiaryGrenade":
value = SparrohPlugin.incendiaryMode.Value;
flag = incendiaryToggle;
break;
case "VoltaicGrenade":
value = SparrohPlugin.voltaicMode.Value;
flag = voltaicToggle;
break;
case "AcidGrenade":
value = SparrohPlugin.acidMode.Value;
flag = acidToggle;
break;
default:
return true;
}
if (value == SparrohPlugin.ActivationMode.None)
{
return true;
}
CooldownData val = (CooldownData)AccessTools.Field(typeof(Throwable), "cooldownData").GetValue(__instance);
if (!((CooldownData)(ref val)).IsCharged)
{
return true;
}
switch (value)
{
case SparrohPlugin.ActivationMode.Hold:
{
InputAction val2 = (InputAction)AccessTools.Property(typeof(Throwable), "AbilityInputAction").GetValue(__instance);
if (val2.WasPressedThisFrame() || val2.IsPressed())
{
return true;
}
return false;
}
case SparrohPlugin.ActivationMode.Toggle:
if (flag)
{
((CooldownData)(ref val)).UseCharge();
isAutoThrow = true;
FieldInfo field = typeof(Throwable).GetField("player", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
object value2 = field.GetValue(__instance);
if (value2 != null && value2.GetType().GetProperty("Gear")?.GetValue(value2) is IList list && list.Count > 3)
{
object obj = list[3];
if (__instance == obj)
{
AccessTools.Method(typeof(Player), "TryThrow", (Type[])null, (Type[])null).Invoke(value2, new object[0]);
}
}
}
isAutoThrow = false;
return false;
}
return false;
default:
return true;
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in HandleCooldownPrefix: " + ex.Message));
return true;
}
}
}
[HarmonyPatch(typeof(Wingsuit))]
public static class WingsuitPatches
{
public static bool salvoAutoEnabled = false;
private static bool isAutoPress = false;
private static float lastAutoFireTime = -1f;
private static float lastToggleTime = -1f;
public static bool suppressSalvoHUD = false;
[HarmonyPatch("OnSalvoPressed")]
[HarmonyPrefix]
private static bool OnSalvoPressedPrefix(Wingsuit __instance, CallbackContext context)
{
SparrohPlugin.ActivationMode value = SparrohPlugin.salvoMode.Value;
float time = Time.time;
if (value == SparrohPlugin.ActivationMode.Toggle && !isAutoPress && time - lastAutoFireTime >= 0.1f && time - lastToggleTime >= 0.05f)
{
salvoAutoEnabled = !salvoAutoEnabled;
lastToggleTime = time;
return false;
}
return true;
}
[HarmonyPatch("OnSalvoPressed")]
[HarmonyPostfix]
private static void OnSalvoPressedPostfix(Wingsuit __instance)
{
try
{
if (SparrohPlugin.suppressSalvoModelAlways.Value)
{
object? value = AccessTools.Field(typeof(Wingsuit), "salvoModel").GetValue(__instance);
Transform val = (Transform)((value is Transform) ? value : null);
if ((Object)(object)val != (Object)null)
{
((Component)val).gameObject.SetActive(false);
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in OnSalvoPressedPostfix: " + ex.Message));
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePostfix(Wingsuit __instance)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
try
{
if (SparrohPlugin.salvoMode.Value == SparrohPlugin.ActivationMode.Toggle && salvoAutoEnabled)
{
Cooldown val = (Cooldown)AccessTools.Field(typeof(Wingsuit), "rocketSalvoCooldown").GetValue(__instance);
if (val != null && ((CooldownData)(ref val.data)).IsCharged)
{
suppressSalvoHUD = true;
isAutoPress = true;
AccessTools.Method(typeof(Wingsuit), "OnSalvoPressed", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { (object)default(CallbackContext) });
AccessTools.Method(typeof(Wingsuit), "OnSalvoReleased", (Type[])null, (Type[])null).Invoke(__instance, new object[1] { (object)default(CallbackContext) });
isAutoPress = false;
suppressSalvoHUD = false;
lastAutoFireTime = Time.time;
}
}
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in UpdatePostfix: " + ex.Message));
}
}
}
[HarmonyPatch(typeof(HUD))]
public static class HUDPatches
{
[HarmonyPatch("Enable")]
[HarmonyPrefix]
private static bool EnablePrefix(HUD __instance)
{
try
{
if (WingsuitPatches.suppressSalvoHUD)
{
return false;
}
return true;
}
catch (Exception ex)
{
SparrohPlugin.Logger.LogError((object)("Error in EnablePrefix: " + ex.Message));
return true;
}
}
}
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
public const string AssemblySemFileVer = "0.0.1.0";
public const string AssemblySemVer = "0.0.1.0";
public const string BranchName = "master";
public const string BuildMetaData = "";
public const string CommitDate = "2025-12-26";
public const string CommitsSinceVersionSource = "7";
public const string EscapedBranchName = "master";
public const string FullBuildMetaData = "Branch.master.Sha.268249c05ee0dccf3acb65882e20f2e18137e5e3";
public const string FullSemVer = "0.0.1-7";
public const string InformationalVersion = "0.0.1-7+Branch.master.Sha.268249c05ee0dccf3acb65882e20f2e18137e5e3";
public const string Major = "0";
public const string MajorMinorPatch = "0.0.1";
public const string Minor = "0";
public const string Patch = "1";
public const string PreReleaseLabel = "";
public const string PreReleaseLabelWithDash = "";
public const string PreReleaseNumber = "7";
public const string PreReleaseTag = "7";
public const string PreReleaseTagWithDash = "-7";
public const string SemVer = "0.0.1-7";
public const string Sha = "268249c05ee0dccf3acb65882e20f2e18137e5e3";
public const string ShortSha = "268249c";
public const string UncommittedChanges = "10";
public const string VersionSourceSha = "";
public const string WeightedPreReleaseNumber = "55007";
}
namespace EnhancedCooldowns
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "EnhancedCooldowns";
public const string PLUGIN_NAME = "EnhancedCooldowns";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}