Decompiled source of UltraChaos v1.1.0

UltraChaos/ULTRARandomizer.dll

Decompiled 2 days 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.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using PluginConfig.API.Functionals;
using TMPro;
using ULTRARandomizer.PluginConfiguratorCOnfig;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ULTRARandomizer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ULTRARandomizer")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("81d38014-5865-42f2-a207-ef443dea36a1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ULTRARandomizer
{
	[BepInPlugin("com.michi.ULTRARandomizer", "ULTRARandomizer", "1.0.0")]
	public class ULTRARandomizerPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.michi.ULTRARandomizer";

		private const string PluginName = "ULTRARandomizer";

		private const string VersionString = "1.0.0";

		private static readonly Harmony Harmony = new Harmony("com.michi.ULTRARandomizer");

		public static ManualLogSource Log = new ManualLogSource("ULTRARandomizer");

		public static List<Material> materials = new List<Material>();

		public static bool globalEnabled;

		public static bool doMats = false;

		public static bool doMeshes = false;

		public static bool RandomizeText = false;

		public static bool RandomizeSounds = false;

		public static bool RandomizeBeams = false;

		public static bool RandomizeExplosions = false;

		public static bool randomizeFonts = false;

		public static bool randomizeLevelOnExit = false;

		public static bool doPlayerHealth = false;

		public static float min = 1f;

		public static float max = 1000f;

		public static int currentMaxHealth;

		public static bool DoChangeEnemyHealth = false;

		public static bool RandomizeEnemies = false;

		public static bool RandomizeProj = false;

		public static bool randomizeDamage = false;

		public static List<SpawnableObject> enemies = new List<SpawnableObject>();

		public static List<RevolverBeam> Beams = new List<RevolverBeam>();

		public static List<ExplosionController> explosions = new List<ExplosionController>();

		public static List<AudioClip> Clips = new List<AudioClip>();

		public static List<Projectile> projectiles = new List<Projectile>();

		public static List<Font> fonts = new List<Font>();

		public static List<TMP_FontAsset> fontsAssets = new List<TMP_FontAsset>();

		public static List<string> lesTexts = new List<string>();

		private List<EnemyType> types = new List<EnemyType>();

		private void Awake()
		{
			Fields.SetFields();
			Harmony.PatchAll();
			Log = ((BaseUnityPlugin)this).Logger;
			SceneManager.sceneLoaded += SceneManager_sceneLoaded;
		}

		public static void CopyOverNecessaryStuff(EnemyIdentifier basething, EnemyIdentifier clonedEnemy)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Invalid comparison between Unknown and I4
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Invalid comparison between Unknown and I4
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Invalid comparison between Unknown and I4
			clonedEnemy.activateOnDeath = basething.activateOnDeath;
			clonedEnemy.onDeath = basething.onDeath;
			clonedEnemy.sandified = basething.sandified;
			clonedEnemy.puppet = basething.puppet;
			clonedEnemy.target = basething.target;
			clonedEnemy.usingDoor = basething.usingDoor;
			if ((int)basething.enemyType == 21 && (int)clonedEnemy.enemyType == 21)
			{
				Idol component = ((Component)basething).GetComponent<Idol>();
				((Component)clonedEnemy).GetComponent<Idol>().target = component.target;
				((Component)clonedEnemy).GetComponent<Idol>().target.Bless(false);
			}
			else if ((int)basething.enemyType == 21 && (int)clonedEnemy.enemyType != 21)
			{
				Idol component2 = ((Component)basething).GetComponent<Idol>();
				component2.target.Unbless(false);
			}
			if (!basething.dontCountAsKills)
			{
				ActivateNextWave componentInParent = ((Component)basething).GetComponentInParent<ActivateNextWave>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					((Component)clonedEnemy).transform.parent = ((Component)componentInParent).transform;
				}
			}
			if (Object.op_Implicit((Object)(object)((Component)clonedEnemy).GetComponent<Machine>()))
			{
				((Component)clonedEnemy).GetComponent<Machine>().dontDie = false;
			}
			if (basething.isBoss || Object.op_Implicit((Object)(object)((Component)basething).GetComponent<BossHealthBar>()))
			{
				((Component)clonedEnemy).gameObject.AddComponent<BossHealthBar>();
			}
		}

		public static void CopyOverNecessaryStuffBeam(RevolverBeam basething, RevolverBeam clonedBeam)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			clonedBeam.target = basething.target;
			clonedBeam.alternateStartPoint = basething.alternateStartPoint;
			clonedBeam.sourceWeapon = basething.sourceWeapon;
		}

		private void GetEnemies()
		{
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			enemies = Resources.FindObjectsOfTypeAll<SpawnableObject>().ToList();
			List<EnemyIdentifier> list = Resources.FindObjectsOfTypeAll<EnemyIdentifier>().ToList();
			enemies.RemoveAll((SpawnableObject enemy) => (int)enemy.spawnableObjectType != 1);
			enemies.Distinct();
			foreach (EnemyIdentifier item in list)
			{
				string newName = Regex.Replace(((Object)((Component)item).gameObject).name, "\\(\\d+\\)", "");
				if (newName.Contains("Clone"))
				{
					newName.Replace("(Clone)", "");
				}
				if (!enemies.Any((SpawnableObject obj) => ((Object)obj.gameObject).name.ToLower().Contains(newName.ToLower())) && newName.Contains("Drone"))
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)((Object)((Component)item).gameObject).name);
					SpawnableObject val = (SpawnableObject)ScriptableObject.CreateInstance("SpawnableObject");
					val.gameObject = ((Component)item).gameObject;
					val.gridIcon = null;
					val.spawnableObjectType = (SpawnableObjectDataType)1;
					((Object)val).name = newName + "ObjectSpawn";
					val.objectName = newName;
					enemies.Add(val);
				}
			}
		}

		private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
		{
			if (!globalEnabled)
			{
				return;
			}
			GetEnemies();
			projectiles = Resources.FindObjectsOfTypeAll<Projectile>().ToList();
			projectiles.Distinct();
			if (doMats)
			{
				ChangeMats();
			}
			if (doMeshes)
			{
				ChangeMeshes();
			}
			if (doPlayerHealth)
			{
				ChangePlayerHealth();
			}
			if (DoChangeEnemyHealth)
			{
				ChangeEnemyHealth();
			}
			ChangeText();
			Beams = Resources.FindObjectsOfTypeAll<RevolverBeam>().ToList();
			Beams.Distinct();
			explosions = Resources.FindObjectsOfTypeAll<ExplosionController>().ToList();
			explosions.Distinct();
			explosions.RemoveAll((ExplosionController biem) => ((Object)biem).name.ToLower().Contains("fire"));
			if (RandomizeSounds)
			{
				Clips.Clear();
				Clips = Resources.FindObjectsOfTypeAll<AudioClip>().ToList();
				AudioSource[] array = Resources.FindObjectsOfTypeAll<AudioSource>();
				AudioSource[] array2 = array;
				foreach (AudioSource val in array2)
				{
					val.clip = Clips[Random.Range(0, Clips.Count)];
				}
			}
			if (((Scene)(ref arg0)).name == "6e981b1865c649749a610aafc471e198")
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"helo");
				((Object)FindInActiveObjectByName("Main")).name = "benjamin";
			}
		}

		private GameObject FindInActiveObjectByName(string name)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			Transform[] array = Resources.FindObjectsOfTypeAll<Transform>();
			for (int i = 0; i < array.Length; i++)
			{
				if ((int)((Object)array[i]).hideFlags == 0 && ((Object)array[i]).name == name)
				{
					return ((Component)array[i]).gameObject;
				}
			}
			return null;
		}

		public static void ChangeText()
		{
			lesTexts.AddRange(GetTexts());
			lesTexts = lesTexts.Distinct().ToList();
			ChangeTMP();
			ChangeNormalText();
		}

		public static List<string> GetTexts()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>();
			List<string> list = new List<string>();
			TextMeshProUGUI[] array2 = array;
			Scene scene;
			foreach (TextMeshProUGUI val in array2)
			{
				scene = ((Component)val).gameObject.scene;
				if (!(((Scene)(ref scene)).name == "DontDestroyOnLoad"))
				{
					fontsAssets.Add(((TMP_Text)val).font);
					list.Add(((TMP_Text)val).text);
				}
			}
			Text[] array3 = Resources.FindObjectsOfTypeAll<Text>();
			Text[] array4 = array3;
			foreach (Text val2 in array4)
			{
				scene = ((Component)val2).gameObject.scene;
				if (!(((Scene)(ref scene)).name == "DontDestroyOnLoad"))
				{
					fonts.Add(val2.font);
					list.Add(val2.text);
				}
			}
			return list;
		}

		public static void ChangeTMP()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll<TextMeshProUGUI>();
			for (int i = 0; i < array.Length; i++)
			{
				Scene scene = ((Component)array[i]).gameObject.scene;
				if (!(((Scene)(ref scene)).name == "DontDestroyOnLoad"))
				{
					if (RandomizeText)
					{
						((TMP_Text)array[i]).text = lesTexts[Random.Range(0, lesTexts.Count)];
					}
					if (randomizeFonts)
					{
						((TMP_Text)array[i]).font = fontsAssets[Random.Range(0, fontsAssets.Count)];
					}
				}
			}
		}

		public static void ChangeNormalText()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			Text[] array = Resources.FindObjectsOfTypeAll<Text>();
			for (int i = 0; i < array.Length; i++)
			{
				Scene scene = ((Component)array[i]).gameObject.scene;
				if (!(((Scene)(ref scene)).name == "DontDestroyOnLoad"))
				{
					if (RandomizeText)
					{
						array[i].text = lesTexts[Random.Range(0, lesTexts.Count)];
					}
					if (randomizeFonts)
					{
						array[i].font = fonts[Random.Range(0, fonts.Count)];
					}
				}
			}
		}

		public static void ChangeMats()
		{
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			Renderer[] array2 = Resources.FindObjectsOfTypeAll<Renderer>();
			materials.AddRange(array);
			Renderer[] array3 = array2;
			foreach (Renderer val in array3)
			{
				if (!Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<ParticleSystem>()) && ((Component)val).gameObject.layer != 19)
				{
					Material val2 = materials[Random.Range(0, array.Length)];
					Material[] array4 = (Material[])(object)new Material[val.materials.Length];
					for (int j = 0; j < array4.Length; j++)
					{
						array4[j] = val2;
					}
					val.materials = array4;
					val.material = val2;
				}
			}
		}

		public static void ChangeMeshes()
		{
			MeshFilter[] array = Resources.FindObjectsOfTypeAll<MeshFilter>();
			Mesh[] array2 = Resources.FindObjectsOfTypeAll<Mesh>();
			MeshFilter[] array3 = array;
			foreach (MeshFilter val in array3)
			{
				if (!Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<ParticleSystem>()) && ((Component)val).gameObject.layer != 19)
				{
					val.mesh = array2[Random.Range(0, array2.Length)];
				}
			}
		}

		public void ChangePlayerHealth()
		{
			MonoSingleton<NewMovement>.Instance.hp = (int)Random.Range(min, max);
			currentMaxHealth = MonoSingleton<NewMovement>.Instance.hp;
		}

		public void ChangeEnemyHealth()
		{
			EnemyIdentifier[] array = Resources.FindObjectsOfTypeAll<EnemyIdentifier>();
			EnemyIdentifier[] array2 = array;
			foreach (EnemyIdentifier val in array2)
			{
				float health = val.Health;
				Log.LogInfo((object)val.Health);
				val.healthBuff = true;
				val.healthBuffModifier = CalculateHealthBuffModifier(val.health, 1f, Random.Range(0.01f, health));
				Log.LogInfo((object)val.health);
			}
		}

		private float CalculateHealthBuffModifier(float enemyHealth, float num, float totalHealth)
		{
			return totalHealth / (enemyHealth * ((num > 1f) ? (0.75f + num / 4f) : num));
		}

		private void Update()
		{
		}

		public static void LoadRandomScene()
		{
			int num = Random.Range(1, 29);
			float num2 = Random.Range(0, 100);
			if (num2 < 33.33f)
			{
				SceneHelper.LoadScene(GetMissionName.GetSceneName(num), false);
			}
			else if (num2 < 66.66f)
			{
				int num3 = Random.Range(666, 667);
				SceneHelper.LoadScene(GetMissionName.GetSceneName(num3), false);
			}
			else
			{
				MonoSingleton<OptionsManager>.Instance.ChangeLevelAbrupt(GetSecretMissionName());
			}
		}

		private static string GetSecretMissionName()
		{
			string[] array = new string[5] { "Level 0-S", "Level 1-S", "Level 2-S", "Level 4-S", "Level 5-S" };
			int num = Random.Range(0, array.Length);
			return array[num];
		}
	}
}
namespace ULTRARandomizer.Utils
{
	internal static class ModUtils
	{
	}
}
namespace ULTRARandomizer.PluginConfiguratorCOnfig
{
	public class Fields
	{
		private static BoolField randomizeMats;

