Decompiled source of GachaProgression v1.0.0

NGA.GachaProgression.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OtherLoader;
using Sodalite.ModPanel;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("NGA")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Persistent player progression! Raid, stash loot, and deploy with seemless scene/loadout saving.")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("NGA.GachaProgression")]
[assembly: AssemblyTitle("BepInEx Plugin Title")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace NGA
{
	[BepInPlugin("NGA.GachaProgression", "GachaProgression", "0.0.1")]
	[BepInDependency("nrgill28.Sodalite", "1.4.1")]
	[BepInDependency("nrgill28.Sodalite", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	public class GachaProgression : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(TNH_Manager))]
		[HarmonyPatch("OnSosigKill")]
		public class TNH_ManagerOnSosigKill : MonoBehaviour
		{
			private static void Prefix(TNH_ManagerOnSosigKill __instance, Sosig s)
			{
				if (!CheckSkip())
				{
					Logger.LogMessage((object)"Sosig died lol");
					SpawnSosigStuff(s);
				}
			}
		}

		public class SupplyPointLoot
		{
			public struct LootClass
			{
				public List<string> items;

				public float likelihood;
			}

			public List<LootClass> lootClasses;

			public SupplyPointLoot()
			{
				lootClasses = new List<LootClass>();
			}

			public void AddLootClass(List<string> items, float likelihood)
			{
				lootClasses.Add(new LootClass
				{
					items = items,
					likelihood = likelihood
				});
			}

			public string DrawFrom()
			{
				float num = 0f;
				foreach (LootClass lootClass in lootClasses)
				{
					num += lootClass.likelihood;
				}
				float num2 = Random.Range(0f, num);
				float num3 = 0f;
				foreach (LootClass lootClass2 in lootClasses)
				{
					num3 += lootClass2.likelihood;
					if (num2 <= num3)
					{
						int index = Random.Range(0, lootClass2.items.Count);
						return lootClass2.items[index];
					}
				}
				return null;
			}
		}

		[HarmonyPatch(typeof(TNH_SupplyPoint))]
		[HarmonyPatch("SpawnBoxes")]
		public class TNH_SupplyPointSpawnBoxes : MonoBehaviour
		{
			private static void Prefix(TNH_SupplyPoint __instance, int min, int max, bool SpawnToken)
			{
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				if (CheckSkip())
				{
					return;
				}
				DifficultySettings difficultySettings = CalculateDifficultySettings();
				SupplyPointLoot supplyPointLoot = (difficultySettings.IsImpossible ? imp_loot_pool : ((!difficultySettings.IsHard) ? basic_loot_pool : hard_loot_pool));
				for (int i = 0; i < __instance.SpawnPoints_Boxes.Count; i++)
				{
					if (Random.value <= SupplyRoomChanceSpawn.Value)
					{
						Logger.LogMessage((object)"Spawning at box location!");
						Transform val = __instance.SpawnPoints_Boxes[i];
						Vector3 position = val.position + Vector3.up * 0.1f + Vector3.up * 0.85f;
						string text = supplyPointLoot.DrawFrom();
						if (text == null || text == "")
						{
							Logger.LogError((object)"Null or empty idtospawn");
							continue;
						}
						Logger.LogMessage((object)("SpawnBoxes: " + text));
						SpawnSomething(text, position);
					}
				}
			}
		}

		[HarmonyPatch(typeof(UnlockedItemSaveData))]
		[HarmonyPatch("IsItemUnlocked", new Type[] { typeof(string) })]
		public class UnlockedItemSaveDataIsItemUnlocked : MonoBehaviour
		{
			private static bool Prefix(UnlockedItemSaveData __instance, ref bool __result, string itemID)
			{
				if (hats_ItemIDs.Contains(itemID))
				{
					OtherLoader.SpawnerIDsByMainObject.TryGetValue(itemID, out var value);
					if ((Object)(object)value == (Object)null)
					{
						return true;
					}
					__result = __instance.ShouldAutoUnlockItem(value);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(FVRPhysicalObject))]
		[HarmonyPatch("FVRFixedUpdate")]
		public class FVRPhysicalObjectFVRFixedUpdate : MonoBehaviour
		{
			private static float timer = 0f;

			private static float interval = 10f;

			private static void Postfix(FVRPhysicalObject __instance)
			{
				if (!(((Object)((Component)__instance).gameObject).name != "GunHatCaseKey(Clone)"))
				{
					timer += Time.fixedDeltaTime;
					if (timer >= interval && (Object)(object)__instance.m_quickbeltSlot == (Object)null)
					{
						SpawnFunFetti(((Component)__instance).transform);
						timer = 0f;
						interval = KeyPingIntv.Value;
					}
				}
			}
		}

		[HarmonyPatch(typeof(GronchHatCase))]
		[HarmonyPatch("Open")]
		public class GronchHatCaseOpen : MonoBehaviour
		{
			private static bool Prefix(GronchHatCase __instance, GronchHatCaseKey k)
			{
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0142: Unknown result type (might be due to invalid IL or missing references)
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				if (CheckSkip())
				{
					return false;
				}
				if (ResetHatRewards.Value)
				{
					Logger.LogMessage((object)"Resetting!");
					ResetAllHatRewards();
				}
				Logger.LogMessage((object)"Before open Hat case, setting random hat");
				RandHat(__instance);
				if (__instance.m_isOpen)
				{
					return false;
				}
				__instance.m_isOpen = true;
				__instance.Lid.localEulerAngles = new Vector3(__instance.CaseLidRots.y, 0f, 0f);
				GM.MMFlags.AddHat(__instance.HID);
				GM.MMFlags.SaveToFile();
				if (!GM.Rewards.RewardUnlocks.IsRewardUnlocked(__instance.HID))
				{
					GM.Rewards.RewardUnlocks.UnlockReward(__instance.HID);
					Object.Instantiate<GameObject>(__instance.SpawnOnAlreadyHave, __instance.FXPoint.position, __instance.FXPoint.rotation);
				}
				GM.Rewards.SaveToFile();
				if (IM.HasSpawnedID(__instance.HID))
				{
					ItemSpawnerID spawnerID = IM.GetSpawnerID(__instance.HID);
					FVRObject mainObject = spawnerID.MainObject;
					Object.Instantiate<GameObject>(((AnvilAsset)mainObject).GetGameObject(), __instance.SpawnPoint.position, __instance.SpawnPoint.rotation);
				}
				Object.Destroy((Object)(object)((Component)k).gameObject);
				return false;
			}
		}

		[HarmonyPatch(typeof(TNH_Manager))]
		[HarmonyPatch("SetPhase_Dead")]
		public class TNH_ManagerSetPhase_Dead : MonoBehaviour
		{
			private static void Postfix(TNH_Manager __instance)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: 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)
				if (!CheckSkip() && ClearLoadoutOnDeath.Value)
				{
					Logger.LogMessage((object)"Player died, deleting their quickbelt! >:}");
					VaultFile val = new VaultFile();
					FVRPlayerBody val2 = Object.FindObjectOfType<FVRPlayerBody>();
					Transform transform = new GameObject().transform;
					transform.position = ((Component)val2).transform.position;
					string text = default(string);
					bool flag = VaultSystem.SpawnObjects((VaultFileDisplayMode)1, val, ref text, transform, Vector3.zero);
					Logger.LogMessage((object)("Finished deleting their quickbelt! >:}" + flag));
				}
			}
		}

		public struct DifficultySettings
		{
			public bool IsHard;

			public bool IsImpossible;
		}

		[HarmonyPatch(typeof(TNH_Manager))]
		[HarmonyPatch("SetPhase_Completed")]
		public class TNH_ManagerSetPhase_Completed : MonoBehaviour
		{
			private static void Postfix(TNH_Manager __instance)
			{
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Expected O, but got Unknown
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_012f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Unknown result type (might be due to invalid IL or missing references)
				//IL_0139: Unknown result type (might be due to invalid IL or missing references)
				if (CheckSkip())
				{
					return;
				}
				DifficultySettings difficultySettings = CalculateDifficultySettings();
				string rewardVaultName = RewardVaultName;
				List<string> list = new List<string>();
				if (difficultySettings.IsImpossible)
				{
					Logger.LogMessage((object)"Impossible reward earned! :)");
					list.Add(rewardVaultName + "WW");
				}
				if (difficultySettings.IsHard)
				{
					Logger.LogMessage((object)"Hard reward earned! :)");
					list.Add(rewardVaultName + "W");
				}
				if (list.Count == 0)
				{
					list.Add(rewardVaultName);
				}
				string text = default(string);
				foreach (string item in list)
				{
					Logger.LogMessage((object)("Spawning reward on game end! :)" + item));
					VaultFile val = new VaultFile();
					bool flag = VaultSystem.LoadVaultFile(item, (VaultFileDisplayMode)0, ref val);
					Logger.LogMessage((object)("Load files status " + flag));
					if (flag)
					{
						FVRPlayerBody val2 = Object.FindObjectOfType<FVRPlayerBody>();
						Transform transform = new GameObject().transform;
						transform.position = ((Component)val2).transform.position;
						bool flag2 = VaultSystem.SpawnObjects((VaultFileDisplayMode)0, val, ref text, transform, Vector3.forward + Vector3.up);
						SpawnFunFetti(transform);
						Logger.LogMessage((object)("Finished spawning end game reward! :) status: " + flag2));
					}
				}
			}
		}

		[HarmonyPatch(typeof(TNH_Manager))]
		[HarmonyPatch("SetPhase_Take")]
		public class TNH_ManagerSetPhase_Take : MonoBehaviour
		{
			private static void Postfix(TNH_Manager __instance)
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				if (!CheckSkip())
				{
					string text = "";
					int num = casesSpawned - keysSpawned;
					if (num < 0)
					{
						text = hatCaseID;
					}
					else if (num > 0)
					{
						text = hatKeyID;
					}
					else
					{
						SpawnSomething(hatCaseID);
						SpawnSomething(hatKeyID);
					}
					Logger.LogMessage((object)("Take completed! Awarding " + num + " " + text));
					while (num < 100 && num > 0)
					{
						SpawnSomething(text);
						num--;
					}
					SpawnFunFetti();
				}
			}
		}

		private static ConfigEntry<bool> GameEnabled;

		private static ConfigEntry<bool> SchedsEnabled;

		private static ConfigEntry<int> UntilNextHat;

		private static ConfigEntry<int> UntilNextKey;

		private static ConfigEntry<int> MaxDeviation;

		private static ConfigEntry<float> SupplyRoomChanceSpawn;

		private static ConfigEntry<int> KeyPingIntv;

		private static ConfigEntry<bool> ClearLoadoutOnDeath;

		private static ConfigEntry<bool> ResetHatRewards;

		public static ConfigEntry<string> XOXO;

		private static int untilNextHatCase = 0;

		private static int untilNextKey = 0;

		private static int casesSpawned = 0;

		private static int keysSpawned = 0;

		private static GameObject funfetti;

		private static string RewardVaultName = "gun_shared_HATKEY";

		private static string hatCaseID = "MiscGunHatCase";

		private static string hatKeyID = "MiscGunHatCaseKey";

		private static string save_prefix = "gun_shared_";

		private static List<float> m_c = new List<float> { -1f, -1f, 0f, 80f, 90f, 96f, 99f, 99.75f };

		private static List<string> su_boxes = new List<string> { "MiscGunHatCase", "MiscGunHatCaseKey" };

		private static List<string> basic_armor = new List<string> { "6b2", "Module3M", "antichrist", "paca", "PRESSARMOR" };

		private static List<string> hard_armor = new List<string> { "6b13", "hexgrid", "gzel", "pacarivals", "trooper" };

		private static List<string> imp_armor = new List<string> { "redut", "iotvfull", "6b13killa", "thorc", "thorcv" };

		private static List<string> basic_helms = new List<string> { "FTW.Helmet.Ronin", "FTW.UNHelmet.helmet", "FTW.TankHelmet.helmet", "FTW.Ushanka.helmet", "FTW.Caiman.helmet", "FTW.CowBoyHat.helmet", "FTW.FASTAirsoft.helmetTan" };

		private static List<string> hard_helms = new List<string> { "ftw.altyn.helmet", "FTW.Kiver.helmet", "FTW.KiverShield.helmet", "FTW.helmet.LSHZ", "FTW.helmet.LSHZMask", "FTW.helmet.LSHZAventail", "FTW.RysT.helmet", "gun_shared_ZHSFULL" };

		private static List<string> imp_helms = new List<string>
		{
			"gun_shared_TCHAKFUL", "FTW.RysTMask.helmet", "ftw.altynmask.helmet", "FTW.HeavyTrooper.attachmentB", "FTW.HeavyTrooper.attachment", "FTW.HeavyTrooper.attachmentWolfe", "FTW.HeavyTrooper.attachmentBT", "FTW.HeavyTrooper.attachmentT", "FTW.OBEY.helmet", "gun_shared_AIRFFUL",
			"gun_shared_FASTFUL", "gun_shared_CAIFUL"
		};

		private static SupplyPointLoot basic_loot_pool;

		private static SupplyPointLoot hard_loot_pool;

		private static SupplyPointLoot imp_loot_pool;

		private static List<string> H_BB = new List<string> { "MiscRailHatRailHat BB Armet", "MiscRailHatRailHat BB FootballHelmet BeefKicker", "MiscRailHatRailHat BB Gladiator Porcus", "MiscRailHatRailHat BB MF2 Scout", "MiscRailHatRailHat BB PropellerCap", "MiscRailHatRailHat BB Truckerhat No1" };

		private static List<string> H_ME = new List<string>
		{
			"MiscRailHatRailHat ME Beanie Jean", "MiscRailHatRailHat ME Boater", "MiscRailHatRailHat ME fisherwiener brown", "MiscRailHatRailHat ME Gambler Crimson", "MiscRailHatRailHat ME Gladiator Secutor", "MiscRailHatRailHat ME GoalieMask", "MiscRailHatRailHat ME Helmet CamoForest", "MiscRailHatRailHat ME KettleHelmet", "MiscRailHatRailHat ME MF2 Demo", "MiscRailHatRailHat ME PinchedFront Pearl",
			"MiscRailHatRailHat ME Yukonhat PlaidRed"
		};

		private static List<string> H_MR = new List<string> { "MiscRailHatRailHat MR Barbute", "MiscRailHatRailHat MR Elf Hat Green", "MiscRailHatRailHat MR Gladiator Murmillo", "MiscRailHatRailHat MR Gladiator Thraex", "MiscRailHatRailHat MR Helmet CamoIce", "MiscRailHatRailHat MR MF2 Engineer", "MiscRailHatRailHat MR MinerHelmet", "MiscRailHatRailHat MR NooseBag", "MiscRailHatRailHat MR PorkPie Brown" };

		private static List<string> H_MW = new List<string> { "MiscRailHatRailHat MW bowler grey", "MiscRailHatRailHat MW Cloche Daisy", "MiscRailHatRailHat MW FootballHelmet Hamfister", "MiscRailHatRailHat MW Gladiator Eques", "MiscRailHatRailHat MW Helmet CamoDesert", "MiscRailHatRailHat MW MF2 Soldier", "MiscRailHatRailHat MW NormanCasquev2", "MiscRailHatRailHat MW RangerHat Tan", "MiscRailHatRailHat MW Sunhat", "MiscRailHatRailHat MW Truckerhat BlueWhite" };

		private static List<string> H_RA = new List<string> { "MiscRailHatRailHat RA Bascinet", "MiscRailHatRailHat RA DunceCap", "MiscRailHatRailHat RA Gladiator Maximus", "MiscRailHatRailHat RA Helmet MercWiener", "MiscRailHatRailHat RA MF2 Sniper", "MiscRailHatRailHat RA SantaHat", "MiscRailHatRailHat RA StovePipe Grey", "MiscRailHatRailHat RA tophat black" };

		private static List<string> H_WD = new List<string>
		{
			"MiscRailHatRailHat WD Beanie Crimson", "MiscRailHatRailHat WD CadetCap Brown", "MiscRailHatRailHat WD CadetCap Green", "MiscRailHatRailHat WD CadetCap Grey", "MiscRailHatRailHat WD CadetCap Tan", "MiscRailHatRailHat WD ClassicHelmet Brown", "MiscRailHatRailHat WD ClassicHelmet Green", "MiscRailHatRailHat WD ClassicHelmet Grey", "MiscRailHatRailHat WD ClassicHelmet Tan", "MiscRailHatRailHat WD Cloche SkyBlue",
			"MiscRailHatRailHat WD CombatCap Brown", "MiscRailHatRailHat WD CombatCap Green", "MiscRailHatRailHat WD CombatCap Grey", "MiscRailHatRailHat WD CombatCap Tan", "MiscRailHatRailHat WD GeneralCap Brown", "MiscRailHatRailHat WD GeneralCap Green", "MiscRailHatRailHat WD GeneralCap Grey", "MiscRailHatRailHat WD GeneralCap Tan", "MiscRailHatRailHat WD Gladiator Hoplite", "MiscRailHatRailHat WD Helmet Shotdog",
			"MiscRailHatRailHat WD Millitarycap Black", "MiscRailHatRailHat WD Millitarycap Blue", "MiscRailHatRailHat WD OpenCrown Grey", "MiscRailHatRailHat WD Truckerhat GreenWhite", "MiscRailHatRailHat WD Yukonhat Olive"
		};

		private static HashSet<string> hats_ItemIDs = new HashSet<string>
		{
			"RailHatBBArmet", "RailHatBBFootballHelmetBeefKicker", "RailHatBBGladiatorPorcus", "RailHatBBMF2Scout", "RailHatBBPropellerCap", "RailHatBBTruckerhatNo1", "RailHatMEBeanieJean", "RailHatMEBoater", "RailHatMEfisherwienerbrown", "RailHatMEGamblerCrimson",
			"RailHatMEGladiatorSecutor", "RailHatMEGoalieMask", "RailHatMEHelmetCamoForest", "RailHatMEKettleHelmet", "RailHatMEMF2Demo", "RailHatMEPinchedFrontPearl", "RailHatMEYukonhatPlaidRed", "RailHatMRBarbute", "RailHatMRElfHatGreen", "RailHatMRGladiatorMurmillo",
			"RailHatMRGladiatorThraex", "RailHatMRHelmetCamoIce", "RailHatMRMF2Engineer", "RailHatMRMinerHelmet", "RailHatMRNooseBag", "RailHatMRPorkPieBrown", "RailHatMWbowlergrey", "RailHatMWClocheDaisy", "RailHatMWFootballHelmetHamfister", "RailHatMWGladiatorEques",
			"RailHatMWHelmetCamoDesert", "RailHatMWMF2Soldier", "RailHatMWNormanCasquev2", "RailHatMWRangerHatTan", "RailHatMWSunhat", "RailHatMWTruckerhatBlueWhite", "RailHatRABascinet", "RailHatRADunceCap", "RailHatRAGladiatorMaximus", "RailHatRAHelmetMercWiener",
			"RailHatRAMF2Sniper", "RailHatRASantaHat", "RailHatRAStovePipeGrey", "RailHatRAtophatblack", "RailHatWDBeanieCrimson", "RailHatWDCadetCapBrown", "RailHatWDCadetCapGreen", "RailHatWDCadetCapGrey", "RailHatWDCadetCapTan", "RailHatWDClassicHelmetBrown",
			"RailHatWDClassicHelmetGreen", "RailHatWDClassicHelmetGrey", "RailHatWDClassicHelmetTan", "RailHatWDClocheSkyBlue", "RailHatWDCombatCapBrown", "RailHatWDCombatCapGreen", "RailHatWDCombatCapGrey", "RailHatWDCombatCapTan", "RailHatWDGeneralCapBrown", "RailHatWDGeneralCapGreen",
			"RailHatWDGeneralCapGrey", "RailHatWDGeneralCapTan", "RailHatWDGladiatorHoplite", "RailHatWDHelmetShotdog", "RailHatWDMillitarycapBlack", "RailHatWDMillitarycapBlue", "RailHatWDOpenCrownGrey", "RailHatWDTruckerhatGreenWhite", "RailHatWDYukonhatOlive"
		};

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("NGA.GachaProgression");
			Logger.LogMessage((object)"New harmony");
			SetUpConfigFields();
			InitiateLootPools();
			Logger.LogMessage((object)"Setted the fields");
			val.PatchAll();
			Logger.LogMessage((object)"Hello, world! Sent from NGA.GachaProgression 0.0.1");
		}

		private void SetUpConfigFields()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			GameEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Overall", "ON/OFF", true, "Enable Gacha Progression");
			SchedsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Reward Schedule", "ON/OFF", true, "Whether to use schedules below. False=no gunhats.");
			UntilNextHat = ((BaseUnityPlugin)this).Config.Bind<int>("Reward Schedule", "Until Next Hat Case", 5, new ConfigDescription("Minimum Sosig kills until next hat box dropped", (AcceptableValueBase)new AcceptableValueIntRangeStep(0, 100, 1), new object[0]));
			UntilNextKey = ((BaseUnityPlugin)this).Config.Bind<int>("Reward Schedule", "Until Next Key Case", 5, new ConfigDescription("Minimum Sosig kills until next KEY dropped", (AcceptableValueBase)new AcceptableValueIntRangeStep(0, 100, 1), new object[0]));
			MaxDeviation = ((BaseUnityPlugin)this).Config.Bind<int>("Reward Schedule", "Max deviation", 2, new ConfigDescription("Maximum kills added to until-next variables above.", (AcceptableValueBase)new AcceptableValueIntRangeStep(0, 100, 1), new object[0]));
			SupplyRoomChanceSpawn = ((BaseUnityPlugin)this).Config.Bind<float>("Reward Schedule", "Supply Room Spawn Chance", 1f, new ConfigDescription("Chance that a box in Supply rooms spawn will spawn loot on top of it.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0f, 1f, 0.05f), new object[0]));
			KeyPingIntv = ((BaseUnityPlugin)this).Config.Bind<int>("Reward Schedule", "Key Ping Interval", 10, new ConfigDescription("How long for keys on ground to flash location.", (AcceptableValueBase)new AcceptableValueIntRangeStep(0, 100, 1), new object[0]));
			ClearLoadoutOnDeath = ((BaseUnityPlugin)this).Config.Bind<bool>("Difficulty", "Clear Loadout on TnH Death", false, "When you die in TNH, whether we wipe what you're wearing clean.");
			ResetHatRewards = ((BaseUnityPlugin)this).Config.Bind<bool>("Difficulty", "(Dangerous!) Reset Hat Progression", false, "Must be manually set back to false! If true, will re-lock all your hats rewards after you open your next hat case. Must be manually set back to false! Restart game.");
			XOXO = ((BaseUnityPlugin)this).Config.Bind<string>("DONT TOUCH", "X1", "XOXOX", "XOXOX");
		}

		private void InitiateLootPools()
		{
			basic_loot_pool = new SupplyPointLoot();
			basic_loot_pool.AddLootClass(su_boxes, 0.5f);
			basic_loot_pool.AddLootClass(basic_armor, 0.25f);
			basic_loot_pool.AddLootClass(basic_helms, 0.25f);
			hard_loot_pool = new SupplyPointLoot();
			hard_loot_pool.AddLootClass(su_boxes, 0.25f);
			hard_loot_pool.AddLootClass(hard_armor, 0.37f);
			hard_loot_pool.AddLootClass(hard_helms, 0.37f);
			imp_loot_pool = new SupplyPointLoot();
			imp_loot_pool.AddLootClass(su_boxes, 0.25f);
			imp_loot_pool.AddLootClass(imp_armor, 0.37f);
			imp_loot_pool.AddLootClass(imp_helms, 0.37f);
		}

		private static bool CheckSkip()
		{
			return !GameEnabled.Value;
		}

		private static void SpawnSosigStuff(Sosig s)
		{
			if (SchedsEnabled.Value)
			{
				UpdateDeathCounters(s);
			}
		}

		private static void UpdateDeathCounters(Sosig s)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (untilNextHatCase <= 0)
			{
				SpawnSomething(hatCaseID, ((Component)s).transform.position);
				SpawnFunFetti(((Component)s).transform);
				casesSpawned++;
				Logger.LogMessage((object)"--------UpdateCase");
				UpdateCaseCounterOnDifficulty();
			}
			else
			{
				Logger.LogMessage((object)"--------UpdateCase MINUS");
				untilNextHatCase--;
			}
			if (untilNextKey <= 0)
			{
				SpawnSomething(hatKeyID, ((Component)s).transform.position);
				SpawnFunFetti(((Component)s).transform);
				keysSpawned++;
				Logger.LogMessage((object)"--------UpdateKey");
				UpdateKeyCounterOnDifficulty();
			}
			else
			{
				Logger.LogMessage((object)"--------UpdateKey MINUS");
				untilNextKey--;
			}
			Logger.LogMessage((object)("Key,Case=" + untilNextKey + "," + untilNextHatCase));
		}

		private static void ResetAllHatRewards()
		{
			List<string> list = new List<string>();
			list.AddRange(H_BB);
			list.AddRange(H_ME);
			list.AddRange(H_MR);
			list.AddRange(H_MW);
			list.AddRange(H_RA);
			list.AddRange(H_WD);
			foreach (string item in list)
			{
				GM.MMFlags.RemoveHat(item);
				GM.Rewards.RewardUnlocks.LockReward(item);
			}
			GM.Rewards.SaveToFile();
			GM.MMFlags.SaveToFile();
			GM.Rewards.InitializeFromSaveFile();
			Logger.LogMessage((object)"Saved reset!");
		}

		public static void SpawnFunFetti(Transform t = null)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)t == (Object)null)
			{
				t = ((Component)Object.FindObjectOfType<FVRPlayerBody>().Head).transform;
			}
			if ((Object)(object)funfetti == (Object)null)
			{
				GronchHatCase component = ((AnvilAsset)IM.OD["RailHatCase"]).GetGameObject().GetComponent<GronchHatCase>();
				funfetti = component.SpawnOnAlreadyHave;
				((Behaviour)funfetti.GetComponent<PlayAudioEventOnAwake>()).enabled = false;
				funfetti.transform.localScale = funfetti.transform.localScale * 0.5f;
			}
			Object.Instantiate<GameObject>(funfetti, t.position, t.rotation);
		}

		public static DifficultySettings CalculateDifficultySettings()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_0014: 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_0026: Invalid comparison between Unknown and I4
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Invalid comparison between Unknown and I4
			bool flag = (int)GM.TNHOptions.EquipmentModeSetting == 1;
			bool flag2 = (int)GM.TNHOptions.HealthMult == 0 || (int)GM.TNHOptions.HealthMult == 1;
			bool flag3 = GM.TNHOptions.LastPlayedChar == 20 || GM.TNHOptions.LastPlayedChar == 21 || GM.TNHOptions.LastPlayedChar == 22 || GM.TNHOptions.LastPlayedChar == 2;
			bool isHard = flag || flag2 || flag3 || ClearLoadoutOnDeath.Value;
			bool isImpossible = (int)GM.TNHOptions.HealthModeSetting == 1 || GM.TNHOptions.LastPlayedChar == 30;
			DifficultySettings result = default(DifficultySettings);
			result.IsHard = isHard;
			result.IsImpossible = isImpossible;
			return result;
		}

		private static void UpdateCaseCounterOnDifficulty()
		{
			DifficultySettings difficultySettings = CalculateDifficultySettings();
			untilNextHatCase = UntilNextHat.Value + Random.Range(0, MaxDeviation.Value + 1);
			Logger.LogMessage((object)"Regular hatcase update counter");
			if (difficultySettings.IsImpossible)
			{
				Logger.LogMessage((object)"Impossible hatcase update counter");
				untilNextHatCase = Random.Range(0, 2);
			}
			else if (difficultySettings.IsHard)
			{
				Logger.LogMessage((object)"Hard hatcase update counter");
				untilNextHatCase = UntilNextHat.Value + Random.Range(0, MaxDeviation.Value + 1);
			}
		}

		private static void UpdateKeyCounterOnDifficulty()
		{
			DifficultySettings difficultySettings = CalculateDifficultySettings();
			untilNextKey = UntilNextKey.Value + Random.Range(0, MaxDeviation.Value + 1);
			Logger.LogMessage((object)"Regular key update counter");
			if (difficultySettings.IsImpossible)
			{
				Logger.LogMessage((object)"Impossible key update counter");
				untilNextKey = Random.Range(0, 2);
			}
			else if (difficultySettings.IsHard)
			{
				Logger.LogMessage((object)"Hard key update counter");
				untilNextKey = UntilNextKey.Value + Random.Range(0, MaxDeviation.Value + 1);
			}
		}

		private static void SpawnSomething(string t_spawnerId, Vector3 position = default(Vector3))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_0115: 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_0068: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (position == Vector3.zero)
			{
				position = ((Component)Object.FindObjectOfType<FVRPlayerBody>().Head).transform.position;
				Logger.LogMessage((object)"Replaced default position w player head.");
			}
			if (t_spawnerId.StartsWith(save_prefix))
			{
				Logger.LogMessage((object)("SpawnSomething trying vaultspawn " + t_spawnerId));
				VaultFile val = new VaultFile();
				bool flag = VaultSystem.LoadVaultFile(t_spawnerId, (VaultFileDisplayMode)0, ref val);
				Logger.LogMessage((object)("Load files status for SpawnSomething " + flag));
				if (flag)
				{
					FVRPlayerBody val2 = Object.FindObjectOfType<FVRPlayerBody>();
					Transform transform = new GameObject().transform;
					transform.position = position;
					string text = default(string);
					bool flag2 = VaultSystem.SpawnObjects((VaultFileDisplayMode)0, val, ref text, transform, Vector3.forward + Vector3.up);
					Logger.LogMessage((object)("Finished spawning vault spawnsmth! :) status: " + flag2));
				}
			}
			else
			{
				ItemSpawnerV2 val3 = new ItemSpawnerV2();
				ItemSpawnerID spawnerID = IM.GetSpawnerID(t_spawnerId);
				Logger.LogMessage((object)("Trying to spawn id: " + t_spawnerId));
				AnvilManager.Run(val3.SpawnItemsToRayPoint(spawnerID, position));
				Logger.LogMessage((object)("Spawned: " + t_spawnerId));
				Object.Destroy((Object)(object)val3);
			}
		}

		private static void RandHat(GronchHatCase c)
		{
			float num = Random.Range(0f, 100f);
			int num2 = 0;
			for (int num3 = m_c.Count - 1; num3 >= 2; num3--)
			{
				if (num >= m_c[num3])
				{
					num2 = num3;
					break;
				}
			}
			string text = num2 switch
			{
				2 => H_WD[Random.Range(0, H_WD.Count)], 
				3 => H_MW[Random.Range(0, H_MW.Count)], 
				4 => H_ME[Random.Range(0, H_ME.Count)], 
				5 => H_MR[Random.Range(0, H_MR.Count)], 
				6 => H_RA[Random.Range(0, H_RA.Count)], 
				7 => H_BB[Random.Range(0, H_BB.Count)], 
				_ => H_WD[Random.Range(0, H_WD.Count)], 
			};
			Logger.LogMessage((object)("Selected Cap: " + text));
			ItemSpawnerID spawnerID = IM.GetSpawnerID(text);
			c.HID = spawnerID.ItemID;
		}
	}
}