Decompiled source of QualityColors v1.0.3

QualityColors.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RadialGunSelect;
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("Quality Colors")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Quality Colors")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d6d7a494-722e-4763-959b-c2d6b6a42b01")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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 Mod
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("megax.etg.qualitycolors", "Quality Colors", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public static class PickupObject_Patch
		{
			[HarmonyPatch(typeof(Gun), "OnExitRange")]
			[HarmonyPatch(typeof(Gun), "DropGun")]
			[HarmonyPatch(typeof(PassiveItem), "Start")]
			[HarmonyPatch(typeof(PassiveItem), "Drop")]
			[HarmonyPatch(typeof(PassiveItem), "OnExitRange")]
			[HarmonyPatch(typeof(PlayerItem), "Start")]
			[HarmonyPatch(typeof(PlayerItem), "OnExitRange")]
			private static void ILManipulator(ILContext ctx)
			{
				ColorReplacer(ctx);
			}

			[HarmonyPatch(typeof(Gun), "OnExitRange")]
			[HarmonyPatch(typeof(Gun), "DropGun")]
			[HarmonyPatch(typeof(PassiveItem), "Start")]
			[HarmonyPatch(typeof(PassiveItem), "Drop")]
			[HarmonyPatch(typeof(PassiveItem), "OnExitRange")]
			[HarmonyPatch(typeof(PlayerItem), "Start")]
			[HarmonyPatch(typeof(PlayerItem), "OnExitRange")]
			private static void Prefix(PickupObject __instance)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				SetOutlineColor(__instance.quality);
			}
		}

		[HarmonyPatch(typeof(RewardPedestal), "DetermineContents")]
		public static class RewardPedestal_DetermineContents_Patch
		{
			private static void Postfix(RewardPedestal __instance)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)__instance.contents == (Object)null) && !((Object)(object)__instance.m_itemDisplaySprite == (Object)null))
				{
					SpriteOutlineManager.RemoveOutlineFromSprite(__instance.m_itemDisplaySprite, false);
					SetOutlineColor(__instance.contents.quality);
					SpriteOutlineManager.AddOutlineToSprite(__instance.m_itemDisplaySprite, _outlineColor, 0.1f, 0.05f, (OutlineType)0);
				}
			}
		}

		[HarmonyPatch(typeof(RewardPedestal), "OnExitRange")]
		public static class RewardPedestal_OnExitRange_Patch
		{
			private static void Prefix(RewardPedestal __instance)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)__instance.contents == (Object)null))
				{
					SetOutlineColor(__instance.contents.quality);
				}
			}

			private static void ILManipulator(ILContext ctx)
			{
				ColorReplacer(ctx);
			}
		}

		public static class ShopItemController_Patch
		{
			[HarmonyPatch(typeof(ShopItemController), "OnExitRange")]
			[HarmonyPatch(typeof(ShopItemController), "InitializeInternal")]
			private static void Postfix(ShopItemController __instance)
			{
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				PickupObject item = __instance.item;
				if (!((Object)(object)item == (Object)null) && !((Object)(object)((BraveBehaviour)__instance).sprite == (Object)null))
				{
					Type type = ((object)item).GetType();
					bool flag = type.IsSubclassOf(typeof(PlayerItem)) || type.IsSubclassOf(typeof(PassiveItem)) || type.IsSubclassOf(typeof(Gun));
					bool flag2 = ((item is PlayerItem || item is PassiveItem || item is Gun) ? true : false);
					bool flag3 = flag2;
					bool flag4 = item.itemName == "Blank";
					if ((flag || flag3) && !flag4)
					{
						SpriteOutlineManager.RemoveOutlineFromSprite(((BraveBehaviour)__instance).sprite, false);
						SetOutlineColor(item.quality);
						SpriteOutlineManager.AddOutlineToSprite(((BraveBehaviour)__instance).sprite, _outlineColor);
					}
				}
			}
		}

		[HarmonyPatch(typeof(AmmonomiconPokedexEntry), "UpdateSynergyHighlights")]
		public static class AmmonomiconPokedexEntry_UpdateSynergyHighlights_Patch
		{
			private static void Postfix(AmmonomiconPokedexEntry __instance)
			{
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				List<AmmonomiconPokedexEntry> pokedexEntries = AmmonomiconController.Instance.BestInteractingLeftPageRenderer.GetPokedexEntries();
				foreach (AmmonomiconPokedexEntry item in pokedexEntries.Where((AmmonomiconPokedexEntry t) => (Object)(object)t != (Object)(object)__instance && SpriteOutlineManager.HasOutline((tk2dBaseSprite)(object)t.m_childSprite)))
				{
					PickupObject val = ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).Objects[item.pickupID];
					SpriteOutlineManager.RemoveOutlineFromSprite((tk2dBaseSprite)(object)item.m_childSprite, true);
					SetOutlineColor(val.quality);
					SpriteOutlineManager.AddScaledOutlineToSprite<tk2dClippedSprite>((tk2dBaseSprite)(object)item.m_childSprite, _outlineColor, 0.1f, 0f);
				}
			}
		}

		[HarmonyPatch(typeof(AmmonomiconPageRenderer), "DoRefreshData")]
		public static class AmmonomiconPageRenderer_DoRefreshData_Patch
		{
			private static void Postfix()
			{
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)AmmonomiconController.Instance.BestInteractingLeftPageRenderer == (Object)null)
				{
					return;
				}
				List<AmmonomiconPokedexEntry> pokedexEntries = AmmonomiconController.Instance.BestInteractingLeftPageRenderer.GetPokedexEntries();
				foreach (AmmonomiconPokedexEntry item in pokedexEntries.Where((AmmonomiconPokedexEntry t) => t.pickupID != -1))
				{
					PickupObject val = ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).Objects[item.pickupID];
					SpriteOutlineManager.RemoveOutlineFromSprite((tk2dBaseSprite)(object)item.m_childSprite, true);
					SetOutlineColor(val.quality);
					SpriteOutlineManager.AddScaledOutlineToSprite<tk2dClippedSprite>((tk2dBaseSprite)(object)item.m_childSprite, _outlineColor, 0.1f, 0f);
				}
			}
		}

		[HarmonyPatch(typeof(AmmonomiconPokedexEntry), "m_button_LostFocus")]
		public static class AmmonomiconPokedexEntry_LostFocus_Patch
		{
			private static void Postfix(AmmonomiconPokedexEntry __instance)
			{
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				if (__instance.IsEquipmentPage)
				{
					List<PickupObject> objects = ((ObjectDatabase<PickupObject>)(object)PickupObjectDatabase.Instance).Objects;
					if (__instance.pickupID >= 0 && __instance.pickupID < objects.Count)
					{
						PickupObject val = objects[__instance.pickupID];
						SpriteOutlineManager.RemoveOutlineFromSprite((tk2dBaseSprite)(object)__instance.m_childSprite, true);
						SetOutlineColor(val.quality);
						SpriteOutlineManager.AddScaledOutlineToSprite<tk2dClippedSprite>((tk2dBaseSprite)(object)__instance.m_childSprite, _outlineColor, 0.1f, 0f);
					}
				}
			}
		}

		[HarmonyPatch(typeof(RadialSegment), "SetHovered")]
		public static class RadialSegment_SetHovered_Patch
		{
			private static void Prefix(ref bool __runOriginal, bool hovered, Color ___hoveredOutlineColor, Color ___unhoveredOutlineColor, Material ___material, tk2dSprite[] ___gunOutlineSprites, tk2dClippedSprite ___gunSprite, Gun ___originalGun)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				if (__runOriginal)
				{
					Color val = (hovered ? ___hoveredOutlineColor : ___unhoveredOutlineColor);
					___material.SetColor(OutlineColor, val);
					if (___gunOutlineSprites != null)
					{
						SetOutlineColor(((PickupObject)___originalGun).quality);
						SpriteOutlineManager.RemoveOutlineFromSprite((tk2dBaseSprite)(object)___gunSprite, false);
						SpriteOutlineManager.AddOutlineToSprite((tk2dBaseSprite)(object)___gunSprite, _outlineColor, 0.1f, 0f, (OutlineType)0);
						__runOriginal = false;
					}
				}
			}
		}

		private const string GUID = "megax.etg.qualitycolors";

		private const string NAME = "Quality Colors";

		private const string VERSION = "1.0.2";

		private const string TEXT_COLOR = "#00FFFF";

		private static ConfigEntry<Color> SQualityColor;

		private static ConfigEntry<Color> AQualityColor;

		private static ConfigEntry<Color> BQualityColor;

		private static ConfigEntry<Color> CQualityColor;

		private static ConfigEntry<Color> DQualityColor;

		private static ConfigEntry<Color> SpecialQualityColor;

		private static ConfigEntry<bool> UseColorsInWeaponWheelSelect;

		private static Color _outlineColor = Color.black;

		private static readonly int OutlineColor = Shader.PropertyToID("_OutlineColor");

		public void Awake()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			SQualityColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "QualityS", new Color(0.6f, 0.6f, 0.6f), (ConfigDescription)null);
			AQualityColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "QualityA", new Color(0.75f, 0.07f, 0.1f), (ConfigDescription)null);
			BQualityColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "QualityB", new Color(0.29f, 0.72f, 0.23f), (ConfigDescription)null);
			CQualityColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "QualityC", new Color(0.21f, 0.71f, 0.8f), (ConfigDescription)null);
			DQualityColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "QualityD", new Color(0.67f, 0.44f, 0.11f), (ConfigDescription)null);
			SpecialQualityColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "QualitySpecial", new Color(0.5f, 0.2f, 1f), (ConfigDescription)null);
			UseColorsInWeaponWheelSelect = ((BaseUnityPlugin)this).Config.Bind<bool>("Mod Compatibility", "UseColorsInWeaponWheelSelect", true, (ConfigDescription)null);
		}

		public void Start()
		{
			ETGModMainBehaviour.WaitForGameManagerStart((Action<GameManager>)GMStart);
		}

		public void GMStart(GameManager g)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("megax.etg.qualitycolors");
			val.PatchAll(typeof(PickupObject_Patch));
			val.PatchAll(typeof(RewardPedestal_DetermineContents_Patch));
			val.PatchAll(typeof(RewardPedestal_OnExitRange_Patch));
			val.PatchAll(typeof(ShopItemController_Patch));
			val.PatchAll(typeof(AmmonomiconPokedexEntry_UpdateSynergyHighlights_Patch));
			val.PatchAll(typeof(AmmonomiconPokedexEntry_LostFocus_Patch));
			val.PatchAll(typeof(AmmonomiconPageRenderer_DoRefreshData_Patch));
			if (UseColorsInWeaponWheelSelect.Value && Chainloader.PluginInfos.ContainsKey("morphious86.etg.radialgunselect"))
			{
				val.PatchAll(typeof(RadialSegment_SetHovered_Patch));
			}
			ETGModConsole.Log((object)"<color=#cecece>Quality</color> <color=#BF121A>Colors</color> <color=#4AB83B>v1.0.2</color> <color=#36B5CC>started</color> <color=#AB701C>successfully!</color>", false);
		}

		public static void Log(string text, string color = "#FFFFFF")
		{
			ETGModConsole.Log((object)("<color=" + color + ">" + text + "</color>"), false);
		}

		private static Color ReplaceOutlineColor(Color _)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			return _outlineColor;
		}

		private static float ReplaceFloatArg(float _)
		{
			return 0f;
		}

		private static void SetOutlineColor(ItemQuality quality)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected I4, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (1 == 0)
			{
			}
			Color outlineColor = (Color)(((int)quality == -50) ? SpecialQualityColor.Value : ((int)quality switch
			{
				5 => SQualityColor.Value, 
				4 => AQualityColor.Value, 
				3 => BQualityColor.Value, 
				2 => CQualityColor.Value, 
				1 => DQualityColor.Value, 
				0 => DQualityColor.Value, 
				_ => Color.black, 
			}));
			if (1 == 0)
			{
			}
			_outlineColor = outlineColor;
		}

		private static void ColorReplacer(ILContext ctx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(ctx);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Color>(x, "get_black")
			}))
			{
				return;
			}
			val.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(Plugin), "ReplaceOutlineColor", (Type[])null, (Type[])null));
			float num = default(float);
			for (int i = 0; i < 2; i++)
			{
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num)
				}))
				{
					return;
				}
			}
			val.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(Plugin), "ReplaceFloatArg", (Type[])null, (Type[])null));
		}
	}
}