Decompiled source of EnlightenedJi v1.1.1

EnlightenedJi.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using I2.Loc;
using Microsoft.CodeAnalysis;
using NineSolsAPI;
using TMPro;
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("EnlightenedJi")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Mods Ji to be harder, heavily inspired by MicheleniDev's Eigong Prime")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+fb28b66ffc67510df258ece87140a0e6e9425f45")]
[assembly: AssemblyProduct("EnlightenedJi")]
[assembly: AssemblyTitle("EnlightenedJi")]
[assembly: AssemblyVersion("1.1.1.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;
		}
	}
}
namespace EnlightenedJi
{
	public class ColorChange
	{
		public static int lutSize = 16;

		public static Material material = null;

		private static int stayRange = 1;

		private static string animatorPath = "A10S5/Room/Boss And Environment Binder/General Boss Fight FSM Object 姬 Variant/FSM Animator/";

		private static string spritePath = animatorPath + "LogicRoot/---Boss---/BossShowHealthArea/StealthGameMonster_Boss_Jee/MonsterCore/Animator(Proxy)/Animator/View/";

		private static string[] jiSpritePaths = new string[7]
		{
			spritePath + "Jee/JeeSprite",
			animatorPath + "[CutScene]BossAngry_Cutscene/[Timeline]/DummyJeeAnimator/View/Jee/JeeSprite",
			animatorPath + "[CutScene]BossAngry_Cutscene/[Timeline]/DummyJeeAnimator/View/Jee/Cloak",
			animatorPath + "[CutScene]BossAngry_Cutscene/[Timeline]/DummyJeeAnimator/View/Jee/Arm",
			animatorPath + "[CutScene]BossDying/[Timeline]/DummyJeeAnimator/View/Jee/JeeSprite",
			spritePath + "Jee/Cloak",
			spritePath + "Jee/Arm"
		};

		private static string[] crimsonSpritePaths = new string[2]
		{
			spritePath + "Weapon/Jee_Sitck/Effect/EffectSprite",
			spritePath + "Effect/Attack_TeleportSword/Sprite"
		};

		private static string[] crimsonParticlePaths = Array.Empty<string>();

		private static string[] crimsonParticleRendererPaths = Array.Empty<string>();

		public static SpriteRenderer[] jiSprites = (SpriteRenderer[])(object)new SpriteRenderer[jiSpritePaths.Length];

		public static SpriteRenderer[] crimsonSprites = (SpriteRenderer[])(object)new SpriteRenderer[crimsonSpritePaths.Length];

		public static ParticleSystem[] crimsonParticles = (ParticleSystem[])(object)new ParticleSystem[crimsonParticlePaths.Length];

		public static ParticleSystemRenderer[] crimsonParticleRenderers = (ParticleSystemRenderer[])(object)new ParticleSystemRenderer[crimsonParticleRendererPaths.Length];

