Decompiled source of LowAmmo v1.1.1

LowAmmo.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppSystem.IO;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LowAmmo")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LowAmmo")]
[assembly: AssemblyTitle("LowAmmo")]
[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 JadiePop.LowAmmo
{
	[BepInPlugin("JadiePop.LowAmmo", "LowAmmo", "1.0.0")]
	public class Plugin : BasePlugin
	{
		public override void Load()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			((BasePlugin)this).Log.LogInfo((object)"LowAmmo is up and running :3");
			new Harmony("JadiePop.LowAmmo").PatchAll();
			_ = Config.Percent;
		}
	}
	[HarmonyPatch]
	internal static class Patch
	{
		[HarmonyPatch(typeof(PUI_InventoryItem), "OnAmmoUpdated")]
		[HarmonyPostfix]
		public static void low_ammo(PUI_InventoryItem __instance)
		{
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0715: Unknown result type (might be due to invalid IL or missing references)
			//IL_0749: Unknown result type (might be due to invalid IL or missing references)
			//IL_077d: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0819: Unknown result type (might be due to invalid IL or missing references)
			//IL_084d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0881: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)((Component)((Component)__instance).transform.parent.parent).gameObject).name == "MovementRoot")
			{
				__instance.m_offsetX = ((TMP_Text)__instance.m_selected_archetypeName).text.GetHashCode();
				if (__instance.m_meleeStaminaWidthMax != __instance.m_offsetX)
				{
					__instance.m_ammoClipVisible = false;
				}
				if (!__instance.m_ammoClipVisible)
				{
					__instance.m_meleeStaminaHeight = 0f;
					__instance.m_ammoClipVisible = true;
				}
				if (__instance.m_meleeStaminaHeight < (float)__instance.m_ammoClipAbsVal)
				{
					__instance.m_meleeStaminaHeight = __instance.m_ammoClipAbsVal;
				}
				if ((__instance.m_meleeStaminaHeight * Config.Percent.Value / 100f > (float)__instance.m_ammoClipAbsVal && __instance.m_showAmmoClip) || (__instance.m_meleeStaminaHeight == 0f && __instance.m_showAmmoClip))
				{
					Transform val = __instance.m_slim_root.transform.FindChild("Pivot");
					Transform transform = __instance.m_selected_root.transform;
					Transform val2 = transform.FindChild("Info Content");
					Transform val3 = transform.FindChild("Slim");
					SpriteRenderer component = ((Component)val.FindChild("Background Small")).GetComponent<SpriteRenderer>();
					component.color = new Color(0.4353f, 0f, 0f, 0.1176f);
					TextMeshPro component2 = ((Component)val.FindChild("AmmoTotal")).GetComponent<TextMeshPro>();
					((Graphic)component2).color = new Color(1f, 0f, 0f, 0.3137f);
					SpriteRenderer component3 = ((Component)val.FindChild("Arrow")).GetComponent<SpriteRenderer>();
					component3.color = new Color(0f, 0f, 0f, 0f);
					TextMeshPro component4 = ((Component)val.FindChild("Infinite ammo")).GetComponent<TextMeshPro>();
					((Graphic)component4).color = new Color(1f, 0f, 0f, 0.3137f);
					TextMeshPro component5 = ((Component)val.FindChild("Archetype Name (1)")).GetComponent<TextMeshPro>();
					((Graphic)component5).color = new Color(1f, 0f, 0f, 0.3137f);
					SpriteRenderer component6 = ((Component)val.FindChild("Background Fade")).GetComponent<SpriteRenderer>();
					component6.color = new Color(0.4353f, 0f, 0f, 0.1176f);
					SpriteRenderer component7 = ((Component)transform.FindChild("BG Full").FindChild("Arrow")).GetComponent<SpriteRenderer>();
					component7.color = new Color(0.4353f, 0f, 0f, 0.1176f);
					SpriteRenderer component8 = ((Component)transform.FindChild("BG Full").FindChild("Background Full")).GetComponent<SpriteRenderer>();
					component8.color = new Color(1f, 0f, 0f, 0.0176f);
					TextMeshPro component9 = ((Component)val2.FindChild("Archetype Name")).GetComponent<TextMeshPro>();
					((Graphic)component9).color = new Color(1f, 0f, 0f, 0.3137f);
					TextMeshPro component10 = ((Component)val2.FindChild("Detailed Name")).GetComponent<TextMeshPro>();
					((Graphic)component10).color = new Color(1f, 0f, 0f, 0.3137f);
					TextMeshPro component11 = ((Component)val2.FindChild("AmmoClip")).GetComponent<TextMeshPro>();
					((Graphic)component11).color = new Color(1f, 0f, 0f, 0.3137f);
					SpriteRenderer component12 = ((Component)val2.FindChild("Icon")).GetComponent<SpriteRenderer>();
					component12.color = new Color(1f, 0f, 0f, 0.3137f);
					TextMeshPro component13 = ((Component)val2.FindChild("Pack Amount")).GetComponent<TextMeshPro>();
					((Graphic)component13).color = new Color(1f, 0f, 0f, 0.3137f);
					TextMeshPro component14 = ((Component)val2.FindChild("Pack Label")).GetComponent<TextMeshPro>();
					((Graphic)component14).color = new Color(1f, 0f, 0f, 0.3137f);
					SpriteRenderer component15 = ((Component)val3.FindChild("Background Slim")).GetComponent<SpriteRenderer>();
					component15.color = new Color(0f, 0f, 0f, 0f);
					TextMeshPro component16 = ((Component)val3.FindChild("AmmoTotal")).GetComponent<TextMeshPro>();
					((Graphic)component16).color = new Color(1f, 0f, 0f, 0.3137f);
					TextMeshPro component17 = ((Component)val3.FindChild("Infinite ammo")).GetComponent<TextMeshPro>();
					((Graphic)component17).color = new Color(1f, 0f, 0f, 0.3137f);
				}
				else
				{
					Transform val4 = __instance.m_slim_root.transform.FindChild("Pivot");
					Transform transform2 = __instance.m_selected_root.transform;
					Transform val5 = transform2.FindChild("Info Content");
					Transform val6 = transform2.FindChild("Slim");
					SpriteRenderer component18 = ((Component)val4.FindChild("Background Small")).GetComponent<SpriteRenderer>();
					component18.color = new Color(0.4353f, 0.4353f, 0.4353f, 0.1176f);
					TextMeshPro component19 = ((Component)val4.FindChild("AmmoTotal")).GetComponent<TextMeshPro>();
					((Graphic)component19).color = new Color(1f, 1f, 1f, 0.3137f);
					SpriteRenderer component20 = ((Component)val4.FindChild("Arrow")).GetComponent<SpriteRenderer>();
					component20.color = new Color(0f, 0f, 0f, 0.7333f);
					TextMeshPro component21 = ((Component)val4.FindChild("Infinite ammo")).GetComponent<TextMeshPro>();
					((Graphic)component21).color = new Color(1f, 1f, 1f, 0.3137f);
					TextMeshPro component22 = ((Component)val4.FindChild("Archetype Name (1)")).GetComponent<TextMeshPro>();
					((Graphic)component22).color = new Color(1f, 1f, 1f, 0.3137f);
					SpriteRenderer component23 = ((Component)val4.FindChild("Background Fade")).GetComponent<SpriteRenderer>();
					component23.color = new Color(0.4353f, 0.4353f, 0.4353f, 0.1176f);
					SpriteRenderer component24 = ((Component)transform2.FindChild("BG Full").FindChild("Arrow")).GetComponent<SpriteRenderer>();
					component24.color = new Color(0.434f, 0.434f, 0.434f, 0.1176f);
					SpriteRenderer component25 = ((Component)transform2.FindChild("BG Full").FindChild("Background Full")).GetComponent<SpriteRenderer>();
					component25.color = new Color(0.4353f, 0.4353f, 0.4353f, 0.1176f);
					TextMeshPro component26 = ((Component)val5.FindChild("Archetype Name")).GetComponent<TextMeshPro>();
					((Graphic)component26).color = new Color(1f, 1f, 1f, 0.3137f);
					TextMeshPro component27 = ((Component)val5.FindChild("Detailed Name")).GetComponent<TextMeshPro>();
					((Graphic)component27).color = new Color(1f, 1f, 1f, 0.3137f);
					TextMeshPro component28 = ((Component)val5.FindChild("AmmoClip")).GetComponent<TextMeshPro>();
					((Graphic)component28).color = new Color(1f, 1f, 1f, 0.3137f);
					SpriteRenderer component29 = ((Component)val5.FindChild("Icon")).GetComponent<SpriteRenderer>();
					component29.color = new Color(1f, 1f, 1f, 0.3137f);
					TextMeshPro component30 = ((Component)val5.FindChild("Pack Amount")).GetComponent<TextMeshPro>();
					((Graphic)component30).color = new Color(1f, 1f, 1f, 0.3137f);
					TextMeshPro component31 = ((Component)val5.FindChild("Pack Label")).GetComponent<TextMeshPro>();
					((Graphic)component31).color = new Color(1f, 1f, 1f, 0.3137f);
					SpriteRenderer component32 = ((Component)val6.FindChild("Background Slim")).GetComponent<SpriteRenderer>();
					component32.color = new Color(0.4353f, 0.4353f, 0.4353f, 0.1176f);
					TextMeshPro component33 = ((Component)val6.FindChild("AmmoTotal")).GetComponent<TextMeshPro>();
					((Graphic)component33).color = new Color(1f, 1f, 1f, 0.3137f);
					TextMeshPro component34 = ((Component)val6.FindChild("Infinite ammo")).GetComponent<TextMeshPro>();
					((Graphic)component34).color = new Color(0.4353f, 0.4353f, 0.4353f, 0.1176f);
				}
				__instance.m_meleeStaminaWidthMax = __instance.m_offsetX;
			}
		}
	}
	internal static class Config
	{
		internal static readonly ConfigEntry<float> Percent;

		static Config()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "LowAmmo.cfg"), true);
			Percent = val.Bind<float>("Ammo Minimum", "Percentage Warning", 20f, "At what percentage of ammo left in the clip should the ui the turn red to warn");
		}
	}
}