Decompiled source of Repo Events v0.0.9

RepoEvents.dll

Decompiled 11 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using PhotonRecieving;
using REPOLib;
using REPOLib.Modules;
using RepoEvents;
using RepoEvents.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RepoEvents")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RepoEvents")]
[assembly: AssemblyTitle("RepoEvents")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[HarmonyPatch(typeof(BatteryDrainPresets), "GetBatteryDrainRate")]
internal class BatteryDrainPatch
{
	private static void Postfix(ref float __result)
	{
		if (SpecialDayManager.CurrentDay == SpecialDay.RipAndTearDay)
		{
			__result *= 0.25f;
		}
	}
}
[HarmonyPatch(typeof(ItemBattery), "RemoveFullBar")]
internal class GunManagerPatch
{
	private static readonly Dictionary<ItemBattery, int> ShotCounter = new Dictionary<ItemBattery, int>();

	private static bool Prefix(ItemBattery __instance, ref int _bars)
	{
		if (SpecialDayManager.CurrentDay != SpecialDay.RipAndTearDay)
		{
			return true;
		}
		if (!ShotCounter.ContainsKey(__instance))
		{
			ShotCounter[__instance] = 0;
		}
		ShotCounter[__instance]++;
		if (ShotCounter[__instance] < 2)
		{
			return false;
		}
		ShotCounter[__instance] = 0;
		return true;
	}
}
[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
internal class ChangeLevelPatch
{
	private static void Postfix(RunManager __instance)
	{
		if (!((Object)(object)__instance.levelCurrent == (Object)null))
		{
			Plugin.Log.LogInfo((object)("Next Level: " + ((Object)__instance.levelCurrent).name));
			SpecialDayManager.Roll();
		}
	}
}
[HarmonyPatch(typeof(EnemyHealth), "Awake")]
internal class EnemyOrbHelper
{
	private static void Postfix(EnemyHealth __instance)
	{
		if (SpecialDayManager.CurrentDay == SpecialDay.RipAndTearDay)
		{
			__instance.spawnValuableMax = int.MaxValue;
			Plugin.Log.LogInfo((object)(((Object)__instance).name + " orb cap removed."));
		}
	}
}
[HarmonyPatch(typeof(EnemyDirector), "AddEnemyValuable")]
internal class EnemyOrbLimitPatch
{
	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		foreach (CodeInstruction instruction in instructions)
		{
			if (instruction.opcode == OpCodes.Ldc_I4_S && instruction.operand is sbyte value && value == 10)
			{
				Plugin.Log.LogInfo((object)"Enemy orb limit changed: 10 -> 9999");
				instruction.opcode = OpCodes.Ldc_I4;
				instruction.operand = 9999;
			}
			yield return instruction;
		}
	}
}
[HarmonyPatch(typeof(ExtractionPoint), "HaulGoalSetRPC")]
internal class ExtractionPointHelper
{
	private static void Prefix(ref int value)
	{
		if (SpecialDayManager.CurrentDay == SpecialDay.RipAndTearDay)
		{
			value = 5000;
		}
	}
}
[HarmonyPatch(typeof(BigMessageUI), "BigMessage")]
internal class NotifyTimerPatch
{
	private static void Postfix(BigMessageUI __instance, string message)
	{
		if (message.Contains("!"))
		{
			Traverse.Create((object)__instance).Field("bigMessageTimer").SetValue((object)5f);
		}
	}
}
[HarmonyPatch(typeof(ItemBattery), "ChargeBattery")]
internal class RipAndTearChargingSpeed
{
	private static bool Prefix(ref float chargeAmount)
	{
		if (SpecialDayManager.CurrentDay != SpecialDay.RipAndTearDay)
		{
			return true;
		}
		chargeAmount *= 3f;
		return true;
	}
}
namespace PhotonRecieving
{
	public class PhotonReciever : MonoBehaviourPun
	{
		[PunRPC]
		public void RecieverRPC(int day)
		{
			SpecialDayManager.SetDay((SpecialDay)day);
			Plugin.Log.LogInfo((object)$"Recieved : {(SpecialDay)day}");
		}
	}
}
namespace PhotonCreation
{
	[HarmonyPatch(typeof(RoundDirector), "Start")]
	internal class CreatePhoton
	{
		private static PhotonView photonView;

		private static void Prefix()
		{
			PhotonView[] array = Object.FindObjectsOfType<PhotonView>();
			PhotonView[] array2 = array;
			foreach (PhotonView val in array2)
			{
				if (((Object)val).name == "Run Manager PUN")
				{
					photonView = val;
					if ((Object)(object)((Component)val).GetComponent<PhotonReciever>() == (Object)null)
					{
						((Component)val).gameObject.AddComponent<PhotonReciever>();
					}
					Plugin.Log.LogInfo((object)("Photon Added to : " + ((Object)val).name));
					break;
				}
			}
			if (PhotonNetwork.IsMasterClient)
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(SendRPC());
			}
		}

		private static IEnumerator SendRPC()
		{
			yield return (object)new WaitForSeconds(1f);
			Plugin.Log.LogInfo((object)"Sending RPC");
			photonView.RPC("RecieverRPC", (RpcTarget)0, new object[1] { (int)SpecialDayManager.CurrentDay });
		}
	}
}
namespace RepoEvents
{
	[BepInPlugin("com.meliodin.repospecialdays", "Repo Special Days", "0.0.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGUID = "com.meliodin.repospecialdays";

		public const string ModName = "Repo Special Days";

		public const string ModVersion = "0.0.9";

		internal static Plugin Instance;

		internal static ManualLogSource Log;

		private Harmony harmony;

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			harmony = new Harmony("com.meliodin.repospecialdays");
			harmony.PatchAll();
			ConfigManager.Setup(((BaseUnityPlugin)this).Config);
			Log.LogWarning((object)"Waiting for REPOLib.");
			BundleLoader.OnAllBundlesLoaded += OnRepoLibReady;
			Log.LogInfo((object)"> > REPO EVENTS LOADING...");
		}

		public static void OnRepoLibReady()
		{
			Log.LogInfo((object)">> RepoLib is ready, now I will try to cache...");
			ValuableDatabase.Cache();
			ValuableDatabase.VCache();
			Log.LogInfo((object)">> SUCCESS!");
			Log.LogInfo((object)">> REPO EVENTS NOW LOADED!");
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			foreach (GameObject val in array)
			{
				if (((Object)val).name.Contains("Emerald Block"))
				{
					Log.LogInfo((object)("Emerald Block FOUND: " + ((Object)val).name));
					Log.LogInfo((object)("Name: " + ((Object)val).name + " | Root: " + ((Object)val.transform.root).name));
					ValuableObject component = val.GetComponent<ValuableObject>();
					Log.LogInfo((object)$"Have ValuableObject? : {(Object)(object)component != (Object)null}");
				}
			}
		}
	}
}
namespace RepoEvents.Patches
{
	[HarmonyPatch(typeof(GameDirector), "gameStateStart")]
	internal class TestNotify
	{
		private static bool notified;