		public static Func<string, (float x, float y, float z)> parseTuple = delegate(string s)
		{
			string[] array = s.Split(',');
			return (float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]));
		};

		public static void InitializePairs(((float x, float y, float z) src, (float x, float y, float z) dst)[] pairs, (float x, float y, float z)[] leftTuple, string[] rightString)
		{
			for (int i = 0; i < leftTuple.Length; i++)
			{
				pairs[i] = (leftTuple[i], parseTuple(rightString[i]));
			}
		}

		private static float ReturnInRange(float n)
		{
			return Math.Min(Math.Max(n, 0f), 255f);
		}

		private static void initializeArr(((float x, float y, float z) src, (float x, float y, float z) dst)[] pairs, Vector3[] srcArr, Vector3[] dstArr)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			for (int i = 0; i < pairs.Length; i++)
			{
				((float x, float y, float z) src, (float x, float y, float z) dst) tuple = pairs[i];
				(float, float, float) item = tuple.src;
				(float, float, float) item2 = tuple.dst;
				for (float num2 = -stayRange; num2 <= (float)stayRange; num2 += 1f)
				{
					for (float num3 = -stayRange; num3 <= (float)stayRange; num3 += 1f)
					{
						for (float num4 = -stayRange; num4 <= (float)stayRange; num4 += 1f)
						{
							srcArr[num] = new Vector3(ReturnInRange(item.Item1 + num2), ReturnInRange(item.Item2 + num3), ReturnInRange(item.Item3 + num4));
							dstArr[num++] = new Vector3(ReturnInRange(item2.Item1 + num2), ReturnInRange(item2.Item2 + num3), ReturnInRange(item2.Item3 + num4));
						}
					}
				}
			}
		}

		public static void getSprites()
		{
			for (int i = 0; i < jiSprites.Length; i++)
			{
				jiSprites[i] = GameObject.Find(jiSpritePaths[i]).GetComponent<SpriteRenderer>();
			}
			for (int j = 0; j < crimsonSprites.Length; j++)
			{
				crimsonSprites[j] = GameObject.Find(crimsonSpritePaths[j]).GetComponent<SpriteRenderer>();
			}
			for (int k = 0; k < crimsonParticles.Length; k++)
			{
				crimsonParticles[k] = GameObject.Find(crimsonParticlePaths[k]).GetComponent<ParticleSystem>();
			}
			for (int l = 0; l < crimsonParticleRenderers.Length; l++)
			{
				crimsonParticleRenderers[l] = GameObject.Find(crimsonParticleRendererPaths[l]).GetComponent<ParticleSystemRenderer>();
			}
		}

		private static void InitializeMat(Material mat, (float x, float y, float z)[] originalColors, string[] newColors)
		{
			if (originalColors.Length != newColors.Length)
			{
				ToastManager.Toast((object)"Arrays not same length!");
				return;
			}
			((float, float, float), (float, float, float))[] pairs = new((float, float, float), (float, float, float))[originalColors.Length];
			Vector3[] array = (Vector3[])(object)new Vector3[originalColors.Length * (int)Math.Pow(stayRange * 2 + 1, 3.0)];
			Vector3[] array2 = (Vector3[])(object)new Vector3[originalColors.Length * (int)Math.Pow(stayRange * 2 + 1, 3.0)];
			InitializePairs(pairs, originalColors, newColors);
			initializeArr(pairs, array, array2);
			Texture3D val = RBFLUTGenerator.GenerateRBF_LUT(array, array2, lutSize);
			mat.SetTexture("_LUT", (Texture)(object)val);
			mat.SetFloat("_LUTSize", (float)lutSize);
		}

		public static void InitializeJiMat(Material mat, string[] newColors)
		{
			(float, float, float)[] originalColors = new(float, float, float)[7]
			{
				(1f, 1f, 1f),
				(247f, 248f, 241f),
				(186f, 240f, 227f),
				(79f, 193f, 129f),
				(104f, 24f, 23f),
				(228f, 190f, 106f),
				(212f, 203f, 167f)
			};
			InitializeMat(mat, originalColors, newColors);
		}

		public static void InitializeCrimsonMat(Material mat, string[] newColors)
		{
			(float, float, float)[] originalColors = new(float, float, float)[2]
			{
				(1f, 1f, 1f),
				(223f, 86f, 96f)
			};
			InitializeMat(mat, originalColors, newColors);
		}

		public static void updateJiSprite(Material mat)
		{
			SpriteRenderer[] array = jiSprites;
			foreach (SpriteRenderer val in array)
			{
				if ((Object)(object)((Renderer)val).material != (Object)(object)mat)
				{
					((Renderer)val).material = mat;
				}
			}
		}

		public static void updateCrimsonSprites(Material mat)
		{
			SpriteRenderer[] array = crimsonSprites;
			foreach (SpriteRenderer val in array)
			{
				if ((Object)(object)((Renderer)val).material != (Object)(object)mat)
				{
					((Renderer)val).material = mat;
				}
			}
		}

		public static void updateCrimsonParticleRenderers(Material mat)
		{
			ParticleSystemRenderer[] array = crimsonParticleRenderers;
			foreach (ParticleSystemRenderer val in array)
			{
				if ((Object)(object)((Renderer)val).material != (Object)(object)mat)
				{
					((Renderer)val).material = mat;
				}
			}
		}

		public static void updateCrimsonParticles(Color color)
		{
			//IL_000e: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem[] array = crimsonParticles;
			foreach (ParticleSystem obj in array)
			{
				MainModule main = obj.main;
				ColorOverLifetimeModule colorOverLifetime = obj.colorOverLifetime;
				ColorBySpeedModule colorBySpeed = obj.colorBySpeed;
				((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(color);
				((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
				((ColorBySpeedModule)(ref colorBySpeed)).color = MinMaxGradient.op_Implicit(color);
				((ColorBySpeedModule)(ref colorBySpeed)).enabled = true;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(color);
			}
		}
	}
	public static class RBFLUTGenerator
	{
		public static Texture3D GenerateRBF_LUT(Vector3[] srcColors, Vector3[] dstColors, int size = 32, float eps = 0.1f)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_0045: 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)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			Color[] array = (Color[])(object)new Color[size * size * size];
			int num = 0;
			Vector3 x = default(Vector3);
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					for (int k = 0; k < size; k++)
					{
						((Vector3)(ref x))..ctor((float)k / ((float)size - 1f), (float)j / ((float)size - 1f), (float)i / ((float)size - 1f));
						Vector3 val = ApplyRBF(srcColors, dstColors, x, eps);
						array[num++] = new Color(val.x, val.y, val.z, 1f);
					}
				}
			}
			Texture3D val2 = new Texture3D(size, size, size, (TextureFormat)17, false)
			{
				wrapMode = (TextureWrapMode)1
			};
			val2.SetPixels(array);
			val2.Apply();
			return val2;
		}

		private static Vector3 ApplyRBF(Vector3[] src, Vector3[] dst, Vector3 x, float eps)
		{
			//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_0010: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			//IL_004a: 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_0068: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			Vector3 val = Vector3.zero;
			for (int i = 0; i < src.Length; i++)
			{
				float num2 = Vector3.Distance(x, src[i] / 255f);
				float num3 = Mathf.Exp((0f - num2 * num2) / eps);
				val += dst[i] / 255f * num3;
				num += num3;
			}
			if (num <= 1E-06f)
			{
				return x;
			}
			return val / num;
		}
	}
	public class DestroyOnDisable : MonoBehaviour
	{
		private void OnDisable()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	[BepInPlugin("EnlightenedJi", "EnlightenedJi", "1.1.1")]
	public class EnlightenedJi : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <InitJiStateChange>d__89 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public EnlightenedJi <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <InitJiStateChange>d__89(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				EnlightenedJi @object = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (SingletonBehaviour<MonsterManager>.Instance.ClosetMonster == null)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				JiStateChange = @object.HandleStateChange;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <JiHPChange>d__96 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float newHp;

			public EnlightenedJi <>4__this;

			public float phase2Ratio;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <JiHPChange>d__96(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				int num = <>1__state;
				EnlightenedJi enlightenedJi = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!Object.op_Implicit((Object)(object)SingletonBehaviour<MonsterManager>.Instance.ClosetMonster))
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				MonsterBase closetMonster = SingletonBehaviour<MonsterManager>.Instance.ClosetMonster;
				FieldRef<MonsterStat, float> val = AccessTools.FieldRefAccess<MonsterStat, float>("BaseHealthValue");
				if (closetMonster.postureSystem.CurrentHealthValue != newHp)
				{
					val.Invoke(closetMonster.monsterStat) = newHp / 1.35f;
					closetMonster.postureSystem.CurrentHealthValue = newHp;
				}
				((BaseUnityPlugin)enlightenedJi).Logger.LogInfo((object)$"Ji Phase 1 HP at {closetMonster.postureSystem.CurrentHealthValue}");
				closetMonster.monsterStat.Phase2HealthRatio = phase2Ratio;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <ModifyHiddenObjects>d__85 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ModifyHiddenObjects>d__85(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0039: 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_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Expected O, but got Unknown
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Expected O, but got Unknown
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name != "A10_S5_Boss_Jee")
				{
					<>2__current = (object)new WaitForSeconds(0.25f);
					<>1__state = 1;
					return true;
				}
				GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
				foreach (GameObject val in array)
				{
					if (((Object)val).name == "MultiSpriteEffect_Prefab 識破提示Variant(Clone)")
					{
						SpriteRenderer component = ((Component)val.transform.Find("View/Sprite")).GetComponent<SpriteRenderer>();
						if (multiMaterial == null && $"{((Renderer)component).material}" == "識破 (Instance) (UnityEngine.Material)")
						{
							multiMaterial = new Material(((Renderer)component).material);
						}
						((Renderer)component).material = (JiModifiedSprite.Value ? mat : multiMaterial);
					}
					else if (((Object)val).name == "Effect_TaiDanger(Clone)")
					{
						SpriteRenderer component2 = ((Component)val.transform.Find("Sprite")).GetComponent<SpriteRenderer>();
						if (taiMaterial == null && $"{((Renderer)component2).material}" == "Sprites-Default (Instance) (UnityEngine.Material)")
						{
							taiMaterial = new Material(((Renderer)component2).material);
						}
						((Renderer)component2).material = (JiModifiedSprite.Value ? crimsonMat : taiMaterial);
					}
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <delayTitleChange>d__88 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <delayTitleChange>d__88(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((TMP_Text)GameObject.Find("GameCore(Clone)/RCG LifeCycle/UIManager/GameplayUICamera/MonsterHPRoot/BossHPRoot/UIBossHP(Clone)/Offset(DontKeyAnimationOnThisNode)/AnimationOffset/BossName").GetComponent<RubyTextMeshProUGUI>()).text = "The Kunlun Immortal";
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private Harmony harmony;

		private static ConfigEntry<float> JiAnimatorSpeed = null;

		private static ConfigEntry<float> JiHPScale = null;

		private static ConfigEntry<bool> JiModifiedAttackSequences = null;

		private static ConfigEntry<bool> JiModifiedSpeed = null;

		private static ConfigEntry<bool> JiModifiedSprite = null;

		private static ConfigEntry<bool> JiModifiedHP = null;

		private static ConfigEntry<float> JiPhase2HPRatio = null;

		public static ConfigEntry<string> blackReplace = null;

		public static ConfigEntry<string> furReplace = null;

		public static ConfigEntry<string> eyeReplace = null;

		public static ConfigEntry<string> greenReplace = null;

		public static ConfigEntry<string> capeReplace = null;

		public static ConfigEntry<string> robeReplace = null;

		public static ConfigEntry<string> tanReplace = null;

		public static ConfigEntry<string> crimsonReplace = null;

		private ConfigEntry<KeyboardShortcut> reloadMaterialKeyboardShortcut;

		private static Material mat = null;

		private static Material crimsonMat = null;

		private static AssetBundle bundle = null;

		private string jiBossPath = "";

		private string jiAttackStatesPath = "";

		private string jiAttackSequences1Path = "";

		private string jiAttackSequences2Path = "";

		private string jiAttackGroupsPath = "";

		private static string[] Attacks = new string[17]
		{
			"", "[1]Divination Free Zone", "[2][Short]Flying Projectiles", "[3][Finisher]BlackHoleAttack", "[4][Altar]Set Laser Altar Environment", "[5][Short]SuckSword 往內", "[6][Finisher]Teleport3Sword Smash 下砸", "[7][Finisher]SwordBlizzard", "", "[9][Short]GroundSword",
			"[10][Altar]SmallBlackHole", "[11][Short]ShorFlyingSword", "[12][Short]QuickHorizontalDoubleSword", "[13][Finisher]QuickTeleportSword 危戳", "[14][Altar]Laser Altar Circle", "[15][Altar]Health Altar", "[16]Divination JumpKicked"
		};

		private static BossGeneralState[] BossGeneralStates = (BossGeneralState[])(object)new BossGeneralState[19];

		private static Weight<MonsterState>[] Weights = new Weight<MonsterState>[17];

		private static int Hurt = 17;

		private static int BigHurt = 18;

		private static string[] SequenceStrings1 = new string[4] { "", "_WithAltar", "_WithSmallBlackHole", "_QuickToBlizzard" };

		private static string[] SequenceStrings2 = new string[6] { "", "_WithAltar", "_WithSmallBlackHole", "_QuickToBlizzard", "_QuickToBlackHole", "_Phase2_OpeningBlackHole" };

		private static MonsterStateGroupSequence[] Sequences1 = (MonsterStateGroupSequence[])(object)new MonsterStateGroupSequence[4];

		private static MonsterStateGroupSequence[] Sequences2 = (MonsterStateGroupSequence[])(object)new MonsterStateGroupSequence[7];

		private static int Default = 0;

		private static int WithAltar = 1;

		private static int WithSmallBlackHole = 2;

		private static int QuickToBlizzard = 3;

		private static int QuickToBlackHole = 4;

		private static int Opening = 5;

		private static int Health = 6;

		private static (int sequence, int index)[] ExistingGroupPairs = new(int, int)[6]
		{
			(WithSmallBlackHole, 1),
			(Default, 3),
			(QuickToBlizzard, 1),
			(Default, 1),
			(WithAltar, 1),
			(WithAltar, 4)
		};

		private static (int[] attacksList, string objectName)[] customGroupPatterns = new(int[], string)[10]
		{
			(new int[4] { 11, 12, 13, 14 }, "SneakAttack(Attack 11/12/13/14)"),
			(new int[2] { 5, 9 }, "BackAttack(Attack 5/9)"),
			(new int[3] { 5, 9, 7 }, "LongerOrBlizardAttack(Attack 5/9/7)"),
			(new int[3] { 11, 12, 14 }, "SwordOrLaserAttack(Attack 11/12/14)"),
			(new int[3] { 10, 12, 14 }, "SwordOrAltarAttack(Attack10/12/14)"),
			(new int[1] { 4 }, "LaserAltarHardAttack(Attack4)"),
			(new int[4] { 2, 5, 9, 12 }, "DoubleTroubleAttack(Attack2/9/12/5)"),
			(new int[6] { 2, 5, 9, 11, 12, 15 }, "SneakAttack2(Attack2/5/9/11/12/15)"),
			(new int[2] { 4, 13 }, "HardAltarOrEasyFinisher(Attack4/13)"),
			(new int[3] { 4, 6, 13 }, "LaserAltarOrFinisher(Attack 4/6/13)")
		};

		private static MonsterStateGroup[] Groups = (MonsterStateGroup[])(object)new MonsterStateGroup[ExistingGroupPairs.Length + customGroupPatterns.Length + 2];

		private static int SmallBlackHole = 0;

		private static int LongerAttack = 1;

		private static int Blizzard = 2;

		private static int EasyLaserAltar = 4;

		private static int BigBlackHole = 6;

		private static int EasyOrHardFinisher = 7;

		private static int SneakAttack = 8;

		private static int BackAttack = 9;

		private static int HardLaserAltar = 13;

		private static int DoubleTrouble = 14;

		private static int SneakAttack2 = 15;

		private static int LaserAltarOrFinisher = 17;

		private static Color crimsonColor;

		private static string BundleName = "EnlightenedJiBundle";

		private static string temp = "";

		private static int randomNum = 0;

		private static bool firstMessage = true;

		private static Material multiMaterial = null;

		private static Material taiMaterial = null;

		private static Random random = new Random();

		private static PostureBreakState JiStunState = null;

		private static StealthEngaging Engaging = null;

		private static BossPhaseChangeState PhaseChangeState = null;

		private static AttackSequenceModule attackSequenceModule = null;

		private static RubyTextMeshPro PhaseTransitionText = null;

		private static MonsterHurtInterrupt HurtInterrupt = null;

		private static Action JiUpdate = null;

		private static Action JiSpeedChange = null;

		private static Action JiStateChange = null;

		private static Action JiSpriteUpdate = null;

		private static Action Pass = delegate
		{
		};

		private static Func<int, float, float> randomAdd = (int probability, float incr) => (randomNum % probability != 0) ? 0f : incr;

		private static Func<string, bool> afterFinisherCheck = (string lastMove) => new List<string> { "Attack13", "PostureBreak", "Attack6" }.Contains(lastMove);

		private static Dictionary<string, Func<string, float>> CurrSpeedDict = null;

		private static Dictionary<string, Func<string, float>> SpeedDict1 = new Dictionary<string, Func<string, float>>
		{
			{
				"[1]Divination Free Zone (BossGeneralState)",
				(string _) => 0f
			},
			{
				"[2][Short]Flying Projectiles (BossGeneralState)",
				(string _) => randomAdd(3, 0.2f)
			},
			{
				"[3][Finisher]BlackHoleAttack (BossGeneralState)",
				(string _) => 2f
			},
			{
				"[4][Altar]Set Laser Altar Environment (BossGeneralState)",
				(string _) => 1.55f
			},
			{
				"[5][Short]SuckSword 往內 (BossGeneralState)",
				(string _) => Math.Max(randomAdd(2, 0.5f), randomAdd(3, 0.2f))
			},
			{
				"[6][Finisher]Teleport3Sword Smash 下砸 (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? randomAdd(3, 0.2f) : 0.5f
			},
			{
				"[7][Finisher]SwordBlizzard (BossGeneralState)",
				(string _) => Math.Max(randomAdd(2, 0.5f), randomAdd(3, 0.2f))
			},
			{
				"[9][Short]GroundSword (BossGeneralState)",
				(string _) => randomAdd(3, 0.2f)
			},
			{
				"[10][Altar]SmallBlackHole (BossGeneralState)",
				(string _) => 3f
			},
			{
				"[11][Short]ShorFlyingSword (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? Math.Max(randomAdd(2, 0.5f), randomAdd(3, 0.2f)) : 2f
			},
			{
				"[12][Short]QuickHorizontalDoubleSword (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? randomAdd(3, 0.2f) : 2f
			},
			{
				"[13][Finisher]QuickTeleportSword 危戳 (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? randomAdd(3, 0.2f) : 0.5f
			},
			{
				"[14][Altar]Laser Altar Circle (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? randomAdd(3, 0.2f) : 2f
			},
			{
				"[15][Altar]Health Altar (BossGeneralState)",
				(string _) => 1f
			},
			{
				"[16]Divination JumpKicked (BossGeneralState)",
				(string _) => 3f
			},
			{
				"PostureBreak (PostureBreakState)",
				(string _) => 3f
			},
			{
				"1_Engaging (StealthEngaging)",
				(string _) => 3f
			}
		};

		private static Dictionary<string, Func<string, float>> SpeedDict2 = new Dictionary<string, Func<string, float>>
		{
			{
				"[1]Divination Free Zone (BossGeneralState)",
				(string _) => randomAdd(3, 0.2f)
			},
			{
				"[2][Short]Flying Projectiles (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? randomAdd(2, 0.3f) : 0.65f
			},
			{
				"[3][Finisher]BlackHoleAttack (BossGeneralState)",
				(string _) => 2f
			},
			{
				"[4][Altar]Set Laser Altar Environment (BossGeneralState)",
				(string _) => 1.65f
			},
			{
				"[5][Short]SuckSword 往內 (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? randomAdd(2, 0.3f) : 0.65f
			},
			{
				"[6][Finisher]Teleport3Sword Smash 下砸 (BossGeneralState)",
				(string _) => Math.Max(randomAdd(3, 0.35f), randomAdd(2, 0.3f))
			},
			{
				"[7][Finisher]SwordBlizzard (BossGeneralState)",
				(string _) => (randomNum % 3 != 0) ? ((randomNum % 3 != 1) ? 0f : 0.5f) : 0.7f
			},
			{
				"[9][Short]GroundSword (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? randomAdd(2, 0.3f) : 0.65f
			},
			{
				"[10][Altar]SmallBlackHole (BossGeneralState)",
				(string _) => 3f
			},
			{
				"[11][Short]ShorFlyingSword (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? randomAdd(2, 0.3f) : 2f
			},
			{
				"[12][Short]QuickHorizontalDoubleSword (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? randomAdd(2, 0.3f) : 2f
			},
			{
				"[13][Finisher]QuickTeleportSword 危戳 (BossGeneralState)",
				(string _) => Math.Max(randomAdd(3, 0.35f), randomAdd(2, 0.3f))
			},
			{
				"[14][Altar]Laser Altar Circle (BossGeneralState)",
				(string lastMove) => (!afterFinisherCheck(lastMove)) ? randomAdd(2, 0.3f) : 2f
			},
			{
				"[15][Altar]Health Altar (BossGeneralState)",
				(string _) => 1f
			},
			{
				"[16]Divination JumpKicked (BossGeneralState)",
				(string _) => 3f
			},
			{
				"PostureBreak (PostureBreakState)",
				(string _) => 3f
			},
			{
				"1_Engaging (StealthEngaging)",
				(string _) => 3f
			}
		};

		private static string[] lore_quotes = new string[26]
		{
			"IT'S TIME TO END THIS!", "HEROES ARE FORGED IN AGONY, YI!", "DO YOU KNOW WHAT IT IS LIKE TO LEAVE YOUR LOVED ONES SO FAR BEHIND? I SUPPOSE YOU DO...", "THANK YOU YI, MY CURTAIN CALL WILL BE FAR GRANDER THAN I COULD HAVE EVER IMAGINED.", "SURELY THIS IS NOT ENOUGH TO KILL YOU?", "THE END DRAWS NEAR, WILL IT BE MINE OR YOURS?", "I WONDER HOW FAR YOU COULD HAVE GOTTEN WITHOUT THAT PIPE OF YOURS?", "THE THINGS YOU DO FOR POWER! SURELY APE MAN FLUIDS CANNOT BE THAT GOOD...", "ENDURE WHAT OTHERS CANNOT!", "LEAR ONCE SPOKE OF YOU, LONG AGO. A MIGHTY FANGSHI ALBEIT OF SHORT STATURE...",
			"WAS NOT LEAR RIGHT AFTER ALL? TIANHUO, A PRODUCT OF SOLARIAN TECHNOLOGY AND ARROGANCE...", "I ENVY YOU, YI. TO STILL HAVE LOVED ONES TO MOURN YOUR LOSS...", "WHY AM I ATTACKING YOU, YI? HOW ELSE WILL I GET MY CURTAIN CALL?", "I THOUGHT MY END WOULD BE GRAND... AND YET YOUR FIREWORK WILL BE THE GRANDEST OF THEM ALL.", "WON'T YOU CARE FOR THIS GROTTO FOR ME AFTERWARDS? ...HAHA, I ONLY JEST.", "MY LONG AWAITED DEATH IS UPON US. I HOPE YOU ENJOY MY SWAN SONG... OR SURVIVE IT RATHER.", "THAT HEART OF YOURS IS JUST AS MUCH A MYSTERY AS MY OWN ABILITIES. FUSANG TRULY CHERISHES YOU...", "I DO NOT BLAME EIGONG. DESTINY WOULD HAVE SIMPLY CHOSEN ANOTHER AGENT.", "YOU GAVE THE SHEET MUSIC TO AN APE MAN CHILD? DEATH TRULY HAS CHANGED YOU.", "YOU ARE REARING AN APE MAN CHILD? SURELY IT DOES NOT KNOW WHAT ELSE YOU HAVE DONE?",
			"TO THINK, OUR FUTURE IS TO BE MERE PETS TO THE APE MEN. DESTINY TRULY HAS A SENSE OF HUMOUR!", "COME AND BEHOLD, MY FINAL MOMENTS!", "I AM AWARE, THAT ALL OF THIS AROUND US, THIS IS JUST A MEMORY.", "IT IS QUITE EMBARRASSING, IS IT NOT? THIS RIDICULOUS TITLE OF MINE...", "I AM GLAD I  REREAD THE HEXAGRAMS. OTHERWISE, I WOULD HAVE HELD BACK FAR MORE THAN I NEEDED TO!", "YOU MUST BE AWARE, THIS FIGHT? A SIMPLE PASTTIME FOR BEINGS FAR GREATER THAN WE COULD IMAGINE."
		};

		private static string[] meme_quotes = new string[21]
		{
			"TIS BUT A SCRATCH!", "NAH, I'D WIN.", "WHAT'S WRONG YI, NO MAIDENS?", "YI, WHAT IS A CAT?", "WHICH DO YOU PREFER YI? YOUNG OR ADULT ME?", "EIGONG TRIED TO COPY MY IMMORTALITY. DON'T TELL ME YOU ARE THINKING OF TAKING MY GROWTH ABILITY...", "PARRYING MY BLACK HOLES? WHAT'S NEXT, A RHIZOMATIC BOMB? RIDICULOUS!", "THE RECORD SHOWS. I TOOK THE BLOWS. AND DID IT MY WAY...", "...ARE YOU TRYING TO SHAVE ME, YI?!", "HOW MANY TIMES DOES THIS MAKE IT NOW?",
			"YOU REQUIRE MY HAIR? OVER MY DEAD BODY!", "SURELY YOU HAVE MEMORIZED ALL MY ATTACKS BY NOW?", "PROMISED INNER EIGONG PRIME? WHAT A TRULY HORRIFIC COMBINATION OF WORDS!", "Meow?", "A GUN?! WHERE DID EIGONG GET A GUN FROM?", "THIS FIGHT WAS EASIER BEFORE? SURELY THAT IS JUST YOUR MEMORY FAILING YOU!", "ARE YOU HAVING A BAD TIME?", "REMEMBER, IT'S OKAY TO TAKE BREAKS!", "YOU MAY BE ABLE TO BEAT ME, BUT CAN YOU DO IT HITLESS?", "PARRY THIS, YOU FILTHY CASUAL!",
			"WHY DOESN'T THAT VIRUS AIL ME LIKE ALL OTHERS? I'M BUILT DIFFERENT!"
		};

		private static Action ActionSpriteUpdate = delegate
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			ColorChange.updateJiSprite(mat);
			ColorChange.updateCrimsonSprites(crimsonMat);
			ColorChange.updateCrimsonParticleRenderers(crimsonMat);
			ColorChange.updateCrimsonParticles(crimsonColor);
		};

		private static Action ActionSpeedChange = delegate
		{
			MonsterBase closetMonster = SingletonBehaviour<MonsterManager>.Instance.ClosetMonster;
			if (Object.op_Implicit((Object)(object)closetMonster))
			{
				if (CurrSpeedDict.TryGetValue(((object)closetMonster.currentMonsterState).ToString(), out Func<string, float> value))
				{
					closetMonster.monsterCore.AnimationSpeed = JiAnimatorSpeed.Value + value(((Actor)closetMonster).LastClipName);
				}
				else
				{
					closetMonster.monsterCore.AnimationSpeed = JiAnimatorSpeed.Value;
				}
				((Behaviour)JiStunState).enabled = (Object)(object)closetMonster.currentMonsterState == (Object)(object)BossGeneralStates[6];
			}
		};

		private void InitConfig()
		{
			string text = "1. General (Retry boss to make any change have effect)";
			string text2 = "2. Speed (Must set JiModifiedSpeed to true to take effect)";
			string text3 = "3. HP (Must set JiModifiedHP to true to take effect)";
			string text4 = "4. Color (Must set JiModifiedSprite to true to take effect)";
			JiModifiedHP = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "JiModifiedHP", true, "Modifies Ji's HP");
			JiModifiedAttackSequences = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "JiModifiedAttackSequences", true, "Modifies Ji's attack sequences");
			JiModifiedSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "JiModifiedSpeed", true, "Modifies Ji's move speed depending on current attack");
			JiModifiedSprite = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "JiModifiedSprite", true, "Modifies the color of Ji's sprite");
			JiAnimatorSpeed = ((BaseUnityPlugin)this).Config.Bind<float>(text2, "JiBaseSpeed", 1.2f, "The base speed at which Ji's attacks occur");
			JiHPScale = ((BaseUnityPlugin)this).Config.Bind<float>(text3, "JiHPScale", 6500f, "The amount of Ji's HP in Phase 1");
			JiPhase2HPRatio = ((BaseUnityPlugin)this).Config.Bind<float>(text3, "JiPhase2HPRatio", 1.65f, "The ratio used to determine phase 2 health (Phase 1 health * ratio)");
			blackReplace = ((BaseUnityPlugin)this).Config.Bind<string>(text4, "blackReplace", "1,1,1", "Replaces black with specified RGB value on Ji's sprite (Must use \"##,##,##\" format)");
			furReplace = ((BaseUnityPlugin)this).Config.Bind<string>(text4, "furReplace", "247,248,241", "Replaces fur color with specified RGB value on Ji's sprite (Must use \"##,##,##\" format)");
			eyeReplace = ((BaseUnityPlugin)this).Config.Bind<string>(text4, "eyeReplace", "186,240,227", "Replaces the hat eye color with specified RGB value on Ji's sprite (Must use \"##,##,##\" format)");
			greenReplace = ((BaseUnityPlugin)this).Config.Bind<string>(text4, "greenReplace", "79,193,129", "Replaces the claw and headband color with specified RGB value on Ji's sprite (Must use \"##,##,##\" format)");
			capeReplace = ((BaseUnityPlugin)this).Config.Bind<string>(text4, "capeReplace", "37,44,31", "Replaces the cape color with specified RGB value on Ji's sprite (Must use \"##,##,##\" format)");
			robeReplace = ((BaseUnityPlugin)this).Config.Bind<string>(text4, "robeReplace", "128,128,128", "Replaces the robe color with specified RGB value on Ji's sprite (Must use \"##,##,##\" format)");
			tanReplace = ((BaseUnityPlugin)this).Config.Bind<string>(text4, "tanHighlightReplace", "201,207,203", "Replaces the secondary robe color with specified RGB value on Ji's sprite (Must use \"##,##,##\" format)");
			crimsonReplace = ((BaseUnityPlugin)this).Config.Bind<string>(text4, "crimsonReplace", "255,215,0", "Replaces the crimson attack color with specified RGB value (Must use \"##,##,##\" format)");
		}

		public AssetBundle? LoadBundle()
		{
			AssetBundle val = null;
			string text = Path.Combine(Application.persistentDataPath, BundleName);
			if (File.Exists(text))
			{
				val = AssetBundle.LoadFromFile(text);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			string text2 = Path.Combine(Path.Combine(Paths.PluginPath, "JiSupremacy-EnlightenedJi"), BundleName);
			if (File.Exists(text2))
			{
				val = AssetBundle.LoadFromFile(text2);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[EnlightenedJi] Failed to load bundle from both locations:\n" + text + "\n" + text2));
			return null;
		}

		private void Awake()
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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)
			//IL_00bc: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			RCGLifeCycle.DontDestroyForever(((Component)this).gameObject);
			harmony = Harmony.CreateAndPatchAll(typeof(EnlightenedJi).Assembly, (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin EnlightenedJi is loaded!");
			SceneManager.sceneLoaded += OnSceneLoaded;
			InitConfig();
			JiUpdate = Pass;
			JiSpeedChange = Pass;
			JiStateChange = Pass;
			JiSpriteUpdate = Pass;
			bundle = LoadBundle();
			if (bundle != null)
			{
				mat = bundle.LoadAsset<Material>("RBFMat");
				if (mat != null)
				{
					crimsonMat = new Material(mat);
				}
			}
			(float, float, float) tuple = ColorChange.parseTuple(crimsonReplace.Value);
			crimsonColor = new Color(tuple.Item1 / 255f, tuple.Item2 / 255f, tuple.Item3 / 255f);
		}

		[IteratorStateMachine(typeof(<ModifyHiddenObjects>d__85))]
		private IEnumerator ModifyHiddenObjects()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ModifyHiddenObjects>d__85(0);
		}

		private void ReloadMaterial()
		{
			//IL_000e: 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)
			if (bundle != null && mat != null)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (!(((Scene)(ref activeScene)).name != "A10_S5_Boss_Jee"))
				{
					ColorChange.InitializeJiMat(mat, new string[7] { blackReplace.Value, furReplace.Value, eyeReplace.Value, greenReplace.Value, capeReplace.Value, robeReplace.Value, tanReplace.Value });
					ColorChange.InitializeCrimsonMat(crimsonMat, new string[2] { blackReplace.Value, crimsonReplace.Value });
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Reloaded material!");
					((MonoBehaviour)this).StartCoroutine(ModifyHiddenObjects());
				}
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name == "A10_S5_Boss_Jee")
			{
				ReloadMaterial();
				if (JiModifiedSprite.Value && bundle != null)
				{
					ColorChange.getSprites();
					JiSpriteUpdate = ActionSpriteUpdate;
				}
				else
				{
					JiSpriteUpdate = Pass;
				}
				if (JiModifiedSpeed.Value)
				{
					CurrSpeedDict = SpeedDict1;
					JiSpeedChange = ActionSpeedChange;
				}
				else
				{
					JiSpeedChange = Pass;
				}
				GetAttackGameObjects();
				if (JiModifiedAttackSequences.Value)
				{
					AlterAttacks();
				}
				JiUpdate = ActionUpdate;
				if (JiModifiedHP.Value)
				{
					((MonoBehaviour)this).StartCoroutine(JiHPChange(JiHPScale.Value, JiPhase2HPRatio.Value));
				}
				else
				{
					((MonoBehaviour)this).StartCoroutine(JiHPChange(5049f, 2f));
				}
				((MonoBehaviour)this).StartCoroutine(InitJiStateChange());
			}
			else
			{
				JiUpdate = Pass;
			}
		}

		[IteratorStateMachine(typeof(<delayTitleChange>d__88))]
		private IEnumerator delayTitleChange()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <delayTitleChange>d__88(0);
		}

		[IteratorStateMachine(typeof(<InitJiStateChange>d__89))]
		private IEnumerator InitJiStateChange()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitJiStateChange>d__89(0)
			{
				<>4__this = this
			};
		}

		private void ActionUpdate()
		{
			JiSpeedChange();
			JiStateChange();
			JiSpriteUpdate();
		}

		public void Update()
		{
			JiUpdate();
		}

		private void HandleStateChange()
		{
			MonsterBase closetMonster = SingletonBehaviour<MonsterManager>.Instance.ClosetMonster;
			if (temp != ((object)closetMonster.currentMonsterState).ToString())
			{
				if (((object)closetMonster.currentMonsterState).ToString() != "1_Engaging (StealthEngaging)")
				{
					temp = ((object)closetMonster.currentMonsterState).ToString();
					randomNum = random.Next();
				}
				if ((Object)(object)closetMonster.currentMonsterState == (Object)(object)PhaseChangeState)
				{
					CurrSpeedDict = SpeedDict2;
					HandlePhaseTransitionText();
					((MonoBehaviour)this).StartCoroutine(delayTitleChange());
				}
				else if ((Object)(object)closetMonster.currentMonsterState == (Object)(object)BossGeneralStates[1])
				{
					((Behaviour)HurtInterrupt).enabled = true;
				}
				else
				{
					((Behaviour)HurtInterrupt).enabled = false;
				}
			}
		}

		private static void HandlePhaseTransitionText()
		{
			if (firstMessage)
			{
				firstMessage = false;
			}
			else
			{
				((TMP_Text)PhaseTransitionText).text = ((randomNum % 4 == 0) ? meme_quotes[random.Next() % meme_quotes.Length] : lore_quotes[random.Next() % lore_quotes.Length]);
			}
		}

		[IteratorStateMachine(typeof(<JiHPChange>d__96))]
		private IEnumerator JiHPChange(float newHp, float phase2Ratio)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <JiHPChange>d__96(0)
			{
				<>4__this = this,
				newHp = newHp,
				phase2Ratio = phase2Ratio
			};
		}

		private static MonsterStateGroupSequence GetCurrentSequence()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			return (MonsterStateGroupSequence)((object)attackSequenceModule).GetType().GetField("sequence", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(attackSequenceModule);
		}

		private MonsterStateGroupSequence getGroupSequence1(string name)
		{
			return GameObject.Find(jiAttackSequences1Path + name).GetComponent<MonsterStateGroupSequence>();
		}

		private MonsterStateGroupSequence getGroupSequence2(string name)
		{
			return GameObject.Find(jiAttackSequences2Path + name).GetComponent<MonsterStateGroupSequence>();
		}

		private MonsterStateGroup getGroup(string name)
		{
			return GameObject.Find(jiAttackGroupsPath + name).GetComponent<MonsterStateGroup>();
		}

		private BossGeneralState getBossGeneralState(string name)
		{
			return GameObject.Find(jiAttackStatesPath + name).GetComponent<BossGeneralState>();
		}

		public void GetAttackGameObjects()
		{
			string text = "A10S5/Room/Boss And Environment Binder/General Boss Fight FSM Object 姬 Variant/FSM Animator/";
			jiBossPath = text + "LogicRoot/---Boss---/BossShowHealthArea/StealthGameMonster_Boss_Jee/";
			jiAttackStatesPath = jiBossPath + "States/Attacks/";
			jiAttackSequences1Path = jiBossPath + "MonsterCore/AttackSequenceModule/MonsterStateSequence_Phase1/";
			jiAttackSequences2Path = jiBossPath + "MonsterCore/AttackSequenceModule/MonsterStateSequence_Phase2/";
			jiAttackGroupsPath = jiBossPath + "MonsterCore/AttackSequenceModule/MonsterStateGroupDefinition/";
			for (int i = 1; i < Attacks.Length; i++)
			{
				BossGeneralStates[i] = getBossGeneralState(Attacks[i]);
				Weights[i] = CreateWeight((MonsterState)(object)BossGeneralStates[i]);
			}
			BossGeneralStates[Hurt] = GameObject.Find(jiBossPath + "States/HurtState/").GetComponent<BossGeneralState>();
			BossGeneralStates[BigHurt] = GameObject.Find(jiBossPath + "States/Hurt_BigState").GetComponent<BossGeneralState>();
			JiStunState = GameObject.Find(jiBossPath + "States/PostureBreak/").GetComponent<PostureBreakState>();
			PhaseChangeState = GameObject.Find(jiBossPath + "States/[BossAngry] BossAngry/").GetComponent<BossPhaseChangeState>();
			Engaging = GameObject.Find(jiBossPath + "States/1_Engaging").GetComponent<StealthEngaging>();
			for (int j = 0; j < SequenceStrings1.Length; j++)
			{
				Sequences1[j] = getGroupSequence1("MonsterStateGroupSequence1" + SequenceStrings1[j]);
			}
			for (int k = 0; k < SequenceStrings2.Length; k++)
			{
				if (SequenceStrings2[k] != null)
				{
					Sequences2[k] = getGroupSequence2("MonsterStateGroupSequence1" + SequenceStrings2[k]);
				}
			}
			Sequences2[Health] = GameObject.Find(jiBossPath + "MonsterCore/AttackSequenceModule/SpecialHealthSequence(Jee_Divination_Logic)").GetComponent<MonsterStateGroupSequence>();
			int num = 0;
			(int, int)[] existingGroupPairs = ExistingGroupPairs;
			for (int l = 0; l < existingGroupPairs.Length; l++)
			{
				var (num2, index) = existingGroupPairs[l];
				Groups[num++] = Sequences1[num2].AttackSequence[index];
			}
			Groups[BigBlackHole] = Sequences2[Opening].AttackSequence[0];
			Groups[EasyOrHardFinisher] = Sequences2[Default].AttackSequence[5];
			attackSequenceModule = GameObject.Find(jiBossPath + "MonsterCore/AttackSequenceModule/").GetComponent<AttackSequenceModule>();
			PhaseTransitionText = GameObject.Find(text + "[CutScene]BossAngry_Cutscene/BubbleRoot/SceneDialogueNPC/BubbleRoot/DialogueBubble/Text").GetComponent<RubyTextMeshPro>();
			HurtInterrupt = GameObject.Find(jiBossPath + "MonsterCore/Animator(Proxy)/Animator/LogicRoot/HurtInterrupt").GetComponent<MonsterHurtInterrupt>();
		}

		private Weight<MonsterState> CreateWeight(MonsterState state)
		{
			return new Weight<MonsterState>
			{
				weight = 1,
				option = state
			};
		}

		private MonsterStateGroup CreateMonsterStateGroup(int[] AttacksList, string objectName)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0067: Expected O, but got Unknown
			List<Weight<MonsterState>> list = new List<Weight<MonsterState>>();
			GameObject val = new GameObject(objectName ?? "");
			new MonsterStateGroup();
			foreach (int num in AttacksList)
			{
				list.Add(Weights[num]);
			}
			MonsterStateWeightSetting val2 = new MonsterStateWeightSetting();
			((OptionWeightQueue<MonsterState>)val2).stateWeightList = list;
			((OptionWeightQueue<MonsterState>)val2).queue = new List<MonsterState>();
			((OptionWeightQueue<MonsterState>)val2).customizedInitQueue = new List<MonsterState>();
			MonsterStateWeightSetting setting = val2;
			MonsterStateGroup obj = val.AddComponent<MonsterStateGroup>();
			obj.setting = setting;
			return obj;
		}

		private void ModifySequence(int sequenceIndex, int phase, int[] groupsToAdd, (int group, int index)[] groupsToOverwrite, (int group, int index)[] groupsToInsert)
		{
			MonsterStateGroupSequence val = ((phase == 1) ? Sequences1[sequenceIndex] : Sequences2[sequenceIndex]);
			foreach (int num in groupsToAdd)
			{
				val.AttackSequence.Add(Groups[num]);
			}
			(int, int)[] array = groupsToOverwrite;
			for (int i = 0; i < array.Length; i++)
			{
				var (num2, index) = array[i];
				val.AttackSequence[index] = Groups[num2];
			}
			array = groupsToInsert;
			for (int i = 0; i < array.Length; i++)
			{
				var (num3, index2) = array[i];
				val.AttackSequence.Insert(index2, Groups[num3]);
			}
		}

		public void AlterAttacks()
		{
			if (!Sequences1[Default].AttackSequence.Contains(Groups[SneakAttack]))
			{
				int num = ExistingGroupPairs.Length + 2;
				(int[], string)[] array = customGroupPatterns;
				for (int i = 0; i < array.Length; i++)
				{
					var (attacksList, objectName) = array[i];
					Groups[num++] = CreateMonsterStateGroup(attacksList, objectName);
				}
				ModifySequence(Default, 1, new int[1] { SneakAttack }, new(int, int)[2]
				{
					(SneakAttack, 2),
					(EasyOrHardFinisher, 4)
				}, new(int, int)[2]
				{
					(BackAttack, 4),
					(EasyOrHardFinisher, 5)
				});
				ModifySequence(WithAltar, 1, new int[1] { SneakAttack }, new(int, int)[3]
				{
					(SmallBlackHole, 2),
					(EasyLaserAltar, 3),
					(EasyOrHardFinisher, 4)
				}, new(int, int)[2]
				{
					(BackAttack, 4),
					(EasyOrHardFinisher, 5)
				});
				ModifySequence(WithSmallBlackHole, 1, new int[1] { SneakAttack }, new(int, int)[3]
				{
					(EasyLaserAltar, 2),
					(Blizzard, 3),
					(EasyOrHardFinisher, 5)
				}, new(int, int)[1] { (EasyOrHardFinisher, 5) });
				ModifySequence(QuickToBlizzard, 1, new int[1] { SneakAttack }, new(int, int)[2]
				{
					(Blizzard, 3),
					(EasyOrHardFinisher, 4)
				}, new(int, int)[2]
				{
					(EasyLaserAltar, 1),
					(EasyOrHardFinisher, 5)
				});
				ModifySequence(Health, 2, new int[1] { SneakAttack }, Array.Empty<(int, int)>(), new(int, int)[2]
				{
					(LaserAltarOrFinisher, 2),
					(BigBlackHole, 3)
				});
				ModifySequence(Opening, 2, new int[1] { SneakAttack2 }, Array.Empty<(int, int)>(), new(int, int)[10]
				{
					(HardLaserAltar, 1),
					(BigBlackHole, 2),
					(HardLaserAltar, 3),
					(Blizzard, 4),
					(SmallBlackHole, 5),
					(LongerAttack, 6),
					(HardLaserAltar, 7),
					(DoubleTrouble, 8),
					(LongerAttack, 9),
					(HardLaserAltar, 10)
				});
				ModifySequence(Default, 2, new int[1] { SneakAttack2 }, new(int, int)[3]
				{
					(EasyOrHardFinisher, 3),
					(EasyOrHardFinisher, 4),
					(EasyOrHardFinisher, 5)
				}, new(int, int)[3]
				{
					(DoubleTrouble, 2),
					(DoubleTrouble, 4),
					(HardLaserAltar, 5)
				});
				ModifySequence(WithAltar, 2, new int[1] { SneakAttack2 }, new(int, int)[5]
				{
					(HardLaserAltar, 1),
					(DoubleTrouble, 2),
					(EasyOrHardFinisher, 4),
					(EasyOrHardFinisher, 5),
					(EasyOrHardFinisher, 6)
				}, new(int, int)[2]
				{
					(Blizzard, 2),
					(HardLaserAltar, 5)
				});
				ModifySequence(WithSmallBlackHole, 2, new int[1] { SneakAttack2 }, new(int, int)[6]
				{
					(LongerAttack, 2),
					(HardLaserAltar, 3),
					(Blizzard, 4),
					(EasyOrHardFinisher, 5),
					(EasyOrHardFinisher, 6),
					(EasyOrHardFinisher, 7)
				}, new(int, int)[1] { (HardLaserAltar, 5) });
				ModifySequence(QuickToBlizzard, 2, new int[1] { SneakAttack2 }, new(int, int)[3]
				{
					(EasyOrHardFinisher, 4),
					(EasyOrHardFinisher, 5),
					(EasyOrHardFinisher, 6)
				}, new(int, int)[2]
				{
					(Blizzard, 3),
					(HardLaserAltar, 5)
				});
				ModifySequence(QuickToBlackHole, 2, new int[1] { SneakAttack2 }, new(int, int)[3]
				{
					(EasyOrHardFinisher, 2),
					(EasyOrHardFinisher, 3),
					(EasyOrHardFinisher, 4)
				}, new(int, int)[4]
				{
					(HardLaserAltar, 2),
					(BigBlackHole, 3),
					(LongerAttack, 4),
					(HardLaserAltar, 5)
				});
			}
		}

		private void OnDestroy()
		{
			firstMessage = true;
			SceneManager.sceneLoaded -= OnSceneLoaded;
			bundle.Unload(false);
			harmony.UnpatchSelf();
		}
	}
	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
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(LocalizationManager), "GetTranslation")]
		private static void EnlightenedJiNameChange(string Term, ref string __result)
		{
			if (!(Term != "Characters/NameTag_Jee"))
			{
				__result = "Enlightened " + __result;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "EnlightenedJi";

		public const string PLUGIN_NAME = "EnlightenedJi";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}