Decompiled source of InfiniteShotgunReload v1.1.0

InfiniteShotgunReload.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("InfiniteShotgunReload")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+116900fb37dae8472eeb6c359d90d5e267e6d181")]
[assembly: AssemblyProduct("InfiniteShotgunReload")]
[assembly: AssemblyTitle("InfiniteShotgunReload")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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;
		}
	}
}
namespace InfiniteShotgunReload
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("InfiniteShotgunReload", "InfiniteShotgunReload", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin InfiniteShotgunReload is loaded!");
			if (Chainloader.PluginInfos.ContainsKey("Hypick.BetterShotgun"))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"BetterShotgun is installed, use the ReloadNoLimit config option instead and uninstall this mod.");
			}
			else
			{
				Harmony.CreateAndPatchAll(typeof(ShotgunPatch), "InfiniteShotgunReload");
			}
		}
	}
	[HarmonyPatch(typeof(ShotgunItem))]
	public class ShotgunPatch
	{
		[HarmonyPatch("ItemInteractLeftRight")]
		[HarmonyPostfix]
		public static void ItemInteractLeftRightPatch(ShotgunItem __instance, bool right)
		{
			if (right && !__instance.isReloading && __instance.shellsLoaded >= 2)
			{
				__instance.StartReloadGun();
			}
		}

		[HarmonyPatch("ShootGun")]
		[HarmonyPrefix]
		[HarmonyPriority(600)]
		public static void SaveShellsPatch(ShotgunItem __instance, out int __state)
		{
			__state = __instance.shellsLoaded;
		}

		[HarmonyPatch("ShootGun")]
		[HarmonyPostfix]
		public static void ShootGunPatch(ShotgunItem __instance, int __state)
		{
			__instance.shellsLoaded = Math.Max(0, __state - 1);
		}

		[HarmonyPatch("reloadGunAnimation")]
		[HarmonyPrefix]
		public static bool ReloadGunAnimationPatch(ShotgunItem __instance, ref IEnumerator __result)
		{
			__result = ReloadGunAnimationPatchCoroutine(__instance);
			return false;
		}

		private static IEnumerator ReloadGunAnimationPatchCoroutine(ShotgunItem __instance)
		{
			__instance.isReloading = true;
			if (__instance.shellsLoaded <= 0)
			{
				((GrabbableObject)__instance).playerHeldBy.playerBodyAnimator.SetBool("ReloadShotgun", true);
				((Renderer)__instance.shotgunShellLeft).enabled = false;
				((Renderer)__instance.shotgunShellRight).enabled = false;
			}
			else
			{
				((GrabbableObject)__instance).playerHeldBy.playerBodyAnimator.SetBool("ReloadShotgun2", true);
				((Renderer)__instance.shotgunShellRight).enabled = false;
			}
			yield return (object)new WaitForSeconds(0.3f);
			__instance.gunAudio.PlayOneShot(__instance.gunReloadSFX);
			__instance.gunAnimator.SetBool("Reloading", true);
			__instance.ReloadGunEffectsServerRpc(true);
			yield return (object)new WaitForSeconds(0.95f);
			((Renderer)__instance.shotgunShellInHand).enabled = true;
			__instance.shotgunShellInHandTransform.SetParent(((GrabbableObject)__instance).playerHeldBy.leftHandItemTarget);
			__instance.shotgunShellInHandTransform.localPosition = new Vector3(-0.0555f, 0.1469f, -0.0655f);
			__instance.shotgunShellInHandTransform.localEulerAngles = new Vector3(-1.956f, 143.856f, -16.427f);
			yield return (object)new WaitForSeconds(0.95f);
			((GrabbableObject)__instance).playerHeldBy.DestroyItemInSlotAndSync(__instance.ammoSlotToUse);
			__instance.ammoSlotToUse = -1;
			__instance.shellsLoaded++;
			((Renderer)__instance.shotgunShellLeft).enabled = true;
			if (__instance.shellsLoaded >= 2)
			{
				((Renderer)__instance.shotgunShellRight).enabled = true;
			}
			((Renderer)__instance.shotgunShellInHand).enabled = false;
			__instance.shotgunShellInHandTransform.SetParent(((Component)__instance).transform);
			yield return (object)new WaitForSeconds(0.45f);
			__instance.gunAudio.PlayOneShot(__instance.gunReloadFinishSFX);
			__instance.gunAnimator.SetBool("Reloading", false);
			((GrabbableObject)__instance).playerHeldBy.playerBodyAnimator.SetBool("ReloadShotgun", false);
			((GrabbableObject)__instance).playerHeldBy.playerBodyAnimator.SetBool("ReloadShotgun2", false);
			__instance.isReloading = false;
			__instance.ReloadGunEffectsServerRpc(false);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "InfiniteShotgunReload";

		public const string PLUGIN_NAME = "InfiniteShotgunReload";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}