Decompiled source of ShowAmmoCount v1.1.0

ShowAmmoCount.dll

Decompiled a year ago
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.Logging;
using HarmonyLib;
using Unity.Netcode;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ShowAmmoCount")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Show Ammo Count")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("ShowAmmoCount")]
[assembly: AssemblyTitle("ShowAmmoCount")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
namespace ShowAmmoCount
{
	[BepInPlugin("ShowAmmoCount", "ShowAmmoCount", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource logger;

		private void Awake()
		{
			logger = ((BaseUnityPlugin)this).Logger;
			logger.LogInfo((object)"Plugin ShowAmmoCount is loaded!");
			Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ShotgunItem), "SetControlTipsForItem")]
		private static bool SetControlTipsForItem(ShotgunItem __instance)
		{
			string[] toolTips = ((GrabbableObject)__instance).itemProperties.toolTips;
			if (toolTips.Length <= 2)
			{
				logger.LogError((object)"Shotgun control tips array length is too short to set tips!");
				return false;
			}
			if (__instance.safetyOn)
			{
				toolTips[2] = $"Turn safety off ({__instance.shellsLoaded}/0): [Q]";
			}
			else
			{
				toolTips[2] = $"Turn safety on ({__instance.shellsLoaded}/2): [Q]";
			}
			HUDManager.Instance.ChangeControlTipMultiple(toolTips, true, ((GrabbableObject)__instance).itemProperties);
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(ShotgunItem), "SetSafetyControlTip")]
		private static bool SetSafetyControlTip(ShotgunItem __instance)
		{
			string text = ((!__instance.safetyOn) ? $"Turn safety on ({__instance.shellsLoaded}/2): [Q]" : $"Turn safety off ({__instance.shellsLoaded}/0): [Q]");
			if (((NetworkBehaviour)__instance).IsOwner)
			{
				HUDManager.Instance.ChangeControlTip(3, text, false);
			}
			return false;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ShotgunItem), "ShootGun")]
		[HarmonyPatch(typeof(ShotgunItem), "ReloadGunEffectsClientRpc")]
		private static void UpdateControlTips(ShotgunItem __instance)
		{
			__instance.SetSafetyControlTip();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ShowAmmoCount";

		public const string PLUGIN_NAME = "ShowAmmoCount";

		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)
		{
		}
	}
}