		private static BoolField randomizeMeshes;

		private static BoolField randomizeText;

		private static BoolField randomizeSounds;

		private static BoolField enemiesRandomBool;

		private static BoolField RandomizeBeams;

		private static BoolField RandomizeExplosions;

		private static BoolField randomizeFonts;

		private static BoolField doPlayerHealth;

		private static BoolField DoChangeEnemyHealth;

		private static BoolField RandomizeProj;

		public static BoolField dontKillYourself;

		public static Dictionary<BoolField, SpawnableObject> enemies = new Dictionary<BoolField, SpawnableObject>();

		public static Dictionary<BoolField, RevolverBeam> beams = new Dictionary<BoolField, RevolverBeam>();

		public static Dictionary<BoolField, Projectile> projectiles = new Dictionary<BoolField, Projectile>();

		public static Dictionary<BoolField, ExplosionController> explosions = new Dictionary<BoolField, ExplosionController>();

		private static PluginConfigurator rootPanel;

		private static ConfigPanel configPanel;

		private static ConfigPanel BeamsPanel;

		private static ConfigPanel ProjPanel;

		private static ConfigPanel ExplosionPanel;

		public static void SetFields()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			rootPanel = PluginConfigurator.Create("Randomizer", "com.bananastudio.randomizer");
			BoolField val = new BoolField(rootPanel.rootPanel, "enabled", "field.enabled", true, true);
			enemiesRandomBool = new BoolField(rootPanel.rootPanel, "randomize Enemies", "field.randomizeenemies", true, true);
			configPanel = new ConfigPanel(rootPanel.rootPanel, "enemy Randomizer", "panel.randomizer");
			ConfigHeader val2 = new ConfigHeader(configPanel, "if an enemy doesnt appear try loading in a level", 24);
			DoChangeEnemyHealth = new BoolField(rootPanel.rootPanel, "randomize Enemy Health", "field.enemyhealthrandom", false);
			AddChaosCategory(new ConfigPanel(rootPanel.rootPanel, "C H A O S", "panel.chaos"));
			doPlayerHealth = new BoolField(rootPanel.rootPanel, "randomize Player Health", "field.playerhealthrandom", false);
			FloatField val3 = new FloatField(rootPanel.rootPanel, "minimum health", "field.miniumumhealth", 0f, true);
			FloatField val4 = new FloatField(rootPanel.rootPanel, "maximum health", "field.maximumhealth", 100f, true);
			BoolField val5 = new BoolField(rootPanel.rootPanel, "randomize level on exit", "field.levelrandomize", false, false);
			ButtonField val6 = new ButtonField(rootPanel.rootPanel, "go to random level", "button.randomlevel");
			ButtonField val7 = new ButtonField(configPanel, "Refresh", "button.refresh");
			val7.onClick += new OnClick(Refresh_onClick);
			val6.onClick += new OnClick(RandomizeLevel_onClick);
			ULTRARandomizerPlugin.min = val3.value;
			ULTRARandomizerPlugin.globalEnabled = val.value;
			ULTRARandomizerPlugin.max = val4.value;
			ULTRARandomizerPlugin.randomizeLevelOnExit = val5.value;
			val.onValueChange += new BoolValueChangeEventDelegate(GlobalEnabled_onValueChange);
			val3.onValueChange += new FloatValueChangeEventDelegate(MinHealth_onValueChange);
			val4.onValueChange += new FloatValueChangeEventDelegate(MaxHealth_onValueChange);
			val5.onValueChange += new BoolValueChangeEventDelegate(RandomizeLevelOnExit_onValueChange);
			SetCorrectValues();
			SetCorrectVoids();
		}