		private static void Postfix(GameDirector __instance)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Invalid comparison between Unknown and I4
			if (!notified && !SemiFunc.MenuLevel() && SpecialDayManager.CurrentDay != SpecialDay.None && !SemiFunc.RunIsLobby() && !SemiFunc.RunIsShop() && !SemiFunc.RunIsArena() && (int)__instance.currentState == 2)
			{
				notified = true;
				SpecialDayManager.NotifySpecialDay();
				notified = false;
			}
		}
	}
	[HarmonyPatch(typeof(EnemyDirector), "Update")]
	internal class RipAndTearEnemyPatch
	{
		private static float timer;

		private static readonly FieldRef<EnemyParent, bool> SpawnedRef = AccessTools.FieldRefAccess<EnemyParent, bool>("Spawned");

		private static float GetRipAndTearRespawnTime()
		{
			int levelsCompleted = RunManager.instance.levelsCompleted;
			float num = 30f - (float)(levelsCompleted - 5) * 1.5f;
			return Mathf.Max(num, 1f);
		}

		private static void Postfix(EnemyDirector __instance)
		{
			if (SpecialDayManager.CurrentDay != SpecialDay.RipAndTearDay || !SemiFunc.IsMasterClientOrSingleplayer() || Time.time < timer)
			{
				return;
			}
			timer = Time.time + 5f;
			foreach (EnemyParent item in __instance.enemiesSpawned)
			{
				if (!((Object)(object)item == (Object)null) && !SpawnedRef.Invoke(item))
				{
					float ripAndTearRespawnTime = GetRipAndTearRespawnTime();
					if (item.DespawnedTimer > ripAndTearRespawnTime)
					{
						item.DespawnedTimerSet(ripAndTearRespawnTime, false);
						Plugin.Log.LogInfo((object)("Rip and Tear: Reduced " + item.enemyName + " respawn timer"));
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(ValuableDirector), "SpawnValuable")]
	internal class SpawnValuablePatch
	{
		private static bool Prefix(ref PrefabRef _valuable, ValuableVolume _volume, string _path)
		{
			switch (SpecialDayManager.CurrentDay)
			{
			case SpecialDay.None:
				Plugin.Log.LogInfo((object)"Today is a normal day.");
				return true;
			case SpecialDay.LoveDay:
				SpawnLoveDay(ref _valuable, ref _volume);
				return true;
			case SpecialDay.PotionDay:
				SpawnPotionDay(ref _valuable);
				return true;
			case SpecialDay.TntDay:
				SpawnTntDay(ref _valuable);
				return true;
			case SpecialDay.MinecraftDay:
				SpawnMinecraftDay(ref _valuable);
				return true;
			case SpecialDay.AnnabelleDay:
				SpawnAnnabelleDay(ref _valuable);
				return true;
			case SpecialDay.RipAndTearDay:
				return false;
			default:
				return false;
			}
		}

		private static void SpawnLoveDay(ref PrefabRef _valuable, ref ValuableVolume _volume)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			GameObject vanillaPrefab = ValuableDatabase.GetVanillaPrefab("Valuable Wizard Love Potion");
			if ((Object)(object)vanillaPrefab == (Object)null)
			{
				Plugin.Log.LogWarning((object)"LovePotion not found");
				return;
			}
			PrefabRef val = new PrefabRef();
			((PrefabRef<GameObject>)(object)val).SetPrefab(vanillaPrefab, "Valuables/02 Small/Valuable Wizard Love Potion");
			_valuable = val;
			Plugin.Log.LogInfo((object)"Swap Success!");
		}

		private static void SpawnPotionDay(ref PrefabRef _valuable)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			(string, string)[] array = new(string, string)[3]
			{
				("Valuable Wizard Levitation Potion", "Valuables/02 Small/Valuable Wizard Levitation Potion"),
				("Valuable Wizard Small Potion", "Valuables/01 Tiny/Valuable Wizard Small Potion"),
				("Valuable Wizard Master Potion", "Valuables/04 Big/Valuable Wizard Master Potion")
			};
			(string, string) tuple = array[Random.Range(0, array.Length)];
			GameObject vanillaPrefab = ValuableDatabase.GetVanillaPrefab(tuple.Item1);
			if ((Object)(object)vanillaPrefab == (Object)null)
			{
				Plugin.Log.LogWarning((object)$"{vanillaPrefab} does not exist!");
				return;
			}
			PrefabRef val = new PrefabRef();
			((PrefabRef<GameObject>)(object)val).SetPrefab(vanillaPrefab, tuple.Item2);
			_valuable = val;
			Plugin.Log.LogInfo((object)"Swap Success");
		}

		private static void SpawnTntDay(ref PrefabRef _valuable)
		{
			PrefabRef prefabRef = ValuableDatabase.GetPrefabRef("Valuable TNT");
			if (prefabRef == null)
			{
				Plugin.Log.LogWarning((object)"TNT does not exist");
				return;
			}
			_valuable = prefabRef;
			Plugin.Log.LogInfo((object)"Swap Success");
		}

		private static void SpawnMinecraftDay(ref PrefabRef _valuable)
		{
			int levelsCompleted = RunManager.instance.levelsCompleted;
			string randomMinecraftBlock = SpecialDayManager.GetRandomMinecraftBlock(levelsCompleted);
			PrefabRef prefabRef = ValuableDatabase.GetPrefabRef(randomMinecraftBlock);
			if (prefabRef == null)
			{
				Plugin.Log.LogInfo((object)("Can't find " + randomMinecraftBlock + "!"));
				return;
			}
			_valuable = prefabRef;
			Plugin.Log.LogInfo((object)("Minecraft day chose: " + randomMinecraftBlock));
		}

		private static void SpawnAnnabelleDay(ref PrefabRef _valuable)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			GameObject vanillaPrefab = ValuableDatabase.GetVanillaPrefab("Valuable Manor Scream Doll");
			if ((Object)(object)vanillaPrefab == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Annabelle not found");
				return;
			}
			PrefabRef val = new PrefabRef();
			((PrefabRef<GameObject>)(object)val).SetPrefab(vanillaPrefab, "Valuables/04 Big/Valuable Manor Scream Doll");
			_valuable = val;
			Plugin.Log.LogInfo((object)"Swap Success!");
		}
	}
}
namespace RepoEvents.Managers
{
	internal static class ConfigManager
	{
		public static ConfigEntry<int> NormalDayWeight;

