Decompiled source of FistIconColorOverride v1.0.0

IconColorOverrides.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
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 Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("IconColorOverrides")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("IconColorOverrides")]
[assembly: AssemblyTitle("IconColorOverrides")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 IconColorOverrides
{
	public static class Extensions
	{
		public static Transform FindIncludeInactive(this Transform self, string path)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			string[] array = path.Split('/');
			Transform val = self;
			string[] array2 = array;
			foreach (string text in array2)
			{
				bool flag = false;
				foreach (Transform item in val)
				{
					Transform val2 = item;
					if (((Object)val2).name == text)
					{
						val = val2;
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					return null;
				}
			}
			return val;
		}
	}
	[BepInPlugin("IconColorOverrides", "IconColorOverrides", "1.0.0")]
	[Harmony]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private static PluginConfigurator config;

		private static Sprite spr_oldFist;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("IconColorOverrides");
			val.PatchAll();
			config = PluginConfig.CreateConfig();
			Logger.LogInfo((object)"Plugin IconColorOverrides is loaded!");
		}

		[HarmonyPatch(typeof(NewMovement), "Awake")]
		[HarmonyPostfix]
		private static void GetOldIcon(NewMovement __instance)
		{
			if ((Object)(object)spr_oldFist == (Object)null)
			{
				Transform val = ((Component)__instance).transform.FindIncludeInactive("Main Camera/HUD Camera/HUD/GunCanvas/GunPanel/Filler/Image/FistPanel (2)/Panel");
				Image val2 = default(Image);
				if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<Image>(ref val2))
				{
					spr_oldFist = val2.sprite;
				}
			}
		}

		[HarmonyPatch(typeof(HudController), "UpdateFistIcon")]
		[HarmonyPostfix]
		private static void PostUpdateFistIcon(HudController __instance, int current)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (PluginConfig.OverrideFistIcon[current])
			{
				MonoSingleton<FistControl>.Instance.fistIconColor = PluginConfig.FistOverrideColor[current];
			}
			if (PluginConfig.UseOldIcon[current] && (Object)(object)spr_oldFist != (Object)null)
			{
				__instance.fistFill.sprite = spr_oldFist;
				__instance.fistBackground.sprite = spr_oldFist;
			}
		}
	}
	public static class PluginConfig
	{
		public static bool[] OverrideFistIcon = new bool[2];

		public static Color[] FistOverrideColor = (Color[])(object)new Color[2]
		{
			Color.white,
			Color.white
		};

		public static bool[] UseOldIcon = new bool[2];

		public static PluginConfigurator CreateConfig()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			PluginConfigurator val = PluginConfigurator.Create("Fist Icon Color Config", "IconColorOverrides");
			val.SetIconWithURL(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", "icon.png"));
			new ConfigSpace(val.rootPanel, 5f);
			ArmSettings(val, val.rootPanel, "Feedbacker", "feedbacker", 0);
			ArmSettings(val, val.rootPanel, "Knuckleblaster", "knuckleblaster", 1);
			return val;
		}

		public static void ArmSettings(PluginConfigurator config, ConfigPanel panel, string pairName, string pairGUID, int idx)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			ConfigPanel val = new ConfigPanel(panel, pairName, pairGUID);
			new ConfigSpace(val, 5f);
			ConfigDivision div = null;
			BoolField val2 = BoolSetting(config, val, "Replace Color", $"replaceColor_{pairGUID}_{idx}", ref OverrideFistIcon[idx]);
			val2.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
			{
				OverrideFistIcon[idx] = e.value;
				((ConfigField)div).interactable = e.value;
				if (Object.op_Implicit((Object)(object)MonoSingleton<FistControl>.Instance))
				{
					MonoSingleton<FistControl>.Instance.UpdateFistIcon();
				}
			};
			div = new ConfigDivision(val, pairGUID + "Div");
			((ConfigField)div).interactable = val2.value;
			ColorSetting(config, (ConfigPanel)(object)div, "Color", $"color_{pairGUID}_{idx}", ref FistOverrideColor[idx]).onValueChange += (ColorValueChangeEventDelegate)delegate(ColorValueChangeEvent e)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				FistOverrideColor[idx] = e.value;
				if (Object.op_Implicit((Object)(object)MonoSingleton<FistControl>.Instance))
				{
					MonoSingleton<FistControl>.Instance.UpdateFistIcon();
				}
			};
			BoolSetting(config, val, "Use Old Icon", $"oldIcon_{pairGUID}_{idx}", ref UseOldIcon[idx]).onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e)
			{
				UseOldIcon[idx] = e.value;
				if (Object.op_Implicit((Object)(object)MonoSingleton<FistControl>.Instance))
				{
					MonoSingleton<FistControl>.Instance.UpdateFistIcon();
				}
			};
		}

		public static BoolField BoolSetting(PluginConfigurator config, ConfigPanel panel, string name, string guid, ref bool value)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			BoolField val = new BoolField(panel, name, guid, value);
			value = val.value;
			return val;
		}

		public static ColorField ColorSetting(PluginConfigurator config, ConfigPanel panel, string name, string guid, ref Color value)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			ColorField val = new ColorField(panel, name, guid, value);
			value = val.value;
			return val;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "IconColorOverrides";

		public const string PLUGIN_NAME = "IconColorOverrides";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}