Decompiled source of BoltPumpQuickShooter v1.0.1

Niko666.BoltPumpQuickShooter.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("Niko666")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Force enable quickbolt for bolt-actions and slam-fire for pump-actions.")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("Niko666.BoltPumpQuickShooter")]
[assembly: AssemblyTitle("BoltPumpQuickShooter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace Niko666
{
	[BepInProcess("h3vr.exe")]
	[BepInPlugin("Niko666.BoltPumpQuickShooter", "BoltPumpQuickShooter", "1.0.1")]
	public class BoltPumpQuickShooter : BaseUnityPlugin
	{
		private ConfigEntry<bool> configEnableSlamfire;

		private ConfigEntry<bool> configEnableQuickbolt;

		private ConfigEntry<bool> configAllowSlamfireInSemiAutoMode;

		public static bool _alreadySlamfire;

		public static bool _enabledForceSlamfire;

		public const string Id = "Niko666.BoltPumpQuickShooter";

		internal static ManualLogSource Logger { get; private set; }

		public static string Name => "BoltPumpQuickShooter";

		public static string Version => "1.0.1";

		public void Awake()
		{
			configEnableSlamfire = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableSlamfire", true, "Force enable slamfire for all pump-action shotguns");
			configEnableQuickbolt = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableQuickbolt", true, "Force enable quickbolt for all bolt-action rifles");
			configAllowSlamfireInSemiAutoMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowSlamfireInSemiAutoMode", false, "Allow slamfire in semi-auto tubefed shotguns (this will make them full-auto, blame anton on this)");
			Logger = ((BaseUnityPlugin)this).Logger;
			if (configEnableSlamfire.Value)
			{
				Harmony.CreateAndPatchAll(typeof(ForceSlamfire), (string)null);
			}
			if (configEnableQuickbolt.Value)
			{
				Harmony.CreateAndPatchAll(typeof(ForceQuickbolt), (string)null);
			}
			if (!configAllowSlamfireInSemiAutoMode.Value)
			{
				Harmony.CreateAndPatchAll(typeof(NotAllowSlamfireInSemiAutoMode), (string)null);
			}
			Logger.LogMessage((object)("Fuck this world! Sent from Niko666.BoltPumpQuickShooter " + Version));
		}
	}
	internal class ForceQuickbolt : MonoBehaviour
	{
		[HarmonyPatch(typeof(BoltActionRifle_Handle), "Awake")]
		[HarmonyPrefix]
		public static bool BoltActionRifle_ForceQuickbolt(BoltActionRifle_Handle __instance)
		{
			if (!__instance.UsesQuickRelease)
			{
				__instance.UsesQuickRelease = true;
			}
			return true;
		}
	}
	internal class ForceSlamfire : MonoBehaviour
	{
		[HarmonyPatch(typeof(TubeFedShotgun), "Awake")]
		[HarmonyPrefix]
		public static bool TubeFedShotgun_ForceSlamfire(TubeFedShotgun __instance)
		{
			if (!__instance.UsesSlamFireTrigger)
			{
				__instance.UsesSlamFireTrigger = true;
				BoltPumpQuickShooter._enabledForceSlamfire = true;
			}
			else
			{
				BoltPumpQuickShooter._alreadySlamfire = true;
			}
			return true;
		}
	}
	internal class NotAllowSlamfireInSemiAutoMode : MonoBehaviour
	{
		[HarmonyPatch(typeof(TubeFedShotgun), "FVRUpdate")]
		[HarmonyPrefix]
		public static bool TubeFedShotgun_NotAllowSlamfireInSemiAutoMode(TubeFedShotgun __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if ((int)__instance.Mode == 1)
			{
				__instance.UsesSlamFireTrigger = false;
			}
			else if ((int)__instance.Mode == 0 && !BoltPumpQuickShooter._alreadySlamfire && BoltPumpQuickShooter._enabledForceSlamfire)
			{
				__instance.UsesSlamFireTrigger = true;
			}
			return true;
		}
	}
}