Decompiled source of Virga v1.0.5

ChallengeMode.dll

Decompiled 11 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ChallengeMode.Buffs;
using ChallengeMode.CharacterMasters;
using ChallengeMode.Interactables;
using ChallengeMode.Modifiers;
using ChallengeMode.Modifiers.Special;
using ChallengeMode.Modifiers.Unique;
using ChallengeMode.PostProcessing;
using EntityStates;
using EntityStates.BrotherMonster;
using EntityStates.BrotherMonster.Weapon;
using EntityStates.LunarWisp;
using EntityStates.Missions.BrotherEncounter;
using EntityStates.Turret1;
using EntityStates.VoidRaidCrab;
using EntityStates.VoidRaidCrab.Weapon;
using HG;
using HG.Reflection;
using IL.RoR2;
using KinematicCharacterController;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using MysticsRisky2Utils;
using MysticsRisky2Utils.BaseAssetTypes;
using MysticsRisky2Utils.ContentManagement;
using MysticsRisky2Utils.SoftDependencies;
using On.EntityStates;
using On.EntityStates.BrotherMonster;
using On.EntityStates.BrotherMonster.Weapon;
using On.EntityStates.Missions.BrotherEncounter;
using On.EntityStates.VoidRaidCrab;
using On.EntityStates.VoidRaidCrab.Weapon;
using On.RoR2;
using On.RoR2.Projectile;
using On.RoR2.UI;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using Rewired;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Artifacts;
using RoR2.Audio;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Hologram;
using RoR2.Navigation;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using RoR2.UI.SkinControllers;
using TMPro;
using ThreeEyedGames;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering.PostProcessing;
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: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("ChallengeMode")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ChallengeMode")]
[assembly: AssemblyTitle("ChallengeMode")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ChallengeMode
{
	public class BrotherEXAssets : BaseLoadableAsset
	{
		public class ChallengeModeSkyLeapHomingController : MonoBehaviour
		{
			public CharacterBody body;

			public GameObject warningCircle;

			public Transform warningCircleTransform;

			public float leapAcceleration = 40f;

			public float leapMaxSpeed = 30f;

			public Vector3 leapSpeed = Vector3.zero;

			public Vector3 homingPosition = Vector3.zero;

			private Vector3 spareVector = Vector3.zero;

			public void Start()
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				warningCircle = Object.Instantiate<GameObject>(leapWarningCircle, new Vector3(((Component)this).transform.position.x, 0f, ((Component)this).transform.position.z), Quaternion.identity);
				warningCircleTransform = warningCircle.transform;
			}

			public void FixedUpdate()
			{
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: 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)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0165: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_020a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0214: Unknown result type (might be due to invalid IL or missing references)
				//IL_0219: Unknown result type (might be due to invalid IL or missing references)
				//IL_021e: Unknown result type (might be due to invalid IL or missing references)
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0260: Unknown result type (might be due to invalid IL or missing references)
				//IL_0287: Unknown result type (might be due to invalid IL or missing references)
				//IL_029d: Unknown result type (might be due to invalid IL or missing references)
				//IL_02af: Unknown result type (might be due to invalid IL or missing references)
				//IL_0248: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)body) && body.master.aiComponents.Length != 0 && body.master.aiComponents[0].currentEnemy != null)
				{
					homingPosition = body.master.aiComponents[0].currentEnemy.lastKnownBullseyePosition.Value;
					homingPosition.y = 0f;
				}
				Vector3 position = ((Component)this).transform.position;
				position.y = 0f;
				Vector3 val = leapSpeed;
				Vector3 val2 = homingPosition - position;
				leapSpeed = val + ((Vector3)(ref val2)).normalized * leapAcceleration * Time.fixedDeltaTime;
				if (Mathf.Abs(leapSpeed.x) > leapMaxSpeed)
				{
					leapSpeed.x = Mathf.Sign(leapSpeed.x) * leapMaxSpeed;
				}
				if (Mathf.Abs(leapSpeed.z) > leapMaxSpeed)
				{
					leapSpeed.z = Mathf.Sign(leapSpeed.z) * leapMaxSpeed;
				}
				Transform transform = ((Component)this).transform;
				transform.position += leapSpeed * Time.fixedDeltaTime;
				if (Object.op_Implicit((Object)(object)body) && body.hasEffectiveAuthority)
				{
					((BaseCharacterController)body.characterMotor).Motor.SetPosition(new Vector3(((Component)this).transform.position.x, body.transform.position.y, ((Component)this).transform.position.z), true);
				}
				float y = 491f;
				RaycastHit val3 = default(RaycastHit);
				if (Physics.Raycast(new Ray(new Vector3(((Component)this).transform.position.x, 560f, ((Component)this).transform.position.z), Vector3.down), ref val3, 500f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)0))
				{
					y = ((RaycastHit)(ref val3)).point.y;
				}
				spareVector.x = ((Component)this).transform.position.x;
				spareVector.y = y;
				spareVector.z = ((Component)this).transform.position.z;
				((Component)this).transform.position = spareVector;
				warningCircleTransform.position = spareVector;
			}

			public void OnEnable()
			{
				InstanceTracker.Add<ChallengeModeSkyLeapHomingController>(this);
			}

			public void OnDisable()
			{
				InstanceTracker.Remove<ChallengeModeSkyLeapHomingController>(this);
			}

			public void OnDestroy()
			{
				if (Object.op_Implicit((Object)(object)warningCircle))
				{
					Object.Destroy((Object)(object)warningCircle);
				}
			}
		}

		public static GameObject arenaEffectsPrefab;

		public static ModdedDamageType destroyItemDamageType;

		public static SkillDef playerStunLockedSkill;

		public static GameObject skyLeapHomingController;

		public static GameObject leapWarningCircle;

		public override void OnPluginAwake()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			((BaseLoadableAsset)this).OnPluginAwake();
			destroyItemDamageType = DamageAPI.ReserveDamageType();
			skyLeapHomingController = Utils.CreateBlankPrefab("ChallengeMode_SkyLeapHomingController", true);
			skyLeapHomingController.AddComponent<NetworkTransform>();
			skyLeapHomingController.GetComponent<NetworkIdentity>().localPlayerAuthority = true;
			skyLeapHomingController.AddComponent<ChallengeModeSkyLeapHomingController>();
		}

		public override void Load()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_015f: Expected O, but got Unknown
			arenaEffectsPrefab = ChallengeModePlugin.AssetBundle.LoadAsset<GameObject>("Assets/Mods/ChallengeMode/Modifiers/BrotherEX/BrotherEXArenaEffects.prefab");
			playerStunLockedSkill = ScriptableObject.CreateInstance<SkillDef>();
			playerStunLockedSkill.skillName = "ChallengeMode_StunLocked";
			playerStunLockedSkill.skillNameToken = "CHALLENGEMODE_SKILL_PLAYERSTUNLOCKED_NAME";
			playerStunLockedSkill.skillDescriptionToken = "CHALLENGEMODE_SKILL_PLAYERSTUNLOCKED_DESCRIPTION";
			playerStunLockedSkill.icon = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Engi/EngiCancelTargetingDummy.asset").WaitForCompletion().icon;
			playerStunLockedSkill.activationStateMachineName = "Weapon";
			playerStunLockedSkill.activationState = new SerializableEntityStateType(typeof(Idle));
			playerStunLockedSkill.interruptPriority = (InterruptPriority)0;
			playerStunLockedSkill.baseRechargeInterval = 0f;
			playerStunLockedSkill.baseMaxStock = 0;
			playerStunLockedSkill.rechargeStock = 0;
			playerStunLockedSkill.requiredStock = 0;
			playerStunLockedSkill.stockToConsume = 0;
			playerStunLockedSkill.resetCooldownTimerOnUse = false;
			playerStunLockedSkill.fullRestockOnAssign = false;
			playerStunLockedSkill.dontAllowPastMaxStocks = false;
			playerStunLockedSkill.beginSkillCooldownOnSkillEnd = false;
			playerStunLockedSkill.cancelSprintingOnActivation = false;
			playerStunLockedSkill.forceSprintDuringState = false;
			playerStunLockedSkill.canceledFromSprinting = false;
			playerStunLockedSkill.isCombatSkill = false;
			playerStunLockedSkill.mustKeyPress = true;
			ChallengeModeContent.Resources.skillDefs.Add(playerStunLockedSkill);
			GenericGameEvents.OnTakeDamage += new DamageReportEventHandler(GenericGameEvents_OnTakeDamage);
			leapWarningCircle = ChallengeModePlugin.AssetBundle.LoadAsset<GameObject>("Assets/Mods/ChallengeMode/Modifiers/BrotherEX/SkyLeapWarning.prefab");
			((BaseLoadableAsset)this).OnLoad();
			base.asset = arenaEffectsPrefab;
		}

		private static void GenericGameEvents_OnTakeDamage(DamageReport damageReport)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && DamageAPI.HasModdedDamageType(damageReport.damageInfo, destroyItemDamageType) && Object.op_Implicit((Object)(object)damageReport.victimMaster) && Object.op_Implicit((Object)(object)damageReport.victimMaster.inventory))
			{
				List<ItemDef> list = (from x in damageReport.victimMaster.inventory.itemAcquisitionOrder
					select ItemCatalog.GetItemDef(x) into x
					where (Object)(object)x != (Object)null && x.canRemove && !x.hidden
					select x).ToList();
				if (list.Count > 0)
				{
					ItemDef val = RoR2Application.rng.NextElementUniform<ItemDef>(list);
					damageReport.victimMaster.inventory.RemoveItem(val, 1);
					damageReport.victimMaster.inventory.GiveItem(Items.ScrapWhite, 1);
					CharacterMasterNotificationQueue.SendTransformNotification(damageReport.victimMaster, val.itemIndex, Items.ScrapWhite.itemIndex, (TransformationType)0);
				}
			}
		}
	}
	public static class ChallengeModeConfig
	{
		public static ConfigurableValue<int> modifiersPerStage = ConfigurableValue.CreateInt("com.themysticsword.challengemode", "Virga", ChallengeModePlugin.config, "General", "Random Modifiers", 3, 0, 5, "Amount of random modifiers to add", (List<string>)null, (ConfigEntry<bool>)null, false, (Action<int>)null);

		public static ConfigurableValue<float> uniqueModifierChance = ConfigurableValue.CreateFloat("com.themysticsword.challengemode", "Virga", ChallengeModePlugin.config, "General", "Stage Modifier Chance", 20f, 0f, 100f, "Chance for stage-unique modifiers to appear additionally on top of the random modifiers", (List<string>)null, (ConfigEntry<bool>)null, false, (Action<float>)null);

		public static ConfigurableValue<float> uniqueModifierRareChance = ConfigurableValue.CreateFloat("com.themysticsword.challengemode", "Virga", ChallengeModePlugin.config, "General", "Stage Modifier Rare Chance", 5f, 0f, 100f, "Same as Stage Modifier Chance, but for modifiers that appear very rarely in some other stages (for example, Frostbite can have 20% in Rallypoint Delta, and 5% in Siphoned Forest)", (List<string>)null, (ConfigEntry<bool>)null, false, (Action<float>)null);

		public static ConfigurableValue<float> specialModifierChance = ConfigurableValue.CreateFloat("com.themysticsword.challengemode", "Virga", ChallengeModePlugin.config, "General", "Boss Modifier Chance", 100f, 0f, 100f, "Chance for final boss modifiers to appear additionally on top of the random modifiers", (List<string>)null, (ConfigEntry<bool>)null, false, (Action<float>)null);

		public static ConfigurableValue<bool> permanentBrotherEX = ConfigurableValue.CreateBool("com.themysticsword.challengemode", "Virga", ChallengeModePlugin.config, "Permanent Toggles", "Mithrix EX", false, "Should the reworked Mithrix fight be active outside of the game mode? (Takes effect only if set before the run starts!)", (List<string>)null, (ConfigEntry<bool>)null, false, (Action<bool>)null);

		public static ConfigurableValue<bool> permanentVoidRaidCrabEX = ConfigurableValue.CreateBool("com.themysticsword.challengemode", "Virga", ChallengeModePlugin.config, "Permanent Toggles", "Voidling EX", false, "Should the reworked Voidling fight be active outside of the game mode? (Takes effect only if set before the run starts!)", (List<string>)null, (ConfigEntry<bool>)null, false, (Action<bool>)null);

		public static ConfigEntry<int> petLevel;

		public static ConfigEntry<float> petExp;

		public static ConfigEntry<int> petFood;

		public static ConfigEntry<float> petHappiness;

		public static ConfigEntry<float> petWakefulness;

		public static ConfigEntry<float> petLastLoginTime;

		public static ConfigEntry<string> petPalette;

		public static void Init()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			Run.onRunStartGlobal += Run_onRunStartGlobal;
			Run.onRunDestroyGlobal += Run_onRunDestroyGlobal;
			ModSettingsManager.AddOption((BaseOption)new GenericButtonOption("PetGame", "General", "", "Play", new UnityAction(PetGame.Activate)));
			Language.GetLocalizedStringByToken += new hook_GetLocalizedStringByToken(Language_GetLocalizedStringByToken);
			petLevel = ChallengeModePlugin.config.Bind<int>("PetGame", "Level", 1, (ConfigDescription)null);
			petExp = ChallengeModePlugin.config.Bind<float>("PetGame", "Exp", 0f, (ConfigDescription)null);
			petFood = ChallengeModePlugin.config.Bind<int>("PetGame", "Food", 0, (ConfigDescription)null);
			petHappiness = ChallengeModePlugin.config.Bind<float>("PetGame", "Happiness", 0.5f, (ConfigDescription)null);
			petWakefulness = ChallengeModePlugin.config.Bind<float>("PetGame", "Wakefulness", 0.5f, (ConfigDescription)null);
			petLastLoginTime = ChallengeModePlugin.config.Bind<float>("PetGame", "LastLoginTime", 0f, (ConfigDescription)null);
			petPalette = ChallengeModePlugin.config.Bind<string>("PetGame", "Palette", "Retro", (ConfigDescription)null);
		}

		private static void Run_onRunStartGlobal(Run run)
		{
			ChallengeRun challengeRun = run as ChallengeRun;
			if ((Object)(object)challengeRun == (Object)null)
			{
				ProcessPermanentModifier(ConfigurableValue<bool>.op_Implicit(permanentBrotherEX), "BrotherEX");
				ProcessPermanentModifier(ConfigurableValue<bool>.op_Implicit(permanentVoidRaidCrabEX), "VoidRaidCrabEX");
			}
			static void ProcessPermanentModifier(bool shouldBeActive, string modifierName)
			{
				if (shouldBeActive && ChallengeRunModifierCatalog.nameToModifier.TryGetValue(modifierName, out var value) && !value.isActive)
				{
					value.OnEnable();
				}
			}
		}

		private static void Run_onRunDestroyGlobal(Run run)
		{
			ChallengeRun challengeRun = run as ChallengeRun;
			if ((Object)(object)challengeRun == (Object)null)
			{
				ProcessPermanentModifier("BrotherEX");
				ProcessPermanentModifier("VoidRaidCrabEX");
			}
			static void ProcessPermanentModifier(string modifierName)
			{
				if (ChallengeRunModifierCatalog.nameToModifier.TryGetValue(modifierName, out var value) && value.isActive)
				{
					value.OnDisable();
				}
			}
		}

		private static string Language_GetLocalizedStringByToken(orig_GetLocalizedStringByToken orig, Language self, string token)
		{
			if (token == "RISK_OF_OPTIONS.COM.THEMYSTICSWORD.CHALLENGEMODE.GENERAL.PETGAME.GENERIC_BUTTON.NAME")
			{
				return self.GetLocalizedStringByToken("CHALLENGEMODE_PETGAME_TITLE");
			}
			if (token == "RISK_OF_OPTIONS.COM.THEMYSTICSWORD.CHALLENGEMODE.GENERAL.PETGAME.GENERIC_BUTTON.SUB_BUTTON.NAME")
			{
				return self.GetLocalizedStringByToken("CHALLENGEMODE_PETGAME_PLAY");
			}
			return orig.Invoke(self, token);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.themysticsword.challengemode", "Virga", "1.0.5")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class ChallengeModePlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static CollectContentPackProvidersDelegate <>9__11_0;

			internal void <Awake>b__11_0(AddContentPackProviderDelegate addContentPackProvider)
			{
				addContentPackProvider.Invoke((IContentPackProvider)(object)new ChallengeModeContent());
			}
		}

		public const string PluginGUID = "com.themysticsword.challengemode";

		public const string PluginName = "Virga";

		public const string PluginVersion = "1.0.5";

		public static Assembly executingAssembly;

		internal static Type declaringType;

		internal static PluginInfo pluginInfo;

		internal static ManualLogSource logger;

		internal static ConfigFile config;

		private static AssetBundle _assetBundle;

		public static AssetBundle AssetBundle
		{
			get
			{
				if ((Object)(object)_assetBundle == (Object)null)
				{
					_assetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(pluginInfo.Location), "challengemodeassetbundle"));
				}
				return _assetBundle;
			}
		}

		public void Awake()
		{
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_00a3: 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)
			pluginInfo = ((BaseUnityPlugin)this).Info;
			logger = ((BaseUnityPlugin)this).Logger;
			config = ((BaseUnityPlugin)this).Config;
			executingAssembly = Assembly.GetExecutingAssembly();
			declaringType = MethodBase.GetCurrentMethod().DeclaringType;
			if (RiskOfOptionsDependency.enabled)
			{
				Sprite val = null;
				string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "icon.png");
				if (File.Exists(path))
				{
					Texture2D val2 = new Texture2D(2, 2);
					ImageConversion.LoadImage(val2, File.ReadAllBytes(path));
					val = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0f, 0f), 100f);
				}
				RiskOfOptionsDependency.RegisterModInfo("com.themysticsword.challengemode", "Virga", "Challenge game mode with random modifiers", val);
			}
			ChallengeModeConfig.Init();
			ChallengeRunModifierCatalog.Init();
			TMProEffects.Init();
			ContentLoadHelper.PluginAwakeLoad<BaseItem>(executingAssembly);
			ContentLoadHelper.PluginAwakeLoad<BaseEquipment>(executingAssembly);
			ContentLoadHelper.PluginAwakeLoad<BaseBuff>(executingAssembly);
			ContentLoadHelper.PluginAwakeLoad<BaseInteractable>(executingAssembly);
			ContentLoadHelper.PluginAwakeLoad<BaseCharacterBody>(executingAssembly);
			ContentLoadHelper.PluginAwakeLoad<BaseCharacterMaster>(executingAssembly);
			ContentLoadHelper.PluginAwakeLoad<ChallengeRunLoadable>(executingAssembly);
			ContentLoadHelper.PluginAwakeLoad<BrotherEXAssets>(executingAssembly);
			ContentLoadHelper.PluginAwakeLoad<VoidRaidCrabEXAssets>(executingAssembly);
			ContentLoadHelper.PluginAwakeLoad<PetGame>(executingAssembly);
			object obj = <>c.<>9__11_0;
			if (obj == null)
			{
				CollectContentPackProvidersDelegate val3 = delegate(AddContentPackProviderDelegate addContentPackProvider)
				{
					addContentPackProvider.Invoke((IContentPackProvider)(object)new ChallengeModeContent());
				};
				<>c.<>9__11_0 = val3;
				obj = (object)val3;
			}
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
		}
	}
	public class ChallengeModeContent : IContentPackProvider
	{
		public static class Resources
		{
			public static List<GameObject> bodyPrefabs = new List<GameObject>();

			public static List<GameObject> masterPrefabs = new List<GameObject>();

			public static List<GameObject> projectilePrefabs = new List<GameObject>();

			public static List<GameObject> effectPrefabs = new List<GameObject>();

			public static List<GameObject> gameModePrefabs = new List<GameObject>();

			public static List<GameObject> networkedObjectPrefabs = new List<GameObject>();

			public static List<NetworkSoundEventDef> networkSoundEventDefs = new List<NetworkSoundEventDef>();

			public static List<UnlockableDef> unlockableDefs = new List<UnlockableDef>();

			public static List<Type> entityStateTypes = new List<Type>();

			public static List<SkillDef> skillDefs = new List<SkillDef>();

			public static List<SkillFamily> skillFamilies = new List<SkillFamily>();

			public static List<SceneDef> sceneDefs = new List<SceneDef>();

			public static List<GameEndingDef> gameEndingDefs = new List<GameEndingDef>();
		}

		public static class Items
		{
			public static ItemDef ChallengeMode_PermanentImmuneToVoidDeath;
		}

		public static class Buffs
		{
			public static BuffDef ChallengeMode_BackpackWeight;

			public static BuffDef ChallengeMode_BlockNextDamage;

			public static BuffDef ChallengeMode_CommsJammed;

			public static BuffDef ChallengeMode_CommsJammedVisuals;

			public static BuffDef ChallengeMode_CurseCooldown;

			public static BuffDef ChallengeMode_DefenseDamage;

			public static BuffDef ChallengeMode_Disarmed;

			public static BuffDef ChallengeMode_EXBoss;

			public static BuffDef ChallengeMode_Frostbite;

			public static BuffDef ChallengeMode_KillRemorse;

			public static BuffDef ChallengeMode_LowHPStress;

			public static BuffDef ChallengeMode_PlayerKnockupStun;

			public static BuffDef ChallengeMode_ProcLimitIndicator;

			public static BuffDef ChallengeMode_Stamina;

			public static BuffDef ChallengeMode_SuperArmor;

			public static BuffDef ChallengeMode_SuperArmorGained;

			public static BuffDef ChallengeMode_VoidRaidCrabScare;
		}

		private ContentPack contentPack = new ContentPack();

		public string identifier => "Virga";

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			contentPack.identifier = identifier;
			ContentLoadHelper contentLoadHelper = new ContentLoadHelper();
			Action[] loadDispatchers = new Action[13]
			{
				delegate
				{
					contentLoadHelper.DispatchLoad<ItemDef>(ChallengeModePlugin.executingAssembly, typeof(BaseItem), (Action<ItemDef[]>)delegate(ItemDef[] x)
					{
						contentPack.itemDefs.Add(x);
					});
				},
				delegate
				{
					contentLoadHelper.DispatchLoad<EquipmentDef>(ChallengeModePlugin.executingAssembly, typeof(BaseEquipment), (Action<EquipmentDef[]>)delegate(EquipmentDef[] x)
					{
						contentPack.equipmentDefs.Add(x);
					});
				},
				delegate
				{
					contentLoadHelper.DispatchLoad<BuffDef>(ChallengeModePlugin.executingAssembly, typeof(BaseBuff), (Action<BuffDef[]>)delegate(BuffDef[] x)
					{
						contentPack.buffDefs.Add(x);
					});
				},
				delegate
				{
					contentLoadHelper.DispatchLoad<GameObject>(ChallengeModePlugin.executingAssembly, typeof(BaseInteractable), (Action<GameObject[]>)null);
				},
				delegate
				{
					contentLoadHelper.DispatchLoad<GameObject>(ChallengeModePlugin.executingAssembly, typeof(BaseCharacterBody), (Action<GameObject[]>)delegate(GameObject[] x)
					{
						contentPack.bodyPrefabs.Add(x);
					});
				},
				delegate
				{
					contentLoadHelper.DispatchLoad<GameObject>(ChallengeModePlugin.executingAssembly, typeof(BaseCharacterMaster), (Action<GameObject[]>)delegate(GameObject[] x)
					{
						contentPack.masterPrefabs.Add(x);
					});
				},
				delegate
				{
					contentLoadHelper.DispatchLoad<GameObject>(ChallengeModePlugin.executingAssembly, typeof(ChallengeRunLoadable), (Action<GameObject[]>)delegate(GameObject[] x)
					{
						contentPack.gameModePrefabs.Add(x);
					});
				},
				delegate
				{
					contentLoadHelper.DispatchLoad<GameObject>(ChallengeModePlugin.executingAssembly, typeof(EXBossAssets), (Action<GameObject[]>)null);
				},
				delegate
				{
					contentLoadHelper.DispatchLoad<GameObject>(ChallengeModePlugin.executingAssembly, typeof(BrotherEXAssets), (Action<GameObject[]>)null);
				},
				delegate
				{
					contentLoadHelper.DispatchLoad<GameObject>(ChallengeModePlugin.executingAssembly, typeof(VoidRaidCrabEXAssets), (Action<GameObject[]>)null);
				},
				delegate
				{
					contentLoadHelper.DispatchLoad<GameObject>(ChallengeModePlugin.executingAssembly, typeof(PetGame), (Action<GameObject[]>)null);
				},
				delegate
				{
					ChallengeModePostProcessing.Init();
				},
				delegate
				{
					Thunder.InitAssets();
				}
			};
			int i = 0;
			while (i < loadDispatchers.Length)
			{
				loadDispatchers[i]();
				args.ReportProgress(Util.Remap((float)(i + 1), 0f, (float)loadDispatchers.Length, 0f, 0.05f));
				yield return null;
				int num = i + 1;
				i = num;
			}
			while (contentLoadHelper.coroutine.MoveNext())
			{
				args.ReportProgress(Util.Remap(contentLoadHelper.progress.value, 0f, 1f, 0.05f, 0.9f));
				yield return contentLoadHelper.coroutine.Current;
			}
			loadDispatchers = new Action[15]
			{
				delegate
				{
					ContentLoadHelper.PopulateTypeFields<ItemDef>(typeof(Items), contentPack.itemDefs, (Func<string, string>)null);
				},
				delegate
				{
					ContentLoadHelper.PopulateTypeFields<BuffDef>(typeof(Buffs), contentPack.buffDefs, (Func<string, string>)null);
				},
				delegate
				{
					contentPack.bodyPrefabs.Add(Resources.bodyPrefabs.ToArray());
				},
				delegate
				{
					contentPack.masterPrefabs.Add(Resources.masterPrefabs.ToArray());
				},
				delegate
				{
					contentPack.projectilePrefabs.Add(Resources.projectilePrefabs.ToArray());
				},
				delegate
				{
					contentPack.gameModePrefabs.Add(Resources.gameModePrefabs.ToArray());
				},
				delegate
				{
					contentPack.networkedObjectPrefabs.Add(Resources.networkedObjectPrefabs.ToArray());
				},
				delegate
				{
					contentPack.effectDefs.Add(Resources.effectPrefabs.ConvertAll((Converter<GameObject, EffectDef>)((GameObject x) => new EffectDef(x))).ToArray());
				},
				delegate
				{
					contentPack.networkSoundEventDefs.Add(Resources.networkSoundEventDefs.ToArray());
				},
				delegate
				{
					contentPack.unlockableDefs.Add(Resources.unlockableDefs.ToArray());
				},
				delegate
				{
					contentPack.entityStateTypes.Add(Resources.entityStateTypes.ToArray());
				},
				delegate
				{
					contentPack.skillDefs.Add(Resources.skillDefs.ToArray());
				},
				delegate
				{
					contentPack.skillFamilies.Add(Resources.skillFamilies.ToArray());
				},
				delegate
				{
					contentPack.sceneDefs.Add(Resources.sceneDefs.ToArray());
				},
				delegate
				{
					contentPack.gameEndingDefs.Add(Resources.gameEndingDefs.ToArray());
				}
			};
			int j = 0;
			while (j < loadDispatchers.Length)
			{
				loadDispatchers[j]();
				args.ReportProgress(Util.Remap((float)(j + 1), 0f, (float)loadDispatchers.Length, 0.9f, 0.95f));
				yield return null;
				int num = j + 1;
				j = num;
			}
			loadDispatchers = new Action[4]
			{
				delegate
				{
					ContentLoadHelper.InvokeAfterContentPackLoaded<BaseItem>(ChallengeModePlugin.executingAssembly);
				},
				delegate
				{
					ContentLoadHelper.InvokeAfterContentPackLoaded<BaseEquipment>(ChallengeModePlugin.executingAssembly);
				},
				delegate
				{
					ContentLoadHelper.InvokeAfterContentPackLoaded<BaseBuff>(ChallengeModePlugin.executingAssembly);
				},
				delegate
				{
					ContentLoadHelper.InvokeAfterContentPackLoaded<BaseInteractable>(ChallengeModePlugin.executingAssembly);
				}
			};
			int k = 0;
			while (k < loadDispatchers.Length)
			{
				loadDispatchers[k]();
				args.ReportProgress(Util.Remap((float)(k + 1), 0f, (float)loadDispatchers.Length, 0.95f, 0.99f));
				yield return null;
				int num = k + 1;
				k = num;
			}
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			ContentPack.Copy(contentPack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}
	}
	public static class ChallengeModeUtils
	{
		public static event Func<CharacterBody, bool> onGetBodyIsHot;

		public static event Func<CharacterBody, bool> onGetBodyIsCold;

		public static bool CurrentStageNameMatches(string stageName)
		{
			return Object.op_Implicit((Object)(object)Stage.instance) && (Object)(object)Stage.instance.sceneDef != (Object)null && Stage.instance.sceneDef.baseSceneName == stageName;
		}

		public static bool CurrentStageHasCommonInteractables()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)Stage.instance) && (Object)(object)Stage.instance.sceneDef != (Object)null && (int)Stage.instance.sceneDef.sceneType != 1)
			{
				return false;
			}
			List<string> list = new List<string> { "moon2", "voidstage", "voidraid", "arena" };
			foreach (string item in list)
			{
				if (CurrentStageNameMatches(item))
				{
					return false;
				}
			}
			return true;
		}

		public static bool CurrentStageHasBosses()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)Stage.instance) && (Object)(object)Stage.instance.sceneDef != (Object)null && ((int)Stage.instance.sceneDef.sceneType == 3 || (int)Stage.instance.sceneDef.sceneType == 0 || (int)Stage.instance.sceneDef.sceneType == -1))
			{
				return false;
			}
			List<string> list = new List<string> { "bazaar", "arena", "voidstage" };
			foreach (string item in list)
			{
				if (CurrentStageNameMatches(item))
				{
					return false;
				}
			}
			return true;
		}

		public static void RemoveFromArray<T>(ref T[] array, T element)
		{
			int num = Array.IndexOf(array, element);
			if (num != -1)
			{
				ArrayUtils.ArrayRemoveAtAndResize<T>(ref array, num, 1);
			}
		}

		public static float MoveNumberTowards(float current, float target, float speed)
		{
			if (current < target)
			{
				current = Mathf.Min(current + speed, target);
			}
			else if (current > target)
			{
				current = Mathf.Max(current - speed, target);
			}
			return current;
		}

		public static bool IsBodyUnderCeiling(CharacterBody body)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return Physics.Raycast(new Ray(body.corePosition + Vector3.up * body.radius, Vector3.up), 500f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1);
		}

		public static bool BodyIsHot(CharacterBody body)
		{
			bool flag = body.HasBuff(Buffs.OnFire) || body.HasBuff(Buffs.StrongerBurn);
			if (!flag)
			{
				DotController val = DotController.FindDotController(((Component)body).gameObject);
				if (Object.op_Implicit((Object)(object)val) && val.HasDotActive((DotIndex)2))
				{
					flag = true;
				}
			}
			if (!flag && ChallengeModeUtils.onGetBodyIsHot != null)
			{
				flag = ChallengeModeUtils.onGetBodyIsHot(body);
			}
			return flag;
		}

		public static bool BodyIsCold(CharacterBody body)
		{
			bool flag = body.HasBuff(Buffs.Slow80) || (Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.isInFrozenState);
			if (!flag && ChallengeModeUtils.onGetBodyIsCold != null)
			{
				flag = ChallengeModeUtils.onGetBodyIsCold(body);
			}
			return flag;
		}
	}
	public class ChallengeRunLoadable : BaseLoadableAsset
	{
		public static GameObject challengeRunPrefab;

		public static GameObject modifierListPrefab;

		public static GameObject extraGameModeMenu;

		public override void OnPluginAwake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			((BaseLoadableAsset)this).OnPluginAwake();
			challengeRunPrefab = Utils.CreateBlankPrefab("xChallengeRun", true);
			NetworkingAPI.RegisterMessageType<ChallengeRun.SyncSetNewModifiers>();
			NetworkingAPI.RegisterMessageType<ChallengeRun.SyncDisableAllModifiers>();
			GameModeCatalog.SetGameModes += new hook_SetGameModes(GameModeCatalog_SetGameModes);
		}

		private void GameModeCatalog_SetGameModes(orig_SetGameModes orig, Run[] newGameModePrefabComponents)
		{
			Array.Sort(newGameModePrefabComponents, (Run a, Run b) => string.CompareOrdinal(((Object)a).name, ((Object)b).name));
			orig.Invoke(newGameModePrefabComponents);
		}

		public override void Load()
		{
			//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)
			Run component = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ClassicRun/ClassicRun.prefab").WaitForCompletion().GetComponent<Run>();
			ChallengeRun challengeRun = challengeRunPrefab.AddComponent<ChallengeRun>();
			((Run)challengeRun).nameToken = "GAMEMODE_CHALLENGEMODE_NAME";
			((Run)challengeRun).userPickable = true;
			((Run)challengeRun).startingSceneGroup = component.startingSceneGroup;
			((Run)challengeRun).gameOverPrefab = component.gameOverPrefab;
			((Run)challengeRun).lobbyBackgroundPrefab = component.lobbyBackgroundPrefab;
			((Run)challengeRun).uiPrefab = component.uiPrefab;
			challengeRunPrefab.AddComponent<TeamManager>();
			challengeRunPrefab.AddComponent<RunCameraManager>();
			SetUpAlternateGameModeButton();
			SetUpModifierList();
			((BaseLoadableAsset)this).OnLoad();
			base.asset = challengeRunPrefab;
		}

		public void SetUpAlternateGameModeButton()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			LanguageTextMeshController.Start += new hook_Start(LanguageTextMeshController_Start);
		}

		private void LanguageTextMeshController_Start(orig_Start orig, LanguageTextMeshController self)
		{
			orig.Invoke(self);
			if (self.token == "TITLE_ECLIPSE" && Object.op_Implicit((Object)(object)((Component)self).GetComponent<HGButton>()))
			{
				((Component)((Component)self).transform.parent).gameObject.AddComponent<ChallengeRunButtonAdder>();
			}
		}

		public void SetUpModifierList()
		{
			//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)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ClassicRun/ClassicRunInfoHudPanel.prefab").WaitForCompletion();
			modifierListPrefab = ChallengeModePlugin.AssetBundle.LoadAsset<GameObject>("Assets/Mods/ChallengeMode/ModifierListPanel.prefab");
			modifierListPrefab.GetComponent<Image>().sprite = ((Component)val.transform.Find("RightInfoBar/ObjectivePanel")).GetComponent<Image>().sprite;
			((Component)modifierListPrefab.transform.Find("StripContainer/ModifierStrip")).GetComponent<Image>().sprite = ((Component)val.transform.Find("RightInfoBar/ObjectivePanel/StripContainer/ObjectiveStrip")).GetComponent<Image>().sprite;
			((Graphic)((Component)modifierListPrefab.transform.Find("StripContainer/ModifierStrip")).GetComponent<Image>()).material = ((Graphic)((Component)val.transform.Find("RightInfoBar/ObjectivePanel/StripContainer/ObjectiveStrip")).GetComponent<Image>()).material;
			FixLabel(((Component)modifierListPrefab.transform.Find("Label")).gameObject, (LabelType)1);
			((Component)modifierListPrefab.transform.Find("Label")).gameObject.AddComponent<LanguageTextMeshController>()._token = "CHALLENGEMODE_MODIFIER_LIST_TITLE";
			FixLabel(((Component)modifierListPrefab.transform.Find("StripContainer/ModifierStrip/Name")).gameObject, (LabelType)0);
			((Component)modifierListPrefab.transform.Find("StripContainer/ModifierStrip/Name")).gameObject.AddComponent<LanguageTextMeshController>();
			FixLabel(((Component)modifierListPrefab.transform.Find("StripContainer/ModifierStrip/Description")).gameObject, (LabelType)2);
			((Component)modifierListPrefab.transform.Find("StripContainer/ModifierStrip/Description")).gameObject.AddComponent<LanguageTextMeshController>();
			ChallengeRunModifierListPanelController challengeRunModifierListPanelController = modifierListPrefab.AddComponent<ChallengeRunModifierListPanelController>();
			challengeRunModifierListPanelController.stripPrefab = ((Component)modifierListPrefab.transform.Find("StripContainer/ModifierStrip")).gameObject;
			challengeRunModifierListPanelController.stripContainer = modifierListPrefab.transform.Find("StripContainer");
			static void FixLabel(GameObject labelObject, LabelType labelType)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: 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_0036: 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)
				TextMeshProUGUI component = labelObject.GetComponent<TextMeshProUGUI>();
				TextAlignmentOptions alignment = ((TMP_Text)component).alignment;
				Object.DestroyImmediate((Object)(object)component);
				HGTextMeshProUGUI val2 = labelObject.AddComponent<HGTextMeshProUGUI>();
				((TMP_Text)val2).alignment = alignment;
				((TMP_Text)val2).enableWordWrapping = true;
				LabelSkinController val3 = labelObject.AddComponent<LabelSkinController>();
				val3.labelType = labelType;
				val3.useRecommendedAlignment = false;
				((BaseSkinController)val3).skinData = Addressables.LoadAssetAsync<UISkinData>((object)"RoR2/Base/UI/skinObjectivePanel.asset").WaitForCompletion();
				val3.label = (TextMeshProUGUI)(object)labelObject.GetComponent<HGTextMeshProUGUI>();
				((BaseSkinController)val3).DoSkinUI();
			}
		}
	}
	public class ChallengeRunButtonAdder : MonoBehaviour
	{
		public void Start()
		{
			GameObject val = Object.Instantiate<GameObject>(((Component)((Component)this).transform.Find("GenericMenuButton (Eclipse)")).gameObject, ((Component)this).transform);
			val.AddComponent<ChallengeRunButton>();
			val.GetComponent<LanguageTextMeshController>().token = "TITLE_CHALLENGEMODE";
			val.GetComponent<HGButton>().hoverToken = "TITLE_CHALLENGEMODE_DESC";
		}
	}
	public class ChallengeRunButton : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__1_0;

			internal void <Start>b__1_0()
			{
				Util.PlaySound("Play_UI_menuClick", ((Component)RoR2Application.instance).gameObject);
				Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode xChallengeRun; host 0; \"", false);
			}
		}

		public HGButton hgButton;

		public void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			hgButton = ((Component)this).GetComponent<HGButton>();
			((Button)hgButton).onClick = new ButtonClickedEvent();
			ButtonClickedEvent onClick = ((Button)hgButton).onClick;
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
					Util.PlaySound("Play_UI_menuClick", ((Component)RoR2Application.instance).gameObject);
					Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode xChallengeRun; host 0; \"", false);
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
		}
	}
	public class ChallengeRun : Run
	{
		public class SyncSetNewModifiers : INetMessage, ISerializableObject
		{
			private NetworkInstanceId objID;

			private int networkingCycle;

			private List<int> modifierIndices;

			public SyncSetNewModifiers()
			{
			}

			public SyncSetNewModifiers(NetworkInstanceId objID, int networkingCycle, List<int> modifierIndices)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				this.objID = objID;
				this.networkingCycle = networkingCycle;
				this.modifierIndices = modifierIndices;
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				objID = reader.ReadNetworkId();
				networkingCycle = reader.ReadInt32();
				int num = reader.ReadInt32();
				modifierIndices = new List<int>();
				for (int i = 0; i < num; i++)
				{
					modifierIndices.Add(reader.ReadInt32());
				}
			}

			public void OnReceived()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkServer.active)
				{
					return;
				}
				GameObject val = Util.FindNetworkObject(objID);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				ChallengeRun component = val.GetComponent<ChallengeRun>();
				if (!Object.op_Implicit((Object)(object)component) || component.networkingCycle >= networkingCycle)
				{
					return;
				}
				component.networkingCycle = networkingCycle;
				component.DisableAllModifiers();
				foreach (int modifierIndex in modifierIndices)
				{
					if (ChallengeRunModifierCatalog.indexToModifier.TryGetValue(modifierIndex, out var value))
					{
						value.OnEnable();
						component.currentModifiers.Add(value);
					}
				}
				ChallengeRunModifierListPanelController.MarkDirty();
			}

			public void Serialize(NetworkWriter writer)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(objID);
				writer.Write(networkingCycle);
				writer.Write(modifierIndices.Count);
				foreach (int modifierIndex in modifierIndices)
				{
					writer.Write(modifierIndex);
				}
			}
		}

		public class SyncDisableAllModifiers : INetMessage, ISerializableObject
		{
			private NetworkInstanceId objID;

			private int networkingCycle;

			public SyncDisableAllModifiers()
			{
			}

			public SyncDisableAllModifiers(NetworkInstanceId objID, int networkingCycle)
			{
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				this.objID = objID;
				this.networkingCycle = networkingCycle;
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				objID = reader.ReadNetworkId();
				networkingCycle = reader.ReadInt32();
			}

			public void OnReceived()
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkServer.active)
				{
					return;
				}
				GameObject val = Util.FindNetworkObject(objID);
				if (Object.op_Implicit((Object)(object)val))
				{
					ChallengeRun component = val.GetComponent<ChallengeRun>();
					if (Object.op_Implicit((Object)(object)component) && component.networkingCycle < networkingCycle)
					{
						component.networkingCycle = networkingCycle;
						component.DisableAllModifiers();
					}
				}
			}

			public void Serialize(NetworkWriter writer)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(objID);
				writer.Write(networkingCycle);
			}
		}

		public Xoroshiro128Plus modifierRng;

		private int networkingCycle = 0;

		public List<ChallengeRunModifier> currentModifiers = new List<ChallengeRunModifier>();

		public List<ChallengeRunModifier> modifierPool = new List<ChallengeRunModifier>();

		public List<ChallengeRunModifier> additionalModifierPool = new List<ChallengeRunModifier>();

		public float markHUDDirtyTimer = 0f;

		public float markHUDDirtyInterval = 1f;

		public float markHUDDirtyLimit = 15f;

		public override void Start()
		{
			Stage.onServerStageBegin += Stage_onServerStageBegin;
			Stage.onServerStageComplete += Stage_onServerStageComplete;
			HUD.onHudTargetChangedGlobal += HUD_onHudTargetChangedGlobal;
			((Run)this).Start();
			if (NetworkServer.active)
			{
				GenerateStageRNGChallengeRun();
			}
		}

		public override void OnDestroy()
		{
			Stage.onServerStageBegin -= Stage_onServerStageBegin;
			Stage.onServerStageComplete -= Stage_onServerStageComplete;
			HUD.onHudTargetChangedGlobal -= HUD_onHudTargetChangedGlobal;
			DisableAllModifiers();
			((Run)this).OnDestroy();
		}

		public override void OnFixedUpdate()
		{
			((Run)this).OnFixedUpdate();
			if (markHUDDirtyLimit > 0f)
			{
				markHUDDirtyLimit -= Time.fixedDeltaTime;
				markHUDDirtyTimer += Time.fixedDeltaTime;
				if (markHUDDirtyTimer >= markHUDDirtyInterval)
				{
					markHUDDirtyTimer -= markHUDDirtyInterval;
					ChallengeRunModifierListPanelController.MarkDirty();
				}
			}
		}

		public override void AdvanceStage(SceneDef nextScene)
		{
			((Run)this).AdvanceStage(nextScene);
			GenerateStageRNGChallengeRun();
		}

		public void GenerateStageRNGChallengeRun()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			modifierRng = new Xoroshiro128Plus(base.stageRng.nextUlong);
		}

		public override void OnClientGameOver(RunReport runReport)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			((Run)this).OnClientGameOver(runReport);
			if (runReport.gameEnding.isWin)
			{
				int num = RoR2Application.rng.RangeInt(5, 15);
				if (((Run)this).loopClearCount > 0)
				{
					num *= ((Run)this).loopClearCount;
				}
				DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(((Run)this).selectedDifficulty);
				if (difficultyDef != null)
				{
					num = Mathf.CeilToInt((float)num * difficultyDef.scalingValue);
				}
				ConfigEntry<int> petFood = ChallengeModeConfig.petFood;
				petFood.Value += num;
			}
		}

		private void Stage_onServerStageBegin(Stage stage)
		{
			RefreshModifierPools();
			AddRandomNewModifiersForThisStageServer();
		}

		private void Stage_onServerStageComplete(Stage stage)
		{
			DisableAllModifiers();
		}

		private void HUD_onHudTargetChangedGlobal(HUD hud)
		{
			ChallengeRunModifierListPanelController.MarkDirty();
		}

		public void RefreshModifierPools()
		{
			modifierPool.Clear();
			additionalModifierPool.Clear();
			for (int i = 0; i < ChallengeRunModifierCatalog.allModifiers.Count; i++)
			{
				ChallengeRunModifier challengeRunModifier = ChallengeRunModifierCatalog.allModifiers[i];
				if (challengeRunModifier.IsAvailable() && challengeRunModifier.isEnabledInConfig)
				{
					if (challengeRunModifier.isAdditional)
					{
						additionalModifierPool.Add(challengeRunModifier);
					}
					else
					{
						modifierPool.Add(challengeRunModifier);
					}
				}
			}
		}

		public void AddRandomNewModifiersForThisStageServer()
		{
			if (!NetworkServer.active)
			{
				return;
			}
			List<ChallengeRunModifier> list = new List<ChallengeRunModifier>();
			for (int i = 0; i < ConfigurableValue<int>.op_Implicit(ChallengeModeConfig.modifiersPerStage); i++)
			{
				if (modifierPool.Count <= 0)
				{
					break;
				}
				ChallengeRunModifier item = modifierRng.NextElementUniform<ChallengeRunModifier>(modifierPool);
				list.Add(item);
				modifierPool.Remove(item);
			}
			foreach (ChallengeRunModifier item2 in additionalModifierPool)
			{
				list.Add(item2);
			}
			AddNewModifiersServer(list);
		}

		public void AddNewModifierServer(ChallengeRunModifier newModifier)
		{
			AddNewModifiersServer(new List<ChallengeRunModifier> { newModifier });
		}

		public void AddNewModifiersServer(List<ChallengeRunModifier> newModifiers)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			foreach (ChallengeRunModifier newModifier in newModifiers)
			{
				try
				{
					newModifier.OnEnable();
				}
				catch (Exception ex)
				{
					ChallengeModePlugin.logger.LogError((object)("Error while enabling modifier " + newModifier.GetType().Name));
					ChallengeModePlugin.logger.LogError((object)ex);
				}
				currentModifiers.Add(newModifier);
			}
			ChallengeRunModifierListPanelController.MarkDirty();
			networkingCycle++;
			NetMessageExtensions.Send((INetMessage)(object)new SyncSetNewModifiers(((Component)this).gameObject.GetComponent<NetworkIdentity>().netId, networkingCycle, currentModifiers.Select((ChallengeRunModifier x) => x.modifierIndex).ToList()), (NetworkDestination)1);
		}

		public void DisableAllModifiers()
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			foreach (ChallengeRunModifier currentModifier in currentModifiers)
			{
				try
				{
					currentModifier.OnDisable();
				}
				catch (Exception ex)
				{
					ChallengeModePlugin.logger.LogError((object)("Error while disabling modifier " + currentModifier.GetType().Name));
					ChallengeModePlugin.logger.LogError((object)ex);
				}
			}
			currentModifiers.Clear();
			ChallengeRunModifierListPanelController.MarkDirty();
			if (NetworkServer.active)
			{
				networkingCycle++;
				NetMessageExtensions.Send((INetMessage)(object)new SyncDisableAllModifiers(((Component)this).gameObject.GetComponent<NetworkIdentity>().netId, networkingCycle), (NetworkDestination)1);
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		public static void CCAddModifier(ConCommandArgs args)
		{
			if (!NetworkServer.active)
			{
				throw new Exception("This is a server-side command.");
			}
			ChallengeRun challengeRun = Run.instance as ChallengeRun;
			if ((Object)(object)challengeRun == (Object)null)
			{
				throw new Exception("Not in a ChallengeRun!");
			}
			string argString = ((ConCommandArgs)(ref args)).GetArgString(0);
			ChallengeRunModifier value = null;
			if (!ChallengeRunModifierCatalog.nameToModifier.TryGetValue(argString, out value))
			{
				throw new Exception($"Modifier not found. modifierName={argString}");
			}
			if (!challengeRun.currentModifiers.Contains(value))
			{
				challengeRun.AddNewModifierServer(value);
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		public static void CCDisableAllModifiers(ConCommandArgs args)
		{
			if (!NetworkServer.active)
			{
				throw new Exception("This is a server-side command.");
			}
			ChallengeRun challengeRun = Run.instance as ChallengeRun;
			if ((Object)(object)challengeRun == (Object)null)
			{
				throw new Exception("Not in a ChallengeRun!");
			}
			challengeRun.DisableAllModifiers();
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		public static void CCRerollModifiers(ConCommandArgs args)
		{
			if (!NetworkServer.active)
			{
				throw new Exception("This is a server-side command.");
			}
			ChallengeRun challengeRun = Run.instance as ChallengeRun;
			if ((Object)(object)challengeRun == (Object)null)
			{
				throw new Exception("Not in a ChallengeRun!");
			}
			challengeRun.DisableAllModifiers();
			challengeRun.RefreshModifierPools();
			challengeRun.AddRandomNewModifiersForThisStageServer();
		}
	}
	public class ChallengeRunModifierListPanelController : MonoBehaviour
	{
		public class ModifierStrip
		{
			public ChallengeRunModifier modifier;

			public GameObject gameObject;
		}

		public class StripEnterAnimation
		{
			public float t;

			public float maxT = 1f;

			public float finalHeight;

			public LayoutElement layoutElement;

			public CanvasGroup canvasGroup;

			public ModifierStrip strip;

			public StripEnterAnimation(ModifierStrip strip)
			{
				this.strip = strip;
				layoutElement = strip.gameObject.GetComponent<LayoutElement>();
				canvasGroup = strip.gameObject.GetComponent<CanvasGroup>();
				finalHeight = layoutElement.minHeight;
			}

			public void SetT(float newT)
			{
				if (Object.op_Implicit((Object)(object)strip.gameObject))
				{
					t = newT;
					float alpha = Mathf.Clamp01(Util.Remap(t / maxT, 0.75f, 1f, 0f, 1f));
					canvasGroup.alpha = alpha;
					float num = Mathf.Clamp01(Util.Remap(t / maxT, 0.5f, 0.75f, 0f, 1f));
					num *= num;
					layoutElement.minHeight = num * finalHeight;
					layoutElement.preferredHeight = layoutElement.minHeight;
					layoutElement.flexibleHeight = 0f;
				}
			}
		}

		public HUD hud;

		public GameObject stripPrefab;

		public Transform stripContainer;

		public List<ModifierStrip> strips = new List<ModifierStrip>();

		public List<StripEnterAnimation> stripEnterAnimations = new List<StripEnterAnimation>();

		public static bool isDirty;

		public void OnEnable()
		{
			InstanceTracker.Add<ChallengeRunModifierListPanelController>(this);
		}

		public void OnDisable()
		{
			InstanceTracker.Remove<ChallengeRunModifierListPanelController>(this);
		}

		public void Update()
		{
			if (stripEnterAnimations.Count <= 0)
			{
				return;
			}
			float num = 2f;
			float num2 = Time.deltaTime / num;
			for (int num3 = stripEnterAnimations.Count - 1; num3 >= 0; num3--)
			{
				float num4 = Mathf.Min(stripEnterAnimations[num3].t + num2, stripEnterAnimations[num3].maxT);
				stripEnterAnimations[num3].SetT(num4);
				if (num4 >= stripEnterAnimations[num3].maxT)
				{
					stripEnterAnimations.RemoveAt(num3);
				}
			}
		}

		public void SetModifiers(List<ChallengeRunModifier> newModifiers)
		{
			foreach (ModifierStrip strip in strips)
			{
				if (!newModifiers.Contains(strip.modifier))
				{
					Object.Destroy((Object)(object)strip.gameObject);
				}
			}
			strips.RemoveAll((ModifierStrip x) => !newModifiers.Contains(x.modifier));
			stripEnterAnimations.RemoveAll((StripEnterAnimation x) => (Object)(object)x.strip.gameObject == (Object)null);
			int num = 0;
			foreach (ChallengeRunModifier modifier in newModifiers)
			{
				if (!strips.Any((ModifierStrip x) => x.modifier == modifier))
				{
					ModifierStrip modifierStrip = new ModifierStrip();
					modifierStrip.modifier = modifier;
					modifierStrip.gameObject = Object.Instantiate<GameObject>(stripPrefab, stripContainer);
					modifierStrip.gameObject.SetActive(true);
					((Component)modifierStrip.gameObject.transform.Find("Name")).GetComponent<LanguageTextMeshController>().token = modifier.nameToken;
					((Component)modifierStrip.gameObject.transform.Find("Description")).GetComponent<LanguageTextMeshController>().token = modifier.descriptionToken;
					strips.Add(modifierStrip);
					StripEnterAnimation stripEnterAnimation = new StripEnterAnimation(modifierStrip);
					stripEnterAnimation.maxT += 0.2f * (float)num;
					stripEnterAnimations.Add(stripEnterAnimation);
					num++;
				}
			}
		}

		public static void MarkDirty()
		{
			if (!isDirty)
			{
				isDirty = true;
				RoR2Application.onNextUpdate += RefreshAll;
			}
		}

		private static void RefreshAll()
		{
			for (int i = 0; i < HUD.readOnlyInstanceList.Count; i++)
			{
				RefreshHUD(HUD.readOnlyInstanceList[i]);
			}
			isDirty = false;
		}

		private static void RefreshHUD(HUD hud)
		{
			if (Object.op_Implicit((Object)(object)hud.targetMaster))
			{
				ChallengeRun challengeRun = Run.instance as ChallengeRun;
				if ((Object)(object)challengeRun != (Object)null)
				{
					SetDisplayDataForViewer(hud, challengeRun.currentModifiers);
				}
			}
		}

		private static void SetDisplayDataForViewer(HUD hud, List<ChallengeRunModifier> modifiers)
		{
			bool shouldDisplay = modifiers.Count > 0;
			ChallengeRunModifierListPanelController challengeRunModifierListPanelController = SetDisplayingOnHud(hud, shouldDisplay);
			if (Object.op_Implicit((Object)(object)challengeRunModifierListPanelController))
			{
				challengeRunModifierListPanelController.SetModifiers(modifiers);
			}
		}

		private static ChallengeRunModifierListPanelController SetDisplayingOnHud(HUD hud, bool shouldDisplay)
		{
			List<ChallengeRunModifierListPanelController> instancesList = InstanceTracker.GetInstancesList<ChallengeRunModifierListPanelController>();
			ChallengeRunModifierListPanelController challengeRunModifierListPanelController = null;
			for (int i = 0; i < instancesList.Count; i++)
			{
				ChallengeRunModifierListPanelController challengeRunModifierListPanelController2 = instancesList[i];
				if ((Object)(object)challengeRunModifierListPanelController2.hud == (Object)(object)hud)
				{
					challengeRunModifierListPanelController = challengeRunModifierListPanelController2;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)challengeRunModifierListPanelController) != shouldDisplay)
			{
				if (!Object.op_Implicit((Object)(object)challengeRunModifierListPanelController))
				{
					Transform val = null;
					if (Object.op_Implicit((Object)(object)hud.gameModeUiInstance))
					{
						ChildLocator component = hud.gameModeUiInstance.GetComponent<ChildLocator>();
						if (Object.op_Implicit((Object)(object)component))
						{
							Transform val2 = component.FindChild("RightInfoBar");
							if (Object.op_Implicit((Object)(object)val2))
							{
								val = (Transform)(object)((Component)val2).GetComponent<RectTransform>();
							}
						}
					}
					if (Object.op_Implicit((Object)(object)val))
					{
						ChallengeRunModifierListPanelController component2 = Object.Instantiate<GameObject>(ChallengeRunLoadable.modifierListPrefab, val).GetComponent<ChallengeRunModifierListPanelController>();
						component2.hud = hud;
						challengeRunModifierListPanelController = component2;
					}
				}
				else
				{
					Object.Destroy((Object)(object)((Component)challengeRunModifierListPanelController).gameObject);
					challengeRunModifierListPanelController = null;
				}
			}
			return challengeRunModifierListPanelController;
		}
	}
	public class ChallengeRunModifier
	{
		internal int modifierIndex = -1;

		public bool isActive = false;

		internal ConfigurableValue<bool> configEnableOption;

		public virtual string nameToken => "";

		public virtual string descriptionToken => "";

		public virtual bool isAdditional => false;

		public bool isEnabledInConfig
		{
			get
			{
				if (configEnableOption != null)
				{
					return ConfigurableValue<bool>.op_Implicit(configEnableOption);
				}
				return true;
			}
		}

		public virtual void OnEnable()
		{
			isActive = true;
		}

		public virtual void OnDisable()
		{
			isActive = false;
		}

		public virtual bool IsAvailable()
		{
			return true;
		}
	}
	public static class ChallengeRunModifierCatalog
	{
		public static List<ChallengeRunModifier> allModifiers = new List<ChallengeRunModifier>();

		public static Dictionary<int, ChallengeRunModifier> indexToModifier = new Dictionary<int, ChallengeRunModifier>();

		public static Dictionary<string, ChallengeRunModifier> nameToModifier = new Dictionary<string, ChallengeRunModifier>();

		public static event Action<List<ChallengeRunModifier>> onCollectModifiers;

		public static void Init()
		{
			allModifiers.Add(new AlwaysSlippery());
			allModifiers.Add(new UtilityCooldown());
			allModifiers.Add(new ChestFailChance());
			allModifiers.Add(new NoOSP());
			allModifiers.Add(new PrimaryStamina());
			allModifiers.Add(new PrinterBug());
			allModifiers.Add(new ChallengeMode.Modifiers.LowHPStress());
			allModifiers.Add(new PerfectedOnPlanet());
			allModifiers.Add(new UselessSteak());
			allModifiers.Add(new MalachiteSpikeOnKill());
			allModifiers.Add(new FireBackfire());
			allModifiers.Add(new BossFocus());
			allModifiers.Add(new DoubleJumpHurts());
			allModifiers.Add(new CurseOnHeavyHit());
			allModifiers.Add(new BlocksForHealth());
			allModifiers.Add(new ExpensivePurchasables());
			allModifiers.Add(new MissChance());
			allModifiers.Add(new ReducedVision());
			allModifiers.Add(new BurnChance());
			allModifiers.Add(new AllChestsCloaked());
			allModifiers.Add(new LoseGoldOverTime());
			allModifiers.Add(new BombDrop());
			allModifiers.Add(new NoGoingBack());
			allModifiers.Add(new BigShot());
			allModifiers.Add(new DroppingItems());
			allModifiers.Add(new RandomMeteors());
			allModifiers.Add(new DronePurgatory());
			allModifiers.Add(new SteakReplacesRandomItems());
			allModifiers.Add(new PurchasesInflictSlow());
			allModifiers.Add(new RerollItems());
			allModifiers.Add(new IncludeVoidReavers());
			allModifiers.Add(new HalfHealingToShields());
			allModifiers.Add(new ChallengeMode.Modifiers.DefenseDamage());
			allModifiers.Add(new EnemiesHaveShield());
			allModifiers.Add(new BossRevive());
			allModifiers.Add(new EquipmentCDRandomized());
			allModifiers.Add(new ChallengeMode.Modifiers.BackpackWeight());
			allModifiers.Add(new ChallengeMode.Modifiers.KillRemorse());
			allModifiers.Add(new HoldoutShrink());
			allModifiers.Add(new TurnOffMyPainInhibitors());
			allModifiers.Add(new BrokenSpine());
			allModifiers.Add(new DebuffInTPRange());
			allModifiers.Add(new NoCrits());
			allModifiers.Add(new IncreasedKnockback());
			allModifiers.Add(new EnemyMissileOnHit());
			allModifiers.Add(new FlutterJumps());
			allModifiers.Add(new FasterBarrierDecay());
			allModifiers.Add(new EnemyLeech());
			allModifiers.Add(new ProcLimit());
			allModifiers.Add(new BossHalfHPArmor());
			allModifiers.Add(new ChallengeMode.Modifiers.Unique.Frostbite());
			allModifiers.Add(new AcidRain());
			allModifiers.Add(new MountainWinds());
			allModifiers.Add(new HotSand());
			allModifiers.Add(new CommsJam());
			allModifiers.Add(new Thunder());
			allModifiers.Add(new BrotherEX());
			allModifiers.Add(new VoidRaidCrabEX());
			if (ChallengeRunModifierCatalog.onCollectModifiers != null)
			{
				ChallengeRunModifierCatalog.onCollectModifiers(allModifiers);
			}
			int num = 0;
			foreach (ChallengeRunModifier allModifier in allModifiers)
			{
				allModifier.modifierIndex = num;
				indexToModifier[num] = allModifier;
				nameToModifier[allModifier.GetType().Name] = allModifier;
				num++;
			}
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				Regex richTextRegex = new Regex("<[^>]*>");
				List<char> forbiddenChars = new List<char> { '=', '\n', '\t', '\\', '"', '\'', '[', ']' };
				foreach (ChallengeRunModifier allModifier2 in allModifiers)
				{
					allModifier2.configEnableOption = ConfigurableValue.CreateBool("com.themysticsword.challengemode", "Virga", ChallengeModePlugin.config, "Enabled Modifiers", GetFilteredString(Language.english.GetLocalizedStringByToken(allModifier2.nameToken)), true, GetFilteredString(Language.english.GetLocalizedStringByToken(allModifier2.descriptionToken)), (List<string>)null, (ConfigEntry<bool>)null, false, (Action<bool>)null);
				}
				string GetFilteredString(string inputString)
				{
					inputString = richTextRegex.Replace(inputString, string.Empty);
					foreach (char item in forbiddenChars)
					{
						inputString = inputString.Replace(item, ' ');
					}
					return inputString;
				}
			});
		}
	}
	public class EXBossAssets : BaseLoadableAsset
	{
		public static GameObject fightEffectsPrefab;

		public static GameObject fightEffectsInstance;

		public static bool fightEffectsActive
		{
			get
			{
				return (Object)(object)fightEffectsInstance != (Object)null;
			}
			set
			{
				if (Object.op_Implicit((Object)(object)fightEffectsInstance) == value)
				{
					return;
				}
				if (value)
				{
					if (Object.op_Implicit((Object)(object)fightEffectsPrefab))
					{
						fightEffectsInstance = Object.Instantiate<GameObject>(fightEffectsPrefab);
						WeatherParticles val = fightEffectsInstance.AddComponent<WeatherParticles>();
						val.lockPosition = true;
						val.lockRotation = false;
					}
				}
				else if (Object.op_Implicit((Object)(object)fightEffectsInstance))
				{
					Object.Destroy((Object)(object)fightEffectsInstance);
				}
			}
		}

		public override void Load()
		{
			fightEffectsPrefab = ChallengeModePlugin.AssetBundle.LoadAsset<GameObject>("Assets/Mods/ChallengeMode/EXBoss/EXBossFightEffects.prefab");
			((BaseLoadableAsset)this).OnLoad();
			base.asset = fightEffectsPrefab;
		}
	}
	public class PetGame : BaseLoadableAsset
	{
		public class ChallengeModePetGameController : MonoBehaviour
		{
			public struct ButtonInfo
			{
				public Action onClick;

				public GameObject objectToBlink;
			}

			public enum State
			{
				SlideIn,
				Loading,
				Playing,
				SlideOut
			}

			public int level = 1;

			public float exp = 0f;

			public float expToLevelUp = 5f;

			public int food = 200;

			public float happiness = 0.5f;

			public float wakefulness = 0.5f;

			public GameObject mainGameHolder;

			public GameObject headpatHolder;

			public GameObject loadingHolder;

			public GameObject interactiveCanvasHolder;

			public GameObject interactiveCanvasButtonHolder;

			public GameObject meshHolder;

			public GameObject screenOffHolder;

			public Animator petAnimator;

			public RuntimeAnimatorController petBaseAnim;

			public AnimatorOverrideController petSleepAnim;

			public TextMeshProUGUI levelText;

			public TextMeshProUGUI foodText;

			public Image expBarFilling;

			public Image happinessBarFilling;

			public Image wakefulnessBarFilling;

			public Image loadingBarFilling;

			public float headpatTimer = 0f;

			public float headpatHappinessRecharge = 0.09f;

			public float timeForFullSadness = 172800f;

			public bool sleeping = false;

			public float sleepWakefulnessRecharge = 0.04f;

			public float timeForFullSleepiness = 32400f;

			public float loadingProgress = 0f;

			public float loadingPerSecond = 1f / 3f;

			public List<ButtonInfo> inGameButtons;

			public int currentButtonIndex = 0;

			public float buttonBlinkTimer = 0f;

			public float buttonBlinkInterval = 0.5f;

			public bool canUseButtons = true;

			public static List<string> paletteNames = new List<string>
			{
				"Retro", "Virtual", "Pink", "Orange", "Sky", "Toxic", "FlowerField", "Trans", "Acid", "Neo",
				"Mocha", "Void"
			};

			public int currentPaletteIndex = 0;

			public Material displayMaterial;

			public State currentState;

			public Transform consoleTransform;

			public float stateAge = 0f;

			public AnimationCurve smooth01Curve;

			public void Awake()
			{
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Expected O, but got Unknown
				//IL_012f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0139: Expected O, but got Unknown
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Expected O, but got Unknown
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: Expected O, but got Unknown
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: Expected O, but got Unknown
				inGameButtons = new List<ButtonInfo>
				{
					new ButtonInfo
					{
						onClick = OnFeed,
						objectToBlink = ((Component)mainGameHolder.transform.Find("HUD/Buttons/Feed/Text (TMP)")).gameObject
					},
					new ButtonInfo
					{
						onClick = OnHeadpat,
						objectToBlink = ((Component)mainGameHolder.transform.Find("HUD/Buttons/Pet/Text (TMP)")).gameObject
					},
					new ButtonInfo
					{
						onClick = OnSleep,
						objectToBlink = ((Component)mainGameHolder.transform.Find("HUD/Buttons/Sleep/Text (TMP)")).gameObject
					}
				};
				((UnityEvent)((Button)((Component)interactiveCanvasButtonHolder.transform.Find("Up")).GetComponent<MPButton>()).onClick).AddListener((UnityAction)delegate
				{
					ChangeCurrentButtonIndex(currentButtonIndex - 1);
				});
				((UnityEvent)((Button)((Component)interactiveCanvasButtonHolder.transform.Find("Down")).GetComponent<MPButton>()).onClick).AddListener((UnityAction)delegate
				{
					ChangeCurrentButtonIndex(currentButtonIndex + 1);
				});
				((UnityEvent)((Button)((Component)interactiveCanvasButtonHolder.transform.Find("OK")).GetComponent<MPButton>()).onClick).AddListener(new UnityAction(ClickCurrentButton));
				((UnityEvent)((Button)((Component)interactiveCanvasButtonHolder.transform.Find("Palette")).GetComponent<MPButton>()).onClick).AddListener(new UnityAction(SwapPalette));
				((UnityEvent)((Button)((Component)interactiveCanvasButtonHolder.transform.Find("On Off")).GetComponent<MPButton>()).onClick).AddListener(new UnityAction(OnQuit));
				level = ChallengeModeConfig.petLevel.Value;
				exp = ChallengeModeConfig.petExp.Value;
				food = ChallengeModeConfig.petFood.Value;
				float value = ChallengeModeConfig.petLastLoginTime.Value;
				float currentLoginTime = GetCurrentLoginTime();
				float num = 0f;
				if (value != 0f)
				{
					num = currentLoginTime - value;
				}
				happiness = Mathf.Clamp01(ChallengeModeConfig.petHappiness.Value - num / timeForFullSadness);
				wakefulness = Mathf.Clamp01(ChallengeModeConfig.petWakefulness.Value - num / timeForFullSleepiness);
				currentPaletteIndex = paletteNames.IndexOf(ChallengeModeConfig.petPalette.Value);
				if (currentPaletteIndex == -1)
				{
					currentPaletteIndex = 0;
				}
				UpdateMaterialPalette();
				smooth01Curve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
				((TMP_Text)((Component)mainGameHolder.transform.Find("HUD/Buttons/Feed/Text (TMP)")).GetComponent<TextMeshProUGUI>()).text = Language.currentLanguage.GetLocalizedStringByToken("CHALLENGEMODE_PETGAME_BUTTON_FEED");
				((TMP_Text)((Component)mainGameHolder.transform.Find("HUD/Buttons/Pet/Text (TMP)")).GetComponent<TextMeshProUGUI>()).text = Language.currentLanguage.GetLocalizedStringByToken("CHALLENGEMODE_PETGAME_BUTTON_PET");
				((TMP_Text)((Component)mainGameHolder.transform.Find("HUD/Buttons/Sleep/Text (TMP)")).GetComponent<TextMeshProUGUI>()).text = Language.currentLanguage.GetLocalizedStringByToken("CHALLENGEMODE_PETGAME_BUTTON_SLEEP");
				((TMP_Text)((Component)loadingHolder.transform.Find("GameTitle")).GetComponent<TextMeshProUGUI>()).text = Language.currentLanguage.GetLocalizedStringByToken("CHALLENGEMODE_PETGAME_TITLE_ONSCREEN");
				((TMP_Text)((Component)meshHolder.transform.Find("OK Button/Text")).GetComponent<TextMeshPro>()).text = Language.currentLanguage.GetLocalizedStringByToken("CHALLENGEMODE_PETGAME_CONSOLE_BUTTON_CONFIRM");
				((TMP_Text)((Component)meshHolder.transform.Find("Palette Button/Text")).GetComponent<TextMeshPro>()).text = Language.currentLanguage.GetLocalizedStringByToken("CHALLENGEMODE_PETGAME_CONSOLE_BUTTON_PALETTESWAP");
				((TMP_Text)((Component)meshHolder.transform.Find("On Off Button/Text")).GetComponent<TextMeshPro>()).text = Language.currentLanguage.GetLocalizedStringByToken("CHALLENGEMODE_PETGAME_CONSOLE_BUTTON_POWER");
			}

			public void Start()
			{
				currentState = State.SlideIn;
				screenOffHolder.SetActive(true);
				MPButton[] componentsInChildren = interactiveCanvasButtonHolder.GetComponentsInChildren<MPButton>();
				foreach (MPButton val in componentsInChildren)
				{
					((Selectable)val).interactable = false;
				}
				UpdateStatVisuals();
				UpdateLevelData();
			}

			public void Update()
			{
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_036d: Unknown result type (might be due to invalid IL or missing references)
				stateAge += Time.deltaTime;
				float num = 0f;
				switch (currentState)
				{
				case State.SlideIn:
					num = Mathf.Clamp01(stateAge / 2f);
					((Component)consoleTransform).transform.localPosition = new Vector3(0f, -10f + 10f * smooth01Curve.Evaluate(num), 11.46f);
					((Component)consoleTransform).transform.localRotation = Quaternion.Euler(new Vector3(0f, -270f + 360f * smooth01Curve.Evaluate(num), 0f));
					if (num >= 1f)
					{
						screenOffHolder.SetActive(false);
						loadingHolder.SetActive(true);
						mainGameHolder.SetActive(false);
						stateAge = 0f;
						currentState = State.Loading;
					}
					break;
				case State.Loading:
					loadingProgress += loadingPerSecond * Time.deltaTime;
					loadingBarFilling.fillAmount = loadingProgress;
					if (loadingProgress >= 1f)
					{
						loadingHolder.SetActive(false);
						mainGameHolder.SetActive(true);
						canUseButtons = true;
						MPButton[] componentsInChildren = interactiveCanvasButtonHolder.GetComponentsInChildren<MPButton>();
						foreach (MPButton val in componentsInChildren)
						{
							((Selectable)val).interactable = true;
						}
						stateAge = 0f;
						currentState = State.Playing;
					}
					break;
				case State.Playing:
					if (headpatTimer > 0f)
					{
						headpatTimer -= Time.deltaTime;
						happiness = Mathf.Clamp01(happiness + headpatHappinessRecharge * Time.deltaTime);
						UpdateStatVisuals();
						if (headpatTimer <= 0f)
						{
							headpatHolder.SetActive(false);
						}
					}
					if (sleeping)
					{
						wakefulness = Mathf.Clamp01(wakefulness + sleepWakefulnessRecharge * Time.deltaTime);
						UpdateStatVisuals();
						if (wakefulness >= 1f)
						{
							sleeping = false;
							petAnimator.runtimeAnimatorController = petBaseAnim;
						}
					}
					buttonBlinkTimer += Time.deltaTime;
					if (!(buttonBlinkTimer >= buttonBlinkInterval))
					{
						break;
					}
					buttonBlinkTimer -= buttonBlinkInterval;
					if (currentButtonIndex >= 0 && currentButtonIndex < inGameButtons.Count)
					{
						GameObject objectToBlink = inGameButtons[currentButtonIndex].objectToBlink;
						if (Object.op_Implicit((Object)(object)objectToBlink))
						{
							objectToBlink.SetActive(!objectToBlink.activeSelf);
						}
					}
					break;
				case State.SlideOut:
					num = Mathf.Clamp01(stateAge / 1f);
					((Component)consoleTransform).transform.localPosition = new Vector3(0f, -10f * smooth01Curve.Evaluate(num), 11.46f);
					if (num >= 1f)
					{
						Deactivate();
					}
					break;
				}
			}

			public void OnFeed()
			{
				if (food > 0)
				{
					sleeping = false;
					headpatTimer = 0.001f;
					petAnimator.runtimeAnimatorController = petBaseAnim;
					food--;
					exp += 1f * ((happiness + wakefulness) / 2f);
					UpdateLevelData();
				}
			}

			public void OnHeadpat()
			{
				sleeping = false;
				petAnimator.runtimeAnimatorController = petBaseAnim;
				headpatHolder.SetActive(true);
				headpatTimer = 3f;
			}

			public void OnSleep()
			{
				if (!(wakefulness >= 1f))
				{
					headpatTimer = 0.001f;
					petAnimator.runtimeAnimatorController = (RuntimeAnimatorController)(object)petSleepAnim;
					sleeping = true;
				}
			}

			public void ChangeCurrentButtonIndex(int newButtonIndex)
			{
				if (currentButtonIndex >= 0 && currentButtonIndex < inGameButtons.Count)
				{
					GameObject objectToBlink = inGameButtons[currentButtonIndex].objectToBlink;
					if (Object.op_Implicit((Object)(object)objectToBlink))
					{
						objectToBlink.SetActive(true);
					}
				}
				currentButtonIndex = newButtonIndex;
				if (currentButtonIndex >= inGameButtons.Count)
				{
					currentButtonIndex = 0;
				}
				else if (currentButtonIndex < 0)
				{
					currentButtonIndex = inGameButtons.Count - 1;
				}
			}

			public void ClickCurrentButton()
			{
				if (canUseButtons && currentButtonIndex >= 0 && currentButtonIndex < inGameButtons.Count && inGameButtons[currentButtonIndex].onClick != null)
				{
					inGameButtons[currentButtonIndex].onClick();
				}
			}

			public void UpdateMaterialPalette()
			{
				if (Object.op_Implicit((Object)(object)displayMaterial))
				{
					Texture2D val = ChallengeModePlugin.AssetBundle.LoadAsset<Texture2D>("Assets/Mods/ChallengeMode/GrovetenderTender/ColourPalettes/texPalette" + paletteNames[currentPaletteIndex] + ".png");
					if (Object.op_Implicit((Object)(object)val))
					{
						displayMaterial.SetTexture("_RemapTex", (Texture)(object)val);
					}
				}
			}

			public void SwapPalette()
			{
				currentPaletteIndex++;
				if (currentPaletteIndex >= paletteNames.Count)
				{
					currentPaletteIndex = 0;
				}
				UpdateMaterialPalette();
			}

			public void OnQuit()
			{
				screenOffHolder.SetActive(true);
				MPButton[] componentsInChildren = interactiveCanvasButtonHolder.GetComponentsInChildren<MPButton>();
				foreach (MPButton val in componentsInChildren)
				{
					((Selectable)val).interactable = false;
				}
				canUseButtons = false;
				stateAge = 0f;
				currentState = State.SlideOut;
			}

			public void RecalculateExpToLevelUp()
			{
				expToLevelUp = Mathf.Floor(5f + 2f * Mathf.Pow((float)(level - 1), 1.15f));
				UpdateStatVisuals();
			}

			public void OnLevelUp()
			{
				RecalculateExpToLevelUp();
				UpdateStatVisuals();
			}

			public void UpdateStatVisuals()
			{
				((TMP_Text)levelText).text = Language.currentLanguage.GetLocalizedFormattedStringByToken("CHALLENGEMODE_PETGAME_LEVEL", new object[1] { level.ToString() });
				((TMP_Text)foodText).text = Language.currentLanguage.GetLocalizedFormattedStringByToken("CHALLENGEMODE_PETGAME_FOOD", new object[1] { food.ToString() });
				expBarFilling.fillAmount = exp / expToLevelUp;
				happinessBarFilling.fillAmount = happiness;
				wakefulnessBarFilling.fillAmount = wakefulness;
			}

			public void UpdateLevelData()
			{
				RecalculateExpToLevelUp();
				if (exp >= expToLevelUp)
				{
					exp -= expToLevelUp;
					level++;
					OnLevelUp();
				}
			}

			public float GetCurrentLoginTime()
			{
				return (float)(DateTime.Now - DateTime.MinValue).TotalSeconds;
			}

			public void OnDestroy()
			{
				ChallengeModeConfig.petLevel.Value = level;
				ChallengeModeConfig.petExp.Value = exp;
				ChallengeModeConfig.petFood.Value = food;
				ChallengeModeConfig.petHappiness.Value = happiness;
				ChallengeModeConfig.petWakefulness.Value = wakefulness;
				ChallengeModeConfig.petLastLoginTime.Value = GetCurrentLoginTime();
				ChallengeModeConfig.petPalette.Value = paletteNames[currentPaletteIndex];
			}
		}

		public static GameObject gameSystemPrefab;

		public static GameObject gameSystemInstance;

		public override void OnPluginAwake()
		{
			((BaseLoadableAsset)this).OnPluginAwake();
		}

		public override void Load()
		{
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			gameSystemPrefab = ChallengeModePlugin.AssetBundle.LoadAsset<GameObject>("Assets/Mods/ChallengeMode/GrovetenderTender/PetGameSystem.prefab");
			ChallengeModePetGameController challengeModePetGameController = ((Component)gameSystemPrefab.transform.Find("PetGameCanvas/GameController")).gameObject.AddComponent<ChallengeModePetGameController>();
			challengeModePetGameController.mainGameHolder = ((Component)((Component)challengeModePetGameController).transform.Find("MainGame")).gameObject;
			challengeModePetGameController.headpatHolder = ((Component)challengeModePetGameController.mainGameHolder.transform.Find("HeadpatAnimation")).gameObject;
			challengeModePetGameController.loadingHolder = ((Component)((Component)challengeModePetGameController).transform.Find("LoadingScreen")).gameObject;
			challengeModePetGameController.interactiveCanvasHolder = ((Component)gameSystemPrefab.transform.Find("InteractiveCanvas")).gameObject;
			challengeModePetGameController.interactiveCanvasButtonHolder = ((Component)gameSystemPrefab.transform.Find("InteractiveCanvas/MainGame/Buttons")).gameObject;
			challengeModePetGameController.meshHolder = ((Component)gameSystemPrefab.transform.Find("MeshRenderingSystem/mdlMiniGameConsole")).gameObject;
			challengeModePetGameController.screenOffHolder = ((Component)gameSystemPrefab.transform.Find("MeshRenderingSystem/mdlMiniGameConsole/ScreenOff")).gameObject;
			challengeModePetGameController.petAnimator = ((Component)challengeModePetGameController.mainGameHolder.transform.Find("Pet")).GetComponent<Animator>();
			challengeModePetGameController.petBaseAnim = ChallengeModePlugin.AssetBundle.LoadAsset<RuntimeAnimatorController>("Assets/Mods/ChallengeMode/GrovetenderTender/Textures/texPet_0.controller");
			challengeModePetGameController.petSleepAnim = ChallengeModePlugin.AssetBundle.LoadAsset<AnimatorOverrideController>("Assets/Mods/ChallengeMode/GrovetenderTender/Textures/AnimatorOverrides/PetSleep.overrideController");
			challengeModePetGameController.levelText = ((Component)challengeModePetGameController.mainGameHolder.transform.Find("HUD/LevelText")).GetComponent<TextMeshProUGUI>();
			challengeModePetGameController.foodText = ((Component)challengeModePetGameController.mainGameHolder.transform.Find("HUD/FoodText")).GetComponent<TextMeshProUGUI>();
			challengeModePetGameController.expBarFilling = ((Component)challengeModePetGameController.mainGameHolder.transform.Find("HUD/ExpBar/Filling")).GetComponent<Image>();
			challengeModePetGameController.happinessBarFilling = ((Component)challengeModePetGameController.mainGameHolder.transform.Find("HUD/Stats/Happiness/Bar/Filling")).GetComponent<Image>();
			challengeModePetGameController.wakefulnessBarFilling = ((Component)challengeModePetGameController.mainGameHolder.transform.Find("HUD/Stats/Wakefulness/Bar/Filling")).GetComponent<Image>();
			challengeModePetGameController.loadingBarFilling = ((Component)challengeModePetGameController.loadingHolder.transform.Find("ProgressBar/Filling")).GetComponent<Image>();
			challengeModePetGameController.displayMaterial = ChallengeModePlugin.AssetBundle.LoadAsset<Material>("Assets/Mods/ChallengeMode/GrovetenderTender/matPetGameRender.mat");
			challengeModePetGameController.consoleTransform = gameSystemPrefab.transform.Find("MeshRenderingSystem/mdlMiniGameConsole");
			HGifyButton(((Component)challengeModePetGameController.interactiveCanvasHolder.transform.Find("MainGame/Buttons/Up")).GetComponent<Button>());
			HGifyButton(((Component)challengeModePetGameController.interactiveCanvasHolder.transform.Find("MainGame/Buttons/Down")).GetComponent<Button>());
			HGifyButton(((Component)challengeModePetGameController.interactiveCanvasHolder.transform.Find("MainGame/Buttons/OK")).GetComponent<Button>());
			HGifyButton(((Component)challengeModePetGameController.interactiveCanvasHolder.transform.Find("MainGame/Buttons/Palette")).GetComponent<Button>());
			HGifyButton(((Component)challengeModePetGameController.interactiveCanvasHolder.transform.Find("MainGame/Buttons/On Off")).GetComponent<Button>());
			gameSystemPrefab.transform.Find("PetGameCamera").position = new Vector3(23042f, -29341f, 44953f);
			gameSystemPrefab.transform.Find("MeshRenderingSystem").position = new Vector3(23092f, -29341f, 44953f);
			base.asset = gameSystemPrefab;
			static void HGifyButton(Button oldButton)
			{
				GameObject gameObject = ((Component)oldButton).gameObject;
				Object.DestroyImmediate((Object)(object)oldButton);
				MPButton val = gameObject.AddComponent<MPButton>();
				((Selectable)val).transition = (Transition)0;
				((Selectable)val).interactable = true;
				val.allowAllEventSystems = true;
			}
		}

		public static void Activate()
		{
			gameSystemInstance = Object.Instantiate<GameObject>(gameSystemPrefab);
		}

		public static void Deactivate()
		{
			if (Object.op_Implicit((Object)(object)gameSystemInstance))
			{
				Object.Destroy((Object)(object)gameSystemInstance);
			}
		}
	}
	public static class TMProEffects
	{
		public class ChallengeModeTextEffects : MonoBehaviour
		{
			public TMP_Text textComponent;

			public bool textChanged;

			public TMP_MeshInfo[] cachedMeshInfo;

			public float updateTimer = 0f;

			public float updateFrequency = 0.016f;

			public List<TMP_LinkInfo> linksToUpdate = new List<TMP_LinkInfo>();

			public float currentTime = 0f;

			public void Awake()
			{
				textComponent = ((Component)this).GetComponent<TMP_Text>();
				textChanged = true;
			}

			public void Start()
			{
				if (Object.op_Implicit((Object)(object)textComponent) && ((Behaviour)textComponent).isActiveAndEnabled)
				{
					textComponent.ForceMeshUpdate(false, false);
				}
			}

			public void OnEnable()
			{
				TMPro_EventManager.TEXT_CHANGED_EVENT.Add((Action<Object>)ON_TEXT_CHANGED);
			}

			public void OnDisable()
			{
				TMPro_EventManager.TEXT_CHANGED_EVENT.Remove((Action<Object>)ON_TEXT_CHANGED);
			}

			public void ON_TEXT_CHANGED(Object obj)
			{
				if (obj == (Object)(object)textComponent)
				{
					textChanged = true;
				}
			}

			public void Update()
			{
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0150: 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_018d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0274: Unknown result type (might be due to invalid IL or missing references)
				//IL_027b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0293: 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_01a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_037e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0385: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0214: Unknown result type (might be due to invalid IL or missing references)
				//IL_0219: Unknown result type (might be due to invalid IL or missing references)
				//IL_0220: Unknown result type (might be due to invalid IL or missing references)
				//IL_0225: Unknown result type (might be due to invalid IL or missing references)
				//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_02af: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0403: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				//IL_023b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0245: Unknown result type (might be due to invalid IL or missing references)
				//IL_024a: Unknown result type (might be due to invalid IL or missing references)
				//IL_024c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0251: Unknown result type (might be due to invalid IL or missing references)
				//IL_0302: Unknown result type (might be due to invalid IL or missing references)
				//IL_030e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0318: Unknown result type (might be due to invalid IL or missing references)
				//IL_031d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0347: Unknown result type (might be due to invalid IL or missing references)
				//IL_0351: Unknown result type (might be due to invalid IL or missing references)
				//IL_0356: Unknown result type (might be due to invalid IL or missing references)
				//IL_035b: Unknown result type (might be due to invalid IL or missing references)
				currentTime += Time.deltaTime;
				updateTimer -= Time.deltaTime;
				while (updateTimer <= 0f)
				{
					updateTimer += updateFrequency;
					if (!Object.op_Implicit((Object)(object)textComponent) || !((Behaviour)textComponent).isActiveAndEnabled)
					{
						continue;
					}
					TMP_TextInfo textInfo = textComponent.textInfo;
					if (textInfo == null || textInfo.meshInfo == null || textInfo.meshInfo.Length == 0 || textInfo.meshInfo[0].vertices == null)
					{
						break;
					}
					if (textChanged)
					{
						textChanged = false;
						cachedMeshInfo = textInfo.CopyMeshInfoVertexData();
						linksToUpdate.Clear();
						for (int i = 0; i < textInfo.linkCount; i++)
						{
							TMP_LinkInfo item = textInfo.linkInfo[i];
							string linkID = ((TMP_LinkInfo)(ref item)).GetLinkID();
							if (linkID == "ChallengeModeShaky" || linkID == "ChallengeModeRainbow")
							{
								linksToUpdate.Add(item);
							}
						}
					}
					bool flag = false;
					foreach (TMP_LinkInfo item2 in linksToUpdate)
					{
						TMP_LinkInfo current = item2;
						string linkID2 = ((TMP_LinkInfo)(ref current)).GetLinkID();
						string text = linkID2;
						string text2 = text;
						if (!(text2 == "ChallengeModeShaky"))
						{
							if (!(text2 == "ChallengeModeRainbow"))
							{
								continue;
							}
							for (int j = current.linkTextfirstCharacterIndex; j < current.linkTextfirstCharacterIndex + current.linkTextLength; j++)
							{
								TMP_CharacterInfo val = textInfo.characterInfo[j];
								if (val.isVisible)
								{
									flag = true;
									Color32[] colors = cachedMeshInfo[val.materialReferenceIndex].colors32;
									Color32[] colors2 = textInfo.meshInfo[val.materialReferenceIndex].colors32;
									for (int k = 0; k <= 3; k++)
									{
										colors2[val.vertexIndex + k] = Color32.op_Implicit(Color.Lerp(Color32.op_Implicit(colors[val.vertexIndex + k]), Color.HSVToRGB((Time.time * 0.15f + 0.06f * (float)j) % 1f, 1f, 1f), 0.2f));
									}
								}
							}
							continue;
						}
						for (int l = current.linkTextfirstCharacterIndex; l < current.linkTextfirstCharacterIndex + current.linkTextLength; l++)
						{
							TMP_CharacterInfo val2 = textInfo.characterInfo[l];
							if (val2.isVisible)
							{
								flag = true;
								float num = 2f;
								Vector3[] vertices = cachedMeshInfo[val2.materialReferenceIndex].vertices;
								Vector3[] vertices2 = textInfo.meshInfo[val2.materialReferenceIndex].vertices;
								Vector3 val3 = new Vector3(Random.Range(0f - num, num), Random.Range(0f - num, num), 0f) * val2.scale;
								for (int m = 0; m <= 3; m++)
								{
									vertices2[val2.vertexIndex + m] = vertices[val2.vertexIndex + m] + val3;
								}
							}
						}
					}
					if (flag)
					{
						for (int n = 0; n < textInfo.meshInfo.Length; n++)
						{
							TMP_MeshInfo val4 = textInfo.meshInfo[n];
							val4.mesh.vertices = val4.vertices;
							val4.mesh.colors32 = val4.colors32;
							textComponent.UpdateGeometry(val4.mesh, n);
							textComponent.UpdateVertexData((TMP_VertexDataUpdateFlags)16);
						}
					}
				}
			}
		}

		public static void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			ChatBox.Start += new hook_Start(ChatBox_Start);
			HGTextMeshProUGUI.Awake += new hook_Awake(HGTextMeshProUGUI_Awake);
		}

		private static void ChatBox_Start(orig_Start orig, ChatBox self)
		{
			orig.Invoke(self);
			((Component)self.messagesText.textComponent).gameObject.AddComponent<ChallengeModeTextEffects>();
		}

		private static void HGTextMeshProUGUI_Awake(orig_Awake orig, HGTextMeshProUGUI self)
		{
			orig.Invoke(self);
			ChallengeModeTextEffects component = ((Component)self).GetComponent<ChallengeModeTextEffects>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				component = ((Component)self).gameObject.AddComponent<ChallengeModeTextEffects>();
				component.textComponent = (TMP_Text)(object)self;
			}
		}
	}
	public class VoidRaidCrabEXAssets : BaseLoadableAsset
	{
		public class ChallengeModeDisarmingProjectile : MonoBehaviour, IOnDamageInflictedServerReceiver
		{
			public void OnDamageInflictedServer(DamageReport damageReport)
			{
				CharacterBody victimBody = damageReport.victimBody;
				if (Object.op_Implicit((Object)(object)victimBody))
				{
					victimBody.AddTimedBuff(ChallengeModeContent.Buffs.ChallengeMode_Disarmed, 4f * damageReport.damageInfo.procCoefficient);
				}
			}
		}

		public class FireDisarmingOrb : BaseState
		{
			public static GameObject muzzleFlashPrefab;

			public static GameObject projectilePrefab;

			public static float baseDuration = 0.12f;

			public static float baseDurationLastFired = 2f;

			public float duration;

			public Transform muzzle;

			public float damageCoefficient = 0.3f;

			public float force = 100f;

			public float coneSpreadAngle = 6.5f;

			public override void OnEnter()
			{
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Unknown result type (might be due to invalid IL or missing references)
				((BaseState)this).OnEnter();
				duration = baseDuration / base.attackSpeedStat;
				if (((EntityState)this).skillLocator.primaryBonusStockSkill.stock <= 0)
				{
					duration = baseDurationLastFired / base.attackSpeedStat;
				}
				muzzle = ((BaseState)this).FindModelChild("EyeProjectileCenter");
				if (!Object.op_Implicit((Object)(object)muzzle))
				{
					muzzle = ((EntityState)this).characterBody.coreTransform;
				}
				((EntityState)this).PlayAnimation("Gesture", "FireEyeBlast", "Eyeblast.playbackRate", duration);
				EffectManager.SimpleMuzzleFlash(muzzleFlashPrefab, ((EntityState)this).gameObject, "EyeProjectileCenter", false);
				if (((EntityState)this).isAuthority)
				{
					Ray aimRay = ((BaseState)this).GetAimRay();
					Quaternion val = Util.QuaternionSafeLookRotation(((Ray)(ref aimRay)).direction);
					FireProjectileInfo val2 = default(FireProjectileInfo);
					val2.projectilePrefab = projectilePrefab;
					val2.position = muzzle.position;
					val2.owner = ((EntityState)this).gameObject;
					val2.damage = base.damageStat * damageCoefficient;
					val2.force = force;
					val2.crit = ((EntityState)this).characterBody.RollCrit();
					val2.rotation = val * GetRandomRollPitch();
					FireProjectileInfo val3 = val2;
					ProjectileManager.instance.FireProjectile(val3);
				}
			}

			public override void FixedUpdate()
			{
				((EntityState)this).FixedUpdate();
				if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration)
				{
					((EntityState)this).outer.SetNextStateToMain();
				}
			}

			public Quaternion GetRandomRollPitch()
			{
				//IL_0010: Unknown result type (might be due t