Decompiled source of Uncap gold v1.0.0

plugins/UncapGold/UncapGold.dll

Decompiled 18 hours ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.GoldGat;
using Microsoft.CodeAnalysis;
using On.EntityStates.GoldGat;
using On.RoR2;
using On.RoR2.Items;
using On.RoR2.Orbs;
using On.RoR2.Quests.TrialQuests;
using On.RoR2.UI;
using ProperSave;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Orbs;
using RoR2.Quests.TrialQuests;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UncapGold")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fe14cb3162fc1415b7b32c843dc0cb8e92475b2e")]
[assembly: AssemblyProduct("UncapGold")]
[assembly: AssemblyTitle("UncapGold")]
[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 UncapGold
{
	internal static class ConversionHooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_AwardExperience <0>__AwardExperience;

			public static hook_FixedUpdate <1>__FixedUpdate;

			public static hook_OnFinishedServer <2>__OnFinishedServer;

			public static hook_FireBullet <3>__FireBullet;

			public static hook_Start <4>__Start;

			public static hook_RecalculateStats <5>__RecalculateStats;

			public static hook_OnEnter <6>__OnEnter;

			public static hook_Start <7>__Start;
		}

		private const float GOLD_GAT_COST_PER_LEVEL = 0.25f;

		private const double BLESSING_ARMOR_PER_GOLD = 0.1;

		private const double ETHEREAL_ARMOR = 10.0;

		private const double SPEED_ON_PICKUP_STATS = 0.03;

		private const double BOOST_ALL_STATS = 0.04;

		private const double MAX_ARMOR = 1E+30;

		private static bool goldToExperience;

		private const double STAGE_END_EXPERIENCE = 0.5;

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//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_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			object obj = <>O.<0>__AwardExperience;
			if (obj == null)
			{
				hook_AwardExperience val = AwardExperience;
				<>O.<0>__AwardExperience = val;
				obj = (object)val;
			}
			ExperienceManager.AwardExperience += (hook_AwardExperience)obj;
			object obj2 = <>O.<1>__FixedUpdate;
			if (obj2 == null)
			{
				hook_FixedUpdate val2 = FixedUpdate;
				<>O.<1>__FixedUpdate = val2;
				obj2 = (object)val2;
			}
			ConvertPlayerMoneyToExperience.FixedUpdate += (hook_FixedUpdate)obj2;
			object obj3 = <>O.<2>__OnFinishedServer;
			if (obj3 == null)
			{
				hook_OnFinishedServer val3 = OnFinishedServer;
				<>O.<2>__OnFinishedServer = val3;
				obj3 = (object)val3;
			}
			InfiniteTowerWaveController.OnFinishedServer += (hook_OnFinishedServer)obj3;
			object obj4 = <>O.<3>__FireBullet;
			if (obj4 == null)
			{
				hook_FireBullet val4 = FireBullet;
				<>O.<3>__FireBullet = val4;
				obj4 = (object)val4;
			}
			GoldGatFire.FireBullet += (hook_FireBullet)obj4;
			object obj5 = <>O.<4>__Start;
			if (obj5 == null)
			{
				hook_Start val5 = Start;
				<>O.<4>__Start = val5;
				obj5 = (object)val5;
			}
			AffixAurelioniteBehavior.Start += (hook_Start)obj5;
			object obj6 = <>O.<5>__RecalculateStats;
			if (obj6 == null)
			{
				hook_RecalculateStats val6 = RecalculateStats;
				<>O.<5>__RecalculateStats = val6;
				obj6 = (object)val6;
			}
			CharacterBody.RecalculateStats += (hook_RecalculateStats)obj6;
			object obj7 = <>O.<6>__OnEnter;
			if (obj7 == null)
			{
				hook_OnEnter val7 = OnEnter;
				<>O.<6>__OnEnter = val7;
				obj7 = (object)val7;
			}
			TrialQuestSadismMoney.OnEnter += (hook_OnEnter)obj7;
			object obj8 = <>O.<7>__Start;
			if (obj8 == null)
			{
				hook_Start val8 = Start;
				<>O.<7>__Start = val8;
				obj8 = (object)val8;
			}
			SpawnAltarZoneController.Start += (hook_Start)obj8;
		}

		private static void AwardExperience(orig_AwardExperience orig, ExperienceManager self, Vector3 origin, CharacterBody body, ulong amount)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (goldToExperience)
			{
				double num = GoldScale.ToReal(amount);
				amount = ((num >= 1.8446744073709552E+19) ? ulong.MaxValue : ((ulong)num));
			}
			orig.Invoke(self, origin, body, amount);
		}

		private static void FixedUpdate(orig_FixedUpdate orig, ConvertPlayerMoneyToExperience self)
		{
			ConvertBank(0.5);
			goldToExperience = true;
			try
			{
				orig.Invoke(self);
			}
			finally
			{
				goldToExperience = false;
			}
		}

		private static void OnFinishedServer(orig_OnFinishedServer orig, InfiniteTowerWaveController self)
		{
			if (self.convertGoldOnWaveFinish)
			{
				ConvertBank(self.goldToExpConversionRatio);
			}
			goldToExperience = true;
			try
			{
				orig.Invoke(self);
			}
			finally
			{
				goldToExperience = false;
			}
		}

		private static void ConvertBank(double ratio)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			ReadOnlyCollection<PlayerCharacterMasterController> instances = PlayerCharacterMasterController.instances;
			for (int i = 0; i < instances.Count; i++)
			{
				CharacterMaster master = instances[i].master;
				double num = GoldBank.Get(master);
				if (!(num <= 0.0))
				{
					GoldBank.Set(master, 0.0);
					double num2 = num * GoldScale.Scale * ratio / (double)instances.Count;
					TeamManager.instance.GiveTeamExperience(master.teamIndex, (num2 >= 1.8446744073709552E+19) ? ulong.MaxValue : ((ulong)num2));
				}
			}
		}

		private static void FireBullet(orig_FireBullet orig, GoldGatFire self)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			CharacterMaster bodyMaster = ((BaseGoldGatState)self).bodyMaster;
			uint num = (Object.op_Implicit((Object)(object)bodyMaster) ? bodyMaster.money : 0u);
			orig.Invoke(self);
			double scale = GoldScale.Scale;
			if (scale != 1.0 && NetworkServer.active && Object.op_Implicit((Object)(object)bodyMaster) && Object.op_Implicit((Object)(object)TeamManager.instance))
			{
				uint teamLevel = TeamManager.instance.GetTeamLevel(bodyMaster.teamIndex);
				int num2 = (int)((float)GoldGatFire.baseMoneyCostPerBullet * (1f + ((float)teamLevel - 1f) * 0.25f));
				bodyMaster.money = num - (uint)Math.Min(num, Math.Max(0.0, (double)num2 / scale));
			}
		}

		private static void Start(orig_Start orig, AffixAurelioniteBehavior self)
		{
			orig.Invoke(self);
			double scale = GoldScale.Scale;
			if (scale != 1.0 && Object.op_Implicit((Object)(object)Run.instance))
			{
				double num = (double)self.goldCoefficient * (double)Run.instance.difficultyCoefficient;
				self.maxGoldForRamping = (uint)Math.Min(4294967295.0, Math.Max(1.0, num / scale));
			}
		}

		private static void RecalculateStats(orig_RecalculateStats orig, CharacterBody self)
		{
			orig.Invoke(self);
			double scale = GoldScale.Scale;
			if (scale != 1.0 && Object.op_Implicit((Object)(object)self.master) && self.HasBuff(Buffs.AurelioniteBlessing))
			{
				double num = 0.1 * (double)self.master.money * (scale - 1.0);
				if (self.HasBuff(Buffs.Ethereal))
				{
					num *= 10.0;
				}
				num *= 1.0 + 0.03 * (double)self.GetBuffCount(Buffs.SpeedOnPickup);
				num *= 1.0 + 0.04 * (double)self.GetBuffCount(Buffs.BoostAllStatsBuff);
				self.armor = (float)Math.Min(1E+30, (double)self.armor + num);
			}
		}

		private static void OnEnter(orig_OnEnter orig, TrialQuestSadismMoney self)
		{
			orig.Invoke(self);
			double scale = GoldScale.Scale;
			if (scale != 1.0 && NetworkServer.active && Object.op_Implicit((Object)(object)Run.instance))
			{
				double num = (double)self.requiredMoneyBase * (double)self.requiredMoneyScalingCoeff * (double)Run.instance.compensatedDifficultyCoefficient;
				self.requiredMoney = (uint)Math.Min(4294967295.0, Math.Max(1.0, num / scale));
			}
		}

		private static void Start(orig_Start orig, SpawnAltarZoneController self)
		{
			orig.Invoke(self);
			self._adjustedPointsPerLevel = (float)((double)self._adjustedPointsPerLevel / GoldScale.Scale);
		}
	}
	internal static class DebugKeys
	{
		public static void Update()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (UncapGold.debugKeys.Value)
			{
				KeyboardShortcut value = UncapGold.giveGoldKey.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					GiveGold();
				}
			}
		}

		private static void GiveGold()
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return;
			}
			if (!NetworkServer.active)
			{
				Log.Warning("The debug keys only work for the host");
				return;
			}
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterMaster val = ((firstLocalUser != null) ? firstLocalUser.cachedMaster : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				int value = UncapGold.debugChestsPerPress.Value;
				double val2 = (double)value * (double)Run.instance.GetDifficultyScaledCost(25);
				val.GiveMoney((uint)Math.Min(4294967295.0, val2), false);
				Log.Info($"Debug key pressed, gave gold for {value} small chests");
			}
		}
	}
	internal static class GoldBank
	{
		private static readonly Dictionary<CharacterMaster, double> banked = new Dictionary<CharacterMaster, double>();

		private static bool refilling;

		public static void Init()
		{
			Run.onRunStartGlobal += delegate
			{
				Clear();
			};
		}

		public static double Get(CharacterMaster master)
		{
			if (!Object.op_Implicit((Object)(object)master) || !banked.TryGetValue(master, out var value))
			{
				return 0.0;
			}
			return value;
		}

		public static void Deposit(CharacterMaster master, double gold)
		{
			if (gold > 0.0 && Object.op_Implicit((Object)(object)master))
			{
				Set(master, Get(master) + gold);
			}
		}

		public static void Set(CharacterMaster master, double gold)
		{
			bool flag = banked.ContainsKey(master);
			if (gold > 0.0)
			{
				banked[master] = gold;
				if (!flag)
				{
					master.OnMoneyValueChanged += OnMoneyValueChanged;
				}
			}
			else if (flag)
			{
				banked.Remove(master);
				master.OnMoneyValueChanged -= OnMoneyValueChanged;
			}
		}

		private static void Clear()
		{
			foreach (CharacterMaster key in banked.Keys)
			{
				if (Object.op_Implicit((Object)(object)key))
				{
					key.OnMoneyValueChanged -= OnMoneyValueChanged;
				}
			}
			banked.Clear();
		}

		private static void OnMoneyValueChanged(CharacterMaster master)
		{
			if (refilling || !NetworkServer.active)
			{
				return;
			}
			uint num = uint.MaxValue - master.money;
			double num2 = Get(master);
			if (num != 0 && !(num2 < 1.0))
			{
				uint num3 = (uint)Math.Min(Math.Floor(num2), num);
				refilling = true;
				try
				{
					master.money += num3;
				}
				finally
				{
					refilling = false;
				}
				Set(master, num2 - (double)num3);
			}
		}
	}
	public enum NumberStyle
	{
		Short,
		Scientific,
		Full
	}
	internal static class GoldDisplay
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Update <0>__Update;

			public static hook_UpdateMoneyText <1>__UpdateMoneyText;

			public static Action <2>__SetCostString;

			public static BuildCostStringDelegate <3>__BuildCostString;
		}

		private const double THOUSAND = 1000.0;

		private const double FULL_LIMIT = 1000000000000000.0;

		private static readonly string[] SUFFIXES = new string[12]
		{
			"", "K", "M", "B", "T", "Qa", "Qi", "Sx", "Sp", "Oc",
			"No", "Dc"
		};

		private static string shownText;

		private static double shownReal;

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__Update;
			if (obj == null)
			{
				hook_Update val = Update;
				<>O.<0>__Update = val;
				obj = (object)val;
			}
			MoneyText.Update += (hook_Update)obj;
			object obj2 = <>O.<1>__UpdateMoneyText;
			if (obj2 == null)
			{
				hook_UpdateMoneyText val2 = UpdateMoneyText;
				<>O.<1>__UpdateMoneyText = val2;
				obj2 = (object)val2;
			}
			ScoreboardStrip.UpdateMoneyText += (hook_UpdateMoneyText)obj2;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SetCostString));
			UncapGold.numberStyle.SettingChanged += delegate
			{
				shownText = null;
			};
			UncapGold.digits.SettingChanged += delegate
			{
				shownText = null;
			};
		}

		private static bool IsVanilla(double real, double scale)
		{
			if (scale == 1.0)
			{
				if (UncapGold.uncapGold.Value)
				{
					return real < 1000.0;
				}
				return true;
			}
			return false;
		}

		public static string Format(double real)
		{
			int value = UncapGold.digits.Value;
			double value2 = RoundToDigits(real, value);
			if (Math.Abs(value2) < 1000.0)
			{
				return value2.ToString("0.##########", CultureInfo.InvariantCulture);
			}
			switch (UncapGold.numberStyle.Value)
			{
			case NumberStyle.Full:
				if (!(Math.Abs(real) < 1000000000000000.0))
				{
					return FormatScientific(real, value);
				}
				return real.ToString("N0", CultureInfo.InvariantCulture);
			case NumberStyle.Scientific:
				return FormatScientific(real, value);
			default:
				return FormatShort(real, value);
			}
		}

		private static string FormatScientific(double real, int digits)
		{
			GetMantissa(real, digits, out var mantissa, out var exponent);
			return mantissa.ToString("F" + (digits - 1), CultureInfo.InvariantCulture) + "e" + exponent;
		}

		private static string FormatShort(double real, int digits)
		{
			GetMantissa(real, digits, out var mantissa, out var exponent);
			int num = exponent / 3;
			if (num >= SUFFIXES.Length)
			{
				return FormatScientific(real, digits);
			}
			int num2 = exponent % 3;
			return (mantissa * Math.Pow(10.0, num2)).ToString("F" + (digits - 1 - num2), CultureInfo.InvariantCulture) + SUFFIXES[num];
		}

		private static void GetMantissa(double real, int digits, out double mantissa, out int exponent)
		{
			exponent = (int)Math.Floor(Math.Log10(Math.Abs(real)));
			mantissa = Math.Round(real / Math.Pow(10.0, exponent), digits - 1);
			if (Math.Abs(mantissa) >= 10.0)
			{
				mantissa /= 10.0;
				exponent++;
			}
		}

		private static double RoundToDigits(double real, int digits)
		{
			if (real == 0.0)
			{
				return 0.0;
			}
			int num = (int)Math.Floor(Math.Log10(Math.Abs(real)));
			int val = Math.Max(0, digits - 1 - num);
			return Math.Round(real, Math.Min(val, 15));
		}

		private static HUD GetGoldHud(MoneyText moneyText)
		{
			foreach (HUD readOnlyInstance in HUD.readOnlyInstanceList)
			{
				if ((Object)(object)readOnlyInstance.moneyText == (Object)(object)moneyText)
				{
					return readOnlyInstance;
				}
			}
			return null;
		}

		private static void Update(orig_Update orig, MoneyText self)
		{
			orig.Invoke(self);
			HUD val = (Object.op_Implicit((Object)(object)self.targetText) ? GetGoldHud(self) : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			double scale = GoldScale.Scale;
			double num = ((double)(uint)self.displayAmount + GoldBank.Get(val.targetMaster)) * scale;
			if (!IsVanilla(num, scale))
			{
				if (shownText == null || shownReal != num)
				{
					shownText = Format(num);
					shownReal = num;
				}
				if ((object)((TMP_Text)self.targetText).text != shownText)
				{
					((TMP_Text)self.targetText).text = shownText;
				}
			}
		}

		private static void UpdateMoneyText(orig_UpdateMoneyText orig, ScoreboardStrip self)
		{
			double num = GoldBank.Get(self.master);
			bool num2 = Object.op_Implicit((Object)(object)self.master) && (self.master.money != self.previousMoney || num > 0.0);
			orig.Invoke(self);
			if (num2)
			{
				double scale = GoldScale.Scale;
				double real = ((double)self.master.money + num) * scale;
				if (!IsVanilla(real, scale))
				{
					((TMP_Text)self.moneyText).text = "$" + Format(real);
				}
			}
		}

		private static void SetCostString()
		{
			//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_0021: Expected O, but got Unknown
			CostTypeDef costTypeDef = CostTypeCatalog.GetCostTypeDef((CostTypeIndex)1);
			object obj = <>O.<3>__BuildCostString;
			if (obj == null)
			{
				BuildCostStringDelegate val = BuildCostString;
				<>O.<3>__BuildCostString = val;
				obj = (object)val;
			}
			costTypeDef.buildCostString = (BuildCostStringDelegate)obj;
		}

		private static void BuildCostString(CostTypeDef costTypeDef, BuildCostStringContext context)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			double scale = GoldScale.Scale;
			double real = (double)context.cost * scale;
			if (IsVanilla(real, scale))
			{
				CostTypeDef.BuildCostStringDefault(costTypeDef, context);
				return;
			}
			context.stringBuilder.Append(Language.GetStringFormatted(costTypeDef.costStringFormatToken, new object[1] { Format(real) }));
		}
	}
	internal static class GoldLog
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnKilledServer <0>__OnKilledServer;
		}

		public static bool Enabled => UncapGold.logGold.Value;

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__OnKilledServer;
			if (obj == null)
			{
				hook_OnKilledServer val = OnKilledServer;
				<>O.<0>__OnKilledServer = val;
				obj = (object)val;
			}
			DeathRewards.OnKilledServer += (hook_OnKilledServer)obj;
		}

		private static void OnKilledServer(orig_OnKilledServer orig, DeathRewards self, DamageReport damageReport)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (Enabled)
			{
				string text = (Object.op_Implicit((Object)(object)self.characterBody) ? ((Object)self.characterBody).name : "?");
				Log.Info($"[gold] kill of {text}: gold reward {self.goldReward}, scale {GoldScale.Scale:0.#e0}, killer team {damageReport?.attackerTeamIndex}");
			}
			orig.Invoke(self, damageReport);
		}

		public static void Spawn(CombatDirector director, double scale, bool scaled)
		{
			if (Enabled)
			{
				Log.Info(string.Format("[gold] spawn by {0}: scale {1:0.#e0}, coefficient {2}, scaled here: {3}", Object.op_Implicit((Object)(object)director) ? ((Object)director).name : "something that is no director", scale, Object.op_Implicit((Object)(object)director) ? director.goldRewardCoefficient : 0f, scaled));
			}
		}

		public static void GiveMoney(CharacterMaster master, uint asked, uint given)
		{
			if (Enabled)
			{
				Log.Info($"[gold] {((Object)master).name} gets {given} (asked for {asked}), now has {master.money}");
			}
		}
	}
	internal static class GoldScale
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<Run> <0>__OnRunStart;

			public static hook_AdvanceStage <1>__AdvanceStage;

			public static hook_OnSerialize <2>__OnSerialize;

			public static hook_OnDeserialize <3>__OnDeserialize;
		}

		private const double STEP = 10.0;

		public const int SMALL_CHEST_COST = 25;

		public const double COST_EXPONENT = 1.25;

		private const double MAX_SMALL_CHEST = 1000000.0;

		private const double MAX_CARRIED = 1000000000.0;

		private const double MIN_SMALL_CHEST = 1000.0;

		private const int MAX_EXPONENT = 60;

		private static int exponent;

		private static bool outdated = true;

		private static double scale = 1.0;

		private static double clientScale = 1.0;

		private static readonly Dictionary<CharacterMaster, double> leftovers = new Dictionary<CharacterMaster, double>();

		public static int Exponent
		{
			get
			{
				if (outdated)
				{
					Refresh();
				}
				return exponent;
			}
		}

		public static double Scale
		{
			get
			{
				if (!NetworkServer.active)
				{
					return clientScale;
				}
				if (outdated)
				{
					Refresh();
				}
				return scale;
			}
		}

		public static void Init()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//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_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			Run.onRunStartGlobal += OnRunStart;
			object obj = <>O.<1>__AdvanceStage;
			if (obj == null)
			{
				hook_AdvanceStage val = AdvanceStage;
				<>O.<1>__AdvanceStage = val;
				obj = (object)val;
			}
			Run.AdvanceStage += (hook_AdvanceStage)obj;
			object obj2 = <>O.<2>__OnSerialize;
			if (obj2 == null)
			{
				hook_OnSerialize val2 = OnSerialize;
				<>O.<2>__OnSerialize = val2;
				obj2 = (object)val2;
			}
			Stage.OnSerialize += (hook_OnSerialize)obj2;
			object obj3 = <>O.<3>__OnDeserialize;
			if (obj3 == null)
			{
				hook_OnDeserialize val3 = OnDeserialize;
				<>O.<3>__OnDeserialize = val3;
				obj3 = (object)val3;
			}
			Stage.OnDeserialize += (hook_OnDeserialize)obj3;
		}

		public static double ToReal(double scaled)
		{
			return scaled * Scale;
		}

		public static int ToScaledPrice(double real)
		{
			return (int)Math.Min(2147483647.0, real / Scale);
		}

		public static uint ToScaled(double real, CharacterMaster receiver)
		{
			double num = Scale;
			if (num == 1.0)
			{
				return (uint)Math.Min(4294967295.0, real);
			}
			double num2 = real / num;
			if (Object.op_Implicit((Object)(object)receiver))
			{
				leftovers.TryGetValue(receiver, out var value);
				num2 += value;
				leftovers[receiver] = num2 - Math.Floor(num2);
			}
			return (uint)Math.Min(4294967295.0, num2);
		}

		private static void OnRunStart(Run run)
		{
			exponent = 0;
			scale = 1.0;
			outdated = true;
			clientScale = 1.0;
			leftovers.Clear();
			if (ProperSaveCompat.Enabled && ProperSaveCompat.TryLoad(out var val))
			{
				exponent = Math.Max(0, Math.Min(60, val));
				scale = Math.Pow(10.0, exponent);
				outdated = false;
			}
		}

		private static void AdvanceStage(orig_AdvanceStage orig, Run self, SceneDef nextScene)
		{
			orig.Invoke(self, nextScene);
			outdated = true;
		}

		private static void Refresh()
		{
			outdated = false;
			Run instance = Run.instance;
			int num = 0;
			if (Object.op_Implicit((Object)(object)instance) && UncapGold.uncapGold.Value)
			{
				instance.RecalculateDifficultyCoefficent();
				num = GetGoldExponent(instance.difficultyCoefficient, GetExponent(instance.difficultyCoefficient));
			}
			bool num2 = num != exponent;
			double num3 = Math.Pow(10.0, exponent - num);
			exponent = num;
			scale = Math.Pow(10.0, exponent);
			if (!num2)
			{
				return;
			}
			leftovers.Clear();
			foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
			{
				double num4 = Math.Round(((double)readOnlyInstances.money + GoldBank.Get(readOnlyInstances)) * num3);
				double num5 = Math.Min(4294967295.0, num4);
				GoldBank.Set(readOnlyInstances, num4 - num5);
				readOnlyInstances.money = (uint)num5;
			}
			Log.Info($"Gold is counted in units of {scale:0.#e0} from here on");
		}

		private static int GetGoldExponent(float difficultyCoefficient, int priceExponent)
		{
			double num = 0.0;
			foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
			{
				num = Math.Max(num, ((double)readOnlyInstances.money + GoldBank.Get(readOnlyInstances)) * scale);
			}
			double num2 = 25.0 * Math.Pow(difficultyCoefficient, 1.25);
			int i;
			for (i = priceExponent; i < 60 && num / Math.Pow(10.0, i) > 1000000000.0 && num2 / Math.Pow(10.0, i + 1) >= 1000.0; i++)
			{
			}
			return i;
		}

		private static int GetExponent(float difficultyCoefficient)
		{
			double num = 25.0 * Math.Pow(difficultyCoefficient, 1.25);
			int num2 = 0;
			while (num >= 1000000.0 && num2 < 60)
			{
				num /= 10.0;
				num2++;
			}
			return num2;
		}

		private static bool OnSerialize(orig_OnSerialize orig, Stage self, NetworkWriter writer, bool forceAll)
		{
			bool result = orig.Invoke(self, writer, forceAll);
			if (forceAll)
			{
				if (outdated)
				{
					Refresh();
				}
				writer.WritePackedUInt32((uint)exponent);
			}
			return result;
		}

		private static void OnDeserialize(orig_OnDeserialize orig, Stage self, NetworkReader reader, bool initialState)
		{
			orig.Invoke(self, reader, initialState);
			if (initialState)
			{
				clientScale = Math.Pow(10.0, reader.ReadPackedUInt32());
			}
		}
	}
	internal static class IncomeHooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_GiveMoney_uint_bool <0>__GiveMoney;

			public static hook_AddOrb <1>__AddOrb;

			public static hook_OnPurchase <2>__OnPurchase;

			public static hook_Start <3>__Start;

			public static hook_AddShrineStack <4>__AddShrineStack;
		}

		private const float BRITTLE_CROWN_GOLD = 2f;

		private const int ROLL_OF_PENNIES_GOLD = 3;

		private static bool realGold;

		private static bool scaledOrb;

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//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_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			object obj = <>O.<0>__GiveMoney;
			if (obj == null)
			{
				hook_GiveMoney_uint_bool val = GiveMoney;
				<>O.<0>__GiveMoney = val;
				obj = (object)val;
			}
			CharacterMaster.GiveMoney_uint_bool += (hook_GiveMoney_uint_bool)obj;
			object obj2 = <>O.<1>__AddOrb;
			if (obj2 == null)
			{
				hook_AddOrb val2 = AddOrb;
				<>O.<1>__AddOrb = val2;
				obj2 = (object)val2;
			}
			OrbManager.AddOrb += (hook_AddOrb)obj2;
			object obj3 = <>O.<2>__OnPurchase;
			if (obj3 == null)
			{
				hook_OnPurchase val3 = OnPurchase;
				<>O.<2>__OnPurchase = val3;
				obj3 = (object)val3;
			}
			MultiShopCardUtils.OnPurchase += (hook_OnPurchase)obj3;
			object obj4 = <>O.<3>__Start;
			if (obj4 == null)
			{
				hook_Start val4 = Start;
				<>O.<3>__Start = val4;
				obj4 = (object)val4;
			}
			BarrelInteraction.Start += (hook_Start)obj4;
			object obj5 = <>O.<4>__AddShrineStack;
			if (obj5 == null)
			{
				hook_AddShrineStack val5 = AddShrineStack;
				<>O.<4>__AddShrineStack = val5;
				obj5 = (object)val5;
			}
			ShrineBloodBehavior.AddShrineStack += (hook_AddShrineStack)obj5;
		}

		private static void GiveMoney(orig_GiveMoney_uint_bool orig, CharacterMaster self, uint amount, bool bypassStatManager)
		{
			uint asked = amount;
			if (realGold)
			{
				amount = GoldScale.ToScaled(amount, self);
			}
			if (UncapGold.uncapGold.Value)
			{
				uint num = uint.MaxValue - self.money;
				if (amount > num)
				{
					GoldBank.Deposit(self, amount - num);
					amount = num;
				}
			}
			orig.Invoke(self, amount, bypassStatManager);
			GoldLog.GiveMoney(self, asked, amount);
		}

		private static void AddOrb(orig_AddOrb orig, OrbManager self, Orb orb)
		{
			GoldOrb val = (GoldOrb)(object)((orb is GoldOrb) ? orb : null);
			if (val != null && NetworkServer.active && GoldScale.Scale != 1.0 && !IsScaled(val))
			{
				HealthComponent val2 = (Object.op_Implicit((Object)(object)((Orb)val).target) ? ((Orb)val).target.healthComponent : null);
				CharacterBody val3 = (Object.op_Implicit((Object)(object)val2) ? val2.body : null);
				val.goldAmount = GoldScale.ToScaled(GetRealGold(val.goldAmount, val3), Object.op_Implicit((Object)(object)val3) ? val3.master : null);
			}
			orig.Invoke(self, orb);
		}

		private static bool IsScaled(GoldOrb goldOrb)
		{
			if (!scaledOrb)
			{
				return goldOrb.goldAmount == PriceHooks.LastUnitPrice;
			}
			return true;
		}

		private static double GetRealGold(uint amount, CharacterBody receiver)
		{
			if (!Object.op_Implicit((Object)(object)receiver) || !Object.op_Implicit((Object)(object)Run.instance))
			{
				return amount;
			}
			float difficultyCoefficient = Run.instance.difficultyCoefficient;
			int num = (Object.op_Implicit((Object)(object)receiver.inventory) ? receiver.inventory.GetItemCountEffective(Items.GoldOnHit) : 0);
			if (num > 0 && amount == (uint)((float)num * 2f * difficultyCoefficient))
			{
				return (double)num * 2.0 * (double)difficultyCoefficient;
			}
			int num2 = (Object.op_Implicit((Object)(object)receiver.healthComponent) ? (receiver.healthComponent.itemCounts.goldOnHurt * 3) : 0);
			if (num2 <= 0 || amount != (uint)((float)num2 * difficultyCoefficient))
			{
				return amount;
			}
			return (double)num2 * (double)difficultyCoefficient;
		}

		private static void OnPurchase(orig_OnPurchase orig, PayCostContext context, int moneyCost)
		{
			scaledOrb = true;
			try
			{
				orig.Invoke(context, moneyCost);
			}
			finally
			{
				scaledOrb = false;
			}
		}

		private static void Start(orig_Start orig, BarrelInteraction self)
		{
			int goldReward = self.goldReward;
			orig.Invoke(self);
			if (NetworkServer.active && Object.op_Implicit((Object)(object)Run.instance) && GoldScale.Scale != 1.0)
			{
				self.goldReward = GoldScale.ToScaledPrice((double)goldReward * (double)Run.instance.difficultyCoefficient);
			}
		}

		private static void AddShrineStack(orig_AddShrineStack orig, ShrineBloodBehavior self, Interactor interactor)
		{
			realGold = true;
			try
			{
				orig.Invoke(self, interactor);
			}
			finally
			{
				realGold = false;
			}
		}
	}
	internal static class KillRewardHooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_TrySpawnObject <0>__TrySpawnObject;

			public static hook_Spawn <1>__Spawn;

			public static hook_UpdateMonsterStatsBasedOnEliteEquipment <2>__UpdateMonsterStatsBasedOnEliteEquipment;
		}

		private static CombatDirector spawningDirector;

		private static ScriptedCombatEncounter spawningEncounter;

		private static readonly Dictionary<Type, FieldInfo> directorFields = new Dictionary<Type, FieldInfo>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//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_005b: Expected O, but got Unknown
			object obj = <>O.<0>__TrySpawnObject;
			if (obj == null)
			{
				hook_TrySpawnObject val = TrySpawnObject;
				<>O.<0>__TrySpawnObject = val;
				obj = (object)val;
			}
			DirectorCore.TrySpawnObject += (hook_TrySpawnObject)obj;
			object obj2 = <>O.<1>__Spawn;
			if (obj2 == null)
			{
				hook_Spawn val2 = Spawn;
				<>O.<1>__Spawn = val2;
				obj2 = (object)val2;
			}
			ScriptedCombatEncounter.Spawn += (hook_Spawn)obj2;
			object obj3 = <>O.<2>__UpdateMonsterStatsBasedOnEliteEquipment;
			if (obj3 == null)
			{
				hook_UpdateMonsterStatsBasedOnEliteEquipment val3 = UpdateMonsterStatsBasedOnEliteEquipment;
				<>O.<2>__UpdateMonsterStatsBasedOnEliteEquipment = val3;
				obj3 = (object)val3;
			}
			Util.UpdateMonsterStatsBasedOnEliteEquipment += (hook_UpdateMonsterStatsBasedOnEliteEquipment)obj3;
		}

		private static GameObject TrySpawnObject(orig_TrySpawnObject orig, DirectorCore self, DirectorSpawnRequest directorSpawnRequest)
		{
			double scale = GoldScale.Scale;
			CombatDirector val = ((scale == 1.0) ? null : GetDirector(directorSpawnRequest));
			if (!Object.op_Implicit((Object)(object)val) || (Object)(object)val == (Object)(object)spawningDirector)
			{
				GoldLog.Spawn((scale == 1.0) ? GetDirector(directorSpawnRequest) : val, scale, scaled: false);
				return orig.Invoke(self, directorSpawnRequest);
			}
			CombatDirector val2 = spawningDirector;
			float goldRewardCoefficient = val.goldRewardCoefficient;
			spawningDirector = val;
			val.goldRewardCoefficient = (float)((double)goldRewardCoefficient / scale);
			GoldLog.Spawn(val, scale, scaled: true);
			try
			{
				return orig.Invoke(self, directorSpawnRequest);
			}
			finally
			{
				val.goldRewardCoefficient = goldRewardCoefficient;
				spawningDirector = val2;
			}
		}

		private static CombatDirector GetDirector(DirectorSpawnRequest request)
		{
			object obj = request.onSpawnedServer?.Target;
			CombatDirector val = (CombatDirector)((obj is CombatDirector) ? obj : null);
			if (val != null)
			{
				return val;
			}
			if (obj == null)
			{
				return null;
			}
			Type type = obj.GetType();
			if (!directorFields.TryGetValue(type, out var value))
			{
				value = Array.Find(type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), (FieldInfo f) => f.FieldType == typeof(CombatDirector));
				directorFields[type] = value;
			}
			object? obj2 = value?.GetValue(obj);
			return (CombatDirector)((obj2 is CombatDirector) ? obj2 : null);
		}

		private static void Spawn(orig_Spawn orig, ScriptedCombatEncounter self, ref SpawnInfo spawnInfo)
		{
			double scale = GoldScale.Scale;
			if (scale == 1.0 || (Object)(object)self == (Object)(object)spawningEncounter)
			{
				orig.Invoke(self, ref spawnInfo);
				return;
			}
			ScriptedCombatEncounter val = spawningEncounter;
			float goldRewardCoefficient = self.goldRewardCoefficient;
			spawningEncounter = self;
			self.goldRewardCoefficient = (float)((double)goldRewardCoefficient / scale);
			try
			{
				orig.Invoke(self, ref spawnInfo);
			}
			finally
			{
				self.goldRewardCoefficient = goldRewardCoefficient;
				spawningEncounter = val;
			}
		}

		private static void UpdateMonsterStatsBasedOnEliteEquipment(orig_UpdateMonsterStatsBasedOnEliteEquipment orig, EliteMonsterUpgradeData monsterUpgradeData)
		{
			//IL_0002: 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)
			monsterUpgradeData.goldRewardCoefficient = (float)((double)monsterUpgradeData.goldRewardCoefficient / GoldScale.Scale);
			orig.Invoke(monsterUpgradeData);
		}
	}
	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);
		}
	}
	internal static class PriceHooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_GetDifficultyScaledCost_int_float <0>__GetDifficultyScaledCost;

			public static hook_Start <1>__Start;

			public static hook_OnTriggerEnter <2>__OnTriggerEnter;
		}

		private const int UNIT_COST = 1;

		private static bool notGold;

		public static long LastUnitPrice { get; private set; } = -1L;

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//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_005b: Expected O, but got Unknown
			object obj = <>O.<0>__GetDifficultyScaledCost;
			if (obj == null)
			{
				hook_GetDifficultyScaledCost_int_float val = GetDifficultyScaledCost;
				<>O.<0>__GetDifficultyScaledCost = val;
				obj = (object)val;
			}
			Run.GetDifficultyScaledCost_int_float += (hook_GetDifficultyScaledCost_int_float)obj;
			object obj2 = <>O.<1>__Start;
			if (obj2 == null)
			{
				hook_Start val2 = Start;
				<>O.<1>__Start = val2;
				obj2 = (object)val2;
			}
			PocketSpawnerVolume.Start += (hook_Start)obj2;
			object obj3 = <>O.<2>__OnTriggerEnter;
			if (obj3 == null)
			{
				hook_OnTriggerEnter val3 = OnTriggerEnter;
				<>O.<2>__OnTriggerEnter = val3;
				obj3 = (object)val3;
			}
			PocketSpawnerVolume.OnTriggerEnter += (hook_OnTriggerEnter)obj3;
		}

		private static int GetDifficultyScaledCost(orig_GetDifficultyScaledCost_int_float orig, Run self, int baseCost, float difficultyCoefficient)
		{
			double num = (notGold ? 1.0 : GoldScale.Scale);
			if (num == 1.0 && !UncapGold.uncapGold.Value)
			{
				return orig.Invoke(self, baseCost, difficultyCoefficient);
			}
			double num2 = (double)baseCost * Math.Pow(difficultyCoefficient, 1.25);
			if (num2 / num >= 2147483647.0)
			{
				return int.MaxValue;
			}
			if (num == 1.0)
			{
				return orig.Invoke(self, baseCost, difficultyCoefficient);
			}
			int num3 = GoldScale.ToScaledPrice(num2);
			if (baseCost == 1)
			{
				LastUnitPrice = num3;
			}
			return num3;
		}

		private static void Start(orig_Start orig, PocketSpawnerVolume self)
		{
			notGold = true;
			try
			{
				orig.Invoke(self);
			}
			finally
			{
				notGold = false;
			}
		}

		private static void OnTriggerEnter(orig_OnTriggerEnter orig, PocketSpawnerVolume self, Collider other)
		{
			notGold = true;
			try
			{
				orig.Invoke(self, other);
			}
			finally
			{
				notGold = false;
			}
		}
	}
	internal static class ProperSaveCompat
	{
		public const string GUID = "com.KingEnderBrine.ProperSave";

		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.ProperSave");

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void Init()
		{
			SaveFile.OnGatherSaveData += GatherSaveData;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static bool TryLoad(out int exponent)
		{
			exponent = 0;
			if (!Loading.IsLoading || Loading.CurrentSave == null)
			{
				return false;
			}
			try
			{
				ProperSaveModel properSaveModel = Loading.CurrentSave.TryGetModdedData<ProperSaveModel>("UncapGold.DATA");
				if (properSaveModel != null)
				{
					exponent = properSaveModel.Exponent;
					Log.Info("Loaded the scale of the gold from the save file");
					return true;
				}
			}
			catch (Exception arg)
			{
				Log.Error($"Couldn't read the scale of the gold from the save file: {arg}");
			}
			return false;
		}

		private static void GatherSaveData(Dictionary<string, object> dictionary)
		{
			if (NetworkServer.active)
			{
				dictionary["UncapGold.DATA"] = new ProperSaveModel
				{
					Exponent = GoldScale.Exponent
				};
			}
		}
	}
	internal class ProperSaveModel
	{
		public const string SAVE_KEY = "UncapGold.DATA";

		public int Exponent { get; set; }
	}
	internal static class RiskOfOptionsCompat
	{
		public const string GUID = "com.rune580.riskofoptions";

		private const string ICON_FILE = "icon.png";

		public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void Init(string pluginLocation)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0042: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00ae: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Keeps gold and prices working once they get bigger than the game can count. Only the host's setting for it counts, how the numbers are shown is up to you.");
			Sprite val = LoadIcon(pluginLocation);
			if (Object.op_Implicit((Object)(object)val))
			{
				ModSettingsManager.SetModIcon(val);
			}
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(UncapGold.uncapGold));
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)UncapGold.numberStyle));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(UncapGold.digits, new IntSliderConfig
			{
				min = 3,
				max = 10
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(UncapGold.debugKeys));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(UncapGold.giveGoldKey));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(UncapGold.logGold));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(UncapGold.debugChestsPerPress, new IntSliderConfig
			{
				min = 1,
				max = 1000
			}));
		}

		private static Sprite LoadIcon(string pluginLocation)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0067: 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)
			string directoryName = Path.GetDirectoryName(pluginLocation);
			string path = Path.Combine(directoryName, "icon.png");
			if (!File.Exists(path))
			{
				path = Path.Combine(Path.GetDirectoryName(directoryName), "icon.png");
			}
			if (!File.Exists(path))
			{
				return null;
			}
			Texture2D val = new Texture2D(2, 2);
			if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
			{
				return null;
			}
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
	[BepInPlugin("360gaggi.UncapGold", "UncapGold", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class UncapGold : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "360gaggi.UncapGold";

		public const string PLUGIN_AUTHOR = "360gaggi";

		public const string PLUGIN_NAME = "UncapGold";

		public const string PLUGIN_VERSION = "1.0.0";

		public const int MIN_DIGITS = 3;

		public const int MAX_DIGITS = 10;

		public const int MAX_DEBUG_CHESTS = 1000;

		public static ConfigEntry<bool> uncapGold;

		public static ConfigEntry<NumberStyle> numberStyle;

		public static ConfigEntry<int> digits;

		public static ConfigEntry<bool> debugKeys;

		public static ConfigEntry<KeyboardShortcut> giveGoldKey;

		public static ConfigEntry<bool> logGold;

		public static ConfigEntry<int> debugChestsPerPress;

		public void Awake()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			uncapGold = ((BaseUnityPlugin)this).Config.Bind<bool>("Gold", "Uncap gold", true, "Keeps gold and prices working once they get bigger than the game can count (prices from around 2 billion on, gold from around 4 billion on). Turn it off to get vanilla back without removing the mod, that takes effect with the next stage. Only the host's setting counts");
			numberStyle = ((BaseUnityPlugin)this).Config.Bind<NumberStyle>("Gold", "Number style", NumberStyle.Short, "How gold and prices of 1000 or more get shown. Short: 12.5K, Scientific: 1.25e4, Full: 12,500");
			digits = ((BaseUnityPlugin)this).Config.Bind<int>("Gold", "Digits", 3, new ConfigDescription("How many digits a shortened number shows at most. With 3: 1.25K, 12.5K, 125K, 1.25M. Full always shows every digit", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 10), Array.Empty<object>()));
			debugKeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Debug keys", false, "Turns on the key below, for trying things out. It only works for the host");
			giveGoldKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Debug", "Give gold", new KeyboardShortcut((KeyCode)286, Array.Empty<KeyCode>()), "Gives you gold");
			debugChestsPerPress = ((BaseUnityPlugin)this).Config.Bind<int>("Debug", "Chests per press", 10, new ConfigDescription("How much gold the give gold key gives, in small chests it pays for", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 1000), Array.Empty<object>()));
			logGold = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Log gold", false, "Writes every spawn, kill and payout of gold into the log, to find out where gold goes missing. Only on the host");
			NetworkModCompatibilityHelper.networkModList = NetworkModCompatibilityHelper.networkModList.Append("360gaggi.UncapGold;1.0.0");
			GoldScale.Init();
			GoldBank.Init();
			PriceHooks.Init();
			IncomeHooks.Init();
			KillRewardHooks.Init();
			GoldLog.Init();
			ConversionHooks.Init();
			GoldDisplay.Init();
			if (ProperSaveCompat.Enabled)
			{
				ProperSaveCompat.Init();
			}
			if (RiskOfOptionsCompat.Enabled)
			{
				RiskOfOptionsCompat.Init(((BaseUnityPlugin)this).Info.Location);
			}
		}

		public void Update()
		{
			DebugKeys.Update();
		}
	}
}