		public static ConfigEntry<int> LoveDayWeight;

		public static ConfigEntry<int> PotionDayWeight;

		public static ConfigEntry<int> TntDayWeight;

		public static ConfigEntry<int> MinecraftDayWeight;

		public static ConfigEntry<int> AnnabelleDayWeight;

		public static ConfigEntry<int> RipAndTearWeight;

		public static ConfigEntry<float> NotificationSize;

		public static void Setup(ConfigFile config)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			NotificationSize = config.Bind<float>("Notification Size", "Notification Size", 25f, new ConfigDescription("Changes the text size for Notifications", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			NormalDayWeight = config.Bind<int>("Special Days", "Normal Day Chance", 70, new ConfigDescription("Chance Weight for a normal day", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			LoveDayWeight = config.Bind<int>("Special Days", "Love Day Chance", 15, new ConfigDescription("Chance weight for a love day", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			PotionDayWeight = config.Bind<int>("Special Days", "Potion Day Chance", 15, new ConfigDescription("Chance weight for a potion day", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			TntDayWeight = config.Bind<int>("Special Days", "Tnt Day Chance", 15, new ConfigDescription("Chance weight for a tnt day", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			MinecraftDayWeight = config.Bind<int>("Special Days", "Minecraft Day Chance", 15, new ConfigDescription("Chance weight for a minecraft day", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			AnnabelleDayWeight = config.Bind<int>("Special Days", "Annabelle Day Chance", 15, new ConfigDescription("Chance weight for a annabelle day", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			RipAndTearWeight = config.Bind<int>("Special Days", "RipAndTear Day Chance", 15, new ConfigDescription("Chance weight for a ripandtear day", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
		}
	}
	internal enum SpecialDay
	{
		None,
		LoveDay,
		PotionDay,
		MusicDay,
		TntDay,
		MinecraftDay,
		AnnabelleDay,
		RipAndTearDay
	}
	internal static class SpecialDayManager
	{
		private static readonly List<string> MinecraftValuables = new List<string>
		{
			"Valuable Emerald Block", "Valuable Diamond Block", "Valuable Gold Block", "Valuable Iron Block", "Valuable Emerald Ore", "Valuable Diamond Ore", "Valuable Gold Ore", "Valuable Iron Ore", "Valuable Redstone Ore", "Valuable TNT",
			"Valuable Glowstone"
		};

		private static readonly List<string> EarlyGameBlacklist = new List<string> { "Valuable Emerald Block", "Valuable Diamond Block" };

		public static SpecialDay CurrentDay { get; private set; }

		public static int HostRoll { get; private set; }

		public static bool HasMinecraftMod => Chainloader.PluginInfos.ContainsKey("com.meliodin.minecraftmod");

		public static string CurrentMinecraftValuable { get; private set; }

		public static void SetDay(SpecialDay day)
		{
			CurrentDay = day;
		}

		public static void Roll()
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer() || SemiFunc.MenuLevel() || SemiFunc.RunIsLobby() || SemiFunc.RunIsShop() || SemiFunc.RunIsArena())
			{
				return;
			}
			Plugin.Log.LogInfo((object)"Rolling for special day...");
			int num = ConfigManager.NormalDayWeight.Value + ConfigManager.LoveDayWeight.Value + ConfigManager.PotionDayWeight.Value + ConfigManager.AnnabelleDayWeight.Value + ConfigManager.RipAndTearWeight.Value;
			if (HasMinecraftMod)
			{
				num += ConfigManager.MinecraftDayWeight.Value;
				num += ConfigManager.TntDayWeight.Value;
			}
			else
			{
				Plugin.Log.LogWarning((object)"Minecraft mod NOT installed, Tnt day + Minecraft day will NOT Roll.");
			}
			int num2 = Random.Range(0, num);
			int num3 = 0;
			num3 += ConfigManager.NormalDayWeight.Value;
			if (num2 < num3)
			{
				SetDay(SpecialDay.None);
			}
			else
			{
				num3 += ConfigManager.LoveDayWeight.Value;
				if (num2 < num3)
				{
					SetDay(SpecialDay.LoveDay);
				}
				else
				{
					num3 += ConfigManager.PotionDayWeight.Value;
					if (num2 < num3)
					{
						SetDay(SpecialDay.PotionDay);
					}
					else
					{
						if (HasMinecraftMod)
						{
							num3 += ConfigManager.TntDayWeight.Value;
							if (num2 < num3)
							{
								SetDay(SpecialDay.TntDay);
								return;
							}
							num3 += ConfigManager.MinecraftDayWeight.Value;
							if (num2 < num3)
							{
								SetDay(SpecialDay.MinecraftDay);
								return;
							}
						}
						num3 += ConfigManager.AnnabelleDayWeight.Value;
						if (num2 < num3)
						{
							SetDay(SpecialDay.AnnabelleDay);
						}
						else
						{
							num3 += ConfigManager.RipAndTearWeight.Value;
							if (num2 < num3)
							{
								SetDay(SpecialDay.RipAndTearDay);
							}
						}
					}
				}
			}
			if (CurrentDay == SpecialDay.RipAndTearDay && RunManager.instance.levelsCompleted < 5)
			{
				Plugin.Log.LogInfo((object)"Rip and tear rolled early, rolling again...");
				Roll();
			}
			Plugin.Log.LogInfo((object)$"Result: {CurrentDay}");
		}

		public static void NotifySpecialDay()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log.LogInfo((object)"Notify Triggered");
			if (Random.Range(0, 1000000) == 1)
			{
				SemiFunc.UIFocusText("Fuck you STRESSED4LIFE20.", Color.magenta, Color.white, 3f);
			}
			switch (CurrentDay)
			{
			case SpecialDay.None:
				SemiFunc.UIFocusText("No special day today", Color.white, Color.white, 3f);
				break;
			case SpecialDay.LoveDay:
				SemiFunc.UIBigMessage("Love Day!", "{heart}", ConfigManager.NotificationSize.Value, Color.magenta, Color.white);
				SemiFunc.UIFocusText("Spread the love... and get all the potions!", Color.white, Color.white, 3f);
				break;
			case SpecialDay.PotionDay:
				SemiFunc.UIBigMessage("Potion Day!", "{spiral}", ConfigManager.NotificationSize.Value, Color.cyan, Color.white);
				SemiFunc.UIFocusText("Abra Cadabra!", Color.white, Color.white, 3f);
				break;
			case SpecialDay.AnnabelleDay:
				SemiFunc.UIBigMessage("Annabelle Day!", "{evil_mouth}", ConfigManager.NotificationSize.Value, Color.black, Color.white);
				SemiFunc.UIFocusText("Exorcist on speed-dial?", Color.white, Color.white, 3f);
				break;
			case SpecialDay.TntDay:
				SemiFunc.UIBigMessage("TNT Day!", "{bang}", ConfigManager.NotificationSize.Value, Color.red, Color.white);
				SemiFunc.UIFocusText("Careful now.", Color.white, Color.white, 3f);
				break;
			case SpecialDay.MinecraftDay:
				SemiFunc.UIBigMessage("Minecraft Day!", "{sparkle}", ConfigManager.NotificationSize.Value, Color.gray, Color.white);
				SemiFunc.UIFocusText("Let's hope you can fit them all", Color.white, Color.white, 3f);
				break;
			case SpecialDay.RipAndTearDay:
				SemiFunc.UIBigMessage("RIP AND TEAR!", "{burnmoney}", ConfigManager.NotificationSize.Value, Color.white, Color.white);
				SemiFunc.UIFocusText("Shoot. Kill. Cash. $$$", Color.white, Color.white, 3f);
				break;
			case SpecialDay.MusicDay:
				break;
			}
		}

		public static string GetRandomMinecraftBlock(int level)
		{
			List<string> list = new List<string>(MinecraftValuables);
			if (level < 5)
			{
				foreach (string item in EarlyGameBlacklist)
				{
					list.Remove(item);
				}
			}
			return list[Random.Range(0, list.Count)];
		}
	}
	internal static class ValuableAdjustments
	{
		private static readonly FieldInfo TinyField = AccessTools.Field(typeof(ValuableDirector), "tinyMaxAmount");

		private static readonly FieldInfo SmallField = AccessTools.Field(typeof(ValuableDirector), "smallMaxAmount");

		private static readonly FieldInfo MediumField = AccessTools.Field(typeof(ValuableDirector), "mediumMaxAmount");

		private static readonly FieldInfo BigField = AccessTools.Field(typeof(ValuableDirector), "bigMaxAmount");

		public static void AdjustFor(string valuableName, ValuableDirector director)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected I4, but got Unknown
			Type requiredSize = ValuableSizeManager.GetRequiredSize(valuableName);
			Type val = requiredSize;
			switch (val - 1)
			{
			case 0:
			{
				int num8 = (int)TinyField.GetValue(director);
				int num9 = (int)SmallField.GetValue(director);
				SmallField.SetValue(director, num9 + num8);
				TinyField.SetValue(director, 0);
				break;
			}
			case 1:
			{
				int num5 = (int)TinyField.GetValue(director);
				int num6 = (int)SmallField.GetValue(director);
				int num7 = (int)MediumField.GetValue(director);
				MediumField.SetValue(director, num7 + num6 + num5);
				TinyField.SetValue(director, 0);
				SmallField.SetValue(director, 0);
				break;
			}
			case 2:
			{
				int num = (int)TinyField.GetValue(director);
				int num2 = (int)SmallField.GetValue(director);
				int num3 = (int)MediumField.GetValue(director);
				int num4 = (int)BigField.GetValue(director);
				BigField.SetValue(director, num4 + num3 + num2 + num);
				TinyField.SetValue(director, 0);
				SmallField.SetValue(director, 0);
				MediumField.SetValue(director, 0);
				break;
			}
			}
		}

		public static void Apply(ValuableDirector director)
		{
			switch (SpecialDayManager.CurrentDay)
			{
			case SpecialDay.None:
				break;
			case SpecialDay.LoveDay:
				AdjustFor("Valuable Wizard Love Potion", director);
				break;
			case SpecialDay.PotionDay:
				AdjustFor("Valuable Wizard Master Potion", director);
				break;
			case SpecialDay.TntDay:
				AdjustFor("Valuable TNT", director);
				break;
			case SpecialDay.MinecraftDay:
				AdjustFor("Valuable Emerald Block", director);
				AdjustFor("Valuable Diamond Block", director);
				AdjustFor("Valuable Gold Block", director);
				AdjustFor("Valuable Iron Block", director);
				AdjustFor("Valuable Emerald Ore", director);
				AdjustFor("Valuable Diamond Ore", director);
				AdjustFor("Valuable Gold Ore", director);
				AdjustFor("Valuable Iron Ore", director);
				AdjustFor("Valuable Redstone Ore", director);
				AdjustFor("Valuable TNT", director);
				AdjustFor("Valuable Glowstone", director);
				break;
			case SpecialDay.AnnabelleDay:
				AdjustFor("Valuable Manor Scream Doll", director);
				break;
			case SpecialDay.MusicDay:
				break;
			}
		}
	}
	internal static class ValuableDatabase
	{
		private static readonly Dictionary<string, GameObject> ValuableLookup = new Dictionary<string, GameObject>();

		private static readonly Dictionary<string, GameObject> VanillaValuableLookup = new Dictionary<string, GameObject>();

		public static void Cache()
		{
			ValuableLookup.Clear();
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			foreach (GameObject val in array)
			{
				if (!((Object)(object)val.GetComponent<ValuableObject>() == (Object)null))
				{
					ValuableLookup[((Object)val).name] = val;
				}
			}
			Plugin.Log.LogInfo((object)$"Cached {ValuableLookup.Count} Valuables");
		}

		public static void VCache()
		{
			VanillaValuableLookup.Clear();
			GameObject[] array = Resources.LoadAll<GameObject>("Valuables");
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				VanillaValuableLookup[((Object)val).name] = val;
			}
			Plugin.Log.LogInfo((object)$"V-Cached: {VanillaValuableLookup.Count}");
		}

		public static GameObject GetPrefab(string name)
		{
			GameObject vanillaPrefab = GetVanillaPrefab(name);
			return ((Object)(object)vanillaPrefab != (Object)null) ? vanillaPrefab.gameObject : null;
		}

		public static GameObject GetVanillaPrefab(string name)
		{
			VanillaValuableLookup.TryGetValue(name, out var value);
			return value;
		}

		public static PrefabRef GetPrefabRef(string name)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(Valuables), "_valuablesRegistered");
			List<PrefabRef> source = (List<PrefabRef>)fieldInfo.GetValue(null);
			PrefabRef val = ((IEnumerable<PrefabRef>)source).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef x) => ((PrefabRef<GameObject>)(object)x).PrefabName == name));
			if (val == null)
			{
				Plugin.Log.LogInfo((object)("Prefab not found: " + name));
			}
			else
			{
				Plugin.Log.LogInfo((object)("Found: " + name));
			}
			return val;
		}
	}
	[HarmonyPatch]
	internal class ValuableSizeManager
	{
		private static readonly Dictionary<string, Type> SizeRules = new Dictionary<string, Type>
		{
			{
				"Valuable Wizard Love Potion",
				(Type)1
			},
			{
				"Valuable Wizard Levitation Potion",
				(Type)1
			},
			{
				"Valuable Wizard Small Potion",
				(Type)0
			},
			{
				"Valuable Wizard Master Potion",
				(Type)3
			},
			{
				"Valuable TNT",
				(Type)3
			},
			{
				"Valuable Emerald Block",
				(Type)3
			},
			{
				"Valuable Diamond Block",
				(Type)3
			},
			{
				"Valuable Gold Block",
				(Type)3
			},
			{
				"Valuable Iron Block",
				(Type)3
			},
			{
				"Valuable Diamond Ore",
				(Type)3
			},
			{
				"Valuable Emerald Ore",
				(Type)3
			},
			{
				"Valuable Gold Ore",
				(Type)3
			},
			{
				"Valuable Redstone Ore",
				(Type)3
			},
			{
				"Valuable Iron Ore",
				(Type)3
			},
			{
				"Valuable Glowstone",
				(Type)3
			},
			{
				"Valuable Manor Scream Doll",
				(Type)3
			}
		};

		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(AccessTools.Inner(typeof(ValuableDirector), "<SetupHost>d__82"), "MoveNext", (Type[])null, (Type[])null);
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			FieldInfo veryTallField = AccessTools.Field(typeof(ValuableDirector), "veryTallMaxAmount");
			foreach (CodeInstruction instruction in instructions)
			{
				int num;
				if (instruction.opcode == OpCodes.Stfld)
				{
					object operand = instruction.operand;
					if (operand is FieldInfo field)
					{
						num = ((field == veryTallField) ? 1 : 0);
						goto IL_00de;
					}
				}
				num = 0;
				goto IL_00de;
				IL_00de:
				if (num != 0)
				{
					Plugin.Log.LogInfo((object)"FOUND veryTallMax");
					yield return instruction;
					yield return new CodeInstruction(OpCodes.Ldloc_1, (object)null);
					yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ValuableAdjustments), "Apply", (Type[])null, (Type[])null));
				}
				else
				{
					yield return instruction;
				}
			}
		}

		public static Type GetRequiredSize(string valuableName)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (SizeRules.TryGetValue(valuableName, out var value))
			{
				Plugin.Log.LogInfo((object)$"{valuableName} requires {value}");
				return value;
			}
			Plugin.Log.LogWarning((object)(valuableName + " not found in Size Rules."));
			return (Type)0;
		}
	}
}