Decompiled source of StartBonusMod v3.1.0

StartBonusMod.dll

Decompiled a week 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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using HG.Reflection;
using IL.RoR2;
using InLobbyConfig;
using InLobbyConfig.Fields;
using ItemStringParser;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using ProperSave;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StartBonusMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9ddc3c571d238e773a452ea9236a778ffc02579a")]
[assembly: AssemblyProduct("StartBonusMod")]
[assembly: AssemblyTitle("StartBonusMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 StartBonusMod
{
	public class BepConfig
	{
		public static ConfigEntry<bool> Enabled;

		public static ConfigEntry<bool> StartingCashEnabled;

		public static ConfigEntry<int> StartingCash;

		public static ConfigEntry<bool> SimpleEnabled;

		public static Dictionary<ItemTier, ConfigEntry<string>> StartingItemByTier = new Dictionary<ItemTier, ConfigEntry<string>>();

		public static Dictionary<ItemTier, ConfigEntry<int>> StartingItemByTierAmount = new Dictionary<ItemTier, ConfigEntry<int>>();

		public static ConfigEntry<string> StartingEquipment;

		public static ConfigEntry<bool> AdvancedEnabled;

		public static ConfigEntry<string> AdvancedItemList;

		public static Dictionary<string, ItemIndex> englishNameToItemIndex = new Dictionary<string, ItemIndex>();

		public static Dictionary<string, EquipmentIndex> englishNameToEquipmentIndex = new Dictionary<string, EquipmentIndex>();

		public static Dictionary<ItemTier, List<string>> itemTierToItemEnglishNames = new Dictionary<ItemTier, List<string>>();

		private static Dictionary<string, string> internalNameToChoice = new Dictionary<string, string>();

		private static bool initialized = false;

		public static void Init()
		{
			//IL_0029: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Expected O, but got Unknown
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Expected O, but got Unknown
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Expected O, but got Unknown
			if (initialized)
			{
				return;
			}
			initialized = true;
			ConfigFile config = ((BaseUnityPlugin)StartBonusMod.instance).Config;
			englishNameToItemIndex.Add("None", (ItemIndex)(-1));
			Enumerator<ItemDef> enumerator = ItemCatalog.allItemDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ItemDef current = enumerator.Current;
					if (!((Object)(object)current == (Object)null) && current.nameToken != null)
					{
						string choiceName = GetChoiceName(current.nameToken, ((Object)current).name);
						englishNameToItemIndex.Add(choiceName, current.itemIndex);
						internalNameToChoice[((Object)current).name] = choiceName;
						if (!itemTierToItemEnglishNames.TryGetValue(current.tier, out var value))
						{
							value = (itemTierToItemEnglishNames[current.tier] = new List<string>());
						}
						value.Add(choiceName);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			foreach (var (_, list3) in itemTierToItemEnglishNames)
			{
				list3.Sort();
				list3.Insert(0, "None");
				list3.Insert(1, "Random");
			}
			englishNameToEquipmentIndex.Add("None", (EquipmentIndex)(-1));
			EquipmentDef[] equipmentDefs = EquipmentCatalog.equipmentDefs;
			foreach (EquipmentDef val2 in equipmentDefs)
			{
				if (!((Object)(object)val2 == (Object)null) && val2.nameToken != null)
				{
					string choiceName2 = GetChoiceName(val2.nameToken, ((Object)val2).name);
					englishNameToEquipmentIndex.Add(choiceName2, val2.equipmentIndex);
					internalNameToChoice[((Object)val2).name] = choiceName2;
				}
			}
			Enabled = config.Bind<bool>("00 Main", "Enabled", true, "Enable Mod");
			StartingCashEnabled = config.Bind<bool>("01 Cash", "SectionEnabled", false, new ConfigDescription("If starting cash shall be given to the player.", (AcceptableValueBase)null, Array.Empty<object>()));
			StartingCash = config.Bind<int>("01 Cash", "Cash", 0, new ConfigDescription("How much starting cash each player receives.", (AcceptableValueBase)null, Array.Empty<object>()));
			SimpleEnabled = config.Bind<bool>("02 Simple Item List", "SectionEnabled", false, new ConfigDescription("Whether to enable Simple Start Bonus Item List", (AcceptableValueBase)null, Array.Empty<object>()));
			List<string> list4 = englishNameToEquipmentIndex.Keys.ToList();
			list4.Remove("None");
			list4.Sort();
			list4.Insert(0, "None");
			list4.Insert(1, "Random");
			StartingEquipment = BindChoice(config, "02 Simple Item List", "Equipment", "Which equipment each player shall receive at the start.", list4);
			Enumerator<ItemTierDef> enumerator3 = ItemTierCatalog.allItemTierDefs.GetEnumerator();
			try
			{
				while (enumerator3.MoveNext())
				{
					ItemTierDef current2 = enumerator3.Current;
					if (itemTierToItemEnglishNames.TryGetValue(current2.tier, out var value2))
					{
						StartingItemByTier[current2.tier] = BindChoice(config, "02 Simple Item List", ((object)current2.tier/*cast due to .constrained prefix*/).ToString() + " Item", "Which " + ((object)current2.tier/*cast due to .constrained prefix*/).ToString() + " item each player shall receive at the start.", value2);
						StartingItemByTierAmount[current2.tier] = config.Bind<int>("02 Simple Item List", ((object)current2.tier/*cast due to .constrained prefix*/).ToString() + " Amount", 0, new ConfigDescription("How many of the " + ((object)current2.tier/*cast due to .constrained prefix*/).ToString() + " item each player shall receive.", (AcceptableValueBase)null, Array.Empty<object>()));
					}
				}
			}
			finally
			{
				((IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose();
			}
			AdvancedEnabled = config.Bind<bool>("03 Advanced Item List", "SectionEnabled", false, new ConfigDescription("Whether to enable Advanced Start Bonus Item List", (AcceptableValueBase)null, Array.Empty<object>()));
			string text = "2xHealWhileSafe & Tier3 & 2xLunar & 4xdtChest2";
			string text2 = "Tier1, Tier2, Tier3, Lunar, Boss, VoidTier1, VoidTier2, VoidTier3, VoidBoss, FoodTier, Cursed, Hex, Page";
			string text3 = "Equipment, LunarEquipment, LunarItem, PowerShape, KeyItem";
			string text4 = "Can use:\n - internal item, equipment, drone and key item names (see https://risk-of-thunder.github.io/R2Wiki/Mod-Creation/Developer-Reference/Items-and-Equipments-Data/)\n- item tier keywords (" + text2 + ")\n- other drop lists of the run (" + text3 + ")\n- droptable names (see README.md)\nExample: " + text;
			AdvancedItemList = config.Bind<string>("03 Advanced Item List", "ItemList", "2xdtChest1 & Tier2", "List of items in the format <amount1>x<item1> & <amount2>x<item2>. See README.md for more detailed description. " + text4);
			if (ModCompatibilityInLobbyConfig.enabled)
			{
				ModCompatibilityInLobbyConfig.CreateFromBepInExConfigFile(config, "Start Bonus");
			}
		}

		private static string GetChoiceName(string nameToken, string internalName)
		{
			string text = Language.GetString(nameToken, "en");
			if (string.IsNullOrWhiteSpace(text) || text.Equals(nameToken))
			{
				return internalName;
			}
			return text + " (" + internalName + ")";
		}

		private static ConfigEntry<string> BindChoice(ConfigFile config, string section, string key, string description, List<string> choices)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			ConfigDefinition val = new ConfigDefinition(section, key);
			string value = config.Bind<string>(val, "None", new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>())).Value;
			config.Remove(val);
			ConfigEntry<string> val2 = config.Bind<string>(val, "None", new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueList<string>(choices.ToArray()), Array.Empty<object>()));
			if (choices.Contains(value))
			{
				val2.Value = value;
			}
			else
			{
				Match match = Regex.Match(value ?? "", "(?:^|\\()\\d+: ([^()]+)\\)?$");
				if (match.Success && internalNameToChoice.TryGetValue(match.Groups[1].Value, out var value2) && choices.Contains(value2))
				{
					val2.Value = value2;
				}
			}
			return val2;
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public static class ModCompatibilityInLobbyConfig
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.InLobbyConfig");
				}
				return _enabled.Value;
			}
		}

		public static void CreateFromBepInExConfigFile(ConfigFile config, string displayName)
		{
			ModConfigCatalog.Add(ConfigFieldUtilities.CreateFromBepInExConfigFile(config, displayName));
		}
	}
	public static class ModCompatibilityProperSave
	{
		private static bool? _enabled;

		public static bool enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.ProperSave");
				}
				return _enabled.Value;
			}
		}

		public static void Register(string key, Func<object> save, Action<object> load)
		{
			if (!enabled)
			{
				return;
			}
			try
			{
				RegisterWithProperSave(key, save, load);
			}
			catch (Exception ex)
			{
				Log.LogWarning("Could not register " + key + " with ProperSave - " + ex.Message);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void RegisterWithProperSave(string key, Func<object> save, Action<object> load)
		{
			SaveFile.OnGatherSaveData += delegate(Dictionary<string, object> data)
			{
				data[key] = save();
			};
			Loading.OnLoadingEnded += delegate(SaveFile saveFile)
			{
				if (saveFile != null)
				{
					object moddedData;
					try
					{
						moddedData = saveFile.GetModdedData<object>(key);
					}
					catch (KeyNotFoundException)
					{
						return;
					}
					load(moddedData);
				}
			};
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Def.StartBonusMod", "StartBonusMod", "3.1.0")]
	public class StartBonusMod : BaseUnityPlugin
	{
		public static StartBonusMod instance;

		public const string PluginGUID = "Def.StartBonusMod";

		public const string PluginAuthor = "Def";

		public const string PluginName = "StartBonusMod";

		public const string PluginVersion = "3.1.0";

		private List<PlayerCharacterMasterController> itemGivenTo = new List<PlayerCharacterMasterController>();

		private HashSet<string> itemGivenToUsers = new HashSet<string>();

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			PInfo = ((BaseUnityPlugin)this).Info;
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			ModCompatibilityProperSave.Register("StartBonusMod.StartingItemsGivenTo", () => itemGivenToUsers.ToList(), LoadStartingItemsGivenTo);
			Language.onCurrentLanguageChanged += delegate
			{
				((ResourceAvailability)(ref ItemCatalog.availability)).CallWhenAvailable((Action)delegate
				{
					((ResourceAvailability)(ref EquipmentCatalog.availability)).CallWhenAvailable((Action)delegate
					{
						((MonoBehaviour)this).StartCoroutine(DelayInitBepConfig());
					});
				});
			};
		}

		private IEnumerator DelayInitBepConfig()
		{
			yield return (object)new WaitForSeconds(2f);
			BepConfig.Init();
		}

		private void OnEnable()
		{
			//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
			Run.SetupUserCharacterMaster += new Manipulator(Run_SetupUserCharacterMaster);
			Run.OnServerCharacterBodySpawned += new hook_OnServerCharacterBodySpawned(Run_OnServerCharacterBodySpawned);
			Run.Start += new hook_Start(Run_Start);
		}

		private void OnDisable()
		{
			//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
			Run.SetupUserCharacterMaster -= new Manipulator(Run_SetupUserCharacterMaster);
			Run.OnServerCharacterBodySpawned -= new hook_OnServerCharacterBodySpawned(Run_OnServerCharacterBodySpawned);
			Run.Start -= new hook_Start(Run_Start);
		}

		private void Run_SetupUserCharacterMaster(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCall<Run>(x, "get_ruleBook"),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<RuleBook>(x, "get_startingMoney"),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterMaster>(x, "GiveMoney")
			});
			val.Index += 4;
			val.RemoveRange(2);
			val.EmitDelegate<Action<CharacterMaster, uint>>((Action<CharacterMaster, uint>)delegate(CharacterMaster characterMaster, uint startingMoney)
			{
				if ((Object)(object)characterMaster != (Object)null)
				{
					if (BepConfig.Enabled.Value && BepConfig.StartingCashEnabled.Value)
					{
						if (Chainloader.PluginInfos.ContainsKey("com.MagnusMagnuson.StartInBazaar"))
						{
							characterMaster.GiveMoney((uint)Run.instance.GetDifficultyScaledCost(BepConfig.StartingCash.Value) + startingMoney, false);
						}
						else
						{
							characterMaster.GiveMoney((uint)Run.instance.GetDifficultyScaledCost(BepConfig.StartingCash.Value), false);
						}
					}
					else
					{
						characterMaster.GiveMoney(startingMoney, false);
					}
				}
			});
		}

		private void Run_Start(orig_Start orig, Run self)
		{
			instance.itemGivenTo.Clear();
			instance.itemGivenToUsers.Clear();
			orig.Invoke(self);
		}

		private void LoadStartingItemsGivenTo(object saved)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!(saved is List<string> other))
			{
				return;
			}
			itemGivenToUsers.UnionWith(other);
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (Object.op_Implicit((Object)(object)instance.networkUser) && itemGivenToUsers.Contains(GetUserKey(instance.networkUser.id)) && !itemGivenTo.Contains(instance))
				{
					itemGivenTo.Add(instance);
				}
			}
		}

		private static string GetUserKey(NetworkUserId id)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			return $"{id.value}/{id.strValue}/{id.subId}";
		}

		private void Run_OnServerCharacterBodySpawned(orig_OnServerCharacterBodySpawned orig, Run self, CharacterBody characterBody)
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, characterBody);
			if (!NetworkServer.active || !BepConfig.Enabled.Value || !((Object)(object)characterBody != (Object)null))
			{
				return;
			}
			CharacterMaster master = characterBody.master;
			if ((Object)(object)master != (Object)null && (Object)(object)master.playerCharacterMasterController != (Object)null && !instance.itemGivenTo.Contains(master.playerCharacterMasterController))
			{
				if (BepConfig.SimpleEnabled.Value)
				{
					GiveStartingItemsSimple(master.inventory);
				}
				if (BepConfig.AdvancedEnabled.Value)
				{
					GiveStartingItemsAdvanced(characterBody);
				}
				instance.itemGivenTo.Add(master.playerCharacterMasterController);
				if (Object.op_Implicit((Object)(object)master.playerCharacterMasterController.networkUser))
				{
					instance.itemGivenToUsers.Add(GetUserKey(master.playerCharacterMasterController.networkUser.id));
				}
			}
		}

		private void GiveStartingItemsAdvanced(CharacterBody body)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<PickupIndex, int> dictionary = new Dictionary<PickupIndex, int>();
			ItemStringParser.ParseItemString(BepConfig.AdvancedItemList.Value, dictionary, ((BaseUnityPlugin)instance).Logger, false, -1);
			foreach (UniquePickup item in ItemStringParser.GivePickups(body, dictionary))
			{
				PickupDropletController.CreatePickupDroplet(item, body.corePosition + Vector3.up * 1.5f, Vector3.up * 15f, false);
			}
		}

		private unsafe void GiveStartingItemsSimple(Inventory inventory)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_00ff: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Invalid comparison between Unknown and I4
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Invalid comparison between Unknown and I4
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Invalid comparison between Unknown and I4
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			//IL_0168: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<ItemTier, ConfigEntry<string>> item in BepConfig.StartingItemByTier)
			{
				item.Deconstruct(out var key, out var value);
				ItemTier val = key;
				ConfigEntry<string> val2 = value;
				int value2 = BepConfig.StartingItemByTierAmount[val].Value;
				if (value2 <= 0)
				{
					continue;
				}
				if (val2.Value.Equals("Random"))
				{
					PickupIndex val3;
					try
					{
						val3 = ItemStringParser.ResolveItemKey(((int)val == 3) ? "LunarItem" : ((object)(*(ItemTier*)(&val))/*cast due to .constrained prefix*/).ToString(), true);
					}
					catch (ArgumentException ex)
					{
						Log.LogWarning($"No random {val} item: {ex.Message}");
						continue;
					}
					PickupDef pickupDef = PickupCatalog.GetPickupDef(val3);
					ItemIndex val4 = (ItemIndex)((pickupDef == null) ? (-1) : ((int)pickupDef.itemIndex));
					if ((int)val4 != -1)
					{
						inventory.GiveItemPermanent(val4, value2);
					}
				}
				else
				{
					ItemIndex val5 = (ItemIndex)(-1);
					val5 = BepConfig.englishNameToItemIndex[val2.Value];
					if ((int)val5 != -1)
					{
						inventory.GiveItemPermanent(val5, value2);
					}
				}
			}
			EquipmentIndex val6 = (EquipmentIndex)(-1);
			if (BepConfig.StartingEquipment.Value.Equals("Random"))
			{
				PickupIndex random = ItemStringParser.GetRandom<PickupIndex>(Run.instance.availableEquipmentDropList, PickupIndex.none);
				if (random != PickupIndex.none)
				{
					val6 = PickupCatalog.GetPickupDef(random).equipmentIndex;
				}
			}
			else
			{
				val6 = BepConfig.englishNameToEquipmentIndex[BepConfig.StartingEquipment.Value];
			}
			if ((int)val6 != -1)
			{
				uint set = inventory.FindBestEquipmentLocationOrCurrent(ref EquipmentLocationQueryArgs.defaultPickup).set;
				EquipmentIndex val7 = val6;
				EquipmentLocation val8 = new EquipmentLocation
				{
					slot = inventory.activeEquipmentSlot,
					set = set
				};
				inventory.SetEquipmentIndex(val7, ref val8);
			}
		}
	}
}