Decompiled source of CyAn Rnd v1.2.2

plugins/CyAn_Rnd/CyAn_Rnd.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
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 BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On.RoR2;
using ProperSave;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CyAn_Rnd")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+7237ca4a6027866817c0ebcb742b28cd837e2d0f")]
[assembly: AssemblyProduct("CyAn_Rnd")]
[assembly: AssemblyTitle("CyAn_Rnd")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CyAn_Rnd
{
	public class ArtifactOfOrder : CyAn_RndArtifactBase
	{
		public static Dictionary<ItemTier, ItemIndex> tierToItemMap = new Dictionary<ItemTier, ItemIndex>();

		public static EquipmentIndex allowedEquipment = (EquipmentIndex)(-1);

		private bool isEnforcingRestrictions;

		public static List<PickupIndex> originalTier1DropList;

		public static List<PickupIndex> originalTier2DropList;

		public static List<PickupIndex> originalTier3DropList;

		public static List<PickupIndex> originalBossDropList;

		public static List<PickupIndex> originalLunarDropList;

		public static List<PickupIndex> originalVoidTier1DropList;

		public static List<PickupIndex> originalVoidTier2DropList;

		public static List<PickupIndex> originalVoidTier3DropList;

		public static List<PickupIndex> originalVoidBossDropList;

		public static bool orderActive = false;

		public List<PickupIndex> originalEquipmentDropList;

		public List<PickupIndex> originalLunarEquipmentDropList;

		public PickupDropTable MonsterDropTable;

		public override string ArtifactName => "Artifact of Order";

		public override string ArtifactLangTokenName => "ORDER";

		public override string ArtifactDescription => "forces only one different item per tier";

		public override Sprite ArtifactEnabledIcon => CyAn_Rnd.LoadEmbeddedSprite("CyAn_Rnd.Resources.order_enabled.png");

		public override Sprite ArtifactDisabledIcon => CyAn_Rnd.LoadEmbeddedSprite("CyAn_Rnd.Resources.order_disabled.png");

		public override void Init(ConfigFile config)
		{
			CreateLang();
			CreateArtifact();
			Hooks();
		}

		public override void Hooks()
		{
			Run.onRunStartGlobal += ModifyItemDropTables;
			SceneDirector.onGenerateInteractableCardSelection += RemovePrintersAndScrappers;
			Inventory.onInventoryChangedGlobal += EnforceArtifactItemRestrictions;
		}

		private void SaveOriginalDropLists(Run run)
		{
			originalTier1DropList = new List<PickupIndex>(run.availableTier1DropList);
			originalTier2DropList = new List<PickupIndex>(run.availableTier2DropList);
			originalTier3DropList = new List<PickupIndex>(run.availableTier3DropList);
			originalBossDropList = new List<PickupIndex>(run.availableBossDropList);
			originalLunarDropList = new List<PickupIndex>(run.availableLunarItemDropList);
			originalVoidTier1DropList = new List<PickupIndex>(run.availableVoidTier1DropList);
			originalVoidTier2DropList = new List<PickupIndex>(run.availableVoidTier2DropList);
			originalVoidTier3DropList = new List<PickupIndex>(run.availableVoidTier3DropList);
			originalVoidBossDropList = new List<PickupIndex>(run.availableVoidBossDropList);
			originalEquipmentDropList = new List<PickupIndex>(run.availableEquipmentDropList);
			originalLunarEquipmentDropList = new List<PickupIndex>(run.availableLunarEquipmentDropList);
		}

		private void ModifyItemDropTables(Run run)
		{
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Invalid comparison between Unknown and I4
			//IL_0148: 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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: 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_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			if (!base.ArtifactEnabled)
			{
				orderActive = false;
				return;
			}
			orderActive = true;
			SaveOriginalDropLists(run);
			Dictionary<ItemTier, List<PickupIndex>> dictionary = new Dictionary<ItemTier, List<PickupIndex>>
			{
				{
					(ItemTier)0,
					new List<PickupIndex>(run.availableTier1DropList)
				},
				{
					(ItemTier)1,
					new List<PickupIndex>(run.availableTier2DropList)
				},
				{
					(ItemTier)2,
					new List<PickupIndex>(run.availableTier3DropList)
				},
				{
					(ItemTier)3,
					new List<PickupIndex>(run.availableLunarItemDropList)
				},
				{
					(ItemTier)4,
					new List<PickupIndex>(run.availableBossDropList)
				},
				{
					(ItemTier)6,
					new List<PickupIndex>(run.availableVoidTier1DropList)
				},
				{
					(ItemTier)7,
					new List<PickupIndex>(run.availableVoidTier2DropList)
				},
				{
					(ItemTier)8,
					new List<PickupIndex>(run.availableVoidTier3DropList)
				},
				{
					(ItemTier)9,
					new List<PickupIndex>(run.availableVoidBossDropList)
				}
			};
			List<PickupIndex> list = new List<PickupIndex>(run.availableEquipmentDropList);
			list.AddRange(run.availableLunarEquipmentDropList);
			if (!CyAn_Rnd.wasLoaded)
			{
				tierToItemMap.Clear();
				foreach (var (val2, list3) in dictionary)
				{
					if (list3.Count != 0)
					{
						PickupDef pickupDef = PickupCatalog.GetPickupDef(list3[Random.Range(0, list3.Count)]);
						if ((int)pickupDef.itemIndex != -1)
						{
							tierToItemMap[val2] = pickupDef.itemIndex;
							Log.Info($"Chosen allowed Item for Tier {val2}: {Language.GetString(pickupDef.nameToken)}");
						}
					}
				}
				if (list.Count > 0)
				{
					allowedEquipment = PickupCatalog.GetPickupDef(list[Random.Range(0, list.Count)]).equipmentIndex;
					Log.Info("Chosen allowed equipment: " + Language.GetString(EquipmentCatalog.GetEquipmentDef(allowedEquipment).nameToken));
				}
				else
				{
					allowedEquipment = (EquipmentIndex)(-1);
				}
			}
			foreach (List<PickupIndex> value2 in dictionary.Values)
			{
				foreach (PickupIndex item in value2)
				{
					PickupDef pickupDef2 = PickupCatalog.GetPickupDef(item);
					if (!tierToItemMap.TryGetValue(pickupDef2.itemTier, out var value) || pickupDef2.itemIndex != value)
					{
						run.DisablePickupDrop(item);
					}
				}
			}
			foreach (PickupIndex item2 in list)
			{
				if (PickupCatalog.GetPickupDef(item2).equipmentIndex != allowedEquipment)
				{
					run.DisablePickupDrop(item2);
				}
			}
		}

		private void RemovePrintersAndScrappers(SceneDirector director, DirectorCardCategorySelection dccs)
		{
			if (!base.ArtifactEnabled)
			{
				return;
			}
			dccs.RemoveCardsThatFailFilter((Predicate<DirectorCard>)delegate(DirectorCard card)
			{
				bool result = true;
				if ((Object)(object)card.spawnCard != (Object)null)
				{
					string name = ((Object)card.spawnCard).name;
					if (name.StartsWith("iscDuplicator") || name == "iscScrapper")
					{
						result = false;
					}
				}
				return result;
			});
		}

		private void EnforceArtifactItemRestrictions(Inventory inventory)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Invalid comparison between Unknown and I4
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
			if (!base.ArtifactEnabled || !((Object)((Component)inventory).gameObject).name.Contains("Player") || (Object)(object)inventory == (Object)null || (Object)(object)Run.instance == (Object)null || isEnforcingRestrictions || CyAn_Rnd.wasLoaded)
			{
				return;
			}
			isEnforcingRestrictions = true;
			AllItemsEnumerator enumerator = ItemCatalog.allItems.GetEnumerator();
			try
			{
				while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
				{
					ItemIndex current = ((AllItemsEnumerator)(ref enumerator)).Current;
					int itemCount = inventory.GetItemCount(current);
					if (itemCount <= 0)
					{
						continue;
					}
					ItemDef itemDef = ItemCatalog.GetItemDef(current);
					if (!((Object)(object)itemDef == (Object)null) && (int)itemDef.tier != 5 && !tierToItemMap.ContainsValue(current))
					{
						if (tierToItemMap.TryGetValue(itemDef.tier, out var value))
						{
							inventory.RemoveItem(current, itemCount);
							inventory.GiveItem(value, itemCount);
							Log.Info("Replaced " + Language.GetString(itemDef.nameToken) + " with " + Language.GetString(ItemCatalog.GetItemDef(value).nameToken));
						}
						else
						{
							Log.Warning($"No replacement found for item tier: {itemDef.tier} (item: {itemDef.nameToken})");
						}
					}
				}
			}
			finally
			{
				((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
			}
			if ((int)allowedEquipment != -1)
			{
				int equipmentSlotCount = inventory.GetEquipmentSlotCount();
				for (uint num = 0u; num < equipmentSlotCount; num++)
				{
					EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(inventory.GetEquipment(num).equipmentIndex);
					if ((Object)(object)equipmentDef != (Object)null && inventory.GetEquipment(num).equipmentIndex != allowedEquipment)
					{
						Log.Info("Replacing equipment: " + ((Object)equipmentDef).name + " with " + ((Object)EquipmentCatalog.GetEquipmentDef(allowedEquipment)).name);
						inventory.SetEquipmentIndex(allowedEquipment);
					}
				}
			}
			isEnforcingRestrictions = false;
		}
	}
	public class CyAn_Arena
	{
		[CompilerGenerated]
		private sealed class <AddShrinesDelay>d__37 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ArenaMissionController controller;

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

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

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

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

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					int num = numShrines * arenaCount;
					if (expScaling && num > 0)
					{
						if (TeleporterInteraction.instance.shrineBonusStacks <= 0)
						{
							TeleporterInteraction.instance.AddShrineStack();
							num--;
						}
						num = (int)((double)TeleporterInteraction.instance.shrineBonusStacks * Math.Pow(2.0, num)) - TeleporterInteraction.instance.shrineBonusStacks;
					}
					for (int i = 0; i < num; i++)
					{
						TeleporterInteraction.instance.AddShrineStack();
					}
					ArenaMissionController obj = controller;
					obj.baseMonsterCredit += extraMonsterCredits * (float)TeleporterInteraction.instance.shrineBonusStacks;
					return false;
				}
				}
			}

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

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

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

			private object <>2__current;

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

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

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

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

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				//IL_007c: 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)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					GameObject[] array = Object.FindObjectsOfType<GameObject>();
					bool flag = false;
					GameObject[] array2 = array;
					for (int i = 0; i < array2.Length; i++)
					{
						if (((Object)array2[i]).name.Contains("PortalArena"))
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						CyAn_Rnd.SyncObject(Object.Instantiate<GameObject>(CyAn_Rnd.raidPortalPrefab, new Vector3(281.1f, -446.82f, -126.1f), new Quaternion(0f, -0.73274f, 0f, 0.68051f)));
					}
					return false;
				}
				}
			}

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

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

		public static int arenaCount = -1;

		public static int arenaCap = 0;

		public static int numShrines = 5;

		public static int extraStacks = 1;

		public static int extraStacksThreshold = 0;

		public static int extraMonsterTypes = 1;

		public static int extraMonsterTypesThreshold = 0;

		public static float extraMonsterCredits = 0f;

		public static float extraItems = 0f;

		public static float extraRewards = 0f;

		public static float stageIncrease = 0f;

		public static float voidRadius = 1f;

		public static bool skipVanilla = false;

		public static bool KillMeOption = false;

		public static bool expScaling = false;

		public static bool useShrine = false;

		public static int[] latestInventoryItems = Array.Empty<int>();

		public static float[] maxCharges = new float[9] { 0.11f, 0.22f, 0.33f, 0.44f, 0.55f, 0.66f, 0.77f, 0.88f, 1f };

		public static float[] startCharges = new float[9] { 0f, 0.11f, 0.22f, 0.33f, 0.44f, 0.55f, 0.66f, 0.77f, 0.88f };

		public static float chargeDurationMult = 1f;

		public static int currentCell = -1;

		public static int DifficultyCounter = 0;

		public static string monsterBlacklist = "";

		public static bool allowDuplicates = false;

		public static float recievedSize = 0f;

		public void RegisterArenaHooks()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			BazaarController.OnStartServer += new hook_OnStartServer(CheckNullPortal);
			PickupPickerController.CreatePickup_PickupIndex += new hook_CreatePickup_PickupIndex(MultiplyItemReward);
			ArenaMissionController.AddItemStack += new hook_AddItemStack(MultiplyEnemyItem);
			ArenaMissionController.AddMonsterType += new hook_AddMonsterType(MultiplyEnemyType);
			ArenaMissionController.BeginRound += new hook_BeginRound(ActivateCell);
			ArenaMissionController.EndRound += new hook_EndRound(FinishCell);
			HoldoutZoneController.Update += new hook_Update(ZoneCharge);
		}

		public void ZoneCharge(orig_Update orig, HoldoutZoneController self)
		{
			if (!((NetworkBehaviour)self).hasAuthority)
			{
				if (recievedSize > 0f)
				{
					self.baseRadius = recievedSize;
					recievedSize = 0f;
				}
				orig.Invoke(self);
			}
			else if (SceneInfo.instance.sceneDef.baseSceneName == "arena")
			{
				if (self.charge <= maxCharges[currentCell])
				{
					orig.Invoke(self);
				}
				else if (self.charge < 0.99f)
				{
					orig.Invoke(self);
					self.charge = 99f;
				}
				else
				{
					orig.Invoke(self);
				}
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private void MultiplyItemReward(orig_CreatePickup_PickupIndex orig, PickupPickerController self, PickupIndex pickupIndex)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (SceneInfo.instance.sceneDef.baseSceneName != "arena")
			{
				orig.Invoke(self, pickupIndex);
				return;
			}
			int num = ((!useShrine) ? Math.Max((int)Math.Floor((float)DifficultyCounter * extraRewards), 1) : Math.Max((int)Math.Floor((float)TeleporterInteraction.instance.shrineBonusStacks * extraRewards), 1));
			if (CyAn_Rnd.preventDrops)
			{
				int playerIndexFromInteractionObject = CyAn_Rnd.GetPlayerIndexFromInteractionObject(((Component)self).gameObject);
				CyAn_Rnd.AddToPlayerInventory(((PickupIndex)(ref pickupIndex)).pickupDef.itemIndex, playerIndexFromInteractionObject, num);
				return;
			}
			for (int i = 0; i < num; i++)
			{
				orig.Invoke(self, pickupIndex);
			}
		}

		private void ActivateCell(orig_BeginRound orig, ArenaMissionController self)
		{
			orig.Invoke(self);
			if (((NetworkBehaviour)self).hasAuthority)
			{
				currentCell++;
				if (currentCell > 8)
				{
					currentCell = 8;
				}
				HoldoutZoneController component = self.nullWards[self.currentRound - 1].GetComponent<HoldoutZoneController>();
				component.baseRadius *= voidRadius;
				component.baseChargeDuration *= chargeDurationMult;
				component.charge = startCharges[currentCell];
				CyAn_Network cyAn_Network = new CyAn_Network(component.baseRadius);
				NetworkServer.SendToAll(CyAn_Rnd.networkId, (MessageBase)(object)cyAn_Network);
			}
		}

		private void FinishCell(orig_EndRound orig, ArenaMissionController self)
		{
			if (stageIncrease > 0f)
			{
				int num = ((!useShrine) ? DifficultyCounter : TeleporterInteraction.instance.shrineBonusStacks);
				Run instance = Run.instance;
				instance.stageClearCount += (int)Math.Floor(stageIncrease * (float)num);
			}
			Log.Message(self.numRewardOptions);
			orig.Invoke(self);
		}

		private void MultiplyEnemyItem(orig_AddItemStack orig, ArenaMissionController self)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)self.inventory))
			{
				orig.Invoke(self);
				return;
			}
			Inventory inventory = self.inventory;
			int[] array = (int[])inventory.itemStacks.Clone();
			int num = extraStacks;
			if (extraStacksThreshold > 0)
			{
				num = ((!useShrine) ? (num + DifficultyCounter / extraStacksThreshold) : (num + TeleporterInteraction.instance.shrineBonusStacks / extraStacksThreshold));
			}
			if (allowDuplicates)
			{
				int[] array2 = (int[])inventory.itemStacks.Clone();
				inventory.CleanInventory();
				for (int i = 0; i < num; i++)
				{
					orig.Invoke(self);
					ItemIndex val = self.inventory.itemAcquisitionOrder[0];
					array2[val] += self.inventory.GetItemCount(val);
					inventory.CleanInventory();
					self.nextItemStackIndex--;
				}
				foreach (ItemIndex tier1Item in ItemCatalog.tier1ItemList)
				{
					inventory.GiveItem(tier1Item, array2[tier1Item]);
				}
				foreach (ItemIndex tier2Item in ItemCatalog.tier2ItemList)
				{
					inventory.GiveItem(tier2Item, array2[tier2Item]);
				}
				foreach (ItemIndex tier3Item in ItemCatalog.tier3ItemList)
				{
					inventory.GiveItem(tier3Item, array2[tier3Item]);
				}
			}
			else
			{
				for (int j = 0; j < num; j++)
				{
					orig.Invoke(self);
					self.nextItemStackIndex--;
				}
			}
			self.nextItemStackIndex++;
			latestInventoryItems = new int[inventory.itemStacks.Length];
			for (int k = 0; k < inventory.itemStacks.Length; k++)
			{
				if (!KillMeOption)
				{
					if (extraItems > 0f)
					{
						int val2 = ((!useShrine) ? ((int)Math.Floor((float)DifficultyCounter * extraItems)) : ((int)Math.Floor((float)TeleporterInteraction.instance.shrineBonusStacks * extraItems)));
						val2 = Math.Max(val2, 1);
						if (inventory.itemStacks[k] > array[k])
						{
							inventory.itemStacks[k] = array[k] + (inventory.itemStacks[k] - array[k]) * val2;
						}
					}
				}
				else if (useShrine)
				{
					inventory.itemStacks[k] += Math.Max((int)Math.Floor((float)TeleporterInteraction.instance.shrineBonusStacks * extraItems), 1);
				}
				else
				{
					inventory.itemStacks[k] += Math.Max((int)Math.Floor((float)DifficultyCounter * extraItems), 1);
				}
				latestInventoryItems[k] = inventory.itemStacks[k];
			}
		}

		private void MultiplyEnemyType(orig_AddMonsterType orig, ArenaMissionController self)
		{
			if (!((NetworkBehaviour)self).hasAuthority)
			{
				orig.Invoke(self);
				return;
			}
			int num = extraMonsterTypes;
			if (extraMonsterTypesThreshold > 0)
			{
				num = ((!useShrine) ? (num + DifficultyCounter / extraMonsterTypesThreshold) : (num + TeleporterInteraction.instance.shrineBonusStacks / extraMonsterTypesThreshold));
			}
			CombatDirector[] combatDirectors = self.combatDirectors;
			int num2 = combatDirectors.Length;
			int num3 = num - 1;
			int num4 = combatDirectors.Length + num3;
			Array.Resize(ref self.combatDirectors, num4);
			for (int i = num2; i < num4; i++)
			{
				self.combatDirectors[i] = NewCombatDirector(self.combatDirectors[num2 - 1]);
			}
			for (int j = 0; j < num; j++)
			{
				orig.Invoke(self);
			}
		}

		public static CombatDirector NewCombatDirector(CombatDirector referenceDirector)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0086: 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)
			GameObject val = new GameObject("ArenaMissionController");
			val.SetActive(false);
			CombatDirector obj = val.AddComponent<CombatDirector>();
			obj.monsterCredit = referenceDirector.monsterCredit;
			obj.refundedMonsterCredit = referenceDirector.refundedMonsterCredit;
			obj.expRewardCoefficient = referenceDirector.expRewardCoefficient;
			obj.goldRewardCoefficient = referenceDirector.goldRewardCoefficient;
			obj.minSeriesSpawnInterval = referenceDirector.minSeriesSpawnInterval;
			obj.maxSeriesSpawnInterval = referenceDirector.maxSeriesSpawnInterval;
			obj.minRerollSpawnInterval = referenceDirector.minRerollSpawnInterval;
			obj.maxRerollSpawnInterval = referenceDirector.maxRerollSpawnInterval;
			obj.moneyWaveIntervals = referenceDirector.moneyWaveIntervals;
			obj.teamIndex = referenceDirector.teamIndex;
			obj.creditMultiplier = referenceDirector.creditMultiplier;
			obj.spawnDistanceMultiplier = referenceDirector.spawnDistanceMultiplier;
			obj.maxSpawnDistance = referenceDirector.maxSpawnDistance;
			obj.minSpawnRange = referenceDirector.minSpawnRange;
			obj.shouldSpawnOneWave = referenceDirector.shouldSpawnOneWave;
			obj.targetPlayers = referenceDirector.targetPlayers;
			obj.skipSpawnIfTooCheap = referenceDirector.skipSpawnIfTooCheap;
			obj.maxConsecutiveCheapSkips = referenceDirector.maxConsecutiveCheapSkips;
			obj.resetMonsterCardIfFailed = referenceDirector.resetMonsterCardIfFailed;
			obj.maximumNumberToSpawnBeforeSkipping = referenceDirector.maximumNumberToSpawnBeforeSkipping;
			obj.eliteBias = referenceDirector.eliteBias;
			obj.combatSquad = referenceDirector.combatSquad;
			obj.ignoreTeamSizeLimit = referenceDirector.ignoreTeamSizeLimit;
			obj._monsterCards = referenceDirector._monsterCards;
			obj.fallBackToStageMonsterCards = referenceDirector.fallBackToStageMonsterCards;
			obj.hasStartedWave = referenceDirector.hasStartedWave;
			obj.rng = referenceDirector.rng;
			obj.currentMonsterCard = referenceDirector.currentMonsterCard;
			obj.currentActiveEliteTier = referenceDirector.currentActiveEliteTier;
			obj.currentActiveEliteDef = referenceDirector.currentActiveEliteDef;
			obj.currentMonsterCardCost = referenceDirector.currentMonsterCardCost;
			obj.monsterCardsSelection = referenceDirector.monsterCardsSelection;
			obj.consecutiveCheapSkips = referenceDirector.consecutiveCheapSkips;
			obj.playerRetargetTimer = referenceDirector.playerRetargetTimer;
			obj.spawnCountInCurrentWave = referenceDirector.spawnCountInCurrentWave;
			obj.moneyWaves = referenceDirector.moneyWaves;
			obj.isHalcyonShrineSpawn = referenceDirector.isHalcyonShrineSpawn;
			obj.shrineHalcyoniteDifficultyLevel = referenceDirector.shrineHalcyoniteDifficultyLevel;
			((Behaviour)obj).enabled = ((Behaviour)referenceDirector).enabled;
			((MonoBehaviour)obj).useGUILayout = ((MonoBehaviour)referenceDirector).useGUILayout;
			obj.monsterSpawnTimer = referenceDirector.monsterSpawnTimer;
			obj.lastAttemptedMonsterCard = referenceDirector.lastAttemptedMonsterCard;
			obj.totalCreditsSpent = referenceDirector.totalCreditsSpent;
			obj.onSpawnedServer = referenceDirector.onSpawnedServer;
			obj.spawnEffectPrefab = referenceDirector.spawnEffectPrefab;
			obj.currentSpawnTarget = referenceDirector.currentSpawnTarget;
			val.SetActive(true);
			return obj;
		}

		public void RemoveMatchingMonsterCards(ArenaMissionController controller)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = new List<int>();
			string[] array = new string[0];
			if (monsterBlacklist.Equals(""))
			{
				return;
			}
			try
			{
				array = monsterBlacklist.Split(',');
			}
			catch (Exception ex)
			{
				Log.Error("Unable to parse Monster Blacklist: " + ex.Message);
			}
			if (controller.availableMonsterCards == null)
			{
				return;
			}
			for (int j = 0; j < controller.availableMonsterCards.Count; j++)
			{
				DirectorCard value = controller.availableMonsterCards.GetChoice(j).value;
				bool flag = false;
				string[] array2 = array;
				foreach (string text in array2)
				{
					if (!text.Equals("") && ((Object)value.spawnCard).name.Contains(text))
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					Log.Info("Removed Monster " + ((Object)value.spawnCard).name + " due to Blacklist");
					list.Add(j);
				}
			}
			foreach (int item in list.OrderByDescending((int i) => i))
			{
				controller.availableMonsterCards.RemoveChoice(item);
			}
		}

		public void ArenaStageStart()
		{
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			if (skipVanilla && arenaCount < 0)
			{
				arenaCount = 0;
			}
			arenaCount++;
			if (arenaCap > 0 && arenaCount > arenaCap)
			{
				arenaCount = arenaCap;
			}
			currentCell = -1;
			DifficultyCounter = 0;
			ArenaMissionController val = Object.FindObjectOfType<ArenaMissionController>();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			RemoveMatchingMonsterCards(val);
			if (latestInventoryItems.Length != 0)
			{
				Inventory inventory = val.inventory;
				foreach (ItemIndex tier1Item in ItemCatalog.tier1ItemList)
				{
					inventory.GiveItem(tier1Item, latestInventoryItems[tier1Item]);
				}
				foreach (ItemIndex tier2Item in ItemCatalog.tier2ItemList)
				{
					inventory.GiveItem(tier2Item, latestInventoryItems[tier2Item]);
				}
				foreach (ItemIndex tier3Item in ItemCatalog.tier3ItemList)
				{
					inventory.GiveItem(tier3Item, latestInventoryItems[tier3Item]);
				}
			}
			if (useShrine)
			{
				Object.Instantiate<GameObject>(CyAn_Rnd.teleporterPrefab, new Vector3(0f, -1000f, 0f), Quaternion.identity);
				((MonoBehaviour)val).StartCoroutine(AddShrinesDelay(val));
				return;
			}
			DifficultyCounter += numShrines;
			if (expScaling && numShrines > 0)
			{
				DifficultyCounter += (int)((double)(arenaCount * DifficultyCounter) * Math.Pow(2.0, numShrines));
			}
			else
			{
				DifficultyCounter += arenaCount * numShrines;
			}
			val.baseMonsterCredit += extraMonsterCredits * (float)DifficultyCounter;
		}

		private void CheckNullPortal(orig_OnStartServer orig, BazaarController self)
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				orig.Invoke(self);
				return;
			}
			orig.Invoke(self);
			((MonoBehaviour)self).StartCoroutine(CheckNullDelay());
		}

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

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

		public static void RecieveData(CyAn_Network data)
		{
			recievedSize = data.CellZoneSize;
		}
	}
	public class CyAn_Network : MessageBase
	{
		public int MsgType { get; private set; }

		public ItemIndex Item { get; private set; }

		public float CellZoneSize { get; private set; }

		public CyAn_Network()
		{
		}

		public CyAn_Network(ItemIndex passItem)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			MsgType = 0;
			Item = passItem;
		}

		public CyAn_Network(float size)
		{
			MsgType = 1;
			CellZoneSize = size;
		}

		public override void Serialize(NetworkWriter writer)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(MsgType);
			switch (MsgType)
			{
			case 0:
				NetworkExtensions.Write(writer, Item);
				break;
			case 1:
				writer.Write(CellZoneSize);
				break;
			default:
				Log.Warning($"Unknown MsgType: {MsgType}");
				break;
			}
		}

		public override void Deserialize(NetworkReader reader)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			MsgType = reader.ReadInt32();
			switch (MsgType)
			{
			case 0:
				Item = NetworkExtensions.ReadItemIndex(reader);
				break;
			case 1:
				CellZoneSize = reader.ReadSingle();
				break;
			default:
				Log.Warning($"Unknown MsgType: {MsgType}");
				break;
			}
		}
	}
	[BepInPlugin("Cyan.Rnd", "Cy/an Rnd", "1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class CyAn_Rnd : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static NetworkMessageDelegate <0>__RecieveData;
		}

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

			private object <>2__current;

			public CyAn_Rnd <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected O, but got Unknown
				int num = <>1__state;
				CyAn_Rnd cyAn_Rnd = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					cyAn_Rnd.RePopulateInteractList();
					return false;
				}
			}

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

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

		public const string PluginGUID = "Cyan.Rnd";

		public const string PluginAuthor = "Cy/an";

		public const string PluginName = "Cy/an Rnd";

		public const string PluginVersion = "1.2.0";

		public static GameObject shopPortalPrefab;

		public static GameObject raidPortalPrefab;

		public static GameObject teleporterPrefab;

		public static bool noHightlights = false;

		public static bool enableBleed = false;

		public static bool enableCrit = false;

		public static bool critMults = false;

		public static bool preventDrops = false;

		public static bool preventLunar = false;

		public static bool wasLoaded = false;

		public static int currentPlayer = 0;

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

		public static short networkId = 4379;

		private static readonly CyAn_Arena CyAn_Arena = new CyAn_Arena();

		private readonly List<CyAn_RndArtifactBase> artifacts = new List<CyAn_RndArtifactBase>();

		public void Awake()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			ConfigandTrySoft();
			InitPrefabs();
			CyAn_Arena.RegisterArenaHooks();
			Stage.Start += new hook_Start(CheckTeleporterInstance);
			GenericPickupController.CreatePickup += new hook_CreatePickup(AddItemDirectly);
			PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 += new hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3(AddDropletDirectly);
			HealthComponent.TakeDamage += new hook_TakeDamage(ExtraCrit);
			DotController.AddDot += new hook_AddDot(ExtraBleed);
			Run.Start += new hook_Start(ResetRunVars);
			UserProfile.HasViewedViewable += new hook_HasViewedViewable(Viewed);
			PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(Purchase);
			NetworkUser.onPostNetworkUserStart += new NetworkUserGenericDelegate(TryRegisterNetwork);
			AddArtifact(new ArtifactOfOrder());
			new Harmony("Cyan.Rnd").PatchAll();
		}

		private void AddArtifact(CyAn_RndArtifactBase artifact)
		{
			artifact.Init(((BaseUnityPlugin)this).Config);
			artifacts.Add(artifact);
		}

		private void InitPrefabs()
		{
			//IL_0005: 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)
			//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_0043: 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)
			shopPortalPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/PortalShop/PortalShop.prefab").WaitForCompletion();
			raidPortalPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/PortalArena/PortalArena.prefab").WaitForCompletion();
			raidPortalPrefab.GetComponent<SceneExitController>().useRunNextStageScene = false;
			teleporterPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Teleporters/Teleporter1.prefab").WaitForCompletion();
		}

		private void ConfigandTrySoft()
		{
			(ConfigEntryBase, Type, Action<object>, object, object)[] configEntries = CreateLoadConfig();
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				InitRiskOfOptions(configEntries);
			}
			else
			{
				Log.Warning("RiskOfOptions is not available");
			}
			if (Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.ProperSave"))
			{
				InitProperSave();
			}
			else
			{
				Log.Warning("ProperSave is not available.");
			}
		}

		private void InitProperSave()
		{
			SaveFile.OnGatherSaveData += SaveToProperSave;
			Loading.OnLoadingStarted += LoadFromProperSave;
			Log.Info("ProperSave setup successful");
			static void LoadFromProperSave(SaveFile file)
			{
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0158: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01de: Unknown result type (might be due to invalid IL or missing references)
				if (!file.ModdedData.TryGetValue("CyanRnd", out var value))
				{
					Log.Warning("Could not find SaveData");
				}
				else
				{
					if (value.Value is object[] array && array.Length == 5)
					{
						try
						{
							CyAn_Arena.latestInventoryItems = ((List<object>)array[0]).Cast<int>().ToArray();
						}
						catch (Exception ex)
						{
							Log.Error("Failed to Load save Data because: \"Failure to convert object to int[]. Exception: " + ex.Message + "\"");
						}
						CyAn_Arena.arenaCount = Convert.ToInt32(array[1]);
						currentPlayer = Convert.ToInt32(array[2]);
						wasLoaded = true;
						try
						{
							ArtifactOfOrder.tierToItemMap = ((List<object>)array[3]).Select(delegate(object obj)
							{
								Dictionary<string, object> obj2 = (Dictionary<string, object>)obj;
								int num = Convert.ToInt32(obj2["Key"]);
								int num2 = Convert.ToInt32(obj2["Value"]);
								return new KeyValuePair<ItemTier, ItemIndex>((ItemTier)num, (ItemIndex)num2);
							}).ToDictionary((KeyValuePair<ItemTier, ItemIndex> kvp) => kvp.Key, (KeyValuePair<ItemTier, ItemIndex> kvp) => kvp.Value);
						}
						catch (Exception ex2)
						{
							Log.Error("Failed to Load save Data because: \"Failure to convert object to Dictionary<ItemTier, ItemIndex>. Exception: " + ex2.Message + "\"");
						}
						ArtifactOfOrder.allowedEquipment = (EquipmentIndex)Convert.ToInt32(array[4]);
						Log.Info($"Loaded latestInventoryItems, arenaCount({CyAn_Arena.arenaCount}) and currentPlayer({currentPlayer}) with ProperSave.");
						Log.Info("[Artifact of Order] Chosen allowed equipment: " + Language.GetString(EquipmentCatalog.GetEquipmentDef(ArtifactOfOrder.allowedEquipment).nameToken));
						{
							foreach (KeyValuePair<ItemTier, ItemIndex> item in ArtifactOfOrder.tierToItemMap)
							{
								ItemDef itemDef = ItemCatalog.GetItemDef(item.Value);
								string arg = (((Object)(object)itemDef != (Object)null) ? Language.GetString(itemDef.nameToken) : $"Unknown({item.Key} : {item.Value})");
								Log.Info($"[Artifact of Order] Loaded Item for {item.Key}: {arg}");
							}
							return;
						}
					}
					Log.Error("Saved data format is invalid or unexpected.");
				}
			}
			static void SaveToProperSave(Dictionary<string, object> dictionary)
			{
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Expected I4, but got Unknown
				object[] value2 = new object[5]
				{
					CyAn_Arena.latestInventoryItems,
					CyAn_Arena.arenaCount,
					currentPlayer,
					ArtifactOfOrder.tierToItemMap.Select((KeyValuePair<ItemTier, ItemIndex> kvp) => new KeyValuePair<int, int>((int)kvp.Key, (int)kvp.Value)).ToList(),
					(int)ArtifactOfOrder.allowedEquipment
				};
				dictionary["CyanRnd"] = value2;
				Log.Info("Save data successfully added to ProperSave.");
			}
		}

		private void InitRiskOfOptions((ConfigEntryBase config, Type StaticType, Action<object> updateStaticVar, object min, object max)[] configEntries)
		{
			(ConfigEntryBase, Type, Action<object>, object, object)[] array = configEntries;
			for (int i = 0; i < array.Length; i++)
			{
				var (config, varType, _, min, max) = array[i];
				AddOption(config, varType, min, max);
			}
			array = configEntries;
			for (int i = 0; i < array.Length; i++)
			{
				var (val, type, updateStaticVar, _, _) = array[i];
				if (type == typeof(int))
				{
					ConfigEntry<int> castConfig4 = (ConfigEntry<int>)(object)val;
					castConfig4.SettingChanged += delegate
					{
						updateStaticVar(castConfig4.Value);
					};
				}
				else if (type == typeof(float))
				{
					ConfigEntry<float> castConfig3 = (ConfigEntry<float>)(object)val;
					castConfig3.SettingChanged += delegate
					{
						updateStaticVar(castConfig3.Value);
					};
				}
				else if (type == typeof(bool))
				{
					ConfigEntry<bool> castConfig2 = (ConfigEntry<bool>)(object)val;
					castConfig2.SettingChanged += delegate
					{
						updateStaticVar(castConfig2.Value);
					};
				}
				else if (type == typeof(string))
				{
					ConfigEntry<string> castConfig = (ConfigEntry<string>)(object)val;
					castConfig.SettingChanged += delegate
					{
						updateStaticVar(castConfig.Value);
					};
				}
				else
				{
					Log.Error($"Could not get type {type} to hook SettingChanged for {val.Definition.Key}");
				}
			}
			Log.Info("RiskOfOptions setup successful.");
		}

		private (ConfigEntryBase config, Type StaticType, Action<object> updateStaticVar, object min, object max)[] CreateLoadConfig()
		{
			(ConfigEntryBase, Type, Action<object>, object, object)[] array = new(ConfigEntryBase, Type, Action<object>, object, object)[42]
			{
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("General", "No Hightlights", false, "If enabled, anytime the game asks if you have viewed a 'viewable' it will skip the check and return true.\nThis should effect things like logbook entries and new characters/abilities in the select screen"), typeof(bool), delegate(object value)
				{
					noHightlights = (bool)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("General", "Prevent ItemDrops", false, "If enabled, stops normal item creation and adds them to the players inventory directly\nIterates over all players if Multiplayer\nyou can enable this temporary ingame if neccesary\nWith this Option enabled you will not pickup any items(tough they will still be added to your inventory), I had to specifically add PickupNotifications, i may have forgotten something if you notice any issue, please notify me(i am not sure were at the point of writing this but if the mod is public some time in the future you can definitly reach me somehow)\nThis may cause errors if there are other mods that try to do something to items while they spawn as this will set the spawn to 'null'"), typeof(bool), delegate(object value)
				{
					preventDrops = (bool)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("General", "Do not prevent lunar", false, "If enabled, 'Prevent ItemDrops' will not effect any item from the tier 'Lunar' at all\nThis Option was added because of a very specific request by someone"), typeof(bool), delegate(object value)
				{
					preventLunar = (bool)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("General", "Bleed Stacking", false, "If enabled, anytime a bleed effect is applied and the chance was over 100% there may be a second bleed stack with the remainder, which is added at the same time\nso with 600% crit chance you get 6 bleed stacks per hit\nwill just repeat the buff adding action of base ror2 for every extra bleed. My game starting lagging at ~10k stacks per hit"), typeof(bool), delegate(object value)
				{
					enableBleed = (bool)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("General", "Crit Stacking", false, "If enabled, anytime a crit is rolled and the chance was over 100% there may be a second crit with the remainder, which amplifies the first\nwith default behaviour a crit(x2) deals x3 the base damage, where a crit(x1) would deal x2, this may be changed with the option below"), typeof(bool), delegate(object value)
				{
					enableCrit = (bool)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("General", "Crit Stacking Multiplies", false, "If enabled, any second, third, etc. crits will not up the damage multiplier by just 1, but x2 instead\nfor example with a 200% crit chance the damage will always be x4 base damage as both crits are guranteed and the second amplifies the first x2 to x2 again"), typeof(bool), delegate(object value)
				{
					critMults = (bool)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("Void Fields", "Use Shrines", false, "If enabled, will spawn a unusable teleporter in the void fields to activate mountainShrines instead of just an internal counter\nAny use of the difficulty counter is replaced by the current active mountain Shrines\nThis Option will probably do nothing if you do not have other mods that interact with mountain shrines, i reccomend looking for one that makes them persist over the whole run after activiating"), typeof(bool), delegate(object value)
				{
					CyAn_Arena.useShrine = (bool)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<int>("Void Fields", "Difficulty Scaling", 5, "Number the Internal void field difficulty counter is set to per additional void field entry\n with otherwise unmodded entrys it goes 0,num,2xnum,3xnum,..."), typeof(int), delegate(object value)
				{
					CyAn_Arena.numShrines = (int)value;
				}, 0, 10000),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("Void Fields", "Skip unmodified fields", false, "If enabled, skips the first normal void fields and will directly apply the difficulty modifier"), typeof(bool), delegate(object value)
				{
					CyAn_Arena.skipVanilla = (bool)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("Void Fields", "exponential Scaling", false, "If enabled, will use 'Difficulty Scaling' to *2 instead of just adding\nfor example if the difficulty were normally set to 4 this would make it add 1 and then do *2,*2,*2 for a total of 8 (adding 1 first so that its not 0*2)"), typeof(bool), delegate(object value)
				{
					CyAn_Arena.expScaling = (bool)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<int>("Void Fields", "Stage Counter Cap", 0, "Sets a cap for the Stage Counter, which is what 'Difficulty Scaling' is multiplied by for each entry\n0 for disabled\nExample with a cap of 2 and a scaling of 3 would be 0*3=0, 1*3=3, 2*3=6, 2*3=6, ...\nThis only effects what is added if you, for example, use shrines and have a persistent shrine mod they will still be uncapped and will just always scale by the current settings *Cap at most"), typeof(int), delegate(object value)
				{
					CyAn_Arena.arenaCap = (int)value;
				}, 0, 1000),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<int>("Void Fields", "Enemy ItemStacks", 1, "Sets the number of itemStacks the void fields enemies can obtain.\n1 per activation is vanilla, but with this you can get for example goat's hoof and crit classes at the same time\ndisabled if Kill Me is checked"), typeof(int), delegate(object value)
				{
					CyAn_Arena.extraStacks = (int)value;
				}, 1, 1000),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<int>("Void Fields", "Enemy Extra ItemStacks Threshold", 0, "Difficulty Count required to increase 'Enemy Extra ItemStacks' by 1\nExample if Set to 100 and the Counter is at 225, it will use your ItemStacks setting +2\n0 for disabled"), typeof(int), delegate(object value)
				{
					CyAn_Arena.extraStacksThreshold = (int)value;
				}, 0, 10000),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("Void Fields", "Allow Duplicates", false, "If enabled this allows the void fields to roll the same item twice\nNormally as long as you god crit glasses once they will not be added to the inventory again, this will make it so you could get crit glasses twice thus possibly having to deal with a higher number(of the same) but less differnt items"), typeof(bool), delegate(object value)
				{
					CyAn_Arena.allowDuplicates = (bool)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<int>("Void Fields", "Monsters", 1, "Sets the number of Monsters the void fields add at once.\nReminder that this will be capped by your enemies as in the further you are in stage/lvl you may get harder enemies which you will never get even if you try 100 times (=this set to 100) stage 1\nStill causes an error but seems to work anyway, error is logged, if you are curious, but feel safe to use this for now"), typeof(int), delegate(object value)
				{
					CyAn_Arena.extraMonsterTypes = (int)value;
				}, 1, 1000),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<int>("Void Fields", "Monsters Threshold", 0, "Difficulty Count required to increase 'Monsters' by 1\nExample if Set to 20 and the Counter is at 60, it will use your Monster Setting +3\n0 for disabled"), typeof(int), delegate(object value)
				{
					CyAn_Arena.extraMonsterTypesThreshold = (int)value;
				}, 0, 10000),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<string>("Void Fields", "Monster Blacklist", "", "Any String written here in the form of '[Name],[Name],...' Will be matched to the potential enemy pool and removed if a match is found\nExample, RoR2 has the Spawn Card 'cscLesserWisp' so having this set to 'cscLesserWisp' will remove only the Wisp from the potential Enemies. Setting it to 'cscLesserWisp,cscGreaterWisp' will remove both lesser and greater Wisp, wereas 'Wisp' will remove any that have the name Wisp in them which might remove other modded entries like Ancient Wisp\nAt this point you just have to know or guess the names of the SpawnCards"), typeof(string), delegate(object value)
				{
					CyAn_Arena.monsterBlacklist = (string)value;
				}, null, null),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Extra Credits", 0f, "How many extra credits are given to the void fields per Difficulty Counter\n0 for disabled[i mean you add 0, so...]\nI am not 100% sure but RoR2 may move unused credits to the next stage combat director, so be aware"), typeof(float), delegate(object value)
				{
					CyAn_Arena.extraMonsterCredits = (float)value;
				}, 0f, 10000f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Enemy Extra Items", 1f, "Multiplier for void field enemy items per Difficulty Count.\n0 for disable"), typeof(float), delegate(object value)
				{
					CyAn_Arena.extraItems = (float)value;
				}, 0f, 10000f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Reward Item Multiplier", 1f, "Multiplier for void field rewards per Difficulty Count.\n0 for disable"), typeof(float), delegate(object value)
				{
					CyAn_Arena.extraRewards = (float)value;
				}, 0f, 10000f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Increase Stage Counter after Cell Finish", 0f, "This value will be multiplied by the difficulty counter and Increase the Stage after each cell by that amount\nAs only whole numbers are allowed it will use the floor so it could be 0 for the first few times if the difficulty and this setting is low enough\n0 for disable"), typeof(float), delegate(object value)
				{
					CyAn_Arena.stageIncrease = (float)value;
				}, 0f, 10f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell Radius", 1f, "Multiplies the base radius with the given number"), typeof(float), delegate(object value)
				{
					CyAn_Arena.voidRadius = (float)value;
				}, 0f, 10000f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell Charge duration", 2f, "Multiplies the base charge duration with the given number\nDefault is 2, which is twice as long, because by default settings all cells only need 11%. All in all you go from 0 to 100% once only for a total speed increase of 4.5(if i mathed(?) correctly)"), typeof(float), delegate(object value)
				{
					CyAn_Arena.chargeDurationMult = (float)value;
				}, 0.0001f, 1000f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 1 start Charge", 0f, "The void cell starts at the given percentage for Cell 1"), typeof(float), delegate(object value)
				{
					CyAn_Arena.startCharges[0] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 1 max Charge", 0.11f, "At the given percent, the void cell instantly finishes for Cell 1"), typeof(float), delegate(object value)
				{
					CyAn_Arena.maxCharges[0] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 2 start Charge", 0.11f, "The void cell starts at the given percentage for Cell 2"), typeof(float), delegate(object value)
				{
					CyAn_Arena.startCharges[1] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 2 max Charge", 0.22f, "At the given percent, the void cell instantly finishes for Cell 2"), typeof(float), delegate(object value)
				{
					CyAn_Arena.maxCharges[1] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 3 start Charge", 0.22f, "The void cell starts at the given percentage for Cell 3"), typeof(float), delegate(object value)
				{
					CyAn_Arena.startCharges[2] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 3 max Charge", 0.33f, "At the given percent, the void cell instantly finishes for Cell 3"), typeof(float), delegate(object value)
				{
					CyAn_Arena.maxCharges[2] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 4 start Charge", 0.33f, "The void cell starts at the given percentage for Cell 4"), typeof(float), delegate(object value)
				{
					CyAn_Arena.startCharges[3] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 4 max Charge", 0.44f, "At the given percent, the void cell instantly finishes for Cell 4"), typeof(float), delegate(object value)
				{
					CyAn_Arena.maxCharges[3] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 5 start Charge", 0.44f, "The void cell starts at the given percentage for Cell 5"), typeof(float), delegate(object value)
				{
					CyAn_Arena.startCharges[4] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 5 max Charge", 0.55f, "At the given percent, the void cell instantly finishes for Cell 5"), typeof(float), delegate(object value)
				{
					CyAn_Arena.maxCharges[4] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 6 start Charge", 0.55f, "The void cell starts at the given percentage for Cell 6"), typeof(float), delegate(object value)
				{
					CyAn_Arena.startCharges[5] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 6 max Charge", 0.66f, "At the given percent, the void cell instantly finishes for Cell 6"), typeof(float), delegate(object value)
				{
					CyAn_Arena.maxCharges[5] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 7 start Charge", 0.66f, "The void cell starts at the given percentage for Cell 7"), typeof(float), delegate(object value)
				{
					CyAn_Arena.startCharges[6] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 7 max Charge", 0.77f, "At the given percent, the void cell instantly finishes for Cell 7"), typeof(float), delegate(object value)
				{
					CyAn_Arena.maxCharges[6] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 8 start Charge", 0.77f, "The void cell starts at the given percentage for Cell 8"), typeof(float), delegate(object value)
				{
					CyAn_Arena.startCharges[7] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 8 max Charge", 0.88f, "At the given percent, the void cell instantly finishes for Cell 8"), typeof(float), delegate(object value)
				{
					CyAn_Arena.maxCharges[7] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 9 start Charge", 0.88f, "The void cell starts at the given percentage for Cell 9"), typeof(float), delegate(object value)
				{
					CyAn_Arena.startCharges[8] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "Void Cell 9 max Charge", 1f, "At the given percent, the void cell instantly finishes for Cell 9"), typeof(float), delegate(object value)
				{
					CyAn_Arena.maxCharges[8] = (float)value;
				}, 0f, 1f),
				((ConfigEntryBase)(object)((BaseUnityPlugin)this).Config.Bind<bool>("Void Fields", "Kill Me", false, "If enabled, enemies gain one of every item type instead of a single item type.\nWill also add all Equipment at the same time\nVoid field rewards are now only lunar items(idk why). Items/Equipment may not show up in the listing but are still present\nTHIS OPTION HAS A SPECIFIC NAME FOR A REASON\nTHIS OPTION HAS A SPECIFIC NAME FOR A REASON\nTHIS OPTION HAS A SPECIFIC NAME FOR A REASON"), typeof(bool), delegate(object value)
				{
					CyAn_Arena.KillMeOption = (bool)value;
				}, null, null)
			};
			(ConfigEntryBase, Type, Action<object>, object, object)[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				var (val, type, action, _, _) = array2[i];
				if (type == typeof(int))
				{
					ConfigEntry<int> val2 = (ConfigEntry<int>)(object)val;
					action(val2.Value);
				}
				else if (type == typeof(float))
				{
					ConfigEntry<float> val3 = (ConfigEntry<float>)(object)val;
					action(val3.Value);
				}
				else if (type == typeof(bool))
				{
					ConfigEntry<bool> val4 = (ConfigEntry<bool>)(object)val;
					action(val4.Value);
				}
				else if (type == typeof(string))
				{
					ConfigEntry<string> val5 = (ConfigEntry<string>)(object)val;
					action(val5.Value);
				}
				else
				{
					Log.Error($"{val.Definition.Key} is of invalid type: {type}");
				}
			}
			return array;
		}

		private void AddOption(ConfigEntryBase config, Type varType, object min, object max)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0093: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			if (varType == typeof(int))
			{
				IntSliderConfig val = new IntSliderConfig
				{
					min = (int)min,
					max = (int)max
				};
				ModSettingsManager.AddOption((BaseOption)new IntSliderOption((ConfigEntry<int>)(object)config, val));
				Log.Info("Added RiskOfOption '" + config.Definition.Key + "' as IntSlider");
			}
			else if (varType == typeof(float))
			{
				FloatFieldConfig val2 = new FloatFieldConfig();
				((NumericFieldConfig<float>)val2).Min = (float)min;
				((NumericFieldConfig<float>)val2).Max = (float)max;
				FloatFieldConfig val3 = val2;
				ModSettingsManager.AddOption((BaseOption)new FloatFieldOption((ConfigEntry<float>)(object)config, val3));
				Log.Info("Added RiskOfOption '" + config.Definition.Key + "' as FloatField");
			}
			else if (varType == typeof(bool))
			{
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption((ConfigEntry<bool>)(object)config));
				Log.Info("Added RiskOfOption '" + config.Definition.Key + "' as CheckBox");
			}
			else if (varType == typeof(string))
			{
				ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption((ConfigEntry<string>)(object)config));
				Log.Info("Added RiskOfOption '" + config.Definition.Key + "' as StringInputField");
			}
			else
			{
				Log.Error($"Failed to create option for {config.Definition.Key} because type was {varType}");
			}
		}

		private bool Viewed(orig_HasViewedViewable orig, UserProfile self, string viewableName)
		{
			if (noHightlights)
			{
				return true;
			}
			return orig.Invoke(self, viewableName);
		}

		private GenericPickupController AddItemDirectly(orig_CreatePickup orig, ref CreatePickupInfo createPickupInfo)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			PickupIndex pickupIndex = ((CreatePickupInfo)(ref createPickupInfo)).pickupIndex;
			PickupDef pickupDef = ((PickupIndex)(ref pickupIndex)).pickupDef;
			if (preventLunar && (int)pickupDef.itemTier == 3)
			{
				return orig.Invoke(ref createPickupInfo);
			}
			if (preventDrops && (int)pickupDef.itemIndex != -1)
			{
				AddToPlayerInventory(pickupDef.itemIndex);
				return null;
			}
			return orig.Invoke(ref createPickupInfo);
		}

		private void AddDropletDirectly(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity)
		{
			//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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			//IL_0021: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			PickupIndex pickupIndex = ((CreatePickupInfo)(ref pickupInfo)).pickupIndex;
			PickupDef pickupDef = ((PickupIndex)(ref pickupIndex)).pickupDef;
			if (preventLunar && (int)pickupDef.itemTier == 3)
			{
				orig.Invoke(pickupInfo, position, velocity);
				return;
			}
			if (!preventDrops || (int)pickupDef.itemIndex == -1)
			{
				orig.Invoke(pickupInfo, position, velocity);
				return;
			}
			var (num, @object) = FindNearest(position);
			if (num <= 26f)
			{
				int playerIndexFromInteractionObject = GetPlayerIndexFromInteractionObject(@object);
				AddToPlayerInventory(pickupDef.itemIndex, playerIndexFromInteractionObject);
			}
			else
			{
				AddToPlayerInventory(pickupDef.itemIndex);
			}
		}

		private void Purchase(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
		{
			self.lastActivator = activator;
			orig.Invoke(self, activator);
		}

		private (float, GameObject) FindNearest(Vector3 position)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			GameObject item = null;
			float num = float.MaxValue;
			foreach (GameObject purchaseInteractable in purchaseInteractables)
			{
				if ((Object)(object)purchaseInteractable == (Object)null)
				{
					RePopulateInteractList();
					return FindNearest(position);
				}
				Vector3 val = position - purchaseInteractable.transform.position;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					item = purchaseInteractable;
				}
			}
			return (num, item);
		}

		private void ExtraBleed(orig_AddDot orig, DotController self, GameObject attackerObject, float duration, DotIndex dotIndex, float damageMultiplier, uint? maxStacksFromAttacker, float? totalDamage, DotIndex? preUpgradeDotIndex)
		{
			//IL_0020: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody component = attackerObject.GetComponent<CharacterBody>();
			if (!enableBleed || (int)dotIndex != 0 || (Object)(object)component == (Object)null)
			{
				orig.Invoke(self, attackerObject, duration, dotIndex, damageMultiplier, maxStacksFromAttacker, totalDamage, preUpgradeDotIndex);
				return;
			}
			int num = (int)(component.bleedChance / 100f) - 1;
			if (num < 0)
			{
				orig.Invoke(self, attackerObject, duration, dotIndex, damageMultiplier, maxStacksFromAttacker, totalDamage, preUpgradeDotIndex);
				return;
			}
			float num2 = component.bleedChance % 100f;
			if (num2 > 0f && Random.value * 100f < num2)
			{
				num++;
			}
			orig.Invoke(self, attackerObject, duration, dotIndex, damageMultiplier, maxStacksFromAttacker, totalDamage, preUpgradeDotIndex);
			for (int i = 0; i < num; i++)
			{
				orig.Invoke(self, attackerObject, duration, dotIndex, damageMultiplier, maxStacksFromAttacker, totalDamage, preUpgradeDotIndex);
			}
		}

		private void ExtraCrit(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			if (!enableCrit || !damageInfo.crit || !Object.op_Implicit((Object)(object)damageInfo.attacker))
			{
				orig.Invoke(self, damageInfo);
				return;
			}
			CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
			if ((Object)(object)component == (Object)null)
			{
				orig.Invoke(self, damageInfo);
				return;
			}
			int num = (int)(component.crit / 100f) - 1;
			if (num < 0)
			{
				orig.Invoke(self, damageInfo);
				return;
			}
			float num2 = component.crit % 100f;
			if (num2 > 0f && Random.value * 100f < num2)
			{
				num++;
			}
			float critMultiplier = component.critMultiplier;
			if (critMults)
			{
				component.critMultiplier += (float)(int)Math.Pow(2.0, num);
			}
			else
			{
				component.critMultiplier += (float)num;
			}
			orig.Invoke(self, damageInfo);
			component.critMultiplier = critMultiplier;
		}

		private void ResetRunVars(orig_Start orig, Run self)
		{
			if (wasLoaded)
			{
				orig.Invoke(self);
				wasLoaded = false;
			}
			else
			{
				CyAn_Arena.latestInventoryItems = new int[0];
				CyAn_Arena.arenaCount = -1;
				orig.Invoke(self);
			}
		}

		private IEnumerator CheckTeleporterInstance(orig_Start orig, Stage self)
		{
			((MonoBehaviour)this).StartCoroutine(DelayRePopulate());
			if (SceneInfo.instance.sceneDef.baseSceneName == "arena")
			{
				CyAn_Arena.ArenaStageStart();
			}
			return orig.Invoke(self);
		}

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

		private void RePopulateInteractList()
		{
			purchaseInteractables.Clear();
			purchaseInteractables = (from obj in Object.FindObjectsOfType<GameObject>()
				where (Object)(object)obj.GetComponent<PurchaseInteraction>() != (Object)null || (Object)(object)obj.GetComponent<ScrapperController>() != (Object)null
				select obj).Distinct().ToList();
		}

		public static int GetPlayerIndexFromInteractionObject(GameObject Object)
		{
			CharacterBody val = null;
			PlayerCharacterMasterController val2 = null;
			PurchaseInteraction component = Object.GetComponent<PurchaseInteraction>();
			ScrapperController component2 = Object.GetComponent<ScrapperController>();
			if ((Object)(object)component != (Object)null || Object.op_Implicit((Object)(object)component2))
			{
				Interactor val3 = ((!Object.op_Implicit((Object)(object)component)) ? component2.interactor : component.lastActivator);
				if ((Object)(object)val3 != (Object)null)
				{
					CharacterMaster component3 = ((Component)val3).GetComponent<CharacterMaster>();
					if ((Object)(object)component3 != (Object)null)
					{
						val = component3.playerCharacterMasterController.body;
					}
					else
					{
						CharacterBody component4 = ((Component)val3).GetComponent<CharacterBody>();
						if ((Object)(object)component4 != (Object)null)
						{
							val = component4;
						}
						else
						{
							Log.Warning("Could not find CharacterBody for: " + ((Object)val3).name);
						}
					}
				}
				else
				{
					Log.Warning("Could not find interactor for interaction: " + ((Object)component).name);
				}
			}
			else
			{
				NetworkUIPromptController component5 = Object.GetComponent<NetworkUIPromptController>();
				if ((Object)(object)component5 != (Object)null)
				{
					CharacterMaster currentParticipantMaster = component5.currentParticipantMaster;
					if ((Object)(object)currentParticipantMaster != (Object)null)
					{
						val2 = currentParticipantMaster.playerCharacterMasterController;
					}
					else
					{
						Log.Warning("Could not find PlayerCharacterMasterController for: " + ((Object)component5).name + " (probably not OptionPickup?: " + ((Object)Object).name + ")");
					}
				}
				else
				{
					Log.Warning("Could not find uiController for: " + ((Object)Object).name);
				}
			}
			if ((Object)(object)val != (Object)null || (Object)(object)val2 != (Object)null)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = val.master.playerCharacterMasterController;
				}
				for (int i = 0; i < PlayerCharacterMasterController.instances.Count; i++)
				{
					if ((Object)(object)PlayerCharacterMasterController.instances[i] == (Object)(object)val2)
					{
						return i;
					}
				}
				Log.Warning($"Could not find {val2} in PlayerCharacterMasterController.instances (body: {val}, master: {val.master})");
			}
			return -1;
		}

		[Server]
		public static void AddToPlayerInventory(ItemIndex item, int target = -1, int total = 1)
		{
			//IL_0067: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			if (target == -1)
			{
				if (currentPlayer >= NetworkUser.readOnlyInstancesList.Count)
				{
					currentPlayer = 0;
				}
				target = currentPlayer;
			}
			if (target >= NetworkUser.readOnlyInstancesList.Count)
			{
				Log.Error($"tried to target invalid position in Connected Users Pos: {target} with CollectionSize: {NetworkUser.readOnlyInstancesList.Count}");
				return;
			}
			NetworkUser val = NetworkUser.readOnlyInstancesList[target];
			CharacterMaster master = val.master;
			CyAn_Network cyAn_Network = new CyAn_Network(item);
			if ((Object)(object)master == (Object)null)
			{
				Log.Error($"Could not find Master for '{val}' default sending {item} to host");
				NetworkServer.SendToClient(0, networkId, (MessageBase)(object)cyAn_Network);
			}
			else
			{
				master.inventory.GiveItem(item, total);
				NetworkServer.SendToClient(target, networkId, (MessageBase)(object)cyAn_Network);
				currentPlayer++;
			}
		}

		private void TryRegisterNetwork(NetworkUser networkUser)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			NetworkClient val = NetworkManager.singleton?.client;
			if (val == null || val.handlers == null || val.handlers.ContainsKey(networkId))
			{
				Log.Warning($"could not register NetworkId {networkId}, because either client is null ({val == null}) or it is already registerd");
				return;
			}
			short num = networkId;
			object obj = <>O.<0>__RecieveData;
			if (obj == null)
			{
				NetworkMessageDelegate val2 = RecieveData;
				<>O.<0>__RecieveData = val2;
				obj = (object)val2;
			}
			val.RegisterHandler(num, (NetworkMessageDelegate)obj);
			Log.Info($"Registerd NetworkId {networkId}");
		}

		private static void RecieveData(NetworkMessage networkMessage)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			CyAn_Network cyAn_Network = networkMessage.ReadMessage<CyAn_Network>();
			if (cyAn_Network.MsgType == 1)
			{
				CyAn_Arena.RecieveData(cyAn_Network);
				return;
			}
			ItemIndex item = cyAn_Network.Item;
			PlayerCharacterMasterController val = ((IEnumerable<PlayerCharacterMasterController>)PlayerCharacterMasterController.instances).FirstOrDefault((Func<PlayerCharacterMasterController, bool>)((PlayerCharacterMasterController x) => ((NetworkBehaviour)x.networkUser).isLocalPlayer));
			if (!((Object)(object)val == (Object)null))
			{
				CharacterMasterNotificationQueue.PushItemNotification(val.master, item);
			}
		}

		[Server]
		public static void SyncObject(GameObject obj)
		{
			NetworkServer.Spawn(obj);
		}

		private void Update()
		{
		}

		private void ForceSpawnPortal(Vector3 position)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			Object.Instantiate<GameObject>(raidPortalPrefab, position + new Vector3(5f, 0f, 0f), Quaternion.identity);
			Object.Instantiate<GameObject>(shopPortalPrefab, position + new Vector3(-5f, 0f, 0f), Quaternion.identity);
		}

		public static Sprite LoadEmbeddedSprite(string resourceName)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
			if (stream == null)
			{
				Log.Error("[ArtifactOfOrder] Embedded resource not found: " + resourceName);
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
	[HarmonyPatch(typeof(ArenaMonsterItemDropTable), "GenerateDropPreReplacement")]
	public static class Patch_ArenaMonsterItemDropTable_GenerateDrop
	{
		public static bool Prefix(ArenaMonsterItemDropTable __instance, Xoroshiro128Plus rng, ref PickupIndex __result)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if (!ArtifactOfOrder.orderActive)
			{
				return true;
			}
			WeightedSelection<PickupIndex> val = (WeightedSelection<PickupIndex>)typeof(ArenaMonsterItemDropTable).GetField("selector", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
			val.Clear();
			Add(__instance, val, ArtifactOfOrder.originalTier1DropList, __instance.tier1Weight);
			Add(__instance, val, ArtifactOfOrder.originalTier2DropList, __instance.tier2Weight);
			Add(__instance, val, ArtifactOfOrder.originalTier3DropList, __instance.tier3Weight);
			Add(__instance, val, ArtifactOfOrder.originalBossDropList, __instance.bossWeight);
			Add(__instance, val, ArtifactOfOrder.originalLunarDropList, __instance.lunarItemWeight);
			Add(__instance, val, ArtifactOfOrder.originalVoidTier1DropList, __instance.voidTier1Weight);
			Add(__instance, val, ArtifactOfOrder.originalVoidTier2DropList, __instance.voidTier2Weight);
			Add(__instance, val, ArtifactOfOrder.originalVoidTier3DropList, __instance.voidTier3Weight);
			Add(__instance, val, ArtifactOfOrder.originalVoidBossDropList, __instance.voidBossWeight);
			__result = PickupDropTable.GenerateDropFromWeightedSelection(rng, val);
			return false;
		}

		private static void Add(ArenaMonsterItemDropTable instance, WeightedSelection<PickupIndex> selector, List<PickupIndex> sourceList, float weight)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (weight <= 0f || sourceList == null || sourceList.Count == 0)
			{
				return;
			}
			MethodInfo method = typeof(ArenaMonsterItemDropTable).GetMethod("PassesFilter", BindingFlags.Instance | BindingFlags.NonPublic);
			foreach (PickupIndex source in sourceList)
			{
				if ((bool)method.Invoke(instance, new object[1] { source }))
				{
					selector.AddChoice(source, weight);
				}
			}
		}
	}
	public abstract class CyAn_RndArtifactBase
	{
		public ArtifactDef ArtifactDef;

		public abstract string ArtifactName { get; }

		public abstract string ArtifactLangTokenName { get; }

		public abstract string ArtifactDescription { get; }

		public abstract Sprite ArtifactEnabledIcon { get; }

		public abstract Sprite ArtifactDisabledIcon { get; }

		public bool ArtifactEnabled
		{
			get
			{
				RunArtifactManager instance = RunArtifactManager.instance;
				if (instance == null)
				{
					return false;
				}
				return instance.IsArtifactEnabled(ArtifactDef);
			}
		}

		public abstract void Init(ConfigFile config);

		protected void CreateLang()
		{
			LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_NAME", ArtifactName);
			LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION", ArtifactDescription);
		}

		protected void CreateArtifact()
		{
			ArtifactDef = ScriptableObject.CreateInstance<ArtifactDef>();
			ArtifactDef.cachedName = "ARTIFACT_" + ArtifactLangTokenName;
			ArtifactDef.nameToken = "ARTIFACT_" + ArtifactLangTokenName + "_NAME";
			ArtifactDef.descriptionToken = "ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION";
			ArtifactDef.smallIconSelectedSprite = ArtifactEnabledIcon;
			ArtifactDef.smallIconDeselectedSprite = ArtifactDisabledIcon;
			ContentAddition.AddArtifactDef(ArtifactDef);
		}

		public abstract void Hooks();
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}