Decompiled source of AmmoIndicator v1.0.1

ShotgunAmmoIndicator.dll

Decompiled 4 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ShotgunAmmoIndicator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShotgunAmmoIndicator")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("433a1b6e-c76b-449b-9a28-e8d9fe813b4c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ShotgunAmmoIndicator;

[BepInPlugin("ironbean.ShotgunAmmoIndicator", "Shotgun Ammo Indicator", "1.0.1")]
public class AmmoIndicator : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ShotgunItem))]
	internal class AmmoPatch
	{
		[HarmonyPatch("ItemActivate")]
		[HarmonyPatch("ReloadGunEffectsServerRpc")]
		[HarmonyPatch("SetControlTipsForItem")]
		[HarmonyPostfix]
		private static void CustomPatch(ref int ___shellsLoaded, ref PlayerControllerB ___previousPlayerHeldBy)
		{
			if (!((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)___previousPlayerHeldBy))
			{
				char c = ((___shellsLoaded >= 1) ? 'O' : ' ');
				char c2 = ((___shellsLoaded >= 2) ? 'O' : ' ');
				HUDManager.Instance.ChangeControlTip(1, $"Fire ({c})({c2}): [RMB]", false);
			}
		}
	}

	private const string modGUID = "ironbean.ShotgunAmmoIndicator";

	private const string modName = "Shotgun Ammo Indicator";

	private const string modVersion = "1.0.1";

	private readonly Harmony harmony = new Harmony("ironbean.ShotgunAmmoIndicator");

	internal static AmmoIndicator Instance;

	internal static ManualLogSource mls;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("ironbean.ShotgunAmmoIndicator");
		mls.LogInfo((object)"Shotgun Ammo Indicator");
		harmony.PatchAll(typeof(AmmoIndicator));
		harmony.PatchAll(typeof(AmmoPatch));
	}
}