Decompiled source of ColorAssist v0.1.5

ColorAssist.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using NineSolsAPI.Utils;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("ColorAssist")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("ColorAssist")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ColorAssist")]
[assembly: AssemblyTitle("ColorAssist")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.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;
		}
	}
	[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;
		}
	}
}
internal sealed class ConfigurationManagerAttributes
{
	public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);

	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public CustomHotkeyDrawerFunc CustomHotkeyDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public Func<string, object> StrToObj;
}
namespace ColorAssist
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("ColorAssist", "ColorAssist", "1.0.0")]
	public class ColorAssist : BaseUnityPlugin
	{
		public ConfigEntry<string> curFilter;

		private ConfigEntry<bool> isEnableFilter;

		private ConfigEntry<bool> isProtanopia;

		private ConfigEntry<bool> isProtanomaly;

		private ConfigEntry<bool> isDeuteranopia;

		private ConfigEntry<bool> isDeuteranomaly;

		private ConfigEntry<bool> isTritanopia;

		private ConfigEntry<bool> isTritanomaly;

		private ConfigEntry<bool> isAchromatopsia;

		private ConfigEntry<bool> isAchromatomaly;

		public ConfigEntry<bool> isHeealthBar;

		public ConfigEntry<bool> isAttackEffect;

		public ConfigEntry<int> R;

		public ConfigEntry<int> G;

		public ConfigEntry<int> B;

		public ConfigEntry<int> A;

		public ConfigEntry<int> R2;

		public ConfigEntry<int> G2;

		public ConfigEntry<int> B2;

		public ConfigEntry<int> A2;

		public Color healthBarColor;

		public Color attackEffectColor;

		public Color defaultColor;

		private const string Protanopia = "Protanopia";

		private const string Protanomaly = "Protanomaly";

		private const string Deuteranopia = "Deuteranopia";

		private const string Deuteranomaly = "Deuteranomaly";

		private const string Tritanopia = "Tritanopia";

		private const string Tritanomaly = "Tritanomaly";

		private const string Achromatopsia = "Achromatopsia";

		private const string Achromatomaly = "Achromatomaly";

		public Material[] colorBlindMaterials;

		public Material kickHint;

		public Material defaultMaterial;

		private AssetBundle shader;

		private ColorblindFilter colorblindFilter;

		private Harmony harmony;

		public static ColorAssist Instance { get; private set; }

		private void Awake()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Expected O, but got Unknown
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Expected O, but got Unknown
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Expected O, but got Unknown
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Expected O, but got Unknown
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Expected O, but got Unknown
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Expected O, but got Unknown
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Expected O, but got Unknown
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Expected O, but got Unknown
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Expected O, but got Unknown
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Expected O, but got Unknown
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Expected O, but got Unknown
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Expected O, but got Unknown
			//IL_073f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0749: Expected O, but got Unknown
			//IL_075e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0763: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			RCGLifeCycle.DontDestroyForever(((Component)this).gameObject);
			harmony = Harmony.CreateAndPatchAll(typeof(ColorAssist).Assembly, (string)null);
			Instance = this;
			curFilter = ((BaseUnityPlugin)this).Config.Bind<string>("", "Current Filter", "", new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 20
				}
			}));
			isEnableFilter = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Enable Filter", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 19
				}
			}));
			isProtanopia = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Protanopia", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 18
				}
			}));
			isProtanomaly = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Protanomaly", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 17
				}
			}));
			isDeuteranopia = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Deuteranopia", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 16
				}
			}));
			isDeuteranomaly = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Deuteranomaly", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 15
				}
			}));
			isTritanopia = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Tritanopia", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 14
				}
			}));
			isTritanomaly = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Tritanomaly", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 13
				}
			}));
			isAchromatopsia = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Achromatopsia", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 12
				}
			}));
			isAchromatomaly = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Achromatomaly", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 11
				}
			}));
			isHeealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Enable HeealthBar Color", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 10
				}
			}));
			R = ((BaseUnityPlugin)this).Config.Bind<int>("", "Red", 255, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 9
				}
			}));
			G = ((BaseUnityPlugin)this).Config.Bind<int>("", "Green", 255, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 8
				}
			}));
			B = ((BaseUnityPlugin)this).Config.Bind<int>("", "Blue", 0, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 7
				}
			}));
			A = ((BaseUnityPlugin)this).Config.Bind<int>("", "Alpha", 255, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 6
				}
			}));
			isAttackEffect = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Enable AttackEffect Color", false, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 5
				}
			}));
			R2 = ((BaseUnityPlugin)this).Config.Bind<int>("", "Red2", 255, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 4
				}
			}));
			G2 = ((BaseUnityPlugin)this).Config.Bind<int>("", "Green2", 255, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 3
				}
			}));
			B2 = ((BaseUnityPlugin)this).Config.Bind<int>("", "Blue2", 0, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 2
				}
			}));
			A2 = ((BaseUnityPlugin)this).Config.Bind<int>("", "Alpha2", 255, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 1
				}
			}));
			colorBlindMaterials = LoadColorBlindMaterials();
			isEnableFilter.SettingChanged += delegate
			{
				UpdateFilterUsage();
			};
			isProtanopia.SettingChanged += delegate
			{
				ChangeFilter("Protanopia");
			};
			isProtanomaly.SettingChanged += delegate
			{
				ChangeFilter("Protanomaly");
			};
			isDeuteranopia.SettingChanged += delegate
			{
				ChangeFilter("Deuteranopia");
			};
			isDeuteranomaly.SettingChanged += delegate
			{
				ChangeFilter("Deuteranomaly");
			};
			isTritanopia.SettingChanged += delegate
			{
				ChangeFilter("Tritanopia");
			};
			isTritanomaly.SettingChanged += delegate
			{
				ChangeFilter("Tritanomaly");
			};
			isAchromatopsia.SettingChanged += delegate
			{
				ChangeFilter("Achromatopsia");
			};
			isAchromatomaly.SettingChanged += delegate
			{
				ChangeFilter("Achromatomaly");
			};
			isHeealthBar.SettingChanged += delegate
			{
				UpdateHealthColor();
			};
			R.SettingChanged += delegate
			{
				UpdateHealthColor();
			};
			G.SettingChanged += delegate
			{
				UpdateHealthColor();
			};
			B.SettingChanged += delegate
			{
				UpdateHealthColor();
			};
			A.SettingChanged += delegate
			{
				UpdateHealthColor();
			};
			isAttackEffect.SettingChanged += delegate
			{
				UpdateAttackEffectColor();
			};
			R2.SettingChanged += delegate
			{
				UpdateAttackEffectColor();
			};
			G2.SettingChanged += delegate
			{
				UpdateAttackEffectColor();
			};
			B2.SettingChanged += delegate
			{
				UpdateAttackEffectColor();
			};
			A2.SettingChanged += delegate
			{
				UpdateAttackEffectColor();
			};
			defaultMaterial = new Material(Shader.Find("Sprites/Default"));
			defaultColor = new Color(0.259f, 1f, 0.521f, 1f);
			UpdateHealthColor();
			UpdateAttackEffectColor();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ColorAssist is loaded!");
		}

		private void Start()
		{
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private Material[] LoadColorBlindMaterials()
		{
			shader = AssemblyUtils.GetEmbeddedAssetBundle("ColorAssist.Resources.shader");
			return (Material[])(object)new Material[8]
			{
				shader.LoadAsset<Material>("Protanopia"),
				shader.LoadAsset<Material>("Protanomaly"),
				shader.LoadAsset<Material>("Deuteranopia"),
				shader.LoadAsset<Material>("Deuteranomaly"),
				shader.LoadAsset<Material>("Tritanopia"),
				shader.LoadAsset<Material>("Tritanomaly"),
				shader.LoadAsset<Material>("Achromatopsia"),
				shader.LoadAsset<Material>("Achromatomaly")
			};
		}

		private void UpdateFilterUsage()
		{
			if ((Object)(object)colorblindFilter == (Object)null)
			{
				AttachColorblindFilter();
			}
			colorblindFilter?.SetUseFilter(isEnableFilter.Value);
		}

		private void AttachColorblindFilter()
		{
			Camera[] allCameras = Camera.allCameras;
			foreach (Camera val in allCameras)
			{
				if (((Object)((Component)val).gameObject).name == "ApplicationUICam")
				{
					colorblindFilter = ((Component)val).gameObject.GetComponent<ColorblindFilter>() ?? ((Component)val).gameObject.AddComponent<ColorblindFilter>();
					break;
				}
			}
		}

		private void SetFilterMaterial(Material filterMaterial)
		{
			AttachColorblindFilter();
			if ((Object)(object)colorblindFilter != (Object)null)
			{
				colorblindFilter.setMaterial(filterMaterial);
				curFilter.Value = ((Object)filterMaterial).name;
			}
		}

		private void ChangeFilter(string filterName)
		{
			string filterName2 = filterName;
			Material val = Array.Find(colorBlindMaterials, (Material m) => ((Object)m).name == filterName2);
			if ((Object)(object)val != (Object)null)
			{
				SetFilterMaterial(val);
			}
			isEnableFilter.Value = true;
		}

		private void UpdateAttackEffectColor()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			attackEffectColor = new Color((float)R2.Value / 255f, (float)G2.Value / 255f, (float)B2.Value / 255f, (float)A2.Value / 255f);
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name == "A11_S0_Boss_YiGung_回蓬萊"))
			{
				activeScene = SceneManager.GetActiveScene();
				if (!(((Scene)(ref activeScene)).name == "A11_S0_Boss_YiGung"))
				{
					return;
				}
			}
			MakeOutline("Animator/View/YiGung/Weapon/Foo/FooSprite", attackEffectColor);
			MakeOutline("Animator/View/YiGung/Weapon/Sword/Effect", attackEffectColor);
			MakeOutline("Animator/View/YiGung/Attack Effect/紅白白紅/紅/AttackEffect", attackEffectColor);
			MakeOutline("Animator/View/YiGung/Attack Effect/紅白白紅/究極紅/AttackEffect", attackEffectColor);
		}

		private void UpdateHealthColor()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			healthBarColor = new Color((float)R.Value / 255f, (float)G.Value / 255f, (float)B.Value / 255f, (float)A.Value / 255f);
			GameObject val = GameObject.Find("GameCore(Clone)/RCG LifeCycle/UIManager/GameplayUICamera/HideUIAbilityCheck/[Activate] PlayerUI Folder/PlayerInGameUI renderer/LeftTop/HealthBarBase/HealthBar/BG renderer/RecoverableHealth");
			if (Object.op_Implicit((Object)(object)val))
			{
				if (isHeealthBar.Value)
				{
					val.GetComponent<SpriteRenderer>().color = healthBarColor;
				}
				else
				{
					val.GetComponent<SpriteRenderer>().color = new Color(0.566f, 0f, 0.161f, 0.706f);
				}
			}
			GameObject val2 = GameObject.Find("GameCore(Clone)/RCG LifeCycle/UIManager/GameplayUICamera/MonsterHPRoot/BossHPRoot/UIBossHP(Clone)/Offset(DontKeyAnimationOnThisNode)/AnimationOffset/HealthBar/BG/MaxHealth/Internal Injury");
			if (Object.op_Implicit((Object)(object)val2))
			{
				if (isHeealthBar.Value)
				{
					val2.GetComponent<SpriteRenderer>().color = healthBarColor;
				}
				else
				{
					val2.GetComponent<SpriteRenderer>().color = new Color(0.481f, 0f, 0.242f, 1f);
				}
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			if (((Scene)(ref scene)).name == "TitleScreenMenu")
			{
				AttachColorblindFilter();
				UpdateFilterUsage();
			}
			if ((Object)(object)kickHint == (Object)null)
			{
				GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
				foreach (GameObject val in array)
				{
					if (((Object)val).name == "MultiSpriteEffect_Prefab 識破提示Variant")
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Object found: " + ((Object)val).name));
						((BaseUnityPlugin)this).Logger.LogInfo((object)((Renderer)val.GetComponentInChildren<SpriteRenderer>()).material);
						kickHint = ((Renderer)val.GetComponentInChildren<SpriteRenderer>()).material;
					}
				}
			}
			if (((Scene)(ref scene)).name == "A11_S0_Boss_YiGung_回蓬萊" || ((Scene)(ref scene)).name == "A11_S0_Boss_YiGung")
			{
				MakeOutline("Animator/View/YiGung/Weapon/Foo/FooSprite", attackEffectColor);
				MakeOutline("Animator/View/YiGung/Weapon/Sword/Effect", attackEffectColor);
				MakeOutline("Animator/View/YiGung/Attack Effect/紅白白紅/紅/AttackEffect", attackEffectColor);
				MakeOutline("Animator/View/YiGung/Attack Effect/紅白白紅/究極紅/AttackEffect", attackEffectColor);
			}
			UpdateHealthColor();
		}

		private void MakeOutline(string path, Color color)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.Find(path);
			SpriteRenderer val = ((obj != null) ? obj.GetComponent<SpriteRenderer>() : null);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"SpriteRenderer not found at the given path.");
				return;
			}
			((Renderer)val).material = (isAttackEffect.Value ? kickHint : defaultMaterial);
			if (((Renderer)val).material.HasProperty("_OutlineColor"))
			{
				((Renderer)val).material.SetColor("_OutlineColor", isAttackEffect.Value ? color : defaultColor);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Outline color set successfully.");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Material does not support _OutlineColor property.");
			}
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			AssetBundle obj = shader;
			if (obj != null)
			{
				obj.Unload(false);
			}
			harmony.UnpatchSelf();
		}
	}
	public class ColorblindFilter : MonoBehaviour
	{
		[SerializeField]
		private bool _useFilter = true;

		private Material _mat;

		public bool UseFilter => _useFilter;

		private void Awake()
		{
			string value = ColorAssist.Instance.curFilter.Value;
			_mat = GetMaterialByName(value) ?? ColorAssist.Instance.colorBlindMaterials[0];
		}

		public void setMaterial(Material m)
		{
			_mat = m;
		}

		private void OnRenderImage(RenderTexture src, RenderTexture dst)
		{
			if (_useFilter)
			{
				Graphics.Blit((Texture)(object)src, dst, _mat);
			}
			else
			{
				Graphics.Blit((Texture)(object)src, dst);
			}
		}

		private Material GetMaterialByName(string materialName)
		{
			Material[] colorBlindMaterials = ColorAssist.Instance.colorBlindMaterials;
			foreach (Material val in colorBlindMaterials)
			{
				if (((Object)val).name == materialName)
				{
					return val;
				}
			}
			return null;
		}

		public void SetUseFilter(bool useFilter)
		{
			_useFilter = useFilter;
		}
	}
	internal static class Log
	{
		private static ManualLogSource? logSource;

		internal static void Init(ManualLogSource logSource)
		{
			Log.logSource = logSource;
		}

		internal static void Debug(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogDebug(data);
			}
		}

		internal static void Error(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogError(data);
			}
		}

		internal static void Fatal(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogFatal(data);
			}
		}

		internal static void Info(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogInfo(data);
			}
		}

		internal static void Message(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogMessage(data);
			}
		}

		internal static void Warning(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogWarning(data);
			}
		}
	}
	[HarmonyPatch]
	public class Patches
	{
		[HarmonyPatch(typeof(SpriteRendererRCGExt), "Awake")]
		[HarmonyPrefix]
		private static bool hookSpriteRendererRCGExt(ref SpriteRendererRCGExt __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Object)((Component)__instance).gameObject).name == "Internal Injury"))
			{
				return true;
			}
			if (!ColorAssist.Instance.isHeealthBar.Value)
			{
				return true;
			}
			((Component)__instance).gameObject.GetComponent<SpriteRenderer>().color = ColorAssist.Instance.healthBarColor;
			return true;
		}

		[HarmonyPatch(typeof(PoolManager), "Borrow", new Type[]
		{
			typeof(PoolObject),
			typeof(Vector3),
			typeof(Quaternion),
			typeof(Transform),
			typeof(Action<PoolObject>)
		})]
		[HarmonyPostfix]
		public static void Postfix(ref PoolObject __result, PoolObject prefab, Vector3 position, Quaternion rotation, Transform parent = null, Action<PoolObject> handler = null)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			Color val = (ColorAssist.Instance.isAttackEffect.Value ? ColorAssist.Instance.attackEffectColor : ColorAssist.Instance.defaultColor);
			if ((Object)(object)ColorAssist.Instance.kickHint == (Object)null)
			{
				GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
				foreach (GameObject val2 in array)
				{
					if (((Object)val2).name == "MultiSpriteEffect_Prefab 識破提示Variant")
					{
						ColorAssist.Instance.kickHint = ((Renderer)val2.GetComponentInChildren<SpriteRenderer>()).material;
					}
				}
			}
			Material material = (ColorAssist.Instance.isAttackEffect.Value ? ColorAssist.Instance.kickHint : ColorAssist.Instance.defaultMaterial);
			if (((Object)prefab).name == "Effect_TaiDanger")
			{
				SpriteRenderer component = ((Component)((Component)__result).transform.Find("Sprite")).GetComponent<SpriteRenderer>();
				if ((Object)(object)ColorAssist.Instance.kickHint != (Object)null)
				{
					((Renderer)component).material = material;
					if (((Renderer)component).material.HasProperty("_OutlineColor"))
					{
						((Renderer)component).material.SetColor("_OutlineColor", val);
					}
					else
					{
						Debug.LogWarning((object)"Material does not have '_OutlineColor' property.");
					}
				}
			}
			if (((Object)prefab).name == "MultiSpriteEffect_Prefab 識破提示Variant")
			{
				SpriteRenderer component2 = ((Component)((Component)__result).transform.Find("View").Find("Sprite")).GetComponent<SpriteRenderer>();
				if (((Renderer)component2).material.HasProperty("_OutlineColor"))
				{
					((Renderer)component2).material.SetColor("_OutlineColor", val);
				}
				else
				{
					Debug.LogWarning((object)"Material does not have '_OutlineColor' property.");
				}
			}
			if (!(((Object)prefab).name == "紅閃 FullScreen Slash FX Damage Danger"))
			{
				return;
			}
			Transform val3 = ((Component)__result).transform.Find("Animator");
			string[] array2 = new string[3] { "Line", "SHape", "SHape 2" };
			foreach (string text in array2)
			{
				SpriteRenderer component3 = ((Component)val3.Find(text)).GetComponent<SpriteRenderer>();
				((Renderer)component3).material = material;
				if (((Renderer)component3).material.HasProperty("_OutlineColor"))
				{
					((Renderer)component3).material.SetColor("_OutlineColor", val);
				}
				else
				{
					Debug.LogWarning((object)("Material in " + text + " does not have '_OutlineColor' property."));
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ColorAssist";

		public const string PLUGIN_NAME = "ColorAssist";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}