Decompiled source of NoInteractDelay v1.2.0

NoInteractDelay.dll

Decompiled 5 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using NoInteractDelay.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NoInteractDelay Mod for Lethal Company")]
[assembly: AssemblyDescription("A simple mod that removes the \"cooldown\" between interacting with objects.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Caprine Logic")]
[assembly: AssemblyProduct("NoInteractDelay Mod for Lethal Company")]
[assembly: AssemblyCopyright("Copyright © Caprine Logic 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("E74C8B23-6EC3-4B48-8850-5C7B20D8207D")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.2.0.0")]
namespace NoInteractDelay
{
	public static class Constants
	{
		public const string PluginGuid = "com.caprinelogic.nointeractdelay";

		public const string Name = "NoInteractDelay";

		public const string Version = "1.2.0";
	}
	public static class GlobalShared
	{
		public static readonly ManualLogSource Logger = Logger.CreateLogSource("com.caprinelogic.nointeractdelay");
	}
	[BepInPlugin("com.caprinelogic.nointeractdelay", "NoInteractDelay", "1.2.0")]
	public class NoInteractDelayPlugin : BaseUnityPlugin
	{
		private ConfigEntry<bool> _removeWorldObjectDelay;

		private ConfigEntry<bool> _removeHeldItemUseDelay;

		private readonly Harmony _harmony = new Harmony("com.caprinelogic.nointeractdelay");

		private void Awake()
		{
			GlobalShared.Logger.LogInfo((object)"Loaded NoInteractDelay v1.2.0");
			_removeWorldObjectDelay = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RemoveWorldObjectDelay", true, "Whether to remove the delay between interacting with objects in the world (buttons, company bell, etc.)");
			_removeHeldItemUseDelay = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RemoveHeldItemUseDelay", true, "Whether to remove the delay between using items you are holding (air horn, clown horn, etc.)");
			if (_removeWorldObjectDelay.Value)
			{
				_harmony.PatchAll(typeof(RemoveInteractionDelay));
				GlobalShared.Logger.LogInfo((object)"Applied patch for world object use");
			}
			if (_removeHeldItemUseDelay.Value)
			{
				_harmony.PatchAll(typeof(RemoveItemUseCooldown));
				GlobalShared.Logger.LogInfo((object)"Applied patch for held item use");
			}
		}
	}
}
namespace NoInteractDelay.Patches
{
	[HarmonyPatch(typeof(InteractTrigger), "Interact")]
	public class RemoveInteractionDelay
	{
		public static bool Prefix(InteractTrigger __instance)
		{
			__instance.interactCooldown = false;
			return true;
		}
	}
	[HarmonyPatch(typeof(GrabbableObject), "RequireCooldown")]
	public class RemoveItemUseCooldown
	{
		public static bool Prefix(GrabbableObject __instance, ref bool __result)
		{
			__result = false;
			return false;
		}
	}
}