Decompiled source of LuckyDice v1.3.2

plugins\LuckyDice\LuckyDice.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Assets.Scripts;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using DRS.UI;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LuckyDice")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.2.0")]
[assembly: AssemblyInformationalVersion("1.3.2")]
[assembly: AssemblyProduct("LuckyDice")]
[assembly: AssemblyTitle("LuckyDice")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 LuckyDice
{
	[HarmonyPatch]
	internal static class Announcer
	{
		private static string pending;

		private static readonly Dictionary<IntPtr, string> Overrides = new Dictionary<IntPtr, string>();

		private static UICoreForm form;

		private static bool warned;

		public static void Show(string text)
		{
			try
			{
				if ((Object)(object)form == (Object)null || ((Il2CppObjectBase)form).WasCollected || !Object.op_Implicit((Object)(object)form))
				{
					form = Object.FindObjectOfType<UICoreForm>();
				}
				if ((Object)(object)form == (Object)null)
				{
					Warn("game HUD not found");
					return;
				}
				LocalizedString locSwarmIncAnnouncement = form.locSwarmIncAnnouncement;
				if (locSwarmIncAnnouncement == null)
				{
					Warn("no announcement text to borrow");
					return;
				}
				pending = text;
				try
				{
					form.DoAnnouncement(locSwarmIncAnnouncement, (Action)null);
				}
				finally
				{
					pending = null;
				}
			}
			catch (Exception ex)
			{
				Warn(ex.Message);
			}
		}

		private static void Warn(string why)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if (!warned)
			{
				warned = true;
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Dice announcement unavailable (");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(why);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
				}
				logger.LogWarning(val);
			}
		}

		private static void Apply(UICoreAnnouncement a)
		{
			if ((Object)(object)a == (Object)null || !Overrides.TryGetValue(((Il2CppObjectBase)a).Pointer, out var value))
			{
				return;
			}
			try
			{
				if ((Object)(object)a.text != (Object)null)
				{
					((TMP_Text)a.text).text = value;
				}
			}
			catch
			{
			}
		}

		[HarmonyPatch(typeof(UICoreAnnouncement), "Show")]
		[HarmonyPrefix]
		private static void ShowPrefix(UICoreAnnouncement __instance)
		{
			if (pending != null)
			{
				Overrides[((Il2CppObjectBase)__instance).Pointer] = pending;
			}
			else
			{
				Overrides.Remove(((Il2CppObjectBase)__instance).Pointer);
			}
		}

		[HarmonyPatch(typeof(UICoreAnnouncement), "Show")]
		[HarmonyPostfix]
		private static void ShowPostfix(UICoreAnnouncement __instance)
		{
			Apply(__instance);
		}

		[HarmonyPatch(typeof(UICoreAnnouncement), "UpdateText")]
		[HarmonyPostfix]
		private static void UpdateTextPostfix(UICoreAnnouncement __instance)
		{
			Apply(__instance);
		}

		[HarmonyPatch(typeof(UICoreAnnouncement), "AnimateIn")]
		[HarmonyPostfix]
		private static void AnimateInPostfix(UICoreAnnouncement __instance)
		{
			Apply(__instance);
		}

		[HarmonyPatch(typeof(UICoreAnnouncement), "OnDisappearComplete")]
		[HarmonyPostfix]
		private static void Done(UICoreAnnouncement __instance)
		{
			Overrides.Remove(((Il2CppObjectBase)__instance).Pointer);
		}
	}
	internal static class BoscoBackup
	{
		internal static ConfigEntry<bool> CopyOverclocks;

		internal static ConfigEntry<bool> SkipTurretsAndDrones;

		private static readonly List<WeaponHandler> Copies = new List<WeaponHandler>();

		public static bool Active => Copies.Count > 0;

		public static void BindConfig(ConfigFile cfg)
		{
			CopyOverclocks = cfg.Bind<bool>("Dice Effects - Bosco Backup", "CopyOverclocks", true, "Give Bosco's copies the same overclocks as your weapons. Turn off if an overclock's side effect doubles up badly.");
			SkipTurretsAndDrones = cfg.Bind<bool>("Dice Effects - Bosco Backup", "SkipTurretsAndDrones", false, "Don't copy weapons that place turrets or drones (they may behave oddly coming from Bosco).");
		}

		public static bool Available()
		{
			try
			{
				Player player = Game.GetPlayer();
				Bosco val = ((player != null) ? player.Bosco : null);
				return (Object)(object)val != (Object)null && Game.Alive((Object)(object)val) && ((Component)val).gameObject.activeInHierarchy && player.Weapons != null && player.Weapons.Count > 0;
			}
			catch
			{
				return false;
			}
		}

		public static void Give()
		{
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Expected O, but got Unknown
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			if (Active)
			{
				return;
			}
			Player player = Game.GetPlayer();
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			List<WeaponHandler> weapons = player.Weapons;
			int num = 0;
			int num2 = 0;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val3;
			for (int i = 0; i < weapons.Count; i++)
			{
				WeaponHandler val = weapons[i];
				WeaponSkillData val2 = ((val != null) ? val.Data : null);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				if (SkipTurretsAndDrones.Value && IsSpawner(val, val2))
				{
					num2++;
					ManualLogSource logger = Plugin.Logger;
					val3 = new BepInExInfoLogInterpolatedStringHandler(47, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Bosco Backup: skipped ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((ASkillData)val2).Title);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (places turrets/drones).");
					}
					logger.LogInfo(val3);
					continue;
				}
				try
				{
					WeaponHandler val4 = player.EquipBoscoWeapon(val2);
					if ((Object)(object)val4 == (Object)null)
					{
						continue;
					}
					Copies.Add(val4);
					num++;
					int num3 = val.WeaponLevel - val4.WeaponLevel;
					if (num3 > 0)
					{
						val4.AddWeaponLevel(num3, false);
					}
					if (CopyOverclocks.Value)
					{
						List<AOverclockData> allOverclocks = val.AllOverclocks;
						int num4 = 0;
						while (allOverclocks != null && num4 < allOverclocks.Count)
						{
							AOverclockData val5 = allOverclocks[num4];
							if ((Object)(object)val5 != (Object)null && !val4.HasOverlock(val5))
							{
								val4.AddOverclock(val5);
							}
							num4++;
						}
					}
					ManualLogSource logger2 = Plugin.Logger;
					val3 = new BepInExInfoLogInterpolatedStringHandler(31, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Bosco Backup: copied ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((ASkillData)val2).Title);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" (level ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(val4.WeaponLevel);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(").");
					}
					logger2.LogInfo(val3);
				}
				catch (Exception ex)
				{
					ManualLogSource logger3 = Plugin.Logger;
					BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(30, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Bosco Backup: couldn't copy ");
						((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(((ASkillData)val2).Title);
						((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Exception>(ex);
					}
					logger3.LogError(val6);
				}
			}
			ManualLogSource logger4 = Plugin.Logger;
			val3 = new BepInExInfoLogInterpolatedStringHandler(60, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Bosco Backup: ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" weapons given, ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num2);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" turret/drone weapons skipped.");
			}
			logger4.LogInfo(val3);
		}

		public static void Remove()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			if (Copies.Count == 0)
			{
				return;
			}
			Player player = Game.GetPlayer();
			int num = 0;
			bool flag = default(bool);
			foreach (WeaponHandler copy in Copies)
			{
				try
				{
					if (!((Object)(object)copy == (Object)null) && !((Il2CppObjectBase)copy).WasCollected)
					{
						if (player != null)
						{
							player.BoscoWeapons?.Remove(copy);
						}
						if (Object.op_Implicit((Object)(object)copy))
						{
							Object.Destroy((Object)(object)copy);
							num++;
						}
					}
				}
				catch (Exception ex)
				{
					ManualLogSource logger = Plugin.Logger;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(40, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Bosco Backup: couldn't remove a weapon: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					logger.LogError(val);
				}
			}
			Copies.Clear();
			ManualLogSource logger2 = Plugin.Logger;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(48, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Bosco Backup ended: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" weapons removed from Bosco.");
			}
			logger2.LogInfo(val2);
		}

		public static void Forget()
		{
			Copies.Clear();
		}

		private static bool IsSpawner(WeaponHandler h, WeaponSkillData d)
		{
			if (!((Object)(object)((Il2CppObjectBase)h).TryCast<SpawnWeaponHandler>() != (Object)null) && !((Object)(object)((Il2CppObjectBase)h).TryCast<OrbitingDroneWeaponHandler>() != (Object)null) && !((Object)(object)((Il2CppObjectBase)d).TryCast<SpawnWeaponSkillData>() != (Object)null))
			{
				return (Object)(object)((Il2CppObjectBase)d).TryCast<DefenseDroneWeaponSkillData>() != (Object)null;
			}
			return true;
		}
	}
	internal static class ConfigReload
	{
		private static ConfigFile config;

		private static FileSystemWatcher watcher;

		private static volatile bool pending;

		private static DateTime dueAt;

		public static void Start(ConfigFile cfg)
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			config = cfg;
			try
			{
				watcher = new FileSystemWatcher(Path.GetDirectoryName(cfg.ConfigFilePath), Path.GetFileName(cfg.ConfigFilePath))
				{
					NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite)
				};
				watcher.Changed += delegate
				{
					Queue();
				};
				watcher.Created += delegate
				{
					Queue();
				};
				watcher.Renamed += delegate
				{
					Queue();
				};
				watcher.EnableRaisingEvents = true;
				Plugin.Logger.LogInfo((object)"Watching config file for live changes.");
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Live config reload unavailable: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger.LogWarning(val);
			}
		}

		private static void Queue()
		{
			dueAt = DateTime.UtcNow.AddMilliseconds(300.0);
			pending = true;
		}

		public static void Tick()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			if (!pending || DateTime.UtcNow < dueAt)
			{
				return;
			}
			pending = false;
			bool flag = default(bool);
			try
			{
				config.Reload();
				DiceModel.ResetMaterial();
				ManualLogSource logger = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(32, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Config reloaded. Dice chance = ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(Dice.DropChancePercent.Value);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("%");
				}
				logger.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = Plugin.Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Config reload failed (file mid-save?): ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger2.LogError(val2);
				pending = true;
				dueAt = DateTime.UtcNow.AddSeconds(1.0);
			}
		}
	}
	public enum DiceEffect
	{
		Nuke,
		MoveSpeed,
		MiningSpeed,
		FireRate,
		OneHitKills,
		SlowMo,
		Invisible,
		Star,
		Nitra,
		Gold,
		BiomeMineral,
		BoscoBackup,
		InfiniteAmmo,
		Magnet
	}
	internal static class Dice
	{
		private class DiceDrop
		{
			public GameObject Go;

			public float Age;

			public float BaseY;

			public bool Flying;
		}

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> DropChancePercent;

		internal static ConfigEntry<float> MinSecondsBetweenDrops;

		internal static ConfigEntry<int> MaxOnMap;

		internal static ConfigEntry<float> LifetimeSeconds;

		internal static ConfigEntry<float> DiceSize;

		internal static ConfigEntry<float> Glow;

		internal static ConfigEntry<bool> DropsDuringExtraction;

		internal static readonly Dictionary<DiceEffect, ConfigEntry<int>> Weight = new Dictionary<DiceEffect, ConfigEntry<int>>();

		internal static readonly Dictionary<DiceEffect, ConfigEntry<float>> Duration = new Dictionary<DiceEffect, ConfigEntry<float>>();

		internal static ConfigEntry<float> MoveSpeedAmount;

		internal static ConfigEntry<float> MiningSpeedAmount;

		internal static ConfigEntry<float> FireRateAmount;

		internal static ConfigEntry<float> SlowSpeedPercent;

		internal static ConfigEntry<int> NitraAmount;

		internal static ConfigEntry<int> GoldAmount;

		internal static bool InternalDamage;

		private static readonly Random Rng = new Random();

		private static readonly Dictionary<DiceEffect, float> Active = new Dictionary<DiceEffect, float>();

		private static readonly List<DiceDrop> Drops = new List<DiceDrop>();

		private static float cooldown;

		private static float fearTick;

		private static float statLogTimer = -1f;

		private static string statLogName;

		private static Func<Player, double> statLogRead;

		private static double statBefore;

		internal static int BlockedHits;

		internal static int StarKills;

		private static int timerErrors;

		private static readonly ECurrency[] Minerals;

		private static int slowMode;

		public static void BindConfig(ConfigFile cfg)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Expected O, but got Unknown
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Expected O, but got Unknown
			Enabled = cfg.Bind<bool>("Dice", "Enabled", true, "Enemies can drop a golden dice that triggers a random effect when picked up.");
			DropChancePercent = cfg.Bind<float>("Dice", "DropChancePercent", 0.4f, new ConfigDescription("Chance (%) for each enemy kill to drop a dice (subject to the cooldown below).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
			MinSecondsBetweenDrops = cfg.Bind<float>("Dice", "MinSecondsBetweenDrops", 25f, "Cooldown after a dice drops before another can.");
			MaxOnMap = cfg.Bind<int>("Dice", "MaxOnMap", 1, "Most dice that can be lying on the ground at once.");
			LifetimeSeconds = cfg.Bind<float>("Dice", "LifetimeSeconds", 60f, "A dice disappears if not picked up within this time (blinks for the last 5 s).");
			DropsDuringExtraction = cfg.Bind<bool>("Dice", "DropsDuringExtraction", false, "Allow dice to drop once the extraction countdown has started.");
			DiceSize = cfg.Bind<float>("Dice", "Size", 0f, "Dice size in world units. 0 = automatic (based on the dwarf's size).");
			Glow = cfg.Bind<float>("Dice", "Glow", 0.35f, new ConfigDescription("How much the dice glows so it stands out (0 = none).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			Effect(DiceEffect.Nuke, 1, 0f, "Kills every enemy on the map.");
			Effect(DiceEffect.MoveSpeed, 4, 20f, "Move speed boost.");
			Effect(DiceEffect.MiningSpeed, 4, 20f, "Mining speed boost.");
			Effect(DiceEffect.FireRate, 4, 15f, "Fire rate boost with infinite ammo.");
			Effect(DiceEffect.OneHitKills, 2, 8f, "Every hit on an enemy kills it.");
			Effect(DiceEffect.SlowMo, 4, 20f, "All enemies move very slowly.");
			Effect(DiceEffect.Invisible, 2, 15f, "Bugs stop chasing and can't attack you; you take no damage.");
			Effect(DiceEffect.Star, 3, 15f, "Mario star: you take no damage and any bug that hits you dies.");
			Effect(DiceEffect.Nitra, 2, 0f, "Instant nitra.");
			Effect(DiceEffect.Gold, 2, 0f, "Instant gold.");
			Effect(DiceEffect.InfiniteAmmo, 3, 10f, "Infinite ammo: no reloading.");
			Effect(DiceEffect.Magnet, 3, 0f, "Spawns a magnet (pulls in all XP). Never rolled while Magnet Tweaks is set to AlwaysActive.");
			Effect(DiceEffect.BoscoBackup, 3, 20f, "Bosco gets a copy of every weapon you're holding.");
			Effect(DiceEffect.BiomeMineral, 1, 0f, "2-8 of one of the current biome's rich minerals (rare by design so upgrades don't get out of hand).");
			BoscoBackup.BindConfig(cfg);
			MoveSpeedAmount = cfg.Bind<float>("Dice Effects - Amounts", "MoveSpeedAmount", 1f, "MoveSpeed bonus. 1.0 = +100% (double).");
			MiningSpeedAmount = cfg.Bind<float>("Dice Effects - Amounts", "MiningSpeedAmount", 1f, "MiningSpeed bonus. 1.0 = +100% (double).");
			FireRateAmount = cfg.Bind<float>("Dice Effects - Amounts", "FireRateAmount", 1f, "FireRate bonus. 1.0 = +100% (double).");
			SlowSpeedPercent = cfg.Bind<float>("Dice Effects - Amounts", "SlowSpeedPercent", 50f, new ConfigDescription("During SlowMo enemies move at this % of their normal speed (50 = half speed).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>()));
			NitraAmount = cfg.Bind<int>("Dice Effects - Amounts", "NitraAmount", 25, "Nitra given by the Nitra effect.");
			GoldAmount = cfg.Bind<int>("Dice Effects - Amounts", "GoldAmount", 25, "Gold given by the Gold effect.");
			void Effect(DiceEffect e, int weight, float dur, string desc)
			{
				Weight[e] = cfg.Bind<int>("Dice Effects - Weights", e.ToString(), weight, desc + " Relative chance; 0 disables it.");
				if (dur > 0f)
				{
					Duration[e] = cfg.Bind<float>("Dice Effects - Durations", e.ToString(), dur, $"Seconds the {e} effect lasts.");
				}
			}
		}

		public static bool IsActive(DiceEffect e)
		{
			if (Active.TryGetValue(e, out var value))
			{
				return value > 0f;
			}
			return false;
		}

		public static void Init()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			try
			{
				ClassInjector.RegisterTypeInIl2Cpp<DiceHud>();
				GameObject val = new GameObject("LuckyDice.Hud");
				Object.DontDestroyOnLoad((Object)val);
				((Object)val).hideFlags = (HideFlags)61;
				val.AddComponent<DiceHud>();
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("HUD setup failed (effects still work): ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				logger.LogError(val2);
			}
		}

		public static void ClearStage()
		{
			foreach (DiceDrop drop in Drops)
			{
				if ((Object)(object)drop.Go != (Object)null && !((Il2CppObjectBase)drop.Go).WasCollected && Object.op_Implicit((Object)(object)drop.Go))
				{
					Object.Destroy((Object)(object)drop.Go);
				}
			}
			Drops.Clear();
			Active.Clear();
			BoscoBackup.Forget();
			EffectTimers.Clear();
			cooldown = 0f;
			statLogTimer = -1f;
		}

		public static void OnEnemyKilled(Enemy enemy)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (Enabled.Value && !InternalDamage && Game.OutOfPod && (!Game.ExtractionStarted || DropsDuringExtraction.Value) && !(cooldown > 0f) && Drops.Count < MaxOnMap.Value && !(Rng.NextDouble() * 100.0 >= (double)DropChancePercent.Value))
			{
				Spawn(((Component)enemy).transform.position);
			}
		}

		public static void Spawn(Vector3 pos)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_0133: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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)
			GameObject val = DiceModel.Create();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			float num = DiceSize.Value;
			if (num <= 0f)
			{
				num = 1f;
				try
				{
					Player player = Game.GetPlayer();
					CapsuleCollider val2 = ((player != null) ? player.Collider : null);
					if ((Object)(object)val2 != (Object)null)
					{
						Bounds bounds = ((Collider)val2).bounds;
						num = Mathf.Clamp(((Bounds)(ref bounds)).size.y * 0.55f, 0.3f, 5f);
					}
				}
				catch
				{
				}
			}
			val.transform.localScale = Vector3.one * num;
			Vector3 val3 = pos + Vector3.up * num * 0.9f;
			val.transform.position = val3;
			val.transform.rotation = Quaternion.Euler((float)Rng.Next(360), (float)Rng.Next(360), (float)Rng.Next(360));
			Drops.Add(new DiceDrop
			{
				Go = val,
				BaseY = val3.y
			});
			cooldown = MinSecondsBetweenDrops.Value;
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(25, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Dice dropped at ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Vector3>(pos);
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" (size ");
				((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<float>(num, "0.00");
				((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(").");
			}
			logger.LogInfo(val4);
		}

		public static void Tick()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			float deltaTime = Time.deltaTime;
			if (deltaTime <= 0f)
			{
				return;
			}
			if (cooldown > 0f)
			{
				cooldown -= deltaTime;
			}
			TickDrops(deltaTime);
			TickEffects(deltaTime);
			bool flag = default(bool);
			try
			{
				EffectTimers.Tick(Active);
			}
			catch (Exception ex)
			{
				if (timerErrors++ < 3)
				{
					ManualLogSource logger = Plugin.Logger;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(15, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Effect timers: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					logger.LogError(val);
				}
			}
			if (!(statLogTimer > 0f) || !((statLogTimer -= deltaTime) <= 0f))
			{
				return;
			}
			Player player = Game.GetPlayer();
			if (!((Object)(object)player != (Object)null) || statLogRead == null)
			{
				return;
			}
			try
			{
				ManualLogSource logger2 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(12, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(statLogName);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" check: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<double>(statBefore, "0.###");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" -> ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<double>(statLogRead(player), "0.###");
				}
				logger2.LogInfo(val2);
			}
			catch
			{
			}
		}

		private static void TickDrops(float dt)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_00e2: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: 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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			if (Drops.Count == 0)
			{
				return;
			}
			Player player = Game.GetPlayer();
			Vector3 val = (((Object)(object)player != (Object)null) ? ((Component)player).transform.position : Vector3.zero);
			float num = 2.5f;
			try
			{
				if ((Object)(object)player != (Object)null)
				{
					num = Mathf.Max(2.5f, (float)player.pickupRadius.Value);
				}
			}
			catch
			{
			}
			Vector3 val2 = default(Vector3);
			Vector3 val3 = default(Vector3);
			for (int num2 = Drops.Count - 1; num2 >= 0; num2--)
			{
				DiceDrop diceDrop = Drops[num2];
				if ((Object)(object)diceDrop.Go == (Object)null || ((Il2CppObjectBase)diceDrop.Go).WasCollected || !Object.op_Implicit((Object)(object)diceDrop.Go))
				{
					Drops.RemoveAt(num2);
				}
				else
				{
					diceDrop.Age += dt;
					Transform transform = diceDrop.Go.transform;
					transform.Rotate(new Vector3(35f, 70f, 20f) * dt, (Space)0);
					if (diceDrop.Age >= LifetimeSeconds.Value)
					{
						Object.Destroy((Object)(object)diceDrop.Go);
						Drops.RemoveAt(num2);
					}
					else
					{
						float num3 = LifetimeSeconds.Value - diceDrop.Age;
						diceDrop.Go.SetActive(num3 > 5f || Mathf.Repeat(num3, 0.4f) > 0.15f);
						if (!((Object)(object)player == (Object)null) && player.IsAlive)
						{
							Vector3 position = transform.position;
							((Vector3)(ref val2))..ctor(val.x - position.x, 0f, val.z - position.z);
							float magnitude = ((Vector3)(ref val2)).magnitude;
							if (!diceDrop.Flying && magnitude <= num)
							{
								diceDrop.Flying = true;
							}
							if (diceDrop.Flying)
							{
								float num4 = Mathf.Max(12f, magnitude * 6f);
								((Vector3)(ref val3))..ctor(val.x, diceDrop.BaseY, val.z);
								transform.position = Vector3.MoveTowards(position, val3, num4 * dt);
								if (magnitude < 0.8f)
								{
									Object.Destroy((Object)(object)diceDrop.Go);
									Drops.RemoveAt(num2);
									Roll();
								}
							}
							else
							{
								transform.position = new Vector3(position.x, diceDrop.BaseY + Mathf.Sin(diceDrop.Age * 3f) * 0.15f * transform.localScale.y, position.z);
							}
						}
					}
				}
			}
		}

		private static void TickEffects(float dt)
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			if (Active.Count == 0)
			{
				return;
			}
			bool flag = default(bool);
			foreach (DiceEffect item in new List<DiceEffect>(Active.Keys))
			{
				Active[item] -= dt;
				if (Active[item] <= 0f)
				{
					Active.Remove(item);
					if (item == DiceEffect.BoscoBackup)
					{
						BoscoBackup.Remove();
					}
					if ((item == DiceEffect.FireRate || item == DiceEffect.InfiniteAmmo) && !IsActive(DiceEffect.FireRate) && !IsActive(DiceEffect.InfiniteAmmo))
					{
						InfiniteAmmo.Ended();
					}
					string text = item switch
					{
						DiceEffect.Star => $" (blocked {BlockedHits} hits, killed {StarKills} attackers)", 
						DiceEffect.Invisible => $" (blocked {BlockedHits} hits)", 
						_ => "", 
					};
					ManualLogSource logger = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(19, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Dice effect ended: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DiceEffect>(item);
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					}
					logger.LogInfo(val);
				}
			}
			if (IsActive(DiceEffect.FireRate) || IsActive(DiceEffect.InfiniteAmmo))
			{
				InfiniteAmmo.Tick();
			}
			if (!IsActive(DiceEffect.Invisible) || !((fearTick -= dt) <= 0f))
			{
				return;
			}
			fearTick = 0.5f;
			string from;
			foreach (Enemy item2 in Game.LiveEnemies(out from))
			{
				try
				{
					item2.ApplyFear(1f);
				}
				catch
				{
				}
			}
		}

		private static void Roll()
		{
			bool skipNitra = Game.HasPickledNitra();
			bool noBosco = !BoscoBackup.Available();
			bool noMagnet = MagnetLink.MagnetAlwaysOn();
			int num = 0;
			foreach (KeyValuePair<DiceEffect, ConfigEntry<int>> item in Weight)
			{
				num += W(item.Key, item.Value);
			}
			if (num <= 0)
			{
				Plugin.Logger.LogWarning((object)"Dice picked up but every effect weight is 0.");
				return;
			}
			int num2 = Rng.Next(num);
			foreach (KeyValuePair<DiceEffect, ConfigEntry<int>> item2 in Weight)
			{
				num2 -= W(item2.Key, item2.Value);
				if (num2 < 0)
				{
					Apply(item2.Key);
					break;
				}
			}
			int W(DiceEffect e, ConfigEntry<int> c)
			{
				if ((!skipNitra || e != DiceEffect.Nitra) && (!noBosco || e != DiceEffect.BoscoBackup) && (!noMagnet || e != DiceEffect.Magnet))
				{
					return Math.Max(0, c.Value);
				}
				return 0;
			}
		}

		public static void Apply(DiceEffect e)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(13, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Dice rolled: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<DiceEffect>(e);
			}
			logger.LogInfo(val);
			string text = null;
			try
			{
				switch (e)
				{
				case DiceEffect.Nuke:
					Game.KillAllEnemies("dice nuke");
					break;
				case DiceEffect.MoveSpeed:
					ApplyBuff("MoveSpeed", (EStatModID)2, (EStatType)3, MoveSpeedAmount.Value, Duration[e].Value, (Player p) => p.moveSpeed.Value);
					break;
				case DiceEffect.MiningSpeed:
					ApplyBuff("MiningSpeed", (EStatModID)3, (EStatType)12, MiningSpeedAmount.Value, Duration[e].Value, (Player p) => p.miningSpeed.Value);
					break;
				case DiceEffect.FireRate:
					ApplyBuff("FireRate", (EStatModID)4, (EStatType)4, FireRateAmount.Value, Duration[e].Value, null);
					break;
				case DiceEffect.BoscoBackup:
					BoscoBackup.Give();
					break;
				case DiceEffect.Magnet:
					MagnetLink.SpawnMagnet();
					break;
				case DiceEffect.Nitra:
					GiveCurrency((ECurrency)2, NitraAmount.Value);
					break;
				case DiceEffect.Gold:
					GiveCurrency((ECurrency)0, GoldAmount.Value);
					break;
				case DiceEffect.BiomeMineral:
				{
					ECurrency[] array = RichMinerals();
					ECurrency val2 = array[Rng.Next(array.Length)];
					int num = Rng.Next(2, 9);
					GiveCurrency(val2, num);
					ManualLogSource logger2 = Plugin.Logger;
					val = new BepInExInfoLogInterpolatedStringHandler(32, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Biome mineral: +");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(MineralName(val2));
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (rich here: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(string.Join(", ", array));
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(").");
					}
					logger2.LogInfo(val);
					text = $"+{num} {MineralName(val2).ToUpperInvariant()}";
					break;
				}
				case DiceEffect.SlowMo:
				{
					ApplySlow(Game.LiveEnemies(out var _), Duration[e].Value, log: true);
					break;
				}
				case DiceEffect.Invisible:
				case DiceEffect.Star:
					fearTick = 0f;
					BlockedHits = 0;
					StarKills = 0;
					break;
				case DiceEffect.OneHitKills:
				case DiceEffect.InfiniteAmmo:
					break;
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger3 = Plugin.Logger;
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(21, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Dice effect ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<DiceEffect>(e);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" failed: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				logger3.LogError(val3);
			}
			if (Duration.TryGetValue(e, out var value))
			{
				Active[e] = Math.Max(Active.TryGetValue(e, out var value2) ? value2 : 0f, value.Value);
			}
			else
			{
				Announcer.Show(text ?? Label(e));
			}
		}

		private static void ApplyBuff(string name, EStatModID id, EStatType stat, float amount, float seconds, Func<Player, double> read)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			Player player = Game.GetPlayer();
			if (!((Object)(object)player == (Object)null))
			{
				statLogName = name;
				statLogRead = read;
				if (read != null)
				{
					statBefore = read(player);
					statLogTimer = 0.5f;
				}
				Il2CppReferenceArray<StatMod> val = new Il2CppReferenceArray<StatMod>(1L);
				((Il2CppArrayBase<StatMod>)(object)val)[0] = new StatMod(stat, (EModGroupType)4, amount);
				player.Stats.AddTimedMod(new TimedBuff
				{
					BuffID = id,
					Guid = Guid.NewGuid().ToString(),
					MaxStacks = 1,
					Duration = seconds,
					StatMods = val,
					TagStatMods = new Il2CppReferenceArray<TagStatMod>(0L)
				});
			}
		}

		private static ECurrency[] RichMinerals()
		{
			//IL_0005: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected I4, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			EBiomeType val = (EBiomeType)100000;
			try
			{
				val = Game.GetPlayer().runSettingsManager.BiomeData.BiomeType;
			}
			catch
			{
			}
			switch ((int)val)
			{
			case 0:
				return (ECurrency[])(object)new ECurrency[2]
				{
					(ECurrency)10,
					(ECurrency)13
				};
			case 3:
				return (ECurrency[])(object)new ECurrency[2]
				{
					(ECurrency)10,
					(ECurrency)12
				};
			case 5:
				return (ECurrency[])(object)new ECurrency[2]
				{
					(ECurrency)10,
					(ECurrency)13
				};
			case 1:
				return (ECurrency[])(object)new ECurrency[2]
				{
					(ECurrency)11,
					(ECurrency)14
				};
			case 4:
				return (ECurrency[])(object)new ECurrency[2]
				{
					(ECurrency)11,
					(ECurrency)15
				};
			case 2:
				return (ECurrency[])(object)new ECurrency[2]
				{
					(ECurrency)12,
					(ECurrency)15
				};
			default:
				try
				{
					Il2CppStructArray<ECurrency> primaryCraftingMaterials = Game.GetPlayer().runSettingsManager.BiomeData.PrimaryCraftingMaterials;
					if (primaryCraftingMaterials != null && ((Il2CppArrayBase<ECurrency>)(object)primaryCraftingMaterials).Length > 0)
					{
						List<ECurrency> list = new List<ECurrency>();
						for (int i = 0; i < ((Il2CppArrayBase<ECurrency>)(object)primaryCraftingMaterials).Length; i++)
						{
							list.Add(((Il2CppArrayBase<ECurrency>)(object)primaryCraftingMaterials)[i]);
						}
						return list.ToArray();
					}
				}
				catch
				{
				}
				return Minerals;
			}
		}

		private unsafe static string MineralName(ECurrency c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			if ((int)c == 12)
			{
				return "ENOR PEARL";
			}
			return ((object)(*(ECurrency*)(&c))/*cast due to .constrained prefix*/).ToString();
		}

		private static void GiveCurrency(ECurrency currency, int amount)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_006d: 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_00f9: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			if (amount <= 0)
			{
				return;
			}
			Player player = Game.GetPlayer();
			PickupSpawner spawner = Game.GetSpawner();
			bool flag = default(bool);
			if ((Object)(object)player != (Object)null && (Object)(object)spawner != (Object)null)
			{
				spawner.SpawnMaterial(currency, amount, ((Component)player).transform.position, 1f);
				ManualLogSource logger = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Spawned ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(amount);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ECurrency>(currency);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
				}
				logger.LogInfo(val);
				return;
			}
			Wallet val2 = ((player != null) ? player.wallet : null);
			if (val2 != null)
			{
				val2.Add(currency, amount, false);
				ManualLogSource logger2 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Added ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(amount);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ECurrency>(currency);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to wallet.");
				}
				logger2.LogInfo(val);
			}
			else
			{
				ManualLogSource logger3 = Plugin.Logger;
				BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(43, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Couldn't give ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<ECurrency>(currency);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": no spawner or wallet found.");
				}
				logger3.LogWarning(val3);
			}
		}

		public static void ApplySlow(List<Enemy> enemies, float seconds, bool log)
		{
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			float num = Mathf.Clamp(SlowSpeedPercent.Value, 1f, 100f) / 100f;
			int num2 = 0;
			bool flag = default(bool);
			foreach (Enemy enemy in enemies)
			{
				try
				{
					if (slowMode == 0)
					{
						double value = enemy.MoveSpeed.Value;
						AddSlow(enemy, seconds, num - 1f);
						double value2 = enemy.MoveSpeed.Value;
						double num3 = ((value > 0.0) ? (value2 / value) : 1.0);
						slowMode = ((!(num3 < (double)num * 0.5)) ? 1 : 2);
						ManualLogSource logger = Plugin.Logger;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 5, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SlowMo calibration: speed ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(value, "0.###");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(value2, "0.###");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (ratio ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(num3, "0.##");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", wanted ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "0.##");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") => ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((slowMode == 1) ? "additive" : "multiplier");
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" mode");
						}
						logger.LogInfo(val);
					}
					else
					{
						AddSlow(enemy, seconds, (slowMode == 1) ? (num - 1f) : num);
					}
					num2++;
				}
				catch (Exception ex)
				{
					if (num2 == 0)
					{
						ManualLogSource logger2 = Plugin.Logger;
						BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(13, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Slow failed: ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
						}
						logger2.LogError(val2);
					}
				}
			}
			if (log)
			{
				ManualLogSource logger3 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(37, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SlowMo applied to ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num2);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" enemies at ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num, "P0");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" speed.");
				}
				logger3.LogInfo(val);
			}
		}

		private static void AddSlow(Enemy en, float seconds, float value)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			en.Stats.AddTimedMod(new TimedEnemyStatBuff
			{
				Source = (ESource)2,
				Type = (EType)2,
				Duration = seconds,
				Value = value
			});
		}

		public static void OnEnemySpawned(Enemy enemy)
		{
			if (Active.TryGetValue(DiceEffect.SlowMo, out var value) && !(value <= 0f))
			{
				ApplySlow(new List<Enemy> { enemy }, value, log: false);
			}
		}

		public static string Label(DiceEffect e)
		{
			return e switch
			{
				DiceEffect.Nuke => "NUKE!", 
				DiceEffect.MoveSpeed => "SPEED BOOST", 
				DiceEffect.MiningSpeed => "MINING FRENZY", 
				DiceEffect.FireRate => "RAPID FIRE", 
				DiceEffect.InfiniteAmmo => "INFINITE AMMO", 
				DiceEffect.Magnet => "MAGNET!", 
				DiceEffect.Nitra => $"+{NitraAmount.Value} NITRA", 
				DiceEffect.Gold => $"+{GoldAmount.Value} GOLD", 
				DiceEffect.BiomeMineral => "BIOME MINERALS", 
				DiceEffect.BoscoBackup => "BOSCO BACKUP", 
				DiceEffect.OneHitKills => "ONE-HIT KILLS", 
				DiceEffect.SlowMo => "SLOW-MO", 
				DiceEffect.Invisible => "INVISIBLE", 
				DiceEffect.Star => "STAR POWER", 
				_ => e.ToString(), 
			};
		}

		public static IEnumerable<KeyValuePair<DiceEffect, float>> ActiveEffects()
		{
			return Active;
		}

		static Dice()
		{
			ECurrency[] array = new ECurrency[6];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			Minerals = (ECurrency[])(object)array;
		}
	}
	internal static class DiceModel
	{
		private static Mesh mesh;

		private static Material material;

		private static bool failed;

		private static string Folder => Path.GetDirectoryName(typeof(Plugin).Assembly.Location);

		public static void ResetMaterial()
		{
			material = null;
		}

		public static GameObject Create()
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_0073: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			if (failed)
			{
				return null;
			}
			try
			{
				if ((Object)(object)mesh == (Object)null || ((Il2CppObjectBase)mesh).WasCollected)
				{
					mesh = LoadMesh(Path.Combine(Folder, "dice.mesh"));
				}
				if ((Object)(object)material == (Object)null || ((Il2CppObjectBase)material).WasCollected)
				{
					material = MakeMaterial(Path.Combine(Folder, "dice.png"));
				}
				GameObject val = new GameObject("LuckyDice.Dice");
				val.AddComponent<MeshFilter>().sharedMesh = mesh;
				MeshRenderer obj = val.AddComponent<MeshRenderer>();
				((Renderer)obj).sharedMaterial = material;
				((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
				return val;
			}
			catch (Exception ex)
			{
				failed = true;
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(72, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Couldn't build the dice model (is dice.mesh/dice.png next to the DLL?): ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				logger.LogError(val2);
				return null;
			}
		}

		private static Mesh LoadMesh(string path)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			byte[] array = File.ReadAllBytes(path);
			if (array.Length < 12 || array[0] != 84 || array[1] != 84 || array[2] != 77 || array[3] != 49)
			{
				throw new Exception("bad dice.mesh header");
			}
			int num = BitConverter.ToInt32(array, 4);
			int num2 = BitConverter.ToInt32(array, 8);
			int num3 = 12;
			Vector3[] array2 = (Vector3[])(object)new Vector3[num];
			Vector3[] array3 = (Vector3[])(object)new Vector3[num];
			Vector2[] array4 = (Vector2[])(object)new Vector2[num];
			int[] array5 = new int[num2];
			int num4 = 0;
			while (num4 < num)
			{
				array2[num4] = new Vector3(BitConverter.ToSingle(array, num3), BitConverter.ToSingle(array, num3 + 4), BitConverter.ToSingle(array, num3 + 8));
				num4++;
				num3 += 12;
			}
			int num5 = 0;
			while (num5 < num)
			{
				array3[num5] = new Vector3(BitConverter.ToSingle(array, num3), BitConverter.ToSingle(array, num3 + 4), BitConverter.ToSingle(array, num3 + 8));
				num5++;
				num3 += 12;
			}
			int num6 = 0;
			while (num6 < num)
			{
				array4[num6] = new Vector2(BitConverter.ToSingle(array, num3), BitConverter.ToSingle(array, num3 + 4));
				num6++;
				num3 += 8;
			}
			int num7 = 0;
			while (num7 < num2)
			{
				array5[num7] = BitConverter.ToInt32(array, num3);
				num7++;
				num3 += 4;
			}
			Mesh val = new Mesh
			{
				name = "LuckyDice.DiceMesh"
			};
			if (num > 65535)
			{
				val.indexFormat = (IndexFormat)1;
			}
			val.vertices = Il2CppStructArray<Vector3>.op_Implicit(array2);
			val.normals = Il2CppStructArray<Vector3>.op_Implicit(array3);
			val.uv = Il2CppStructArray<Vector2>.op_Implicit(array4);
			val.triangles = Il2CppStructArray<int>.op_Implicit(array5);
			val.RecalculateBounds();
			((Object)val).hideFlags = (HideFlags)32;
			ManualLogSource logger = Plugin.Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(32, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Dice mesh loaded: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" verts, ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2 / 3);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" tris.");
			}
			logger.LogInfo(val2);
			return val;
		}

		private static Material MakeMaterial(string texPath)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true);
			if (!ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(File.ReadAllBytes(texPath))))
			{
				throw new Exception("couldn't decode dice.png");
			}
			((Object)val).hideFlags = (HideFlags)32;
			Shader val2 = null;
			string[] array = new string[5] { "Universal Render Pipeline/Lit", "Universal Render Pipeline/Simple Lit", "Universal Render Pipeline/Unlit", "Standard", "Unlit/Texture" };
			bool flag = default(bool);
			foreach (string text in array)
			{
				val2 = Shader.Find(text);
				if ((Object)(object)val2 != (Object)null)
				{
					ManualLogSource logger = Plugin.Logger;
					BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(13, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Dice shader: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text);
					}
					logger.LogInfo(val3);
					break;
				}
			}
			Material val4;
			if ((Object)(object)val2 != (Object)null)
			{
				val4 = new Material(val2);
			}
			else
			{
				MeshRenderer val5 = Object.FindObjectOfType<MeshRenderer>();
				if ((Object)(object)val5 == (Object)null || (Object)(object)((Renderer)val5).sharedMaterial == (Object)null)
				{
					throw new Exception("no usable shader found");
				}
				val4 = new Material(((Renderer)val5).sharedMaterial);
				ManualLogSource logger2 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Dice shader borrowed: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)val4.shader).name);
				}
				logger2.LogInfo(val3);
			}
			val4.mainTexture = (Texture)(object)val;
			if (val4.HasProperty("_BaseMap"))
			{
				val4.SetTexture("_BaseMap", (Texture)(object)val);
			}
			if (val4.HasProperty("_MainTex"))
			{
				val4.SetTexture("_MainTex", (Texture)(object)val);
			}
			if (val4.HasProperty("_BaseColor"))
			{
				val4.SetColor("_BaseColor", Color.white);
			}
			if (val4.HasProperty("_Color"))
			{
				val4.SetColor("_Color", Color.white);
			}
			if (val4.HasProperty("_Metallic"))
			{
				val4.SetFloat("_Metallic", 0.3f);
			}
			if (val4.HasProperty("_Smoothness"))
			{
				val4.SetFloat("_Smoothness", 0.55f);
			}
			float value = Dice.Glow.Value;
			if (value > 0f && val4.HasProperty("_EmissionColor"))
			{
				val4.EnableKeyword("_EMISSION");
				if (val4.HasProperty("_EmissionMap"))
				{
					val4.SetTexture("_EmissionMap", (Texture)(object)val);
				}
				val4.SetColor("_EmissionColor", Color.white * value);
				val4.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
			}
			((Object)val4).hideFlags = (HideFlags)32;
			return val4;
		}
	}
	public class DiceHud : MonoBehaviour
	{
		public DiceHud(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Update()
		{
			ConfigReload.Tick();
		}

		public static void Announce(string text)
		{
		}

		private void OnGUI()
		{
			//IL_00c8: 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)
			try
			{
				if (EffectTimers.UsingNativeUi)
				{
					return;
				}
				string text = "";
				foreach (KeyValuePair<DiceEffect, float> item in Dice.ActiveEffects())
				{
					if (item.Value > 0f)
					{
						text += $"{Dice.Label(item.Key)}  {Mathf.CeilToInt(item.Value)}s\n";
					}
				}
				if (text.Length > 0)
				{
					Shadowed(new Rect(0f, (float)Screen.height * 0.12f, (float)Screen.width, (float)Screen.height * 0.2f), text, Mathf.RoundToInt((float)Screen.height * 0.022f), (TextAnchor)1, new Color(0.5f, 1f, 0.9f));
				}
			}
			catch
			{
			}
		}

		private static void Shadowed(Rect r, string text, int size, TextAnchor align, Color color)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle label = GUI.skin.label;
			label.fontSize = size;
			label.alignment = align;
			label.normal.textColor = new Color(0f, 0f, 0f, 0.8f);
			GUI.Label(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, label);
			label.normal.textColor = color;
			GUI.Label(r, text, label);
		}
	}
	[HarmonyPatch(typeof(BaseEnemyBehaviour), "HandleSeekPathing")]
	internal static class InvisibleNoSeek
	{
		private static bool Prefix()
		{
			return !Dice.IsActive(DiceEffect.Invisible);
		}
	}
	internal static class DicePatches
	{
		[HarmonyPatch(typeof(PickupSpawner), "OnEnemyDeath")]
		[HarmonyPostfix]
		private static void EnemyDied(Enemy __0)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			try
			{
				Dice.OnEnemyKilled(__0);
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(18, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Dice drop failed: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logger.LogError(val);
			}
		}

		[HarmonyPatch(typeof(CoreGameEvents), "TriggerEnemySpawn")]
		[HarmonyPostfix]
		private static void EnemySpawned(EnemySpawnArgs __0)
		{
			try
			{
				if (__0 != null)
				{
					Dice.OnEnemySpawned(__0.Enemy);
				}
			}
			catch
			{
			}
		}

		[HarmonyPatch(typeof(Enemy), "TakeDamage")]
		[HarmonyPrefix]
		private static void EnemyTakeDamage(Enemy __instance, ref long __0)
		{
			if (Dice.IsActive(DiceEffect.OneHitKills) && __0 > 0 && !Dice.InternalDamage)
			{
				__0 = Math.Max(__0, Game.LethalDamage(__instance));
			}
		}

		[HarmonyPatch(typeof(Player), "TakeDamage")]
		[HarmonyPrefix]
		private static bool PlayerTakeDamage(Entity __5, ref bool __result)
		{
			bool flag = Dice.IsActive(DiceEffect.Star);
			if (!flag && !Dice.IsActive(DiceEffect.Invisible))
			{
				return true;
			}
			Dice.BlockedHits++;
			if (flag && (Object)(object)__5 != (Object)null)
			{
				try
				{
					Enemy val = ((Il2CppObjectBase)__5).TryCast<Enemy>();
					if ((Object)(object)val != (Object)null && Game.Kill(val))
					{
						Dice.StarKills++;
					}
				}
				catch
				{
				}
			}
			__result = false;
			return false;
		}
	}
	internal static class EffectTimers
	{
		private class Timer
		{
			public GameObject Go;

			public TMP_Text Counter;

			public TMP_Text Label;

			public int LastShown = -1;
		}

		private static readonly Dictionary<DiceEffect, Timer> Timers = new Dictionary<DiceEffect, Timer>();

		private static UIDropPodCountdown template;

		private static bool warned;

		public static bool UsingNativeUi { get; private set; }

		private static UIDropPodCountdown FindTemplate()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)template != (Object)null && !((Il2CppObjectBase)template).WasCollected && Object.op_Implicit((Object)(object)template))
			{
				return template;
			}
			template = null;
			foreach (Object item in (Il2CppArrayBase<Object>)(object)Resources.FindObjectsOfTypeAll(Il2CppType.Of<UIDropPodCountdown>()))
			{
				UIDropPodCountdown val = ((item != null) ? ((Il2CppObjectBase)item).TryCast<UIDropPodCountdown>() : null);
				if ((Object)(object)val != (Object)null)
				{
					Scene scene = ((Component)val).gameObject.scene;
					if (((Scene)(ref scene)).IsValid())
					{
						template = val;
						break;
					}
				}
			}
			return template;
		}

		public static void Tick(IEnumerable<KeyValuePair<DiceEffect, float>> active)
		{
			bool flag = false;
			foreach (KeyValuePair<DiceEffect, float> item in active)
			{
				if (item.Value > 0f)
				{
					flag = true;
					break;
				}
			}
			if (!flag && Timers.Count == 0)
			{
				return;
			}
			UIDropPodCountdown val = FindTemplate();
			UsingNativeUi = (Object)(object)val != (Object)null && (Object)(object)val.content != (Object)null;
			if (!UsingNativeUi)
			{
				if (!warned)
				{
					warned = true;
					Plugin.Logger.LogWarning((object)"Effect timers: extraction countdown UI not found yet; using fallback text.");
				}
				return;
			}
			HashSet<DiceEffect> hashSet = new HashSet<DiceEffect>();
			int num = (((Component)val.content).gameObject.activeInHierarchy ? 1 : 0);
			foreach (KeyValuePair<DiceEffect, float> item2 in active)
			{
				if (item2.Value <= 0f)
				{
					continue;
				}
				hashSet.Add(item2.Key);
				if (!Timers.TryGetValue(item2.Key, out var value) || (Object)(object)value.Go == (Object)null || ((Il2CppObjectBase)value.Go).WasCollected || !Object.op_Implicit((Object)(object)value.Go))
				{
					value = Create(val, item2.Key);
					if (value == null)
					{
						continue;
					}
					Timers[item2.Key] = value;
				}
				Place(val, value, num++);
				int num2 = Mathf.CeilToInt(item2.Value);
				if (num2 != value.LastShown)
				{
					value.LastShown = num2;
					if ((Object)(object)value.Label != (Object)null)
					{
						value.Counter.text = num2.ToString();
						continue;
					}
					value.Counter.text = $"<size=50%>{Dice.Label(item2.Key)}</size>  {num2}";
				}
			}
			foreach (DiceEffect item3 in new List<DiceEffect>(Timers.Keys))
			{
				if (!hashSet.Contains(item3))
				{
					Remove(item3);
				}
			}
		}

		private static Timer Create(UIDropPodCountdown tpl, DiceEffect effect)
		{
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Expected O, but got Unknown
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				RectTransform content = tpl.content;
				Transform val = (((Object)(object)((Component)tpl).transform.parent != (Object)null) ? ((Component)tpl).transform.parent : ((Component)tpl).transform);
				GameObject val2 = Object.Instantiate<GameObject>(((Component)content).gameObject);
				((Object)val2).name = $"LuckyDice.Timer.{effect}";
				val2.transform.SetParent(val, false);
				foreach (Component componentsInChild in val2.GetComponentsInChildren<Component>(true))
				{
					if (!((Object)(object)componentsInChild == (Object)null))
					{
						string fullName = ((Object)componentsInChild).GetIl2CppType().FullName;
						if (fullName.Contains("UIDropPodCountdown") || fullName.Contains("Localize") || fullName.Contains("FontSwap"))
						{
							Object.Destroy((Object)(object)componentsInChild);
						}
					}
				}
				val2.SetActive(true);
				foreach (CanvasGroup componentsInChild2 in val2.GetComponentsInChildren<CanvasGroup>(true))
				{
					componentsInChild2.alpha = 1f;
				}
				Vector3 localScale = val2.transform.localScale;
				if (((Vector3)(ref localScale)).sqrMagnitude < 0.01f)
				{
					val2.transform.localScale = Vector3.one;
				}
				TMP_Text val3 = null;
				TMP_Text val4 = null;
				string text = RelativePath(((Component)content).transform, ((Object)(object)tpl.counterText != (Object)null) ? ((TMP_Text)tpl.counterText).transform : null);
				if (text != null)
				{
					Transform obj = ((text.Length == 0) ? val2.transform : val2.transform.Find(text));
					val3 = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null);
				}
				foreach (TMP_Text componentsInChild3 in val2.GetComponentsInChildren<TMP_Text>(true))
				{
					if ((Object)(object)val3 == (Object)null)
					{
						val3 = componentsInChild3;
					}
					else if (((Il2CppObjectBase)componentsInChild3).Pointer != ((Il2CppObjectBase)val3).Pointer)
					{
						val4 = componentsInChild3;
						break;
					}
				}
				if ((Object)(object)val3 == (Object)null)
				{
					Object.Destroy((Object)(object)val2);
					return null;
				}
				if ((Object)(object)val4 != (Object)null)
				{
					val4.text = Dice.Label(effect);
				}
				else
				{
					FitInBox(val3, val2.GetComponent<RectTransform>());
				}
				ManualLogSource logger = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(42, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Effect timer created for ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<DiceEffect>(effect);
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" (label field: ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)(object)val4 != (Object)null) ? "yes" : "no");
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(").");
				}
				logger.LogInfo(val5);
				return new Timer
				{
					Go = val2,
					Counter = val3,
					Label = val4
				};
			}
			catch (Exception ex)
			{
				ManualLogSource logger2 = Plugin.Logger;
				BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(28, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Effect timer create failed: ");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Exception>(ex);
				}
				logger2.LogError(val6);
				return null;
			}
		}

		private static void FitInBox(TMP_Text text, RectTransform box)
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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)
			try
			{
				float fontSize = text.fontSize;
				RectTransform rectTransform = text.rectTransform;
				if ((Object)(object)box != (Object)null && ((Il2CppObjectBase)rectTransform).Pointer != ((Il2CppObjectBase)box).Pointer)
				{
					rectTransform.anchorMin = Vector2.zero;
					rectTransform.anchorMax = Vector2.one;
					rectTransform.pivot = new Vector2(0.5f, 0.5f);
					rectTransform.offsetMin = new Vector2(12f, 6f);
					rectTransform.offsetMax = new Vector2(-12f, -6f);
				}
				text.alignment = (TextAlignmentOptions)514;
				text.fontSizeMax = fontSize;
				text.fontSizeMin = 8f;
				text.enableAutoSizing = true;
				text.richText = true;
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(16, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Timer text fit: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				logger.LogWarning(val);
			}
		}

		private static void Place(UIDropPodCountdown tpl, Timer t, int slot)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0073: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			RectTransform content = tpl.content;
			RectTransform component = t.Go.GetComponent<RectTransform>();
			if (!((Object)(object)component == (Object)null))
			{
				Rect rect = content.rect;
				Vector2 size = ((Rect)(ref rect)).size;
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0.5f, 0.5f);
				component.anchorMax = val;
				component.anchorMin = val;
				component.pivot = new Vector2(0.5f, 0.5f);
				component.sizeDelta = size;
				Transform parent = ((Transform)component).parent;
				rect = content.rect;
				Vector3 val2 = parent.InverseTransformPoint(((Transform)content).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)));
				RectTransform val3 = ((Il2CppObjectBase)parent).TryCast<RectTransform>();
				Vector2 val4;
				if (!((Object)(object)val3 != (Object)null))
				{
					val4 = Vector2.zero;
				}
				else
				{
					rect = val3.rect;
					val4 = ((Rect)(ref rect)).center;
				}
				Vector2 val5 = val4;
				float num = Mathf.Max(size.y * ((Transform)content).localScale.y, 40f) + 8f;
				component.anchoredPosition = new Vector2(val2.x - val5.x, val2.y - val5.y - (float)slot * num);
			}
		}

		private static string RelativePath(Transform root, Transform target)
		{
			if ((Object)(object)target == (Object)null)
			{
				return null;
			}
			List<string> list = new List<string>();
			Transform val = target;
			while ((Object)(object)val != (Object)null)
			{
				if (((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)root).Pointer)
				{
					list.Reverse();
					return string.Join("/", list);
				}
				list.Add(((Object)val).name);
				val = val.parent;
			}
			return null;
		}

		private static void Remove(DiceEffect e)
		{
			if (Timers.TryGetValue(e, out var value) && (Object)(object)value.Go != (Object)null && !((Il2CppObjectBase)value.Go).WasCollected && Object.op_Implicit((Object)(object)value.Go))
			{
				Object.Destroy((Object)(object)value.Go);
			}
			Timers.Remove(e);
		}

		public static void Clear()
		{
			foreach (DiceEffect item in new List<DiceEffect>(Timers.Keys))
			{
				Remove(item);
			}
			template = null;
			warned = false;
		}
	}
	internal static class Game
	{
		private static Player player;

		private static PickupSpawner spawner;

		private static EnemySpawner enemySpawner;

		public static bool OutOfPod;

		public static bool ExtractionStarted;

		public static bool Alive(Object o)
		{
			if (o != (Object)null && !((Il2CppObjectBase)o).WasCollected)
			{
				return Object.op_Implicit(o);
			}
			return false;
		}

		public static Player GetPlayer()
		{
			if (Alive((Object)(object)player))
			{
				return player;
			}
			try
			{
				player = Object.FindObjectOfType<Player>();
			}
			catch
			{
				player = null;
			}
			if (!Alive((Object)(object)player))
			{
				return null;
			}
			return player;
		}

		public static PickupSpawner GetSpawner()
		{
			if (Alive((Object)(object)spawner))
			{
				return spawner;
			}
			try
			{
				spawner = Object.FindObjectOfType<PickupSpawner>();
			}
			catch
			{
				spawner = null;
			}
			if (!Alive((Object)(object)spawner))
			{
				return null;
			}
			return spawner;
		}

		public static EnemySpawner GetEnemySpawner()
		{
			if (Alive((Object)(object)enemySpawner))
			{
				return enemySpawner;
			}
			try
			{
				enemySpawner = Object.FindObjectOfType<EnemySpawner>();
			}
			catch
			{
				enemySpawner = null;
			}
			if (!Alive((Object)(object)enemySpawner))
			{
				return null;
			}
			return enemySpawner;
		}

		internal static void SetSpawner(PickupSpawner s)
		{
			spawner = s;
		}

		internal static void SetPlayer(Player p)
		{
			player = p;
		}

		public static List<Enemy> LiveEnemies(out string from)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			List<Enemy> list = new List<Enemy>();
			from = "none";
			try
			{
				EnemySpawner obj = GetEnemySpawner();
				List<Enemy> val = ((obj != null) ? obj.enemies : null);
				if (val != null && val.Count > 0)
				{
					for (int i = 0; i < val.Count; i++)
					{
						list.Add(val[i]);
					}
					from = "spawner list";
				}
				else
				{
					foreach (Enemy item in Object.FindObjectsOfType<Enemy>())
					{
						list.Add(item);
					}
					from = "scene search";
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(23, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Couldn't list enemies: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
				}
				logger.LogError(val2);
			}
			list.RemoveAll((Enemy e) => !Alive((Object)(object)e) || e.IsDead || !((Component)e).gameObject.activeInHierarchy);
			return list;
		}

		public static long LethalDamage(Enemy enemy)
		{
			try
			{
				double num = ((Entity)enemy).CurrentHP;
				double num2 = 1.0;
				try
				{
					num2 = enemy.DamageTakenMod.Value;
				}
				catch
				{
				}
				if (num2 < 0.2 || num2 > 5.0)
				{
					num2 = 1.0;
				}
				return (long)Math.Ceiling(num / num2 * 1.2) + 1;
			}
			catch
			{
				return 1000000L;
			}
		}

		public static bool Kill(Enemy enemy)
		{
			if (!Alive((Object)(object)enemy) || enemy.IsDead)
			{
				return false;
			}
			Dice.InternalDamage = true;
			try
			{
				long num = LethalDamage(enemy);
				((Entity)enemy).TakeDamage(num, false, (EDamageType)0, false, (EDamageSource)7, (Entity)null, false);
				if (!enemy.IsDead)
				{
					((Entity)enemy).Die((EDamageType)0, num, false);
				}
			}
			finally
			{
				Dice.InternalDamage = false;
			}
			return enemy.IsDead;
		}

		public static void KillAllEnemies(string reason)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			string from;
			List<Enemy> list = LiveEnemies(out from);
			int num = 0;
			int num2 = 0;
			bool flag = default(bool);
			foreach (Enemy item in list)
			{
				try
				{
					if (Kill(item))
					{
						num++;
					}
					else
					{
						num2++;
					}
				}
				catch (Exception ex)
				{
					if (num2++ == 0)
					{
						ManualLogSource logger = Plugin.Logger;
						BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(13, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Kill failed: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
						}
						logger.LogError(val);
					}
				}
			}
			ManualLogSource logger2 = Plugin.Logger;
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(49, 5, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Kill all [");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(reason);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] (");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(from);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("): ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(list.Count);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" found, ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" killed, ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num2);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" survived/failed");
			}
			logger2.LogInfo(val2);
		}

		public static bool HasPickledNitra()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Invalid comparison between Unknown and I4
			try
			{
				Player obj = GetPlayer();
				List<ArtifactStateHandler> val = ((obj != null) ? obj.EquippedArtifacts : null);
				if (val == null)
				{
					return false;
				}
				for (int i = 0; i < val.Count; i++)
				{
					ArtifactStateHandler obj2 = val[i];
					object obj3;
					if (obj2 == null)
					{
						obj3 = null;
					}
					else
					{
						ArtifactSkillData data = obj2.Data;
						obj3 = ((data != null) ? ((Il2CppObjectBase)data).TryCast<ScaleStatWithWalletArtifactData>() : null);
					}
					ScaleStatWithWalletArtifactData val2 = (ScaleStatWithWalletArtifactData)obj3;
					if ((Object)(object)val2 == (Object)null || (int)val2.CurrencyType != 2)
					{
						continue;
					}
					Il2CppReferenceArray<StatMod> statModPrCurrency = val2.StatModPrCurrency;
					int num = 0;
					while (statModPrCurrency != null && num < ((Il2CppArrayBase<StatMod>)(object)statModPrCurrency).Length)
					{
						if (((Il2CppArrayBase<StatMod>)(object)statModPrCurrency)[num] != null && (int)((Il2CppArrayBase<StatMod>)(object)statModPrCurrency)[num].StatType == 3)
						{
							return true;
						}
						num++;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		public static void ResetStage()
		{
			OutOfPod = false;
			ExtractionStarted = false;
		}
	}
	internal static class GamePatches
	{
		private static int errors;

		[HarmonyPatch(typeof(CoreGameEvents), "TriggerStageBegin")]
		[HarmonyPostfix]
		private static void StageBegin()
		{
			Game.ResetStage();
			Dice.ClearStage();
		}

		[HarmonyPatch(typeof(Player), "OnExitDropPod")]
		[HarmonyPostfix]
		private static void ExitPod(Player __instance)
		{
			Game.SetPlayer(__instance);
			Game.ResetStage();
			Game.OutOfPod = true;
		}

		[HarmonyPatch(typeof(CoreGameEvents), "TriggerPlayerEnteredDropPod")]
		[HarmonyPostfix]
		private static void EnteredPod()
		{
			Game.ResetStage();
		}

		[HarmonyPatch(typeof(UIDropPodCountdown), "Show")]
		[HarmonyPostfix]
		private static void CountdownShown()
		{
			if (Game.OutOfPod)
			{
				Game.ExtractionStarted = true;
			}
		}

		[HarmonyPatch(typeof(PickupSpawner), "SpawnXP")]
		[HarmonyPostfix]
		private static void CacheSpawner(PickupSpawner __instance)
		{
			Game.SetSpawner(__instance);
		}

		[HarmonyPatch(typeof(GameController), "Update")]
		[HarmonyPostfix]
		private static void Tick()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			try
			{
				Dice.Tick();
			}
			catch (Exception ex)
			{
				if (errors++ < 5)
				{
					ManualLogSource logger = Plugin.Logger;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(13, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Tick failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					logger.LogError(val);
				}
			}
		}
	}
	internal static class InfiniteAmmo
	{
		private static bool logged;

		private static int errors;

		public static void Tick()
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			Player player = Game.GetPlayer();
			List<WeaponHandler> val = ((player != null) ? player.Weapons : null);
			if (val == null)
			{
				return;
			}
			bool flag = default(bool);
			for (int i = 0; i < val.Count; i++)
			{
				WeaponHandler val2 = val[i];
				if ((Object)(object)val2 == (Object)null || ((Il2CppObjectBase)val2).WasCollected || !Object.op_Implicit((Object)(object)val2))
				{
					continue;
				}
				try
				{
					ProjectileWeaponHandler val3 = ((Il2CppObjectBase)val2).TryCast<ProjectileWeaponHandler>();
					if ((Object)(object)val3 != (Object)null)
					{
						int clipSize = val3.ClipSize;
						if (clipSize > 0 && val3.bulletsLeft < clipSize)
						{
							val3.bulletsLeft = clipSize;
							try
							{
								val3.AmmoUpdated();
							}
							catch
							{
							}
						}
					}
					if (val2.reloadTimeLeft > 0.001f)
					{
						val2.reloadTimeLeft = 0.001f;
					}
				}
				catch (Exception ex)
				{
					if (errors++ < 3)
					{
						ManualLogSource logger = Plugin.Logger;
						BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(18, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Infinite ammo (");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)val2).name);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("): ");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex);
						}
						logger.LogError(val4);
					}
				}
			}
			if (!logged)
			{
				logged = true;
				Plugin.Logger.LogInfo((object)"Infinite ammo active.");
			}
		}

		public static void Ended()
		{
			logged = false;
		}
	}
	internal static class MagnetLink
	{
		private const string MagnetTweaksGuid = "tobipolar.drgs.magnettweaks";

		private static bool warned;

		public static bool MagnetAlwaysOn()
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			try
			{
				if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("tobipolar.drgs.magnettweaks", out var value))
				{
					return false;
				}
				object obj = ((value != null) ? value.Instance : null);
				BasePlugin val = (BasePlugin)((obj is BasePlugin) ? obj : null);
				if (val == null)
				{
					return false;
				}
				foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in val.Config)
				{
					if (item.Key.Section == "Magnet" && item.Key.Key == "Mode")
					{
						return item.Value.BoxedValue?.ToString() == "AlwaysActive";
					}
				}
			}
			catch (Exception ex)
			{
				if (!warned)
				{
					warned = true;
					ManualLogSource logger = Plugin.Logger;
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(68, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Couldn't read Magnet Tweaks' mode (");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("); Magnet effect stays available.");
					}
					logger.LogWarning(val2);
				}
			}
			return false;
		}

		public static void SpawnMagnet()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			Player player = Game.GetPlayer();
			PickupSpawner spawner = Game.GetSpawner();
			if ((Object)(object)player == (Object)null || (Object)(object)spawner == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"Magnet effect: no player/pickup spawner yet.");
				return;
			}
			spawner.SpawnMagnet(((Component)player).transform.position);
			Plugin.Logger.LogInfo((object)"Magnet effect: magnet spawned.");
		}
	}
	[BepInPlugin("tobipolar.drgs.luckydice", "Lucky Dice", "1.3.2")]
	public class Plugin : BasePlugin
	{
		public const string Guid = "tobipolar.drgs.luckydice";

		public const string Name = "Lucky Dice";

		public const string Version = "1.3.2";

		internal static ManualLogSource Logger;

		private void MigrateOldConfig(params string[] oldNames)
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				string configFilePath = ((BasePlugin)this).Config.ConfigFilePath;
				if (File.Exists(configFilePath) && new FileInfo(configFilePath).Length != 0)
				{
					return;
				}
				foreach (string text in oldNames)
				{
					string text2 = Path.Combine(Paths.ConfigPath, text);
					if (File.Exists(text2))
					{
						File.Copy(text2, configFilePath, overwrite: true);
						((BasePlugin)this).Config.Reload();
						ManualLogSource log = ((BasePlugin)this).Log;
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(56, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Settings copied from the old ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". You can delete that file.");
						}
						log.LogInfo(val);
						break;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = ((BasePlugin)this).Log;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Couldn't copy old settings: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				log2.LogWarning(val2);
			}
		}

		public override void Load()
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			MigrateOldConfig("toby.drgs.luckydice.cfg");
			Dice.BindConfig(((BasePlugin)this).Config);
			Harmony.CreateAndPatchAll(typeof(GamePatches), "tobipolar.drgs.luckydice");
			Harmony.CreateAndPatchAll(typeof(DicePatches), "tobipolar.drgs.luckydice");
			bool flag = default(bool);
			try
			{
				Harmony.CreateAndPatchAll(typeof(Announcer), "tobipolar.drgs.luckydice");
			}
			catch (Exception ex)
			{
				ManualLogSource log = ((BasePlugin)this).Log;
				BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Announcements unavailable: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				log.LogWarning(val);
			}
			try
			{
				Harmony.CreateAndPatchAll(typeof(InvisibleNoSeek), "tobipolar.drgs.luckydice");
			}
			catch (Exception ex2)
			{
				ManualLogSource logger = Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(27, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Invisibility patch failed: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex2);
				}
				logger.LogError(val2);
			}
			Dice.Init();
			ConfigReload.Start(((BasePlugin)this).Config);
			ManualLogSource logger2 = Logger;
			BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(32, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("Lucky Dice");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>("1.3.2");
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" loaded. Enabled = ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<bool>(Dice.Enabled.Value);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", chance = ");
				((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<float>(Dice.DropChancePercent.Value);
				((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("%");
			}
			logger2.LogInfo(val3);
		}
	}
}