Decompiled source of ArtifactOfRevolution v1.0.2

plugins/ArtifactOfRevolution.dll

Decompiled 21 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.ExpansionManagement;
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("ArtifactOfRevolution")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cd4fc3818f5b50aff2532e3ad323c33074fbf5d0")]
[assembly: AssemblyProduct("ArtifactOfRevolution")]
[assembly: AssemblyTitle("ArtifactOfRevolution")]
[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 ArtifactOfRevolution
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("SomeBunny.ArtifactOfRevolution", "ArtifactOfRevolution", "1.0.2")]
	public class ArtifactOfRevolutionPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "SomeBunny.ArtifactOfRevolution";

		public const string PluginAuthor = "SomeBunny";

		public const string PluginName = "ArtifactOfRevolution";

		public const string PluginVersion = "1.0.2";

		public static ConfigFile configurationFile;

		public void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("SomeBunny.ArtifactOfRevolution").PatchAll();
			configurationFile = ((BaseUnityPlugin)this).Config;
			Log.Init(((BaseUnityPlugin)this).Logger);
			ArtifactOfRevolution artifactOfRevolution = new ArtifactOfRevolution();
			artifactOfRevolution.Init();
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		private static string Format(object data, string file, int line)
		{
			string fileName = Path.GetFileName(file);
			return $"[{fileName}:{line}] {data}";
		}

		internal static void Debug(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogDebug((object)Format(data, file, line));
		}

		internal static void Error(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogError((object)Format(data, file, line));
		}

		internal static void Fatal(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogFatal((object)Format(data, file, line));
		}

		internal static void Info(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogInfo((object)Format(data, file, line));
		}

		internal static void Message(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogMessage((object)Format(data, file, line));
		}

		internal static void Warning(object data, [CallerFilePath] string file = "", [CallerLineNumber] int line = 0)
		{
			_logSource.LogWarning((object)Format(data, file, line));
		}
	}
	public class ArtifactOfRevolution
	{
		[HarmonyPatch(typeof(Run), "Start")]
		public class Run_Start
		{
			[HarmonyPostfix]
			public static void Postfix(Run __instance)
			{
				if (NetworkServer.active && Inst.ArtifactEnabled)
				{
					treasureRng.ResetSeed(__instance.seed);
					RevolutionItemInventory = Object.Instantiate<GameObject>(RevolutionItemController).GetComponent<Inventory>();
					((Component)RevolutionItemInventory).GetComponent<TeamFilter>().teamIndex = (TeamIndex)2;
					NetworkServer.Spawn(((Component)RevolutionItemInventory).gameObject);
					RerollNewInventory();
				}
			}
		}

		[HarmonyPatch(typeof(SpawnCard), "DoSpawn")]
		public class SpawnCard_DoSpawn
		{
			[HarmonyPostfix]
			public static void Postfix(SpawnCard __instance, ref SpawnResult __result)
			{
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Invalid comparison between Unknown and I4
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Invalid comparison between Unknown and I4
				if (!Inst.ArtifactEnabled || !Object.op_Implicit((Object)(object)RevolutionItemInventory))
				{
					return;
				}
				CharacterMaster val = (Object.op_Implicit((Object)(object)__result.spawnedInstance) ? __result.spawnedInstance.GetComponent<CharacterMaster>() : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					if ((int)val.teamIndex == 2)
					{
						val.inventory.AddItemsFrom(RevolutionItemInventory);
					}
					if (VoidEnemiesGetItems.Value && (int)val.teamIndex == 4)
					{
						val.inventory.AddItemsFrom(RevolutionItemInventory);
					}
				}
			}
		}

		[HarmonyPatch(typeof(SceneDirector), "PopulateScene")]
		public class SceneDirector_PopulateScene
		{
			[HarmonyPrefix]
			public static void Postfix(SceneDirector __instance)
			{
				if (NetworkServer.active)
				{
					HasRolledNewInventory = false;
					RerollNewInventory();
				}
			}
		}

		private static ArtifactDef InvasionArtifactDefinition;

		public InteractableSpawnCard VoidCampSpawnCard;

		public DirectorCard VoidDirectorCard = null;

		private static ArtifactOfRevolution Inst;

		public static ConfigEntry<float> ItemsPerStage;

		public static ConfigEntry<int> StartingItemCount;

		public static ConfigEntry<float> ItemStackAmountPerStage;

		public static ConfigEntry<bool> VoidEnemiesGetItems;

		public static BasicPickupDropTable VoidItems;

		public static ConfigEntry<int> WhiteItemWeight;

		public static ConfigEntry<int> WhiteItemCountGiven;

		public static ConfigEntry<int> GreenItemWeight;

		public static ConfigEntry<int> GreenItemCountGiven;

		public static ConfigEntry<int> RedItemWeight;

		public static ConfigEntry<int> RedItemCountGiven;

		public static ConfigEntry<int> LunarItemWeight;

		public static ConfigEntry<int> LunarItemCountGiven;

		public static ConfigEntry<int> BossItemWeight;

		public static ConfigEntry<int> BossItemCountGiven;

		public static ConfigEntry<int> FoodItemWeight_1;

		public static ConfigEntry<int> FoodItemWeight_2;

		public static ConfigEntry<int> FoodItemWeight_3;

		public static ConfigEntry<float> CorruptItemIntoVoid;

		public static ConfigEntry<bool> ChaosMode;

		public static ConfigEntry<bool> ChaosStackingMode;

		public static ConfigEntry<bool> UnpredictableMode;

		public static ExpansionDef SOTVExpansion;

		public static ItemDef Zoea;

		private static GameObject RevolutionItemController;

		private static Inventory RevolutionItemInventory;

		private static readonly Xoroshiro128Plus treasureRng = new Xoroshiro128Plus(0uL);

		public static Dictionary<ItemTier, int> ItemsPerTier;

		public static WeightedTypeCollection<PickupDropTable> ItemDropTables;

		private static bool HasRolledNewInventory = false;

		private static string ArtifactLangTokenName => "ARTIFACT_OF_REVOLUTION";

		private static string ArtifactName => "Artifact of Revolution";

		private static string ArtifactDescription => "Enemies gain items. Enemy item loadout is changed every stage, and grows in power over time.";

		public bool ArtifactEnabled => RunArtifactManager.instance.IsArtifactEnabled(InvasionArtifactDefinition);

		public void Init()
		{
			//IL_0079: 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_00b7: 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_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			Inst = this;
			LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_NAME", ArtifactName);
			LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION", ArtifactDescription);
			InvasionArtifactDefinition = ScriptableObject.CreateInstance<ArtifactDef>();
			Texture2D textureFromResource = Tools.GetTextureFromResource("ArtifactOfRevolution/Textures/texArtifactRevolutionEnabled.png");
			Sprite smallIconSelectedSprite = Sprite.Create(textureFromResource, new Rect(0f, 0f, (float)((Texture)textureFromResource).width, (float)((Texture)textureFromResource).height), new Vector2(0.5f, 0.5f));
			Texture2D textureFromResource2 = Tools.GetTextureFromResource("ArtifactOfRevolution/Textures/texArtifactRevolutionDisabled.png");
			Sprite smallIconDeselectedSprite = Sprite.Create(textureFromResource2, new Rect(0f, 0f, (float)((Texture)textureFromResource2).width, (float)((Texture)textureFromResource2).height), new Vector2(0.5f, 0.5f));
			InvasionArtifactDefinition.smallIconSelectedSprite = smallIconSelectedSprite;
			InvasionArtifactDefinition.smallIconDeselectedSprite = smallIconDeselectedSprite;
			InvasionArtifactDefinition.nameToken = "ARTIFACT_" + ArtifactLangTokenName + "_NAME";
			InvasionArtifactDefinition.descriptionToken = "ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION";
			ContentAddition.AddArtifactDef(InvasionArtifactDefinition);
			LegacyResourcesAPI.LoadAsyncCallback<GameObject>("Prefabs/NetworkedObjects/MonsterTeamGainsItemsArtifactInventory", (Action<GameObject>)delegate(GameObject operationResult)
			{
				RevolutionItemController = PrefabAPI.InstantiateClone(operationResult, "RevolutionInventory", false);
				((Behaviour)RevolutionItemController.GetComponent<EnemyInfoPanelInventoryProvider>()).enabled = true;
				PrefabAPI.RegisterNetworkPrefab(RevolutionItemController);
			});
			StartingItemCount = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Base", "Baseline item Stack Count", 1, "The baseline amount of item stacks the enemies will recieve.");
			ItemsPerStage = ArtifactOfRevolutionPlugin.configurationFile.Bind<float>(ArtifactName + " | Base", "Item Amount Increase Per Stage", 0.5f, "The amount by which the amount of items enemies will recieve increases per stage. (0.5 Grants +1 Items every 2 stages).");
			ItemStackAmountPerStage = ArtifactOfRevolutionPlugin.configurationFile.Bind<float>(ArtifactName + " | Base", "Item Stack Increase Per Stage", 0.2f, "The amount by which the amount of item stacks enemies will recieve increases per stage. (0.2 Grants +1 to every Item Stack every 5 stages).");
			VoidEnemiesGetItems = ArtifactOfRevolutionPlugin.configurationFile.Bind<bool>(ArtifactName + " | Base", "Void Enemies Get Items", true, "Do Void Enemies Get Items?");
			WhiteItemWeight = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Items | Common", "Weight", 85, "[Common] The weight with which this item tier will be selected.");
			WhiteItemCountGiven = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Items | Common", "Item Stack Amount", 3, " [Common] The amount of items given per stack for this item tier.");
			GreenItemWeight = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Items | Uncommon", "Weight", 24, "[Uncommon] The weight with which this item tier will be selected.");
			GreenItemCountGiven = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Items | Uncommon", "Item Stack Amount", 2, " [Uncommon] The amount of items given per stack for this item tier.");
			RedItemWeight = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Items | Legendary", "Weight", 8, "[Legendary] The weight with which this item tier will be selected.");
			RedItemCountGiven = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Items | Legendary", "Item Stack Amount", 1, " [Legendary] The amount of items given per stack for this item tier.");
			LunarItemWeight = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Special Items | Lunar", "Weight", 2, "[Lunar] The weight with which this item tier will be selected.");
			LunarItemCountGiven = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Special Items | Lunar", "Item Stack Amount", 1, " [Lunar] The amount of items given per stack for this item tier.");
			BossItemWeight = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Special Items | Boss", "Weight", 5, "[Boss] The weight with which this item tier will be selected.");
			BossItemCountGiven = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Special Items | Boss", "Item Stack Amount", 1, " [Boss] The amount of items given per stack for this item tier.");
			FoodItemWeight_1 = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Special Items | Food Items Common", "Weight", 15, "[Requires AC DLC] [Food Items [Common]] The weight with which this item tier will be selected.");
			FoodItemWeight_2 = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Special Items | Food Items Uncommon", "Weight", 5, "[Requires AC DLC] [Food Items [Uncommon]] The weight with which this item tier will be selected.");
			FoodItemWeight_3 = ArtifactOfRevolutionPlugin.configurationFile.Bind<int>(ArtifactName + " | Special Items | Food Items Legendary", "Weight", 2, "[Requires AC DLC] [Food Items [Legendary]] The weight with which this item tier will be selected.");
			CorruptItemIntoVoid = ArtifactOfRevolutionPlugin.configurationFile.Bind<float>(ArtifactName + " | Special Items | Void", "Chance for Stack To Become Void items", 0.05f, "[Requires SOTV DLC] The chance that a given item stack will turn into a Void Item of an equivalent tier.");
			ChaosMode = ArtifactOfRevolutionPlugin.configurationFile.Bind<bool>(ArtifactName + " | Fun Stuff", "Scrambled Mode", false, "Absolutely screws with the item tier selection RNG. Not meant to be balanced in any way.");
			ChaosStackingMode = ArtifactOfRevolutionPlugin.configurationFile.Bind<bool>(ArtifactName + " | Fun Stuff", "Chaos Mode", false, "Absolutely screws with the item stack counts given to enemies. Not meant to be balanced in any way.");
			UnpredictableMode = ArtifactOfRevolutionPlugin.configurationFile.Bind<bool>(ArtifactName + " | Fun Stuff", "Unpredictable Mode", false, "Absolutely screws with the amount of stacks given to enemies. Not meant to be balanced in any way.");
			ExpansionDef AC = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC3/DLC3.asset").WaitForCompletion();
			SOTVExpansion = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC1/Common/DLC1.asset").WaitForCompletion();
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: 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_0050: 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_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				PickupDropTable newVal = LegacyResourcesAPI.Load<PickupDropTable>("DropTables/dtMonsterTeamTier1Item");
				PickupDropTable newVal2 = LegacyResourcesAPI.Load<PickupDropTable>("DropTables/dtMonsterTeamTier2Item");
				PickupDropTable newVal3 = LegacyResourcesAPI.Load<PickupDropTable>("DropTables/dtMonsterTeamTier3Item");
				PickupDropTable newVal4 = Addressables.LoadAssetAsync<PickupDropTable>((object)"RoR2/Base/DuplicatorWild/dtDuplicatorWild.asset").WaitForCompletion();
				PickupDropTable newVal5 = Addressables.LoadAssetAsync<PickupDropTable>((object)"RoR2/Base/LunarChest/dtLunarChest.asset").WaitForCompletion();
				PickupDropTable newVal6 = (PickupDropTable)(object)Addressables.LoadAssetAsync<ExplicitPickupDropTable>((object)"RoR2/DLC3/MealPrep/dtFoodTier1.asset").WaitForCompletion();
				PickupDropTable newVal7 = (PickupDropTable)(object)Addressables.LoadAssetAsync<ExplicitPickupDropTable>((object)"RoR2/DLC3/MealPrep/dtFoodTier2.asset").WaitForCompletion();
				PickupDropTable newVal8 = (PickupDropTable)(object)Addressables.LoadAssetAsync<ExplicitPickupDropTable>((object)"RoR2/DLC3/MealPrep/dtFoodTier3.asset").WaitForCompletion();
				VoidItems = Addressables.LoadAssetAsync<BasicPickupDropTable>((object)"RoR2/DLC1/TreasureCacheVoid/dtVoidLockbox.asset").WaitForCompletion();
				Zoea = Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/DLC1/VoidMegaCrabItem.asset").WaitForCompletion();
				ItemDropTables = new WeightedTypeCollection<PickupDropTable>
				{
					elements = new WeightedType<PickupDropTable>[8]
					{
						new WeightedType<PickupDropTable>(newVal, WhiteItemWeight.Value),
						new WeightedType<PickupDropTable>(newVal2, GreenItemWeight.Value),
						new WeightedType<PickupDropTable>(newVal3, RedItemWeight.Value),
						new WeightedType<PickupDropTable>(newVal5, LunarItemWeight.Value),
						new WeightedType<PickupDropTable>(newVal4, BossItemWeight.Value),
						new WeightedType<PickupDropTable>(newVal6, FoodItemWeight_1.Value, AC),
						new WeightedType<PickupDropTable>(newVal7, FoodItemWeight_2.Value, AC),
						new WeightedType<PickupDropTable>(newVal8, FoodItemWeight_3.Value, AC)
					}
				};
				ItemsPerTier = new Dictionary<ItemTier, int>
				{
					{
						(ItemTier)4,
						BossItemCountGiven.Value
					},
					{
						(ItemTier)3,
						LunarItemCountGiven.Value
					},
					{
						(ItemTier)5,
						0
					},
					{
						(ItemTier)0,
						WhiteItemCountGiven.Value
					},
					{
						(ItemTier)1,
						GreenItemCountGiven.Value
					},
					{
						(ItemTier)2,
						RedItemCountGiven.Value
					},
					{
						(ItemTier)9,
						1
					},
					{
						(ItemTier)6,
						2
					},
					{
						(ItemTier)7,
						1
					},
					{
						(ItemTier)8,
						1
					},
					{
						(ItemTier)10,
						1
					}
				};
			});
			Run.onRunDestroyGlobal += Run_onRunDestroyGlobal;
		}

		private void Run_onRunDestroyGlobal(Run obj)
		{
			if (NetworkServer.active)
			{
				treasureRng.ResetSeed(0uL);
				if (Object.op_Implicit((Object)(object)RevolutionItemInventory))
				{
					RevolutionItemInventory.CleanInventory();
					NetworkServer.Destroy(((Component)RevolutionItemInventory).gameObject);
				}
				RevolutionItemInventory = null;
			}
		}

		private static void RerollNewInventory()
		{
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Invalid comparison between Unknown and I4
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Invalid comparison between Unknown and I4
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Invalid comparison between Unknown and I4
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Invalid comparison between Unknown and I4
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Invalid comparison between Unknown and I4
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Invalid comparison between Unknown and I4
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Invalid comparison between Unknown and I4
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			if (!Inst.ArtifactEnabled || !Object.op_Implicit((Object)(object)RevolutionItemInventory) || HasRolledNewInventory)
			{
				return;
			}
			HasRolledNewInventory = true;
			RevolutionItemInventory.CleanInventory();
			int num = Mathf.FloorToInt((float)(((Object)(object)Run.instance != (Object)null) ? Run.instance.stageClearCount : 0) * ItemsPerStage.Value);
			num += StartingItemCount.Value;
			if (UnpredictableMode.Value)
			{
				num = (((double)Random.value < 0.4) ? Random.Range(1, num + 2) : ((!((double)Random.value < 0.3)) ? Random.Range(8 + num, 17 + num) : Random.Range(num, 4)));
			}
			for (int i = 0; i < num; i++)
			{
				PickupDropTable val = ItemDropTables.SelectByWeight();
				UniquePickup val2 = val.GeneratePickup(treasureRng);
				if (!((UniquePickup)(ref val2)).isValid)
				{
					continue;
				}
				PickupDef pickupDef = PickupCatalog.GetPickupDef(val2.pickupIndex);
				if (pickupDef == null)
				{
					continue;
				}
				ItemTier itemTier = pickupDef.itemTier;
				if (((int)itemTier == 0 || (int)itemTier == 1 || (int)itemTier == 2 || (int)itemTier == 4) && Run.instance.IsExpansionEnabled(SOTVExpansion) && Random.value < CorruptItemIntoVoid.Value)
				{
					if ((int)itemTier == 4)
					{
						pickupDef = PickupCatalog.GetPickupDef(PickupCatalog.FindPickupIndex(Zoea.itemIndex));
					}
					else
					{
						VoidItems.voidTier1Weight = (((int)itemTier == 0) ? 1 : 0);
						VoidItems.voidTier2Weight = (((int)itemTier == 1) ? 1 : 0);
						VoidItems.voidTier3Weight = (((int)itemTier == 2) ? 1 : 0);
						pickupDef = PickupCatalog.GetPickupDef(((PickupDropTable)VoidItems).GeneratePickup(treasureRng).pickupIndex);
					}
				}
				int value = 1;
				ItemsPerTier.TryGetValue(pickupDef.itemTier, out value);
				int num2 = (int)Mathf.Floor((float)Run.instance.stageClearCount * ItemStackAmountPerStage.Value);
				value += num2;
				if (ChaosStackingMode.Value)
				{
					value = (((double)Random.value < 0.4) ? Random.Range(1, value + 5) : ((!((double)Random.value < 0.3)) ? Random.Range(8, 17) : Random.Range(3, 9)));
				}
				RevolutionItemInventory.GiveItemPermanent(pickupDef.itemIndex, value);
			}
		}
	}
	public static class Tools
	{
		public static byte[] ExtractEmbeddedResource(string filePath)
		{
			filePath = filePath.Replace("/", ".");
			filePath = filePath.Replace("\\", ".");
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			using Stream stream = callingAssembly.GetManifestResourceStream(filePath);
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			return array;
		}

		public static Texture2D GetTextureFromResource(string resourceName)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			byte[] array = ExtractEmbeddedResource(resourceName);
			if (array == null)
			{
				return null;
			}
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			ImageConversion.LoadImage(val, array);
			((Texture)val).filterMode = (FilterMode)0;
			string text = resourceName.Substring(0, resourceName.LastIndexOf('.'));
			if (text.LastIndexOf('.') >= 0)
			{
				text = text.Substring(text.LastIndexOf('.') + 1);
			}
			((Object)val).name = text;
			return val;
		}

		public static void Shuffle<T>(this IList<T> list)
		{
			int num = list.Count;
			while (num > 1)
			{
				num--;
				Random random = new Random();
				int index = random.Next(num + 1);
				T value = list[index];
				list[index] = list[num];
				list[num] = value;
			}
		}
	}
	public class WeightedTypeCollection<T>
	{
		public WeightedType<T>[] elements;

		public T SelectByWeight(Random generatorRandom)
		{
			List<int> list = new List<int>();
			int num = 0;
			for (int i = 0; i < elements.Length; i++)
			{
				WeightedType<T> weightedType = elements[i];
				ExpansionDef requiredExpansion = weightedType.requiredExpansion;
				if ((Object)(object)requiredExpansion != (Object)null)
				{
					if (Run.instance.IsExpansionEnabled(requiredExpansion) && (float)weightedType.Weight > 0f)
					{
						list.Add(i);
						num += weightedType.Weight;
					}
				}
				else if ((float)weightedType.Weight > 0f)
				{
					if (ArtifactOfRevolution.ChaosMode.Value)
					{
						list.Add(i);
						list.Add(i);
					}
					list.Add(i);
					num += weightedType.Weight;
				}
			}
			list.Shuffle();
			if (ArtifactOfRevolution.ChaosMode.Value)
			{
				return elements[list[0]].value;
			}
			int num2 = 100;
			int? num3 = null;
			while (!num3.HasValue)
			{
				num2--;
				if (num2 < 0)
				{
					break;
				}
				int num4 = Random.Range(0, num + 1);
				for (int j = 0; j < list.Count; j++)
				{
					int num5 = list[j];
					if (num4 >= 0 && num4 <= elements[num5].Weight)
					{
						num3 = num5;
						break;
					}
				}
				if (num3.HasValue)
				{
					break;
				}
			}
			return elements[num3.GetValueOrDefault()].value;
		}

		public T SelectByWeight()
		{
			return SelectByWeight(null);
		}
	}
	public class WeightedType<T>
	{
		public T value;

		public int Weight;

		public ExpansionDef requiredExpansion = null;

		public WeightedType(T newVal, int weight = 100, ExpansionDef expansionDef = null)
		{
			value = newVal;
			Weight = weight;
			requiredExpansion = expansionDef;
		}
	}
}