Decompiled source of Instant Items and Interactions v1.0.0

tony4twentys-Instant Items and Interactions.dll

Decompiled a month ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Instant Interactions")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Instant Interactions")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9733dfb1-a5e4-46ce-8fef-87e6089b0f58")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace InstantInteractions;

[BepInPlugin("tony4twentys.Instant_Items_And_Interactions", "Instant Items and Interactions", "1.0.0")]
public class InstantInteractionsPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(CharacterInteractible), "GetInteractTime")]
	private static class Patch_CharacterInteractible_GetInteractTime
	{
		private static void Postfix(ref float __result)
		{
			__result = 0.01f;
		}
	}

	[HarmonyPatch(typeof(Item), "ContinueUsePrimary")]
	private static class Patch_Item_ContinueUsePrimary
	{
		private static void Postfix(Item __instance)
		{
			if (__instance.isUsingPrimary && !__instance.finishedCast)
			{
				__instance.castProgress = 1f;
				__instance.FinishCastPrimary();
			}
		}
	}

	[HarmonyPatch(typeof(Item), "ContinueUseSecondary")]
	private static class Patch_Item_ContinueUseSecondary
	{
		private static void Postfix(Item __instance)
		{
			if (__instance.isUsingSecondary && !__instance.finishedCast)
			{
				__instance.castProgress = 1f;
				__instance.FinishCastSecondary();
			}
		}
	}

	[HarmonyPatch(typeof(Luggage), "GetInteractTime")]
	private static class Patch_Luggage_GetInteractTime
	{
		private static void Postfix(ref float __result)
		{
			__result = 0.01f;
		}
	}

	[HarmonyPatch(typeof(Campfire), "GetInteractTime")]
	private static class Patch_Campfire_GetInteractTime
	{
		private static void Postfix(ref float __result)
		{
			__result = 0.01f;
		}
	}

	private Harmony _harmony;

	private void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		_harmony = new Harmony("tony4twentys.Instant_Items_And_Interactions");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[InstantInteractionsAndItems] Loaded. All interactions and item usage set to instant.");
	}

	private void OnDestroy()
	{
		try
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
		catch
		{
		}
	}
}