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 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 R2API.Utils;
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+1eabc40f8b8d8c257b897319aab904636cc774c3")]
[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]
[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 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 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected I4, but got Unknown
//IL_00d7: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected I4, but got Unknown
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Expected O, but got Unknown
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Expected O, but got Unknown
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Expected O, but got Unknown
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Expected O, but got Unknown
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Expected I4, but got Unknown
//IL_037f: Unknown result type (might be due to invalid IL or missing references)
//IL_039c: Unknown result type (might be due to invalid IL or missing references)
//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0402: Expected O, but got Unknown
//IL_040e: Unknown result type (might be due to invalid IL or missing references)
//IL_041b: Unknown result type (might be due to invalid IL or missing references)
//IL_0420: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_0446: Unknown result type (might be due to invalid IL or missing references)
//IL_0465: Unknown result type (might be due to invalid IL or missing references)
//IL_046f: Expected O, but got Unknown
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Expected I4, but got Unknown
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
//IL_04b1: 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 @string = Language.GetString(current.nameToken, "en");
@string = ((!string.IsNullOrWhiteSpace(@string) && !@string.Equals(current.nameToken)) ? $"{@string} ({(int)current.itemIndex}: {((Object)current).name})" : $"{(int)current.itemIndex}: {((Object)current).name}");
englishNameToItemIndex.Add(@string, current.itemIndex);
if (!itemTierToItemEnglishNames.TryGetValue(current.tier, out var value))
{
value = (itemTierToItemEnglishNames[current.tier] = new List<string>());
}
value.Add(@string);
}
}
}
finally
{
((IDisposable)enumerator).Dispose();
}
ItemTier key;
foreach (KeyValuePair<ItemTier, List<string>> itemTierToItemEnglishName in itemTierToItemEnglishNames)
{
itemTierToItemEnglishName.Deconstruct(out key, out var value2);
List<string> list2 = value2;
list2.Sort();
list2.Insert(0, "None");
list2.Insert(1, "Random");
}
englishNameToEquipmentIndex.Add("None", (EquipmentIndex)(-1));
EquipmentDef[] equipmentDefs = EquipmentCatalog.equipmentDefs;
foreach (EquipmentDef val in equipmentDefs)
{
if (!((Object)(object)val == (Object)null) && val.nameToken != null)
{
string string2 = Language.GetString(val.nameToken, "en");
string2 = ((!string.IsNullOrWhiteSpace(string2) && !string2.Equals(val.nameToken)) ? $"{string2} ({(int)val.equipmentIndex}: {((Object)val).name})" : $"{(int)val.equipmentIndex}: {((Object)val).name}");
englishNameToEquipmentIndex.Add(string2, val.equipmentIndex);
}
}
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> list3 = englishNameToEquipmentIndex.Keys.ToList();
list3.Remove("None");
list3.Sort();
list3.Insert(0, "None");
list3.Insert(1, "Random");
AcceptableValueList<string> val2 = new AcceptableValueList<string>(list3.ToArray());
StartingEquipment = config.Bind<string>("02 Simple Item List", "Equipment", "None", new ConfigDescription("Which equipment each player shall receive at the start.", (AcceptableValueBase)(object)val2, Array.Empty<object>()));
Enumerator<ItemTierDef> enumerator3 = ItemTierCatalog.allItemTierDefs.GetEnumerator();
try
{
while (enumerator3.MoveNext())
{
ItemTierDef current2 = enumerator3.Current;
AcceptableValueList<string> val3 = new AcceptableValueList<string>(itemTierToItemEnglishNames[current2.tier].ToArray());
Dictionary<ItemTier, ConfigEntry<string>> startingItemByTier = StartingItemByTier;
ItemTier tier = current2.tier;
key = current2.tier;
string text = ((object)(ItemTier)(ref key)).ToString() + " Item";
key = current2.tier;
startingItemByTier[tier] = config.Bind<string>("02 Simple Item List", text, "None", new ConfigDescription("Which " + ((object)(ItemTier)(ref key)).ToString() + " item each player shall receive at the start.", (AcceptableValueBase)(object)val3, Array.Empty<object>()));
Dictionary<ItemTier, ConfigEntry<int>> startingItemByTierAmount = StartingItemByTierAmount;
ItemTier tier2 = current2.tier;
key = current2.tier;
string text2 = ((object)(ItemTier)(ref key)).ToString() + " Amount";
key = current2.tier;
startingItemByTierAmount[tier2] = config.Bind<int>("02 Simple Item List", text2, 0, new ConfigDescription("How many of the " + ((object)(ItemTier)(ref key)).ToString() + " item each player shall receive.", (AcceptableValueBase)null, Array.Empty<object>()));
}
}
finally
{
((IDisposable)enumerator3).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 text3 = "2xHealWhileSafe & Tier3 & 2xLunar & 4xdtChest2";
string text4 = "Tier1, Tier2, Tier3, Lunar, Boss, VoidTier1, VoidTier2, VoidTier3, VoidBoss, FoodTier";
string text5 = "Can use:\n - internal item names(see https://risk-of-thunder.github.io/R2Wiki/Mod-Creation/Developer-Reference/Items-and-Equipments-Data/)\n- item tier keywords (" + text4 + ")\n- droptable names (see README.md)\nExample: " + text3;
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. " + text5);
if (ModCompatibilityInLobbyConfig.enabled)
{
ModCompatibilityInLobbyConfig.CreateFromBepInExConfigFile(config, "Start Bonus");
}
}
}
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));
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Def.StartBonusMod", "StartBonusMod", "3.0.3")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class StartBonusMod : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <DelayInitBepConfig>d__11 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DelayInitBepConfig>d__11(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(2f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
BepConfig.Init();
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static StartBonusMod instance;
public const string PluginGUID = "Def.StartBonusMod";
public const string PluginAuthor = "Def";
public const string PluginName = "StartBonusMod";
public const string PluginVersion = "3.0.3";
private List<PlayerCharacterMasterController> itemGivenTo = new List<PlayerCharacterMasterController>();
public static PluginInfo PInfo { get; private set; }
public void Awake()
{
PInfo = ((BaseUnityPlugin)this).Info;
instance = this;
Log.Init(((BaseUnityPlugin)this).Logger);
Language.onCurrentLanguageChanged += delegate
{
((ResourceAvailability)(ref ItemCatalog.availability)).CallWhenAvailable((Action)delegate
{
((ResourceAvailability)(ref EquipmentCatalog.availability)).CallWhenAvailable((Action)delegate
{
((MonoBehaviour)this).StartCoroutine(DelayInitBepConfig());
});
});
};
}
[IteratorStateMachine(typeof(<DelayInitBepConfig>d__11))]
private IEnumerator DelayInitBepConfig()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <DelayInitBepConfig>d__11(0);
}
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>[5]
{
(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.MatchCallvirt<CharacterMaster>(x, "GiveMoney")
});
val.Index += 4;
val.Remove();
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);
}
else
{
characterMaster.GiveMoney((uint)Run.instance.GetDifficultyScaledCost(BepConfig.StartingCash.Value));
}
}
else
{
characterMaster.GiveMoney(startingMoney);
}
}
});
}
private void Run_Start(orig_Start orig, Run self)
{
instance.itemGivenTo.Clear();
orig.Invoke(self);
}
private void Run_OnServerCharacterBodySpawned(orig_OnServerCharacterBodySpawned orig, Run self, CharacterBody characterBody)
{
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(master);
}
instance.itemGivenTo.Add(master.playerCharacterMasterController);
}
}
private void GiveStartingItemsAdvanced(CharacterMaster master)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Invalid comparison between Unknown and I4
//IL_0071: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Invalid comparison between Unknown and I4
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
Inventory inventory = master.inventory;
Dictionary<PickupIndex, int> dictionary = new Dictionary<PickupIndex, int>();
ItemStringParser.ParseItemString(BepConfig.AdvancedItemList.Value, dictionary, ((BaseUnityPlugin)instance).Logger, false, -1);
uint num = 0u;
foreach (KeyValuePair<PickupIndex, int> item in dictionary)
{
item.Deconstruct(out var key, out var value);
PickupIndex val = key;
int num2 = value;
PickupDef pickupDef = PickupCatalog.GetPickupDef(val);
ItemIndex itemIndex = pickupDef.itemIndex;
EquipmentIndex equipmentIndex = pickupDef.equipmentIndex;
if ((int)itemIndex != -1 && num2 > 0)
{
inventory.GiveItemPermanent(itemIndex, num2);
}
int num3 = ((!(((Object)master.bodyPrefab).name == "ToolbotBody")) ? 1 : 2);
int num4 = master.inventory.GetItemCountEffective(Items.ExtraEquipment.itemIndex) + 1;
int num5 = num3 * num4;
int num6 = num2;
while ((int)equipmentIndex != -1 && num6 > 0 && num < num5)
{
uint num7 = (uint)(num % num3);
uint num8 = (uint)(num / num3);
inventory.SetEquipmentIndexForSlot(equipmentIndex, num7, num8);
num6--;
num++;
}
}
}
private void GiveStartingItemsSimple(Inventory inventory)
{
//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_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: 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_009b: Invalid comparison between Unknown and I4
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Invalid comparison between Unknown and I4
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: 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_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Invalid comparison between Unknown and I4
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: 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 key2 = key;
ConfigEntry<string> val = value;
int value2 = BepConfig.StartingItemByTierAmount[key2].Value;
if (value2 <= 0)
{
continue;
}
if (val.Value.Equals("Random"))
{
ItemIndex itemIndex = PickupCatalog.GetPickupDef(ItemStringParser.ResolveItemKey(((object)(ItemTier)(ref key2)).ToString(), true)).itemIndex;
if ((int)itemIndex != -1)
{
inventory.GiveItemPermanent(itemIndex, value2);
}
continue;
}
ItemIndex val2 = (ItemIndex)(-1);
val2 = BepConfig.englishNameToItemIndex[val.Value];
if ((int)val2 != -1)
{
inventory.GiveItemPermanent(val2, value2);
}
}
EquipmentIndex val3 = (EquipmentIndex)(-1);
if (BepConfig.StartingEquipment.Value.Equals("Random"))
{
PickupIndex random = ItemStringParser.GetRandom<PickupIndex>(Run.instance.availableEquipmentDropList, PickupIndex.none);
if (random != PickupIndex.none)
{
val3 = PickupCatalog.GetPickupDef(random).equipmentIndex;
}
}
else
{
val3 = BepConfig.englishNameToEquipmentIndex[BepConfig.StartingEquipment.Value];
}
if ((int)val3 != -1)
{
inventory.SetEquipmentIndex(val3, false);
}
}
}
}