Decompiled source of CyAn Rnd v1.0.1

plugins/CyAn_Rnd/CyAn_Rnd.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
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 Microsoft.CodeAnalysis;
using On.RoR2;
using ProperSave;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("An_Rnd")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+25b1b27d9121661aaf13e7e522995f48a458c9c7")]
[assembly: AssemblyProduct("An_Rnd")]
[assembly: AssemblyTitle("An_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 An_Rnd
{
	public class An_Network : MessageBase
	{
		public ItemIndex Item { get; private set; }

		public An_Network()
		{
		}

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

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

		public override void Deserialize(NetworkReader reader)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			Item = NetworkExtensions.ReadItemIndex(reader);
		}
	}
	[BepInPlugin("Cyan.Rnd", "Cy/an Rnd", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class An_Rnd : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static NetworkMessageDelegate <0>__RecieveItem;
		}

		public const string PluginGUID = "Cyan.Rnd";

		public const string PluginAuthor = "Cy/an";

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

		public const string PluginVersion = "1.0.0";

		private static GameObject shopPortalPrefab;

		private static GameObject raidPortalPrefab;

		private static GameObject teleporterPrefab;

		public static int arenaCount = -1;

		public static int arenaCap = 0;

		public static int chunkSize = 50;

		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 bool noHightlights = false;

		public static bool enableBleed = false;

		public static bool enableCrit = false;

		public static bool critMults = false;

		public static bool allowDuplicates = false;

		public static bool preventDrops = false;

		public static bool preventLunar = false;

		public static bool wasLoaded = false;

		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 = 0f;

		public static int currentCell = -1;

		public static int currentPlayer = 0;

		public static int DifficultyCounter = 0;

		public static string monsterBlacklist = "";

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

		public static short networkId = 4379;

		public void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			InitPortalPrefab();
			ConfigandTrySoft();
			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);
			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);
			Stage.Start += new hook_Start(CheckTeleporterInstance);
			Run.Start += new hook_Start(ResetRunVars);
			UserProfile.HasViewedViewable += new hook_HasViewedViewable(Viewed);
			PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(Purchase);
			NetworkUser.onPostNetworkUserStart += new NetworkUserGenericDelegate(TryRegisterNetwork);
		}

		private void InitPortalPrefab()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_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)
			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)
			{
				if (!file.ModdedData.TryGetValue("CyanRnd", out var value))
				{
					Log.Warning("Could not find SaveData");
				}
				else if (value.Value is object[] array && array.Length == 3)
				{
					try
					{
						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 + "\"");
					}
					arenaCount = Convert.ToInt32(array[1]);
					currentPlayer = Convert.ToInt32(array[2]);
					wasLoaded = true;
					Log.Info($"Loaded latestInventoryItems, arenaCount({arenaCount}) and currentPlayer({currentPlayer}) with ProperSave.");
				}
				else
				{
					Log.Error("Saved data format is invalid or unexpected.");
				}
			}
			static void SaveToProperSave(Dictionary<string, object> dictionary)
			{
				object[] value2 = new object[3] { latestInventoryItems, arenaCount, currentPlayer };
				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)
		{
			for (int i = 0; i < configEntries.Length; i++)
			{
				var (config, varType, _, min, max) = configEntries[i];
				AddOption(config, varType, min, max);
			}
			for (int j = 0; j < configEntries.Length; j++)
			{
				var (val, type, updateStaticVar, _, _) = configEntries[j];
				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"), 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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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\nCurrently duplicates the last Itemstack gotten (as in the last add happens twice) not sure why, will fix later"), typeof(bool), delegate(object value)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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)
				{
					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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00a6: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			if (varType == typeof(int))
			{
				IntSliderConfig val = new IntSliderConfig
				{
					min = (int)min,
					max = (int)max
				};
				IntSliderOption val2 = new IntSliderOption((ConfigEntry<int>)(object)config, val);
				ModSettingsManager.AddOption((BaseOption)(object)val2);
				Log.Info("Added RiskOfOption '" + config.Definition.Key + "' as IntSlider");
			}
			else if (varType == typeof(float))
			{
				FloatFieldConfig val3 = new FloatFieldConfig();
				((NumericFieldConfig<float>)val3).Min = (float)min;
				((NumericFieldConfig<float>)val3).Max = (float)max;
				FloatFieldConfig val4 = val3;
				FloatFieldOption val5 = new FloatFieldOption((ConfigEntry<float>)(object)config, val4);
				ModSettingsManager.AddOption((BaseOption)(object)val5);
				Log.Info("Added RiskOfOption '" + config.Definition.Key + "' as FloatField");
			}
			else if (varType == typeof(bool))
			{
				CheckBoxOption val6 = new CheckBoxOption((ConfigEntry<bool>)(object)config);
				ModSettingsManager.AddOption((BaseOption)(object)val6);
				Log.Info("Added RiskOfOption '" + config.Definition.Key + "' as CheckBox");
			}
			else if (varType == typeof(string))
			{
				StringInputFieldOption val7 = new StringInputFieldOption((ConfigEntry<string>)(object)config);
				ModSettingsManager.AddOption((BaseOption)(object)val7);
				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_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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between Unknown and I4
			//IL_0050: 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_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)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_002c: 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)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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)
			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_0040: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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)
			{
				float num3 = Random.value * 100f;
				if (num3 < 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)
			{
				float num3 = Random.value * 100f;
				if (num3 < 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)
			{
				wasLoaded = false;
				orig.Invoke(self);
			}
			else
			{
				latestInventoryItems = new int[0];
				arenaCount = -1;
				orig.Invoke(self);
			}
		}

		private IEnumerator CheckTeleporterInstance(orig_Start orig, Stage self)
		{
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_0135: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).StartCoroutine(DelayRePopulate());
			if (SceneInfo.instance.sceneDef.baseSceneName == "arena")
			{
				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 orig.Invoke(self);
				}
				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)
				{
					GameObject val2 = Object.Instantiate<GameObject>(teleporterPrefab, new Vector3(0f, -1000f, 0f), Quaternion.identity);
					((MonoBehaviour)this).StartCoroutine(AddShrinesDelay(val));
				}
				else
				{
					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;
				}
			}
			return orig.Invoke(self);
		}

		private IEnumerator DelayRePopulate()
		{
			yield return (object)new WaitForSeconds(0.1f);
			RePopulateInteractList();
		}

		private void RePopulateInteractList()
		{
			purchaseInteractables.Clear();
			GameObject[] source = Object.FindObjectsOfType<GameObject>();
			purchaseInteractables = source.Where((GameObject obj) => (Object)(object)obj.GetComponent<PurchaseInteraction>() != (Object)null || (Object)(object)obj.GetComponent<ScrapperController>() != (Object)null).Distinct().ToList();
		}

		private IEnumerator AddShrinesDelay(ArenaMissionController controller)
		{
			yield return (object)new WaitForSeconds(0.1f);
			int toAdd = numShrines * arenaCount;
			if (expScaling && toAdd > 0)
			{
				if (TeleporterInteraction.instance.shrineBonusStacks <= 0)
				{
					TeleporterInteraction.instance.AddShrineStack();
					toAdd--;
				}
				toAdd = (int)((double)TeleporterInteraction.instance.shrineBonusStacks * Math.Pow(2.0, toAdd)) - TeleporterInteraction.instance.shrineBonusStacks;
			}
			for (int i = 0; i < toAdd; i++)
			{
				TeleporterInteraction.instance.AddShrineStack();
			}
			controller.baseMonsterCredit += extraMonsterCredits * (float)TeleporterInteraction.instance.shrineBonusStacks;
		}

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

		private void MultiplyItemReward(orig_CreatePickup_PickupIndex orig, PickupPickerController self, PickupIndex pickupIndex)
		{
			//IL_0064: 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)
			int num = ((!useShrine) ? Math.Max((int)Math.Floor((float)DifficultyCounter * extraRewards), 1) : Math.Max((int)Math.Floor((float)TeleporterInteraction.instance.shrineBonusStacks * extraRewards), 1));
			if (preventDrops)
			{
				int playerIndexFromInteractionObject = GetPlayerIndexFromInteractionObject(((Component)self).gameObject);
				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];
			}
		}

		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);
			}
			orig.Invoke(self);
		}

		private void MultiplyEnemyItem(orig_AddItemStack orig, ArenaMissionController self)
		{
			//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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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)
			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();
				for (int i = 0; i < num; i++)
				{
					inventory.CleanInventory();
					orig.Invoke(self);
					ItemIndex val = self.inventory.itemAcquisitionOrder[0];
					array2[val] += self.inventory.GetItemCount(val);
					self.nextItemStackIndex--;
				}
				inventory.CleanInventory();
				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 (extraStacksThreshold > 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_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ArenaMissionController");
			val.SetActive(false);
			CombatDirector val2 = val.AddComponent<CombatDirector>();
			val2.monsterCredit = referenceDirector.monsterCredit;
			val2.refundedMonsterCredit = referenceDirector.refundedMonsterCredit;
			val2.expRewardCoefficient = referenceDirector.expRewardCoefficient;
			val2.goldRewardCoefficient = referenceDirector.goldRewardCoefficient;
			val2.minSeriesSpawnInterval = referenceDirector.minSeriesSpawnInterval;
			val2.maxSeriesSpawnInterval = referenceDirector.maxSeriesSpawnInterval;
			val2.minRerollSpawnInterval = referenceDirector.minRerollSpawnInterval;
			val2.maxRerollSpawnInterval = referenceDirector.maxRerollSpawnInterval;
			val2.moneyWaveIntervals = referenceDirector.moneyWaveIntervals;
			val2.teamIndex = referenceDirector.teamIndex;
			val2.creditMultiplier = referenceDirector.creditMultiplier;
			val2.spawnDistanceMultiplier = referenceDirector.spawnDistanceMultiplier;
			val2.maxSpawnDistance = referenceDirector.maxSpawnDistance;
			val2.minSpawnRange = referenceDirector.minSpawnRange;
			val2.shouldSpawnOneWave = referenceDirector.shouldSpawnOneWave;
			val2.targetPlayers = referenceDirector.targetPlayers;
			val2.skipSpawnIfTooCheap = referenceDirector.skipSpawnIfTooCheap;
			val2.maxConsecutiveCheapSkips = referenceDirector.maxConsecutiveCheapSkips;
			val2.resetMonsterCardIfFailed = referenceDirector.resetMonsterCardIfFailed;
			val2.maximumNumberToSpawnBeforeSkipping = referenceDirector.maximumNumberToSpawnBeforeSkipping;
			val2.eliteBias = referenceDirector.eliteBias;
			val2.combatSquad = referenceDirector.combatSquad;
			val2.ignoreTeamSizeLimit = referenceDirector.ignoreTeamSizeLimit;
			val2._monsterCards = referenceDirector._monsterCards;
			val2.fallBackToStageMonsterCards = referenceDirector.fallBackToStageMonsterCards;
			val2.hasStartedWave = referenceDirector.hasStartedWave;
			val2.rng = referenceDirector.rng;
			val2.currentMonsterCard = referenceDirector.currentMonsterCard;
			val2.currentActiveEliteTier = referenceDirector.currentActiveEliteTier;
			val2.currentActiveEliteDef = referenceDirector.currentActiveEliteDef;
			val2.currentMonsterCardCost = referenceDirector.currentMonsterCardCost;
			val2.monsterCardsSelection = referenceDirector.monsterCardsSelection;
			val2.consecutiveCheapSkips = referenceDirector.consecutiveCheapSkips;
			val2.playerRetargetTimer = referenceDirector.playerRetargetTimer;
			val2.spawnCountInCurrentWave = referenceDirector.spawnCountInCurrentWave;
			val2.moneyWaves = referenceDirector.moneyWaves;
			val2.isHalcyonShrineSpawn = referenceDirector.isHalcyonShrineSpawn;
			val2.shrineHalcyoniteDifficultyLevel = referenceDirector.shrineHalcyoniteDifficultyLevel;
			((Behaviour)val2).enabled = ((Behaviour)referenceDirector).enabled;
			((MonoBehaviour)val2).useGUILayout = ((MonoBehaviour)referenceDirector).useGUILayout;
			val2.monsterSpawnTimer = referenceDirector.monsterSpawnTimer;
			val2.lastAttemptedMonsterCard = referenceDirector.lastAttemptedMonsterCard;
			val2.totalCreditsSpent = referenceDirector.totalCreditsSpent;
			val2.onSpawnedServer = referenceDirector.onSpawnedServer;
			val2.spawnEffectPrefab = referenceDirector.spawnEffectPrefab;
			val2.currentSpawnTarget = referenceDirector.currentSpawnTarget;
			val.SetActive(true);
			return val2;
		}

		public void RemoveMatchingMonsterCards(ArenaMissionController controller)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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)
			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);
			}
		}

		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());
		}

		private IEnumerator CheckNullDelay()
		{
			yield return (object)new WaitForSeconds(1f);
			GameObject[] obj = Object.FindObjectsOfType<GameObject>();
			bool found = false;
			GameObject[] array = obj;
			foreach (GameObject portal2 in array)
			{
				if (((Object)portal2).name.Contains("PortalArena"))
				{
					found = true;
					break;
				}
			}
			if (!found)
			{
				GameObject portal = Object.Instantiate<GameObject>(raidPortalPrefab, new Vector3(281.1f, -446.82f, -126.1f), new Quaternion(0f, -0.73274f, 0f, 0.68051f));
				SyncObject(portal);
			}
		}

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

		[Server]
		private void AddToPlayerInventory(ItemIndex item, int target = -1, int total = 1)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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)
			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;
			An_Network an_Network = new An_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)an_Network);
			}
			else
			{
				master.inventory.GiveItem(item, total);
				NetworkServer.SendToClient(target, networkId, (MessageBase)(object)an_Network);
				currentPlayer++;
			}
		}

		private void TryRegisterNetwork(NetworkUser networkUser)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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>__RecieveItem;
			if (obj == null)
			{
				NetworkMessageDelegate val2 = RecieveItem;
				<>O.<0>__RecieveItem = val2;
				obj = (object)val2;
			}
			val.RegisterHandler(num, (NetworkMessageDelegate)obj);
			Log.Info($"Registerd NetworkId {networkId}");
		}

		private static void RecieveItem(NetworkMessage networkMessage)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			ItemIndex item = networkMessage.ReadMessage<An_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]
		private void SyncObject(GameObject obj)
		{
			NetworkServer.Spawn(obj);
		}
	}
	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);
		}
	}
}