Decompiled source of Custom Stamina Colors v1.0.0

plugins/CustomStaminaColors.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
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: AssemblyCompany("CustomStaminaColors")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Custom Stamina Colors")]
[assembly: AssemblyTitle("CustomStaminaColors")]
[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 CustomStaminaColors
{
	[HarmonyPatch(typeof(ENT_Player))]
	internal class Patcher
	{
		[HarmonyPatch("InteractCheck")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> InteractCheckPatch(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Expected O, but got Unknown
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Expected O, but got Unknown
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Call)
				{
					if (CodeInstructionExtensions.Calls(list[i], typeof(Color).GetProperty("white").GetGetMethod()))
					{
						List<CodeInstruction> list2 = new List<CodeInstruction>();
						list2.Add(new CodeInstruction(OpCodes.Ldloca_S, (object)12));
						list2.Add(new CodeInstruction(OpCodes.Ldc_R4, (object)Plugin.staminaFullColor.Value.r));
						list2.Add(new CodeInstruction(OpCodes.Ldc_R4, (object)Plugin.staminaFullColor.Value.g));
						list2.Add(new CodeInstruction(OpCodes.Ldc_R4, (object)Plugin.staminaFullColor.Value.b));
						list2.Add(new CodeInstruction(OpCodes.Call, (object)typeof(Color).GetConstructor(new Type[3]
						{
							typeof(float),
							typeof(float),
							typeof(float)
						})));
						List<CodeInstruction> list3 = list2;
						list3[0].labels.AddRange(list[i].labels);
						list.RemoveAt(i);
						list.RemoveAt(i);
						list.InsertRange(i, list3);
					}
					if (CodeInstructionExtensions.Calls(list[i], typeof(Color).GetProperty("red").GetGetMethod()))
					{
						List<CodeInstruction> list2 = new List<CodeInstruction>();
						list2.Add(new CodeInstruction(OpCodes.Ldc_R4, (object)Plugin.staminaEmptyColor.Value.r));
						list2.Add(new CodeInstruction(OpCodes.Ldc_R4, (object)Plugin.staminaEmptyColor.Value.g));
						list2.Add(new CodeInstruction(OpCodes.Ldc_R4, (object)Plugin.staminaEmptyColor.Value.b));
						list2.Add(new CodeInstruction(OpCodes.Newobj, (object)typeof(Color).GetConstructor(new Type[3]
						{
							typeof(float),
							typeof(float),
							typeof(float)
						})));
						list2.Add(new CodeInstruction(OpCodes.Ldloc_S, (object)12));
						List<CodeInstruction> list4 = list2;
						list4[0].labels.AddRange(list[i].labels);
						list.RemoveAt(i);
						list.RemoveAt(i);
						list.InsertRange(i, list4);
						break;
					}
				}
			}
			return list.AsEnumerable();
		}
	}
	[BepInPlugin("CustomStaminaColors", "Custom Stamina Colors", "1.0.0")]
	[BepInProcess("White Knuckle.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private static Harmony harmony;

		public static ConfigEntry<Color> staminaFullColor;

		public static ConfigEntry<Color> staminaEmptyColor;

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			staminaFullColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "StaminaFull", new Color(1f, 1f, 1f), "The color of the hand sprites with full stamina in hexadecimal format.");
			staminaEmptyColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "StaminaEmpty", new Color(1f, 0f, 0f), "The color of the hand sprites with empty stamina in hexadecimal format.");
			harmony = new Harmony("CustomStaminaColors");
			harmony.PatchAll(Assembly.GetExecutingAssembly());
			Logger.LogInfo((object)"Plugin CustomStaminaColors is loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CustomStaminaColors";

		public const string PLUGIN_NAME = "Custom Stamina Colors";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}