Decompiled source of MachineGun v0.2.0

MachineGun.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using MachineGun.Patches;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MachineGun")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5763d84c6a35ba4023fff8443d2ca6d089f3d84a")]
[assembly: AssemblyProduct("MachineGun")]
[assembly: AssemblyTitle("MachineGun")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace MachineGun
{
	public class MachineGunButton : LcInputActions
	{
		[InputAction(/*Could not decode attribute arguments.*/)]
		public InputAction FireShotgunKey { get; set; }
	}
	[BepInPlugin("jacobot5.MachineGun", "MachineGun", "0.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MachineGunMod : BaseUnityPlugin
	{
		private const string modGUID = "jacobot5.MachineGun";

		private const string modName = "MachineGun";

		private const string modVersion = "0.2.0";

		private readonly Harmony harmony = new Harmony("jacobot5.MachineGun");

		private static MachineGunMod Instance;

		internal static MachineGunButton ButtonInstance;

		public static ConfigEntry<float> configShotsPerSecond;

		public static ConfigEntry<float> configKnockbackForce;

		public static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			ButtonInstance = new MachineGunButton();
			mls = Logger.CreateLogSource("jacobot5.MachineGun");
			mls.LogInfo((object)"MachineGun has awoken.");
			configShotsPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("General.Toggles", "ShotsPerSecond", 4f, "How many times to shoot the Shotgun per second. Default is 4.");
			configKnockbackForce = ((BaseUnityPlugin)this).Config.Bind<float>("General.Toggles", "KnockbackForce", 4f, "How much knockback force to apply. Default is 4.");
			harmony.PatchAll(typeof(MachineGunMod));
			harmony.PatchAll(typeof(ShotgunItemPatch));
		}
	}
}
namespace MachineGun.Patches
{
	[HarmonyPatch(typeof(ShotgunItem))]
	internal class ShotgunItemPatch
	{
		private static float shotClock = 1f / MachineGunMod.configShotsPerSecond.Value;

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void BlitzFirePatch(ShotgunItem __instance)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (!(MachineGunMod.ButtonInstance.FireShotgunKey.ReadValue<float>() >= 1f) || !((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				return;
			}
			if (shotClock <= 0f)
			{
				((GrabbableObject)__instance).ItemActivate(false, true);
				if (!__instance.safetyOn)
				{
					PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy;
					playerHeldBy.externalForces += ((Component)__instance).transform.forward * (0f - MachineGunMod.configKnockbackForce.Value);
				}
				shotClock = 1f / MachineGunMod.configShotsPerSecond.Value;
			}
			shotClock -= Time.deltaTime;
		}

		[HarmonyPatch("ShootGun")]
		[HarmonyPrefix]
		private static bool EnsureAmmoPatch(ShotgunItem __instance)
		{
			__instance.shellsLoaded = 2;
			return true;
		}
	}
}