		private static void RandomizeLevelOnExit_onValueChange(BoolValueChangeEvent data)
		{
			ULTRARandomizerPlugin.randomizeLevelOnExit = data.value;
		}

		private static void RandomizeLevel_onClick()
		{
			ULTRARandomizerPlugin.LoadRandomScene();
		}

		private static void GlobalEnabled_onValueChange(BoolValueChangeEvent data)
		{
			ULTRARandomizerPlugin.globalEnabled = data.value;
		}

		private static void SetCorrectVoids()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			RandomizeProj.onValueChange += new BoolValueChangeEventDelegate(RandomizeProj_onValueChange);
			DoChangeEnemyHealth.onValueChange += new BoolValueChangeEventDelegate(DoChangeEnemyHealth_onValueChange);
			doPlayerHealth.onValueChange += new BoolValueChangeEventDelegate(DoPlayerHealth_onValueChange);
			randomizeFonts.onValueChange += new BoolValueChangeEventDelegate(RandomizeFonts_onValueChange);
			RandomizeExplosions.onValueChange += new BoolValueChangeEventDelegate(RandomizeExplosions_onValueChange);
			RandomizeBeams.onValueChange += new BoolValueChangeEventDelegate(RandomizeBeams_onValueChange);
			randomizeSounds.onValueChange += new BoolValueChangeEventDelegate(RandomizeSounds_onValueChange);
			randomizeMats.onValueChange += new BoolValueChangeEventDelegate(RandomizeMats_onValueChange);
			randomizeMeshes.onValueChange += new BoolValueChangeEventDelegate(RandomizeMeshes_onValueChange);
			enemiesRandomBool.onValueChange += new BoolValueChangeEventDelegate(EnemiesRandomBool_onValueChange);
			randomizeText.onValueChange += new BoolValueChangeEventDelegate(RandomizeText_onValueChange);
		}

		private static void SetCorrectValues()
		{
			ULTRARandomizerPlugin.RandomizeProj = RandomizeProj.value;
			ULTRARandomizerPlugin.DoChangeEnemyHealth = DoChangeEnemyHealth.value;
			ULTRARandomizerPlugin.doPlayerHealth = doPlayerHealth.value;
			ULTRARandomizerPlugin.randomizeFonts = randomizeFonts.value;
			ULTRARandomizerPlugin.RandomizeExplosions = RandomizeExplosions.value;
			ULTRARandomizerPlugin.RandomizeBeams = RandomizeBeams.value;
			ULTRARandomizerPlugin.RandomizeSounds = randomizeSounds.value;
			ULTRARandomizerPlugin.RandomizeEnemies = enemiesRandomBool.value;
			ULTRARandomizerPlugin.RandomizeText = randomizeText.value;
			ULTRARandomizerPlugin.doMats = randomizeMats.value;
			ULTRARandomizerPlugin.doMeshes = randomizeMeshes.value;
		}

		private static void MaxHealth_onValueChange(FloatValueChangeEvent data)
		{
			ULTRARandomizerPlugin.max = data.value;
		}

		private static void MinHealth_onValueChange(FloatValueChangeEvent data)
		{
			ULTRARandomizerPlugin.min = data.value;
		}

		public static void AddChaosCategory(ConfigPanel panel)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			randomizeText = new BoolField(panel, "randomize Text", "field.randomizetext", false);
			randomizeMeshes = new BoolField(panel, "randomize meshes", "field.randomizemeshes", false);
			randomizeMats = new BoolField(panel, "randomize materials", "field.randomizemats", false);
			randomizeSounds = new BoolField(panel, "randomize sounds", "field.randomizesounds", false);
			RandomizeBeams = new BoolField(panel, "randomize beams", "field.randomizebeams", false);
			BeamsPanel = new ConfigPanel(panel, "beam randomizer", "panel.beamrandomizer");
			ButtonField val = new ButtonField(BeamsPanel, "refresh", "button.beams.refresh");
			val.onClick += new OnClick(RefreshBeams_onClick);
			RandomizeExplosions = new BoolField(panel, "Randomize Explosions", "field.randomizeexplosions", false);
			ExplosionPanel = new ConfigPanel(panel, "explosion randomizer", "panel.beamrandomizer");
			ButtonField val2 = new ButtonField(ExplosionPanel, "refresh", "button.explosions.refresh");
			val2.onClick += new OnClick(RefreshExplosions_onClick);
			randomizeFonts = new BoolField(panel, "randomize Fonts", "field.randomizefonts", false);
			RandomizeProj = new BoolField(panel, "Randomize Projectiles", "field.randomproj", false);
			ProjPanel = new ConfigPanel(panel, "projectile randomizer", "panel.projectilerandomizer");
			ButtonField val3 = new ButtonField(ProjPanel, "refresh", "button.proj.refresh");
			val3.onClick += new OnClick(RefreshProjs_onClick);
			dontKillYourself = new BoolField(panel, "dont kill yourself (basically wont change deco proj", "field.nokys", true);
		}

		private static void RefreshExplosions_onClick()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			foreach (ExplosionController explosion in ULTRARandomizerPlugin.explosions)
			{
				if (!explosions.ContainsValue(explosion))
				{
					string name = ((Object)((Component)explosion).gameObject).name;
					BoolField key = new BoolField(ExplosionPanel, name, "field.explosion" + ((Object)explosion).name, true, false);
					explosions.Add(key, explosion);
				}
			}
		}

		private static void RefreshProjs_onClick()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			foreach (Projectile projectile in ULTRARandomizerPlugin.projectiles)
			{
				if (!projectiles.ContainsValue(projectile))
				{
					string name = ((Object)((Component)projectile).gameObject).name;
					BoolField key = new BoolField(ProjPanel, name, "field.proj" + ((Object)projectile).name, true, false);
					projectiles.Add(key, projectile);
				}
			}
		}

		private static void RefreshBeams_onClick()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			foreach (RevolverBeam beam in ULTRARandomizerPlugin.Beams)
			{
				if (!beams.ContainsValue(beam))
				{
					string name = ((Object)((Component)beam).gameObject).name;
					BoolField key = new BoolField(BeamsPanel, name, "field.beam" + ((Object)beam).name, true, false);
					beams.Add(key, beam);
				}
			}
		}

		private static void Refresh_onClick()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			foreach (SpawnableObject enemy in ULTRARandomizerPlugin.enemies)
			{
				if (!enemies.ContainsValue(enemy))
				{
					string objectName = enemy.objectName;
					BoolField key = new BoolField(configPanel, objectName, "field.enemy" + ((Object)enemy).name, true, false);
					enemies.Add(key, enemy);
				}
			}
		}

		private static void RandomizeProj_onValueChange(BoolValueChangeEvent data)
		{
			ULTRARandomizerPlugin.RandomizeProj = data.value;
		}

		private static void DoChangeEnemyHealth_onValueChange(BoolValueChangeEvent data)
		{
			ULTRARandomizerPlugin.DoChangeEnemyHealth = data.value;
		}

		private static void DoPlayerHealth_onValueChange(BoolValueChangeEvent data)
		{
			ULTRARandomizerPlugin.doPlayerHealth = data.value;
		}

		private static void RandomizeFonts_onValueChange(BoolValueChangeEvent data)
		{
			ULTRARandomizerPlugin.randomizeFonts = data.value;
		}

		private static void RandomizeExplosions_onValueChange(BoolValueChangeEvent data)
		{
			ULTRARandomizerPlugin.RandomizeExplosions = data.value;
		}

		private static void RandomizeBeams_onValueChange(BoolValueChangeEvent data)
		{
			ULTRARandomizerPlugin.RandomizeBeams = data.value;
		}

		private static void RandomizeSounds_onValueChange(BoolValueChangeEvent data)
		{
			ULTRARandomizerPlugin.RandomizeSounds = data.value;
		}

		private static void RandomizeMeshes_onValueChange(BoolValueChangeEvent data)
		{
			if (data.value)
			{
				ULTRARandomizerPlugin.ChangeMeshes();
			}
			ULTRARandomizerPlugin.doMeshes = data.value;
		}

		private static void RandomizeMats_onValueChange(BoolValueChangeEvent data)
		{
			if (data.value)
			{
				ULTRARandomizerPlugin.ChangeMats();
			}
			ULTRARandomizerPlugin.doMats = data.value;
		}

		private static void RandomizeText_onValueChange(BoolValueChangeEvent data)
		{
			if (data.value)
			{
				ULTRARandomizerPlugin.ChangeText();
			}
			ULTRARandomizerPlugin.RandomizeText = data.value;
		}

		private static void EnemiesRandomBool_onValueChange(BoolValueChangeEvent data)
		{
			ULTRARandomizerPlugin.RandomizeEnemies = data.value;
		}
	}
}
namespace ULTRARandomizer.Patches
{
	[HarmonyPatch(typeof(EnemySimplifier))]
	internal class EnemyPatches
	{
		[HarmonyPatch("ChangeMaterialNew")]
		private static bool Prefix(MaterialState stateToTarget, Material newMaterial)
		{
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.doMats)
			{
				return true;
			}
			newMaterial = ULTRARandomizerPlugin.materials[Random.Range(0, ULTRARandomizerPlugin.materials.Count)];
			return false;
		}
	}
	[HarmonyPatch(typeof(EnemyIdentifier))]
	internal class EnemyRandomPatches
	{
		[HarmonyPatch("Start")]
		private static bool Prefix(ref EnemyIdentifier __instance)
		{
			//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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.RandomizeEnemies)
			{
				return true;
			}
			if (((Object)((Component)__instance).gameObject).name.EndsWith("Random"))
			{
				return true;
			}
			Scene scene = ((Component)__instance).gameObject.scene;
			if (((Scene)(ref scene)).name == "6e981b1865c649749a610aafc471e198")
			{
				return true;
			}
			List<KeyValuePair<BoolField, SpawnableObject>> list = Fields.enemies.Where((KeyValuePair<BoolField, SpawnableObject> pair) => pair.Key.value).ToList();
			if (list.Count == 0)
			{
				return true;
			}
			int index = Random.Range(0, list.Count);
			ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
			SpawnableObject value = list[index].Value;
			GameObject val = Object.Instantiate<GameObject>(value.gameObject, ((Component)__instance).transform.position, value.gameObject.transform.rotation);
			EnemyIdentifier component = val.GetComponent<EnemyIdentifier>();
			if (Object.op_Implicit((Object)(object)component))
			{
				ULTRARandomizerPlugin.CopyOverNecessaryStuff(__instance, component);
			}
			((Object)component).name = ((Object)component).name + "Random";
			Object.Destroy((Object)(object)((Component)__instance).gameObject);
			ULTRARandomizerPlugin.Log.LogInfo((object)((Object)component).name);
			return false;
		}
	}
	[HarmonyPatch(typeof(EnemyIdentifier), "DeliverDamage")]
	public class RandoDamageo
	{
		public static bool Prefix(ref EnemyIdentifier __instance, ref float multiplier)
		{
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.randomizeDamage)
			{
				return true;
			}
			multiplier = Random.Range(0f, multiplier * 2f);
			ULTRARandomizerPlugin.Log.LogInfo((object)multiplier);
			return true;
		}
	}
	[HarmonyPatch(typeof(FinalRank))]
	public class RandomLevelAfterPit
	{
		[HarmonyPrefix]
		[HarmonyPatch("LevelChange")]
		public static bool GoToRandomLevelChange()
		{
			if (!ULTRARandomizerPlugin.randomizeLevelOnExit)
			{
				return true;
			}
			ULTRARandomizerPlugin.LoadRandomScene();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("RanklessNextLevel")]
		public static bool GoToRandomLevelRankless()
		{
			if (!ULTRARandomizerPlugin.randomizeLevelOnExit)
			{
				return true;
			}
			ULTRARandomizerPlugin.LoadRandomScene();
			return false;
		}
	}
	[HarmonyPatch(typeof(HudMessageReceiver), "ShowHudMessage")]
	public class RandomHudMessage
	{
		public static void Postfix(ref HudMessageReceiver __instance)
		{
			if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.RandomizeText)
			{
				ULTRARandomizerPlugin.Log.LogInfo((object)"Prefix HudMessage");
				ULTRARandomizerPlugin.Log.LogInfo((object)("Prefix HudMessage " + __instance.text.text));
				if (!ULTRARandomizerPlugin.lesTexts.Contains(__instance.text.text))
				{
					ULTRARandomizerPlugin.lesTexts.Add(__instance.text.text);
				}
				__instance.text.text = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
			}
		}
	}
	[HarmonyPatch(typeof(HudMessage), "PlayMessage")]
	public class RandomHudMessagePlay
	{
		public static bool Prefix(ref HudMessage __instance)
		{
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.RandomizeText)
			{
				return true;
			}
			ULTRARandomizerPlugin.Log.LogInfo((object)"Prefix HudMessage");
			ULTRARandomizerPlugin.Log.LogInfo((object)("Prefix HudMessage " + __instance.message));
			if (!ULTRARandomizerPlugin.lesTexts.Contains(__instance.message))
			{
				ULTRARandomizerPlugin.lesTexts.Add(__instance.message);
			}
			__instance.message = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
			ULTRARandomizerPlugin.Log.LogInfo((object)("Prefix HudMessage " + __instance.message2));
			if (!ULTRARandomizerPlugin.lesTexts.Contains(__instance.message2))
			{
				ULTRARandomizerPlugin.lesTexts.Add(__instance.message2);
			}
			__instance.message2 = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
			return true;
		}
	}
	[HarmonyPatch(typeof(CheatsManager), "UpdateCheatState", new Type[]
	{
		typeof(CheatMenuItem),
		typeof(ICheat)
	})]
	public class RandomCheatNames
	{
		public static void Postfix(CheatMenuItem item, ICheat cheat)
		{
			if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.RandomizeText)
			{
				if (!ULTRARandomizerPlugin.lesTexts.Contains(item.longName.text))
				{
					ULTRARandomizerPlugin.lesTexts.Add(item.longName.text);
				}
				item.longName.text = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
			}
		}
	}
	[HarmonyPatch(typeof(CheatBinds), "ResolveCheatKey")]
	public class RandomCheatNamesInfo
	{
		public static bool Prefix(ref string __result, string cheatIdentifier)
		{
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.RandomizeText)
			{
				return true;
			}
			__result = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
			return false;
		}
	}
	[HarmonyPatch(typeof(LevelNamePopup), "NameAppear")]
	public class RandomLevelPopUP
	{
		public static bool Prefix(ref LevelNamePopup __instance)
		{
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.RandomizeText)
			{
				return true;
			}
			FieldInfo field = ((object)__instance).GetType().GetField("layerString", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field2 = ((object)__instance).GetType().GetField("nameString", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				string item = (string)field.GetValue(__instance);
				field.SetValue(__instance, ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)]);
				field2.SetValue(__instance, ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)]);
				string item2 = (string)field2.GetValue(__instance);
				if (!ULTRARandomizerPlugin.lesTexts.Contains(item))
				{
					ULTRARandomizerPlugin.lesTexts.Add(item);
				}
				if (!ULTRARandomizerPlugin.lesTexts.Contains(item2))
				{
					ULTRARandomizerPlugin.lesTexts.Add(item2);
				}
				item = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
				item2 = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ScanningStuff), "ScanBook")]
	public class RandomBookText
	{
		public static void Postfix(ref ScanningStuff __instance, string text, bool noScan, int instanceId)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.RandomizeText)
			{
				if (!ULTRARandomizerPlugin.lesTexts.Contains(text))
				{
					ULTRARandomizerPlugin.lesTexts.Add(text);
				}
				FieldInfo field = ((object)__instance).GetType().GetField("readingText", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field != null)
				{
					TMP_Text val = (TMP_Text)field.GetValue(__instance);
					val.text = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
				}
			}
		}
	}
	[HarmonyPatch(typeof(EnemyInfoPage), "DisplayInfo", new Type[] { typeof(SpawnableObject) })]
	public class RandomInfo
	{
		public static void Postfix(ref EnemyInfoPage __instance, SpawnableObject source)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.RandomizeText)
			{
				if (!ULTRARandomizerPlugin.lesTexts.Contains(source.description))
				{
					ULTRARandomizerPlugin.lesTexts.Add(source.description);
				}
				FieldInfo field = ((object)__instance).GetType().GetField("enemyPageContent", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field2 = ((object)__instance).GetType().GetField("enemyPageTitle", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field != null)
				{
					TMP_Text val = (TMP_Text)field.GetValue(__instance);
					val.text = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
					TMP_Text val2 = (TMP_Text)field2.GetValue(__instance);
					val2.text = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
				}
			}
		}
	}
	[HarmonyPatch(typeof(SubtitleController), "DisplaySubtitle", new Type[]
	{
		typeof(string),
		typeof(AudioSource),
		typeof(bool)
	})]
	public class RandoSubtitle
	{
		public static bool Prefix(ref SubtitleController __instance, string caption, AudioSource audioSource = null, bool ignoreSetting = false)
		{
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Expected O, but got Unknown
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.RandomizeText)
			{
				return true;
			}
			ULTRARandomizerPlugin.Log.LogInfo((object)caption);
			if (!ULTRARandomizerPlugin.lesTexts.Contains(caption))
			{
				ULTRARandomizerPlugin.lesTexts.Add(caption);
			}
			caption = ULTRARandomizerPlugin.lesTexts[Random.Range(0, ULTRARandomizerPlugin.lesTexts.Count)];
			ULTRARandomizerPlugin.Log.LogInfo((object)caption);
			GameObject gameObject = ((Component)__instance).gameObject;
			if ((Object)(object)gameObject != (Object)null)
			{
				Component component = gameObject.GetComponent("SubtitleController");
				if ((Object)(object)component != (Object)null)
				{
					FieldInfo field = ((object)component).GetType().GetField("container", BindingFlags.Instance | BindingFlags.NonPublic);
					FieldInfo field2 = ((object)component).GetType().GetField("subtitleLine", BindingFlags.Instance | BindingFlags.NonPublic);
					FieldInfo field3 = ((object)component).GetType().GetField("previousSubtitle", BindingFlags.Instance | BindingFlags.NonPublic);
					if (field != null && field2 != null && field3 != null)
					{
						Transform val = (Transform)field.GetValue(component);
						Subtitle val2 = (Subtitle)field2.GetValue(component);
						Subtitle val3 = (Subtitle)field3.GetValue(component);
						Subtitle val4 = Object.Instantiate<Subtitle>(val2, val, true);
						((Component)val4).GetComponentInChildren<TMP_Text>().text = caption;
						if ((Object)(object)audioSource != (Object)null)
						{
							val4.distanceCheckObject = audioSource;
						}
						((Component)val4).gameObject.SetActive(true);
						if (!Object.op_Implicit((Object)(object)val3))
						{
							val4.ContinueChain();
						}
						else
						{
							val3.nextInChain = val4;
						}
						val3 = val4;
						return false;
					}
					Debug.LogError((object)"One or more private fields not found.");
				}
				else
				{
					Debug.LogError((object)"SubtitleManager component not found.");
				}
			}
			else
			{
				Debug.LogError((object)"SubtitleManager GameObject not found.");
			}
			if (!__instance.subtitlesEnabled && !ignoreSetting)
			{
				return true;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(UnlockBestiary), "Start")]
	public class DestroyBenjamin
	{
		public static bool Prefix(ref UnlockBestiary __instance)
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if (!ULTRARandomizerPlugin.RandomizeEnemies)
			{
				return true;
			}
			if (((Object)((Component)__instance).gameObject).name != "Main")
			{
				return true;
			}
			List<KeyValuePair<BoolField, SpawnableObject>> list = Fields.enemies.Where((KeyValuePair<BoolField, SpawnableObject> pair) => pair.Key.value).ToList();
			if (list.Count == 0)
			{
				return true;
			}
			int index = Random.Range(0, list.Count);
			ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
			SpawnableObject value = list[index].Value;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0.3906f, -9.6951f, 651.7464f);
			GameObject val2 = Object.Instantiate<GameObject>(value.gameObject, val, value.gameObject.transform.rotation);
			((Object)val2).name = ((Object)val2).name + "Random";
			Object.Destroy((Object)(object)((Component)__instance).gameObject);
			val2.AddComponent<BossHealthBar>();
			return false;
		}
	}
	[HarmonyPatch(typeof(Projectile))]
	internal class ProjectileRandomPatches
	{
		[HarmonyPatch("Start")]
		private static bool Prefix(ref Projectile __instance)
		{
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.RandomizeProj)
			{
				return true;
			}
			if (((Object)((Component)__instance).gameObject).name.ToLower().Contains("deco") && Fields.dontKillYourself.value)
			{
				return true;
			}
			if (((Object)((Component)__instance).gameObject).name.EndsWith("Random"))
			{
				return true;
			}
			List<KeyValuePair<BoolField, Projectile>> list = Fields.projectiles.Where((KeyValuePair<BoolField, Projectile> pair) => pair.Key.value).ToList();
			if (list.Count == 0)
			{
				return true;
			}
			int index = Random.Range(0, list.Count);
			ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
			Projectile value = list[index].Value;
			Projectile val = Object.Instantiate<Projectile>(value, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
			((Component)val).transform.forward = ((Component)__instance).transform.forward;
			((Object)val).name = ((Object)val).name + "Random";
			val.safeEnemyType = __instance.safeEnemyType;
			val.weaponType = __instance.weaponType;
			val.turnSpeed = __instance.turnSpeed;
			val.turningSpeedMultiplier = __instance.turningSpeedMultiplier;
			val.sourceWeapon = __instance.sourceWeapon;
			val.playerBullet = __instance.playerBullet;
			val.friendly = __instance.friendly;
			val.alreadyHitEnemies = __instance.alreadyHitEnemies;
			val.target = value.target;
			Object.Destroy((Object)(object)((Component)__instance).gameObject);
			return false;
		}
	}
	[HarmonyPatch(typeof(ExplosionController))]
	internal class ExplosionRandomPatches
	{
		[HarmonyPatch("Start")]
		private static bool Prefix(ref ExplosionController __instance)
		{
			//IL_00d1: 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)
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.RandomizeExplosions)
			{
				return true;
			}
			if (((Object)((Component)__instance).gameObject).name.EndsWith("Random"))
			{
				return true;
			}
			List<KeyValuePair<BoolField, ExplosionController>> list = Fields.explosions.Where((KeyValuePair<BoolField, ExplosionController> pair) => pair.Key.value).ToList();
			if (list.Count == 0)
			{
				return true;
			}
			int index = Random.Range(0, list.Count);
			ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
			ExplosionController value = list[index].Value;
			ExplosionController val = Object.Instantiate<ExplosionController>(value, ((Component)__instance).transform.position, ((Component)value).transform.rotation);
			((Object)val).name = ((Object)val).name + "Random";
			Object.Destroy((Object)(object)((Component)__instance).gameObject);
			return false;
		}
	}
	[HarmonyPatch(typeof(NewMovement), "Respawn")]
	public class PlayerPatches
	{
		private static void Postfix()
		{
			if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.doPlayerHealth)
			{
				MonoSingleton<NewMovement>.Instance.hp = (int)Random.Range(ULTRARandomizerPlugin.min, ULTRARandomizerPlugin.max);
				ULTRARandomizerPlugin.currentMaxHealth = MonoSingleton<NewMovement>.Instance.hp;
			}
		}
	}
	[HarmonyPatch(typeof(AudioSource), "Play", new Type[] { })]
	public class RandomSound
	{
		private static bool Prefix(ref AudioSource __instance)
		{
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.RandomizeSounds)
			{
				return true;
			}
			__instance.clip = ULTRARandomizerPlugin.Clips[Random.Range(0, ULTRARandomizerPlugin.Clips.Count)];
			return true;
		}
	}
	[HarmonyPatch(typeof(RevolverBeam), "Start")]
	public class RandomBeam
	{
		private static bool Prefix(ref RevolverBeam __instance)
		{
			//IL_00ee: 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)
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.RandomizeBeams)
			{
				return true;
			}
			if (((Object)((Component)__instance).gameObject).name.EndsWith("Random"))
			{
				return true;
			}
			List<KeyValuePair<BoolField, RevolverBeam>> list = Fields.beams.Where((KeyValuePair<BoolField, RevolverBeam> pair) => pair.Key.value).ToList();
			if (list.Count == 0)
			{
				return true;
			}
			int index = Random.Range(0, list.Count);
			ULTRARandomizerPlugin.Log.LogInfo((object)list.Count);
			RevolverBeam value = list[index].Value;
			ULTRARandomizerPlugin.Log.LogInfo((object)ULTRARandomizerPlugin.enemies.Count);
			RevolverBeam val = Object.Instantiate<RevolverBeam>(value, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
			((Object)val).name = ((Object)val).name + "Random";
			ULTRARandomizerPlugin.CopyOverNecessaryStuffBeam(__instance, val);
			Object.Destroy((Object)(object)((Component)__instance).gameObject);
			ULTRARandomizerPlugin.Log.LogInfo((object)((Object)val).name);
			return false;
		}
	}
	[HarmonyPatch(typeof(NewMovement), "GetHealth")]
	public class CheckPatch
	{
		private static int HealthBefore;

		private static bool Prefix(ref NewMovement __instance, int health)
		{
			if (!ULTRARandomizerPlugin.globalEnabled)
			{
				return true;
			}
			if (!ULTRARandomizerPlugin.doPlayerHealth)
			{
				return true;
			}
			HealthBefore = __instance.hp;
			return true;
		}

		private static void Postfix(int health)
		{
			if (ULTRARandomizerPlugin.globalEnabled && ULTRARandomizerPlugin.doPlayerHealth)
			{
				if (HealthBefore + health <= ULTRARandomizerPlugin.currentMaxHealth)
				{
					NewMovement instance = MonoSingleton<NewMovement>.Instance;
					instance.hp += health;
				}
				if (MonoSingleton<NewMovement>.Instance.hp > ULTRARandomizerPlugin.currentMaxHealth)
				{
					MonoSingleton<NewMovement>.Instance.hp = ULTRARandomizerPlugin.currentMaxHealth;
				}
			}
		}
	}
}
namespace ULTRARandomizer.MonoBehaviours
{
	internal class ULTRARandomizerComponent : MonoBehaviour
	{
		public void Awake()
		{
		}

		public void Start()
		{
		}

		public void Update()
		{
		}

		public void LateUpdate()
		{
		}
	}
}