Decompiled source of Chaos Mod v1.2.1

plugins/ChaosMod/ChaosMod.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using ChaosMod.Events;
using ChaosMod.UI;
using DG.Tweening;
using DarkMachine.UI;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Video;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ChaosMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ChaosMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8da1cd7b-300c-4747-ac63-98141c78df4b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ChaosMod
{
	[BepInPlugin("nachariah.whiteknuckle.chaosmod", "ChaosMod", "1.2.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string pluginGuid = "nachariah.whiteknuckle.chaosmod";

		public const string pluginVersion = "1.2.1";

		public static Dictionary<int, float> difficultyTimers = new Dictionary<int, float>();

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[ChaosMod - Awake] Patching...");
			Harmony val = new Harmony("nachariah.whiteknuckle.chaosmod");
			val.PatchAll();
			EventManager.LoadBundle();
			EventManager.FillList();
			SceneManager.sceneLoaded += OnSceneLoaded;
			difficultyTimers.Add(0, 20f);
			difficultyTimers.Add(1, 10f);
			difficultyTimers.Add(2, 5f);
			difficultyTimers.Add(3, 2f);
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name == "Game-Main")
			{
				CommandConsole.hasCheated = true;
				CL_GameManager.gamemode.allowAchievements = false;
				CL_GameManager.gamemode.allowCheatedScores = false;
				Main.GameStart();
			}
			else if (((Scene)(ref scene)).name == "Main-Menu")
			{
				ChaosUI.LoadMenuMenu();
			}
		}
	}
	public static class Main
	{
		private static bool active = false;

		public static bool hardMode = false;

		private static float timeMax = 10f;

		private static float timeLeft;

		public static int pauseThreshold = 0;

		private static bool inCutscene = false;

		private static float timeSinceStart = 0f;

		public static void MainUpdate()
		{
			if (!active || pauseThreshold > 0)
			{
				return;
			}
			if (OS_Manager.IsAnyComputerInUse())
			{
				timeSinceStart = 0f;
				return;
			}
			float num = Time.deltaTime;
			if (timeSinceStart < 5f)
			{
				timeSinceStart += num;
				num *= timeSinceStart / 5f;
			}
			timeLeft -= num;
			if (hardMode && !ChaosSettings.customTimer)
			{
				timeLeft -= num;
			}
			if (timeLeft < 0f)
			{
				EventManager.RandomEvent();
				timeLeft = timeMax;
			}
			ChaosUI.instance.SetTimer(timeLeft / timeMax);
		}

		private static void StartChaos()
		{
			EventManager.FillList();
			EventManager.eventsOnCooldown.Clear();
			hardMode = CL_GameManager.IsHardmode();
			float value;
			if (ChaosSettings.customTimer)
			{
				timeMax = ChaosSettings.customTimerValue;
			}
			else if (Plugin.difficultyTimers.TryGetValue(ChaosSettings.difficulty, out value))
			{
				timeMax = value;
			}
			else
			{
				timeMax = 10f;
			}
			timeLeft = timeMax;
			ChaosUI.ShowUI();
			pauseThreshold = 0;
			timeSinceStart = 0f;
			active = true;
		}

		public static void GameStart()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (active)
			{
				active = false;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "Game-Main")
			{
				StartChaos();
			}
		}

		public static void AddPause(bool b = true, bool cutscene = false)
		{
			if (cutscene)
			{
				if (inCutscene == b)
				{
					return;
				}
				inCutscene = b;
			}
			if (b)
			{
				pauseThreshold++;
			}
			else
			{
				pauseThreshold--;
			}
			Debug.Log((object)("[ChaosMod - AddPause] Add: " + b + " | Pause Count: " + pauseThreshold));
			if (pauseThreshold != 0)
			{
				timeLeft = timeMax;
				timeSinceStart = 0f;
				ChaosUI.instance.SetTimer(0f);
				ChaosUI.instance.RemoveAllEntries();
			}
		}
	}
	public static class ChaosSettings
	{
		public static int difficulty = 1;

		public static bool customTimer = false;

		public static float customTimerValue = 10f;

		public static float loggerYOffset = 0f;

		public static Dictionary<string, bool> eventEnabled = new Dictionary<string, bool>();

		public static void Load()
		{
			difficulty = PlayerPrefs.GetInt("Chaos_Difficulty", 1);
			customTimer = PlayerPrefs.GetInt("Chaos_CustomTimer", 0) == 1;
			customTimerValue = PlayerPrefs.GetFloat("Chaos_CustomTimerValue", 10f);
			loggerYOffset = PlayerPrefs.GetFloat("Chaos_LoggerYOffset", 0f);
			foreach (string item in eventEnabled.Keys.ToList())
			{
				eventEnabled[item] = PlayerPrefs.GetInt("Chaos_Event_" + item, 1) == 1;
			}
		}

		public static void Save()
		{
			PlayerPrefs.SetInt("Chaos_Difficulty", difficulty);
			PlayerPrefs.SetInt("Chaos_CustomTimer", customTimer ? 1 : 0);
			PlayerPrefs.SetFloat("Chaos_CustomTimerValue", customTimerValue);
			PlayerPrefs.SetFloat("Chaos_LoggerYOffset", loggerYOffset);
			foreach (KeyValuePair<string, bool> item in eventEnabled)
			{
				PlayerPrefs.SetInt("Chaos_Event_" + item.Key, item.Value ? 1 : 0);
			}
			PlayerPrefs.Save();
		}
	}
	public class ForceMonitor : MonoBehaviour
	{
		private bool active = false;

		public UT_PlayerForceMover RelatedMover;

		public void Initialize(UT_PlayerForceMover mover)
		{
			RelatedMover = mover;
			if (mover.active)
			{
				active = true;
				Main.AddPause();
			}
		}

		private void OnEnable()
		{
			if (Object.op_Implicit((Object)(object)RelatedMover) && RelatedMover.active)
			{
				active = true;
				Main.AddPause();
			}
		}

		private void OnDisable()
		{
			if (Object.op_Implicit((Object)(object)RelatedMover) && RelatedMover.active)
			{
				active = false;
				Main.AddPause(b: false);
			}
		}

		public void ChangeState(bool b)
		{
			if (active != b)
			{
				active = b;
				Main.AddPause(b);
			}
		}
	}
	public class TakeOverMonitor : MonoBehaviour
	{
		private bool active = false;

		public UT_PlayerTakeOver RelatedMover;

		public void Initialize(UT_PlayerTakeOver mover)
		{
			RelatedMover = mover;
			if (mover.active)
			{
				active = true;
				Main.AddPause();
			}
		}

		private void OnEnable()
		{
			if (Object.op_Implicit((Object)(object)RelatedMover) && RelatedMover.active)
			{
				active = true;
				Main.AddPause();
			}
		}

		private void OnDisable()
		{
			if (Object.op_Implicit((Object)(object)RelatedMover) && RelatedMover.active)
			{
				active = false;
				Main.AddPause(b: false);
			}
		}

		public void ChangeState(bool b)
		{
			if (active != b)
			{
				active = b;
				Main.AddPause(b);
			}
		}
	}
}
namespace ChaosMod.UI
{
	public class ChaosUI : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Event, bool> <>9__27_0;

			public static UnityAction<int> <>9__33_0;

			public static UnityAction<float> <>9__33_1;

			public static UnityAction<float> <>9__33_3;

			public static UnityAction <>9__33_4;

			internal bool <SetEndScreens>b__27_0(Event e)
			{
				bool value;
				return ChaosSettings.eventEnabled.TryGetValue(e.name, out value) && value;
			}

			internal void <BuildChaosSettings>b__33_0(int i)
			{
				ChaosSettings.difficulty = i;
				ChaosSettings.Save();
			}

			internal void <BuildChaosSettings>b__33_1(float b)
			{
				ChaosSettings.customTimerValue = b;
				ChaosSettings.Save();
			}

			internal void <BuildChaosSettings>b__33_3(float v)
			{
				ChaosSettings.loggerYOffset = v;
				ChaosSettings.Save();
			}

			internal void <BuildChaosSettings>b__33_4()
			{
				ChaosUIHelpers.SetAllToggles(!ChaosSettings.eventEnabled["Perk Overdose"]);
			}
		}

		public static ChaosUI instance;

		public TMP_FontAsset ticketingFont = null;

		private static GameObject chaosSettingsPage;

		private static List<Transform> contentColumns = new List<Transform>();

		private static GameObject toggleTemplate;

		private static GameObject sliderTemplate;

		private static GameObject textTemplate;

		private static GameObject dropdownTemplate;

		private static GameObject buttonTemplate;

		public static Dictionary<string, string> nameTruncates = new Dictionary<string, string>();

		private GameObject canvasObj;

		private RectTransform bgRect;

		private RectTransform fillRect;

		private RectTransform listRoot;

		private static GameObject root = null;

		private readonly List<EventEntry> entries = new List<EventEntry>();

		public static List<Toggle> EventToggles = new List<Toggle>();

		private static Dictionary<int, string> difficultyDict = null;

		public static void ShowUI()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)instance == (Object)null)
			{
				GameObject val = new GameObject("ChaosTimer");
				instance = val.AddComponent<ChaosUI>();
				instance.CreateUI();
				if ((Object)(object)root != (Object)null)
				{
					root.SetActive(false);
				}
			}
		}

		private void CreateUI()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0093: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			canvasObj = new GameObject();
			canvasObj.transform.parent = ((Component)this).transform;
			Canvas val = canvasObj.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 999;
			canvasObj.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)1;
			GameObject val2 = new GameObject("Background");
			val2.transform.parent = canvasObj.transform;
			Image val3 = val2.AddComponent<Image>();
			((Graphic)val3).color = new Color(0f, 0f, 0f, 0.3f);
			bgRect = ((Graphic)val3).rectTransform;
			bgRect.anchorMin = Vector2.zero;
			bgRect.anchorMax = Vector2.right;
			bgRect.pivot = Vector2.right / 2f;
			bgRect.sizeDelta = new Vector2(0f, 4f);
			bgRect.anchoredPosition = new Vector2(0f, 0f);
			GameObject val4 = new GameObject("Background");
			val4.transform.parent = val2.transform;
			Image val5 = val4.AddComponent<Image>();
			((Graphic)val5).color = new Color(1f, 1f, 1f, 0.6f);
			val5.type = (Type)3;
			val5.fillMethod = (FillMethod)0;
			val5.fillOrigin = 0;
			val5.fillAmount = 0f;
			fillRect = ((Graphic)val5).rectTransform;
			fillRect.anchorMin = Vector2.zero;
			fillRect.anchorMax = Vector2.up;
			fillRect.pivot = Vector2.up / 2f;
			RectTransform obj = fillRect;
			Rect rect = bgRect.rect;
			obj.sizeDelta = new Vector2(((Rect)(ref rect)).width, 0f);
			fillRect.anchoredPosition = Vector2.zero;
			GameObject val6 = new GameObject("EventList");
			val6.transform.SetParent(canvasObj.transform, false);
			listRoot = val6.AddComponent<RectTransform>();
			listRoot.anchorMin = new Vector2(1f, 0f);
			listRoot.anchorMax = new Vector2(1f, 0f);
			listRoot.pivot = new Vector2(1f, 0f);
			listRoot.sizeDelta = new Vector2(100f, 0f);
			listRoot.anchoredPosition = new Vector2(-4f, 25f);
			ticketingFont = FindTicketingFont();
		}

		public void SetTimer(float value)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)fillRect == (Object)null) && !((Object)(object)bgRect == (Object)null))
			{
				value = Mathf.Clamp01(value);
				Rect rect = bgRect.rect;
				float width = ((Rect)(ref rect)).width;
				fillRect.sizeDelta = new Vector2(width * value, 0f);
			}
		}

		public EventEntry AddEntry(string name, float time, bool doubleEvent)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)listRoot == (Object)null)
			{
				return null;
			}
			GameObject val = new GameObject(name);
			val.transform.SetParent((Transform)(object)listRoot, false);
			EventEntry eventEntry = val.AddComponent<EventEntry>();
			eventEntry.Wake(name, time, this, doubleEvent);
			entries.Insert(0, eventEntry);
			RepositionEntries();
			return eventEntry;
		}

		public void RemoveEntry(EventEntry entry)
		{
			if (entries.Remove(entry))
			{
				RepositionEntries();
			}
		}

		public void RemoveAllEntries()
		{
			foreach (EventEntry entry in entries)
			{
				Object.Destroy((Object)(object)((Component)entry).gameObject);
			}
			RepositionEntries();
		}

		private void RepositionEntries()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			float num = ChaosSettings.loggerYOffset;
			for (int i = 0; i < entries.Count; i++)
			{
				entries[i].SetTargetPosition(new Vector2(0f, num));
				num += entries[i].Height + 6f;
			}
		}

		private static void LoadNameTruncates()
		{
			nameTruncates["You are playing in IRON KNUCKLE mode. No perks for you!"] = "IRON KNUCKLE MODE";
			nameTruncates["Will you be my buddy?"] = "Be my buddy?";
			nameTruncates["I'll take that, it's mine now"] = "I'll Take That";
			nameTruncates["Give up, you're surrounded"] = "You're Surrounded";
		}

		private static TMP_FontAsset FindTicketingFont()
		{
			TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
			foreach (TMP_FontAsset val in array)
			{
				if (((Object)val).name == "Ticketing SDF")
				{
					return val;
				}
			}
			Debug.LogWarning((object)"[Chaos - FindTicketingFont] Ticketing SDF font not found");
			return null;
		}

		public static void SetEndScreens()
		{
			string text = "Chaos Mod";
			if (difficultyDict == null)
			{
				difficultyDict = new Dictionary<int, string>();
				difficultyDict.Add(0, "Easy");
				difficultyDict.Add(1, "Normal");
				difficultyDict.Add(2, "Hard");
				difficultyDict.Add(3, "IMPOSSIBLE");
			}
			string value;
			if (ChaosSettings.customTimer)
			{
				text = text + " | " + ChaosSettings.customTimerValue.ToString("0.##") + "s Timer";
			}
			else if (difficultyDict.TryGetValue(ChaosSettings.difficulty, out value))
			{
				text = text + " | " + value;
			}
			if (EventManager.Events.Count == 0)
			{
				EventManager.FillList();
			}
			bool value2;
			List<Event> list = EventManager.Events.Where((Event e) => ChaosSettings.eventEnabled.TryGetValue(e.name, out value2) && value2).ToList();
			if (EventManager.Events.Count != list.Count)
			{
				text = text + " | " + list.Count + " Event";
				if (list.Count != 1)
				{
					text += "s";
				}
			}
			CL_GameManager.gMan.statManager.GetScoreScreen(false).SetTip(text);
			CL_GameManager.gMan.statManager.GetScoreScreen(true).SetTip(text);
			if (CL_GameManager.curDeathType != null)
			{
				CL_GameManager.gMan.statManager.GetScoreScreen(false).SetDeathText(CL_GameManager.curDeathType.deathText);
			}
		}

		public void FlashScreen(Color color, float duration = 0.15f)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_003e: 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)
			//IL_0059: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)canvasObj == (Object)null))
			{
				GameObject val = new GameObject("ScreenFlash");
				val.transform.SetParent(canvasObj.transform, false);
				Image val2 = val.AddComponent<Image>();
				((Graphic)val2).color = color;
				RectTransform rectTransform = ((Graphic)val2).rectTransform;
				rectTransform.anchorMin = Vector2.zero;
				rectTransform.anchorMax = Vector2.one;
				rectTransform.offsetMin = Vector2.zero;
				rectTransform.offsetMax = Vector2.zero;
				((MonoBehaviour)this).StartCoroutine(FlashRoutine(val2, duration));
			}
		}

		private IEnumerator FlashRoutine(Image flash, float duration)
		{
			Color start = ((Graphic)flash).color;
			float t = 0f;
			while (t < duration)
			{
				t += Time.deltaTime;
				Color c = start;
				c.a = Mathf.Lerp(start.a, 0f, t / duration);
				((Graphic)flash).color = c;
				yield return null;
			}
			Object.Destroy((Object)(object)((Component)flash).gameObject);
		}

		public static void LoadMenuMenu()
		{
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_009c: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Expected O, but got Unknown
			if ((Object)(object)root == (Object)null)
			{
				root = new GameObject("ChaosMainMenuUI");
				Object.DontDestroyOnLoad((Object)(object)root);
				Canvas val = root.AddComponent<Canvas>();
				val.renderMode = (RenderMode)0;
				val.sortingOrder = 1;
				root.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)1;
				root.AddComponent<GraphicRaycaster>();
				TMP_FontAsset font = FindTicketingFont();
				CreateText(root.transform, "CHAOS MOD v1.2.1", font, 14f, (TextAlignmentOptions)260, new Vector2(1f, 1f), new Vector2(-5f, -30f), new Vector2(250f, 30f));
				LoadNameTruncates();
			}
			root.SetActive(true);
			GameObject val2 = GameObject.Find("Canvas - Main Menu/Main Menu/Support Menu/");
			GameObject val3 = Object.Instantiate<GameObject>(((Component)val2.transform.Find("Update Info")).gameObject);
			val3.transform.parent = val2.transform;
			val3.transform.SetAsFirstSibling();
			val3.transform.localScale = Vector3.one;
			((Graphic)val3.GetComponent<Image>()).color = new Color(0.5f, 0.5f, 1f, 1f);
			TextMeshProUGUI component = ((Component)val3.transform.GetChild(0)).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = "Chaos Settings";
			((Graphic)component).color = new Color(1f, 1f, 1f, 0.25f);
			ColorBlock colors = default(ColorBlock);
			((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0.75f);
			((ColorBlock)(ref colors)).highlightedColor = new Color(0.2406f, 0.2406f, 1f, 0.9f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.0991f, 0.0991f, 1f, 1f);
			((ColorBlock)(ref colors)).selectedColor = new Color(0f, 0f, 1f, 1f);
			((ColorBlock)(ref colors)).disabledColor = new Color(0.7843f, 0.7843f, 0.7843f, 0.502f);
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			((ColorBlock)(ref colors)).fadeDuration = 0.1f;
			Button component2 = val3.GetComponent<Button>();
			((Selectable)component2).colors = colors;
			if ((Object)(object)root.transform.Find("Chaos Settings") == (Object)null)
			{
				CreateOptionsPanel(root.transform);
			}
			GameObject gameObject = ((Component)root.transform.Find("Chaos Settings")).gameObject;
			gameObject.SetActive(true);
			UI_MenuScreen uiScreen = gameObject.GetComponent<UI_MenuScreen>();
			((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
			{
				uiScreen.Open();
			});
		}

		private static GameObject CreateOptionsPanel(Transform root)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = GameObject.Find("Canvas - Screens/Screens/Canvas - Screen - Settings/Settings Menu/SettingsParent/Settings Pane").transform;
			GameObject val = Object.Instantiate<GameObject>(((Component)transform).gameObject, root);
			val.SetActive(false);
			((Object)val).name = "Chaos Settings";
			val.transform.localScale = Vector3.one * 0.37f;
			chaosSettingsPage = val;
			PreparePage(val);
			return val;
		}

		private static void PreparePage(GameObject page)
		{
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Expected O, but got Unknown
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Expected O, but got Unknown
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Expected O, but got Unknown
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Expected O, but got Unknown
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Expected O, but got Unknown
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Expected O, but got Unknown
			Transform val = page.transform.Find("Video Settings").Find("Main Panel").Find("Tab - Video");
			contentColumns.Add(val.Find("Column - Video"));
			contentColumns.Add(val.Find("Column - 2 Other"));
			contentColumns.Add(val.Find("Column - 3"));
			((TMP_Text)((Component)page.transform.Find("Overview Titles").Find("Title Text")).GetComponent<TextMeshProUGUI>()).text = "CHAOS SETTINGS";
			toggleTemplate = ((Component)contentColumns[0].Find("Vsync Toggle")).gameObject;
			sliderTemplate = ((Component)contentColumns[0].Find("SliderAsset - FOV")).gameObject;
			textTemplate = ((Component)contentColumns[0].Find("Video Settings")).gameObject;
			dropdownTemplate = ((Component)contentColumns[0].Find("Screen Resolution")).gameObject;
			buttonTemplate = ((Component)page.transform.Find("Video Settings").Find("Controls Page Tab Selector").Find("Video")).gameObject;
			((Component)page.transform.Find("Tab Selection Hor")).gameObject.SetActive(false);
			((Component)page.transform.Find("Video Settings").Find("Controls Page Tab Selector")).gameObject.SetActive(false);
			((Component)page.transform.Find("Video Settings").Find("Tab Title")).gameObject.SetActive(false);
			Object.Destroy((Object)(object)((Component)page.transform.Find("Video Settings").Find("Main Panel").Find("Tab - Audio")).gameObject);
			foreach (Transform item in contentColumns[0])
			{
				Transform val2 = item;
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
			foreach (Transform item2 in contentColumns[1])
			{
				Transform val3 = item2;
				Object.Destroy((Object)(object)((Component)val3).gameObject);
			}
			foreach (Transform item3 in contentColumns[2])
			{
				Transform val4 = item3;
				Object.Destroy((Object)(object)((Component)val4).gameObject);
			}
			UI_LerpOpen component = page.GetComponent<UI_LerpOpen>();
			Object.Destroy((Object)(object)component);
			page.transform.localPosition = Vector3.zero;
			component = page.AddComponent<UI_LerpOpen>();
			component.startHidden = true;
			component.startPosition = new Vector3(3000f, 0f, 0f);
			component.affectScale = false;
			component.affectPosition = true;
			component.hideOpposite = true;
			component.positionLerpTime = 0.6f;
			component.easeOut = (Ease)8;
			component.easeIn = (Ease)9;
			FieldInfo field = typeof(UI_MenuScreen).GetField("menu", BindingFlags.Instance | BindingFlags.NonPublic);
			UI_MenuScreen uiScreen = page.AddComponent<UI_MenuScreen>();
			uiScreen.openEvent = new UnityEvent();
			uiScreen.closeEvent = new UnityEvent();
			uiScreen.openEvent.AddListener(new UnityAction(component.Show));
			uiScreen.closeEvent.AddListener(new UnityAction(component.Hide));
			field.SetValue(uiScreen, GameObject.Find("Canvas - Main Menu/Main Menu").GetComponent<UI_Menu>());
			((UnityEvent)((Component)page.transform.Find("Save And Close")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				uiScreen.CloseScreen();
			});
			BuildChaosSettings();
		}

		private static void BuildChaosSettings()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Expected O, but got Unknown
			CloneText(contentColumns[0], "Timer");
			List<OptionData> list = new List<OptionData>();
			list.Add(new OptionData("Easy (20s)"));
			list.Add(new OptionData("Normal (10s)"));
			list.Add(new OptionData("Hard (5s)"));
			list.Add(new OptionData("IMPOSSIBLE (2s)"));
			TMP_Dropdown difficultydropdown = CloneDropdown(contentColumns[0], "Difficulty", list, ChaosSettings.difficulty, delegate(int i)
			{
				ChaosSettings.difficulty = i;
				ChaosSettings.Save();
			});
			CloneText(contentColumns[0], "");
			SubmitSlider timerslider = CloneSlider(contentColumns[1], "Timer Interval", ChaosSettings.customTimerValue, 0.1f, 120f, delegate(float b)
			{
				ChaosSettings.customTimerValue = b;
				ChaosSettings.Save();
			});
			CloneToggle(contentColumns[0], "Custom Timer", ChaosSettings.customTimer, delegate(bool v)
			{
				ChaosSettings.customTimer = v;
				((Selectable)timerslider).interactable = v;
				((Selectable)difficultydropdown).interactable = !v;
				ChaosSettings.Save();
			});
			((Selectable)timerslider).interactable = ChaosSettings.customTimer;
			((Selectable)difficultydropdown).interactable = !ChaosSettings.customTimer;
			((Component)timerslider).transform.parent.parent = contentColumns[0];
			CloneText(contentColumns[1], "UI");
			CloneSlider(contentColumns[1], "Event Logger Vertical Offset", ChaosSettings.loggerYOffset, 0f, 400f, delegate(float v)
			{
				ChaosSettings.loggerYOffset = v;
				ChaosSettings.Save();
			});
			CloneText(contentColumns[2], "Active Events");
			RectTransform content;
			ScrollRect val = CreateScrollRect(contentColumns[2], new Vector2(310f, 230f), out content);
			foreach (KeyValuePair<string, bool> item2 in ChaosSettings.eventEnabled)
			{
				string eventName = item2.Key;
				Toggle item = CloneToggle((Transform)(object)content, eventName, item2.Value, delegate(bool b)
				{
					ChaosSettings.eventEnabled[eventName] = b;
					ChaosSettings.Save();
				});
				EventToggles.Add(item);
			}
			Toggle val2 = CloneToggle((Transform)(object)content, "", value: false, null);
			((Component)((Component)val2).transform.GetChild(0)).gameObject.SetActive(false);
			Transform parent = contentColumns[2];
			object obj = <>c.<>9__33_4;
			if (obj == null)
			{
				UnityAction val3 = delegate
				{
					ChaosUIHelpers.SetAllToggles(!ChaosSettings.eventEnabled["Perk Overdose"]);
				};
				<>c.<>9__33_4 = val3;
				obj = (object)val3;
			}
			CloneButton(parent, "TOGGLE ALL", (UnityAction)obj);
		}

		public static TMP_Text CreateText(Transform parent, string text, TMP_FontAsset font, float size, TextAlignmentOptions alignment, Vector2 anchor, Vector2 pos, Vector2 dimensions)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0023: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_006f: 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)
			GameObject val = new GameObject("Text");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			Vector2 anchorMin = (val2.anchorMax = anchor);
			val2.anchorMin = anchorMin;
			val2.pivot = anchor;
			val2.anchoredPosition = pos;
			val2.sizeDelta = dimensions;
			TMP_Text val4 = (TMP_Text)(object)val.AddComponent<TextMeshProUGUI>();
			val4.text = text;
			val4.font = font;
			val4.fontSize = size;
			val4.alignment = alignment;
			((Graphic)val4).color = Color.white;
			return val4;
		}

		private static TextMeshProUGUI CloneText(Transform parent, string label)
		{
			GameObject val = Object.Instantiate<GameObject>(textTemplate, parent);
			TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
			((Object)val).name = label;
			val.SetActive(true);
			((TMP_Text)component).text = label;
			((Behaviour)component).enabled = true;
			((Behaviour)val.GetComponent<LayoutElement>()).enabled = true;
			return component;
		}

		private static Button CloneButton(Transform parent, string label, UnityAction callback)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(buttonTemplate, parent);
			Button component = val.GetComponent<Button>();
			((Object)val).name = label;
			val.SetActive(true);
			((TMP_Text)((Component)((Component)component).transform.GetChild(0)).GetComponent<TextMeshProUGUI>()).text = label;
			component.onClick = new ButtonClickedEvent();
			if (callback != null)
			{
				((UnityEvent)component.onClick).AddListener(callback);
			}
			((Behaviour)component).enabled = true;
			((Behaviour)val.GetComponent<Image>()).enabled = true;
			((Behaviour)val.GetComponent<UI_AnimateOnSelect>()).enabled = true;
			return component;
		}

		private static Toggle CloneToggle(Transform parent, string label, bool value, UnityAction<bool> callback)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(toggleTemplate, parent);
			Toggle component = val.GetComponent<Toggle>();
			((Object)val).name = label;
			val.SetActive(true);
			TextMeshProUGUI componentInChildren = ((Component)component).GetComponentInChildren<TextMeshProUGUI>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				if (nameTruncates.TryGetValue(label, out var value2))
				{
					((TMP_Text)componentInChildren).text = value2;
				}
				else
				{
					((TMP_Text)componentInChildren).text = label;
				}
			}
			component.onValueChanged = new ToggleEvent();
			component.SetIsOnWithoutNotify(value);
			if (callback != null)
			{
				((UnityEvent<bool>)(object)component.onValueChanged).AddListener(callback);
			}
			((Behaviour)component).enabled = true;
			((Behaviour)((Component)val.transform.GetChild(0)).GetComponent<Image>()).enabled = true;
			return component;
		}

		public static ScrollRect CreateScrollRect(Transform parent, Vector2 size, out RectTransform content)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0088: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Expected O, but got Unknown
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ScrollRect");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(0f, 0f);
			val2.anchorMax = val3;
			val2.anchorMin = val3;
			val2.pivot = new Vector2(0f, 0f);
			val2.sizeDelta = size;
			GameObject val4 = new GameObject("Viewport");
			val4.transform.SetParent(val.transform, false);
			RectTransform val5 = val4.AddComponent<RectTransform>();
			val5.anchorMin = Vector2.zero;
			val5.anchorMax = Vector2.one;
			val3 = (val5.offsetMin = (val5.offsetMax = Vector2.zero));
			val4.AddComponent<RectMask2D>();
			GameObject val7 = new GameObject("Content");
			val7.transform.SetParent(val4.transform, false);
			content = val7.AddComponent<RectTransform>();
			content.anchorMin = new Vector2(0f, 1f);
			content.anchorMax = new Vector2(1f, 1f);
			content.pivot = new Vector2(0.5f, 1f);
			content.anchoredPosition = Vector2.zero;
			content.sizeDelta = Vector2.zero;
			VerticalLayoutGroup val8 = val7.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val8).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val8).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val8).spacing = 30f;
			ContentSizeFitter val9 = val7.AddComponent<ContentSizeFitter>();
			val9.verticalFit = (FitMode)2;
			GameObject val10 = new GameObject("Scrollbar");
			val10.transform.SetParent(val.transform, false);
			RectTransform val11 = val10.AddComponent<RectTransform>();
			val11.anchorMin = new Vector2(1f, 0f);
			val11.anchorMax = new Vector2(1f, 1f);
			val11.pivot = new Vector2(1f, 1f);
			val11.sizeDelta = new Vector2(20f, 0f);
			val11.anchoredPosition = Vector2.zero;
			Image val12 = val10.AddComponent<Image>();
			((Graphic)val12).color = new Color(0f, 0f, 0f, 0.25f);
			Scrollbar val13 = val10.AddComponent<Scrollbar>();
			val13.direction = (Direction)2;
			GameObject val14 = new GameObject("Sliding Area");
			val14.transform.SetParent(val10.transform, false);
			RectTransform val15 = val14.AddComponent<RectTransform>();
			val15.anchorMin = Vector2.zero;
			val15.anchorMax = Vector2.one;
			val15.offsetMin = new Vector2(2f, 2f);
			val15.offsetMax = new Vector2(-2f, -2f);
			GameObject val16 = new GameObject("Handle");
			val16.transform.SetParent(val14.transform, false);
			RectTransform val17 = val16.AddComponent<RectTransform>();
			val17.anchorMin = Vector2.zero;
			val17.anchorMax = Vector2.one;
			val17.offsetMin = Vector2.zero;
			val17.offsetMax = Vector2.zero;
			Image val18 = val16.AddComponent<Image>();
			((Graphic)val18).color = Color.white;
			((Selectable)val13).targetGraphic = (Graphic)(object)val18;
			val13.handleRect = val17;
			ScrollRect val19 = val.AddComponent<ScrollRect>();
			val19.viewport = val5;
			val19.content = content;
			val19.horizontal = false;
			val19.scrollSensitivity = 25f;
			val19.verticalScrollbar = val13;
			val19.verticalScrollbarVisibility = (ScrollbarVisibility)2;
			val19.verticalScrollbarSpacing = 0f;
			return val19;
		}

		private static SubmitSlider CloneSlider(Transform parent, string label, float value, float min, float max, UnityAction<float> callback)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(sliderTemplate, parent);
			SubmitSlider component = ((Component)val.transform.Find("Slider")).GetComponent<SubmitSlider>();
			((Object)val).name = label;
			val.SetActive(true);
			((Behaviour)component).enabled = true;
			component.minValue = min;
			component.maxValue = max;
			component.onValueChanged = new SliderEvent();
			component.SetValueWithoutNotify(value);
			((UnityEvent<float>)(object)component.onValueChanged).AddListener(callback);
			((Behaviour)val.GetComponent<TextMeshProUGUI>()).enabled = true;
			((TMP_Text)val.GetComponent<TextMeshProUGUI>()).text = label;
			((Behaviour)val.GetComponent<LayoutElement>()).enabled = true;
			TextMeshProUGUI valueText = ((Component)val.transform.GetChild(0)).GetComponent<TextMeshProUGUI>();
			((Behaviour)valueText).enabled = true;
			((TMP_Text)valueText).text = $"{value}";
			((UnityEvent<float>)(object)component.onValueChanged).AddListener((UnityAction<float>)delegate(float v)
			{
				((TMP_Text)valueText).text = v.ToString("0.##");
			});
			return component;
		}

		private static TMP_Dropdown CloneDropdown(Transform parent, string label, List<OptionData> options, int value, UnityAction<int> callback)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(dropdownTemplate, parent);
			TMP_Dropdown component = ((Component)val.transform.GetChild(0)).GetComponent<TMP_Dropdown>();
			((Object)val).name = label;
			val.SetActive(true);
			((Behaviour)val.GetComponent<TextMeshProUGUI>()).enabled = true;
			((TMP_Text)val.GetComponent<TextMeshProUGUI>()).text = label;
			((Behaviour)component).enabled = true;
			component.ClearOptions();
			component.AddOptions(options);
			component.onValueChanged = new DropdownEvent();
			component.SetValueWithoutNotify(value);
			((UnityEvent<int>)(object)component.onValueChanged).AddListener(callback);
			((Behaviour)((Component)component).GetComponent<Image>()).enabled = true;
			((Behaviour)((Component)component).GetComponent<CanvasGroup>()).enabled = true;
			return component;
		}
	}
	internal static class ChaosUIHelpers
	{
		public static void SetAllToggles(bool value)
		{
			foreach (Toggle eventToggle in ChaosUI.EventToggles)
			{
				eventToggle.SetIsOnWithoutNotify(value);
				((UnityEvent<bool>)(object)eventToggle.onValueChanged).Invoke(value);
			}
		}
	}
	public class EventEntry : MonoBehaviour
	{
		private ChaosUI owner;

		private RectTransform rect;

		private RectTransform timerFill;

		private TextMeshProUGUI label;

		private bool awake = false;

		private bool eventCompleted = false;

		private float timeLeft = 20f;

		private float eventTimer = 0f;

		private float eventTimerMax = 0f;

		private Vector2 targetPos;

		private float height = 18f;

		public List<Object> relatedObjects = new List<Object>();

		public float Height => height;

		public void Wake(string name, float time, ChaosUI ownerUI, bool doubleEvent)
		{
			owner = ownerUI;
			awake = true;
			eventTimerMax = time;
			eventTimer = time;
			CreateEntryUI(name, doubleEvent);
		}

		private void CreateEntryUI(string name, bool tintText)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_007d: Expected O, but got Unknown
			//IL_0115: 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_012d: 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)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			rect = ((Component)this).gameObject.AddComponent<RectTransform>();
			rect.anchorMin = Vector2.one;
			rect.anchorMax = Vector2.one;
			rect.pivot = Vector2.one;
			rect.sizeDelta = new Vector2(350f, height);
			rect.anchoredPosition = Vector2.zero;
			GameObject val = new GameObject("Text");
			val.transform.SetParent(((Component)this).transform, false);
			label = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)label).text = name;
			if ((Object)(object)owner.ticketingFont != (Object)null)
			{
				((TMP_Text)label).font = owner.ticketingFont;
			}
			((TMP_Text)label).fontSize = 10f;
			((TMP_Text)label).alignment = (TextAlignmentOptions)4100;
			if (tintText)
			{
				((Graphic)label).color = Color.red;
			}
			else
			{
				((Graphic)label).color = Color.white;
			}
			RectTransform rectTransform = ((TMP_Text)label).rectTransform;
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			rectTransform.offsetMin = new Vector2(6f, 2f);
			rectTransform.offsetMax = new Vector2(-12f, -2f);
			if (eventTimerMax > 0f)
			{
				GameObject val2 = new GameObject("Timer");
				val2.transform.SetParent(((Component)this).transform, false);
				Image val3 = val2.AddComponent<Image>();
				((Graphic)val3).color = new Color(0f, 0f, 0f, 0.6f);
				RectTransform rectTransform2 = ((Graphic)val3).rectTransform;
				rectTransform2.anchorMin = Vector2.right;
				rectTransform2.anchorMax = Vector2.one;
				rectTransform2.pivot = new Vector2(1f, 0.5f);
				rectTransform2.sizeDelta = new Vector2(8f, 0f);
				rectTransform2.anchoredPosition = new Vector2(-2f, 0f);
				GameObject val4 = new GameObject("Fill");
				val4.transform.SetParent(val2.transform, false);
				Image val5 = val4.AddComponent<Image>();
				((Graphic)val5).color = new Color(1f, 1f, 1f, 0.6f);
				timerFill = ((Graphic)val5).rectTransform;
				timerFill.anchorMin = Vector2.zero;
				timerFill.anchorMax = Vector2.right;
				timerFill.pivot = Vector2.right / 2f;
				RectTransform obj = timerFill;
				Rect val6 = rectTransform2.rect;
				obj.sizeDelta = new Vector2(0f, ((Rect)(ref val6)).height);
				timerFill.anchoredPosition = Vector2.zero;
			}
		}

		public void SetTargetPosition(Vector2 pos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			targetPos = pos;
		}

		private void Update()
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if (awake)
			{
				if (timeLeft > 0f)
				{
					timeLeft -= Time.deltaTime;
				}
				if (eventTimer > 0f)
				{
					eventTimer -= Time.deltaTime;
				}
				if ((Object)(object)timerFill != (Object)null && eventTimerMax > 0f)
				{
					float num = Mathf.Clamp01(eventTimer / eventTimerMax);
					Rect val = rect.rect;
					float num2 = ((Rect)(ref val)).height;
					timerFill.sizeDelta = new Vector2(0f, num2 * num);
				}
				rect.anchoredPosition = Vector2.Lerp(rect.anchoredPosition, targetPos, Time.deltaTime * 12f);
				if (timeLeft <= 0f && eventTimer <= 0f)
				{
					owner.RemoveEntry(this);
					eventCompleted = true;
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		private void OnDestroy()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			if (eventCompleted)
			{
				return;
			}
			owner.RemoveEntry(this);
			foreach (GameObject relatedObject in relatedObjects)
			{
				GameObject val = relatedObject;
				Object.Destroy((Object)(object)val);
			}
		}
	}
}
namespace ChaosMod.Patches
{
	[HarmonyPatch(typeof(ENT_Player), "Update")]
	public static class ENT_Player_Update_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(ENT_Player __instance)
		{
			Main.MainUpdate();
		}
	}
	[HarmonyPatch(typeof(ENT_Player), "Revive")]
	public static class ENT_Player_Revive_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(ENT_Player __instance)
		{
			Main.AddPause();
			ChaosUI.instance.RemoveAllEntries();
			Main.AddPause(b: false);
		}
	}
	[HarmonyPatch(typeof(ENT_Player), "SetCutsceneMode")]
	public static class ENT_Player_SetCutsceneMode_Patch
	{
		[HarmonyPrefix]
		private static void Prefix(ENT_Player __instance, bool b)
		{
			Main.AddPause(b, cutscene: true);
		}
	}
	[HarmonyPatch(typeof(UT_PlayerForceMover), "Start")]
	public static class UT_PlayerForceMover_Start_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(UT_PlayerForceMover __instance)
		{
			ForceMonitor forceMonitor = ((Component)__instance).gameObject.AddComponent<ForceMonitor>();
			forceMonitor.Initialize(__instance);
		}
	}
	[HarmonyPatch(typeof(UT_PlayerForceMover), "SetActive")]
	public static class UT_PlayerForceMover_SetActive_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(UT_PlayerForceMover __instance, bool b)
		{
			ForceMonitor component = ((Component)__instance).GetComponent<ForceMonitor>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.ChangeState(b);
			}
		}
	}
	[HarmonyPatch(typeof(UT_PlayerTakeOver), "Start")]
	public static class UT_PlayerTakeOver_Start_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(UT_PlayerTakeOver __instance)
		{
			TakeOverMonitor takeOverMonitor = ((Component)__instance).gameObject.AddComponent<TakeOverMonitor>();
			takeOverMonitor.Initialize(__instance);
		}
	}
	[HarmonyPatch(typeof(UT_PlayerTakeOver), "SetActive")]
	public static class UT_PlayerTakeOver_SetActive_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(UT_PlayerTakeOver __instance, bool b)
		{
			TakeOverMonitor component = ((Component)__instance).GetComponent<TakeOverMonitor>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.ChangeState(b);
			}
		}
	}
	[HarmonyPatch(typeof(ENT_Player), "OnControllerColliderHit")]
	public static class ENT_Player_Hit_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(ENT_Player __instance, ControllerColliderHit hit)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			if ((Object)(object)hit.gameObject.GetComponent<PirateAI>() != (Object)null)
			{
				DeathType val = new DeathType();
				val.deathText = "DEAD MEN TELL NO TALES";
				CL_GameManager.gMan.deathTypes[0] = val;
				EventManager.PlayAudio((AudioClip)EventManager.prefabs["ShipCollide"], 0.5f, 1f, AudioUtils.GetEffectsMixer());
				DamageInfo val2 = DamageInfo.CreateDamageInfo(1f, "The Ghost Ship", new List<string>(), (GameEntity)null);
				((GameEntity)__instance).Kill(val2.type, val2);
			}
			else if ((Object)(object)hit.gameObject.GetComponent<TrainAI>() != (Object)null)
			{
				DeathType val3 = new DeathType();
				val3.deathText = "TOO MUCH OLD SPICE";
				CL_GameManager.gMan.deathTypes[0] = val3;
				EventManager.PlayAudio((AudioClip)EventManager.prefabs["TrainHit"], 0.5f, 1f, AudioUtils.GetEffectsMixer());
				AudioSource val4 = default(AudioSource);
				if (hit.gameObject.TryGetComponent<AudioSource>(ref val4))
				{
					val4.volume = 0.5f;
				}
				DamageInfo val5 = DamageInfo.CreateDamageInfo(1f, "Terry Crews", new List<string>(), (GameEntity)null);
				((GameEntity)__instance).Kill(val5.type, val5);
			}
			else if ((Object)(object)hit.gameObject.GetComponent<ShrekAI>() != (Object)null)
			{
				Vector3 val6 = ((Component)__instance).transform.position - hit.transform.position;
				((GameEntity)__instance).AddForce(((Vector3)(ref val6)).normalized * 20f, "");
				if (((GameEntity)__instance).health - 1f <= 0f)
				{
					DeathType val7 = new DeathType();
					val7.deathText = "SHREKT";
					CL_GameManager.gMan.deathTypes[0] = val7;
					EventManager.PlayAudio((AudioClip)EventManager.prefabs["ShipCollide"], 0.45f, 0.9f, AudioUtils.GetEffectsMixer());
					DamageInfo val8 = DamageInfo.CreateDamageInfo(1f, "Shrek", new List<string>(), (GameEntity)null);
					((GameEntity)__instance).Kill(val8.type, val8);
				}
				else
				{
					((GameEntity)__instance).Damage(DamageInfo.CreateDamageInfo(1f, "Shrek", new List<string>(), (GameEntity)null));
				}
			}
		}
	}
	[HarmonyPatch(typeof(CL_GameManager), "Win")]
	public static class CL_GameManager_Win_Patch
	{
		[HarmonyPrefix]
		private static void Prefix(CL_GameManager __instance)
		{
			ChaosUI.SetEndScreens();
		}
	}
	[HarmonyPatch(typeof(CL_GameManager), "Die")]
	public static class CL_GameManager_Die_Patch
	{
		[HarmonyPostfix]
		private static void Postfix(CL_GameManager __instance)
		{
			ChaosUI.SetEndScreens();
		}
	}
}
namespace ChaosMod.Events
{
	public class EventManager : MonoBehaviour
	{
		public static readonly List<Event> Events = new List<Event>();

		public static Dictionary<string, int> eventsOnCooldown = new Dictionary<string, int>();

		public static Dictionary<string, Object> prefabs = new Dictionary<string, Object>();

		public static AssetBundle chaosBundle = null;

		public static void FillList()
		{
			Events.Clear();
			Events.Add(default(Event).SetEntry("Perk Overdose", 0f, PerkOverdose));
			Events.Add(default(Event).SetEntry("Bloodbug Infestation", 0f, BloodbugHorde));
			Events.Add(default(Event).SetEntry("House M.D.", 30f, SpawnHouseMD));
			Events.Add(default(Event).SetEntry("Random Perk", 0f, RandomPerk));
			Events.Add(default(Event).SetEntry("Random Item", 0f, RandomItem));
			Events.Add(default(Event).SetEntry("You are playing in IRON KNUCKLE mode. No perks for you!", 0f, IronKnuckle, 30));
			Events.Add(default(Event).SetEntry("Jumpscare!", 0f, Jumpscare));
			Events.Add(default(Event).SetEntry("It's Turbo Time!", 0f, TurboTime));
			Events.Add(default(Event).SetEntry("FEAST MODE ACTIVATED", 20f, FeastMode));
			Events.Add(default(Event).SetEntry("Roach Rain", 20f, SkyDiamonds));
			Events.Add(default(Event).SetEntry("Yarr Harr", 0f, PirateShip));
			Events.Add(default(Event).SetEntry("Yahoo!", 0f, PlayerLaunch));
			Events.Add(default(Event).SetEntry("Will you be my buddy?", 0f, SpawnBuddies));
			Events.Add(default(Event).SetEntry("Moving Day", 0f, SpawnFurniture));
			Events.Add(default(Event).SetEntry("Old Spice Train", 0f, OldSpiceTrain));
			Events.Add(default(Event).SetEntry("Advertisement", 4f, JoeBiden));
			Events.Add(default(Event).SetEntry("The Red Carpet", 0f, RedCarpet));
			Events.Add(default(Event).SetEntry("Prop Magnet", 0f, PropMagnet));
			Events.Add(default(Event).SetEntry("Spawn Shrek", 25f, SpawnShrek));
			Events.Add(default(Event).SetEntry("Gift Rain", 10f, HappyBirthday));
			Events.Add(default(Event).SetEntry("BBQ CHICKEN ALERT", 12f, BBQChickenAlert));
			Events.Add(default(Event).SetEntry("Random Trinket", 0f, RandomTrinket));
			Events.Add(default(Event).SetEntry("Random Binding", 60f, RandomBinding));
			Events.Add(default(Event).SetEntry("Random Artifact", 0f, RandomArtifact, 60));
			Events.Add(default(Event).SetEntry("Low Gravity", 15f, LowGravity));
			Events.Add(default(Event).SetEntry("Butterfingers", 0f, ButterFingers));
			Events.Add(default(Event).SetEntry("Drunk", 15f, Drunk, 6));
			Events.Add(default(Event).SetEntry("Give up, you're surrounded", 0f, TurretCircle));
			Events.Add(default(Event).SetEntry("Turn props into loot", 0f, PropLoot, 30));
			Events.Add(default(Event).SetEntry("I'll take that, it's mine now", 0f, YoinkItem));
			Events.Add(default(Event).SetEntry("Double Event!", 0f, DoubleRandomEvent));
			foreach (Event @event in Events)
			{
				if (!ChaosSettings.eventEnabled.ContainsKey(@event.name))
				{
					ChaosSettings.eventEnabled.Add(@event.name, value: true);
				}
			}
			ChaosSettings.Load();
		}

		public static void RandomEvent(bool ignoreDouble = false)
		{
			if ((Object)(object)chaosBundle == (Object)null)
			{
				LoadBundle();
			}
			if (Events.Count == 0)
			{
				FillList();
			}
			foreach (Event @event in Events)
			{
				if (eventsOnCooldown.TryGetValue(@event.name, out var value))
				{
					if (value > 1)
					{
						eventsOnCooldown[@event.name]--;
					}
					else
					{
						eventsOnCooldown.Remove(@event.name);
					}
				}
			}
			int value2;
			List<Event> list = Events.Where((Event e) => ChaosSettings.eventEnabled.TryGetValue(e.name, out value2) && value2).ToList();
			if (list.Count != 0)
			{
				List<Event> list2 = list.Where((Event e) => !eventsOnCooldown.TryGetValue(e.name, out value2)).ToList();
				if (list2.Any())
				{
					list = list2;
				}
				int num = list.Count;
				if (ignoreDouble)
				{
					num--;
				}
				Event obj = list[Random.Range(0, num)];
				EventEntry obj2 = ChaosUI.instance.AddEntry(obj.name, obj.time, ignoreDouble);
				obj.action?.Invoke(obj2);
				if (obj.cooldown > 0)
				{
					eventsOnCooldown[obj.name] = obj.cooldown;
				}
			}
		}

		public static void LoadBundle()
		{
			string location = Assembly.GetExecutingAssembly().Location;
			string directoryName = Path.GetDirectoryName(location);
			string text = Path.Combine(directoryName, "chaosassets");
			if (!File.Exists(text))
			{
				Debug.LogError((object)("[ChaosMod - LoadBundle] AssetBundle not found - Make sure it's in the same folder as the .dll file and it's named 'chaosassets' | " + text));
				return;
			}
			chaosBundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)chaosBundle == (Object)null)
			{
				Debug.LogError((object)"[ChaosMod - LoadBundle] Failed to load ChaosMod AssetBundle");
				return;
			}
			Debug.Log((object)"[ChaosMod - LoadBundle] AssetBundle Loaded!");
			prefabs["House"] = (Object)(object)chaosBundle.LoadAsset<GameObject>("House");
			prefabs["Jumpscare"] = (Object)(object)chaosBundle.LoadAsset<GameObject>("Jumpscare");
			prefabs["TurboTime"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("TurboTime");
			prefabs["FeastMode"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("FeastMode");
			prefabs["SkyDiamonds"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("SkyDiamonds");
			prefabs["PirateShip"] = (Object)(object)chaosBundle.LoadAsset<GameObject>("PirateShip");
			prefabs["ShipCollide"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("ShipCollide");
			prefabs["Yahoo"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("Yahoo");
			prefabs["Train"] = (Object)(object)chaosBundle.LoadAsset<GameObject>("Train");
			prefabs["OldSpice1"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("OldSpice1");
			prefabs["OldSpice2"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("OldSpice2");
			prefabs["OldSpice3"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("OldSpice3");
			prefabs["TrainHit"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("TrainHit");
			prefabs["JoeBiden"] = (Object)(object)chaosBundle.LoadAsset<GameObject>("JoeBiden");
			prefabs["BDay"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("BDay");
			prefabs["BBQChicken"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("BBQChickenAudio");
			prefabs["BBQChickenPlatform"] = (Object)(object)chaosBundle.LoadAsset<GameObject>("BBQChickenPlatform");
			prefabs["Shrek"] = (Object)(object)chaosBundle.LoadAsset<GameObject>("Shrek");
			prefabs["ButterfingerSlip"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("slip");
			prefabs["YoinkAudio"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("minenow");
			prefabs["Hello"] = (Object)(object)chaosBundle.LoadAsset<AudioClip>("den_samgrub_bonus_sound");
		}

		public static void PlayAudio(AudioClip clip, float distortion = 0f, float volume = 1f, AudioMixerGroup mixerGroup = null)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)clip == (Object)null))
			{
				GameObject val = new GameObject(((Object)clip).name);
				val.transform.position = ((Component)ENT_Player.playerObject).transform.position;
				AudioSource val2 = val.AddComponent<AudioSource>();
				val2.clip = clip;
				val2.volume = volume;
				if (distortion > 0f)
				{
					AudioDistortionFilter val3 = val.AddComponent<AudioDistortionFilter>();
					val3.distortionLevel = distortion;
				}
				if (Object.op_Implicit((Object)(object)mixerGroup))
				{
					val2.outputAudioMixerGroup = mixerGroup;
				}
				val2.Play();
				Object.Destroy((Object)(object)val, clip.length);
			}
		}

		private static Perk GetRandomPerk(string[] tags = null)
		{
			List<Perk> perkAssets = CL_AssetManager.GetFullCombinedAssetDatabase().perkAssets;
			if (perkAssets == null || perkAssets.Count == 0)
			{
				Debug.LogError((object)"[ChaosMod - GetRandomPerk] Fail due to no/null perks");
				return null;
			}
			if (tags == null)
			{
				return perkAssets[Random.Range(0, perkAssets.Count)];
			}
			List<Perk> list = new List<Perk>();
			foreach (Perk item in perkAssets)
			{
				string name = ((Object)item).name;
				bool flag = false;
				foreach (string text in tags)
				{
					if (name.ToLower().Contains(text.ToLower()))
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					list.Add(item);
				}
			}
			return list[Random.Range(0, list.Count)];
		}

		private static GameObject GetRandomItem(string[] tags = null)
		{
			List<GameObject> itemPrefabs = CL_AssetManager.GetFullCombinedAssetDatabase().itemPrefabs;
			if (itemPrefabs == null || itemPrefabs.Count == 0)
			{
				Debug.LogError((object)"[ChaosMod - GetRandomItem] Fail due to no/null items");
				return null;
			}
			if (tags == null)
			{
				return itemPrefabs[Random.Range(0, itemPrefabs.Count)];
			}
			List<GameObject> list = new List<GameObject>();
			foreach (GameObject item in itemPrefabs)
			{
				string name = ((Object)item).name;
				bool flag = false;
				foreach (string text in tags)
				{
					if (name.ToLower().Contains(text.ToLower()))
					{
						flag = true;
						break;
					}
				}
				if (flag && name.ToLower() != "item_component")
				{
					list.Add(item);
				}
			}
			return list[Random.Range(0, list.Count)];
		}

		private static BuffContainer GetBlankBuffContainer(Dictionary<string, float> buffs)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			BuffContainer val = new BuffContainer();
			val.buffs = new List<Buff>();
			foreach (KeyValuePair<string, float> buff in buffs)
			{
				Buff val2 = new Buff();
				val2.id = buff.Key;
				val2.maxAmount = buff.Value;
				val.buffs.Add(val2);
			}
			val.loseOverTime = false;
			val.buffTime = 1f;
			val.desc = (val.id = "");
			return val;
		}

		private static List<GameObject> SpawnObjectCircle(GameObject original, Vector3 center, EventEntry entry, float amount = 10f, float radius = 2f, bool faceAway = false)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_0095: 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)
			List<GameObject> list = new List<GameObject>();
			Vector3 val = default(Vector3);
			for (int i = 0; (float)i < amount; i++)
			{
				float num = (float)i * (float)Math.PI * 2f / amount;
				((Vector3)(ref val))..ctor(Mathf.Cos(num) * radius, 0f, Mathf.Sin(num) * radius);
				Vector3 val2 = center + val;
				GameObject val3 = Object.Instantiate<GameObject>(original, val2, Quaternion.identity, ((Component)CL_EventManager.currentLevel).transform);
				list.Add(val3);
				if (Object.op_Implicit((Object)(object)entry))
				{
					entry.relatedObjects.Add((Object)(object)val3);
				}
				if (faceAway)
				{
					val3.transform.localRotation = Quaternion.LookRotation(val2 - center);
				}
				else
				{
					val3.transform.localRotation = Quaternion.LookRotation(center - val2);
				}
			}
			return list;
		}

		private static void PerkOverdose(EventEntry entry)
		{
			string[] tags = new string[7] { "_C1_", "_Rho_", "_T1_", "_T2_", "_T3_", "_T4_", "_TX_" };
			ENT_Player.GetPlayer().AddPerk(GetRandomPerk(tags), 10, true);
		}

		private static void BloodbugHorde(EventEntry entry)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)ENT_Player.GetPlayer()).transform.position;
			GameObject entityObject = EntityHolder.GetEntityObject("denizen_bloodbug");
			SpawnObjectCircle(entityObject, position, entry, 10f, 4f);
		}

		private static void SpawnHouseMD(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>((GameObject)prefabs["House"], ((Component)Camera.main).transform.position + Random.onUnitSphere * 10f, Quaternion.identity);
			entry.relatedObjects.Add((Object)(object)val);
			Shader val2 = Shader.Find("Unlit/Unlit Transparent Color");
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogError((object)"[ChaosMod - SpawnHouseMD] Could not find game shader!");
				return;
			}
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
			foreach (Renderer val3 in componentsInChildren)
			{
				Material[] materials = val3.materials;
				foreach (Material val4 in materials)
				{
					val4.shader = val2;
				}
			}
			AudioSource component = val.GetComponent<AudioSource>();
			component.volume = 0.65f;
			component.outputAudioMixerGroup = AudioUtils.GetEffectsMixer();
			((Component)component).gameObject.AddComponent<AudioDistortionFilter>().distortionLevel = 0.05f;
			val.AddComponent<HouseAI>();
		}

		private static void RandomPerk(EventEntry entry)
		{
			string[] tags = new string[7] { "_C1_", "_Rho_", "_T1_", "_T2_", "_T3_", "_T4_", "_TX_" };
			ENT_Player.GetPlayer().AddPerk(GetRandomPerk(tags), 1, true);
		}

		private static void RandomTrinket(EventEntry entry)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			string[] tags = new string[1] { "_Trinket_" };
			Item clone = GetRandomItem(tags).GetComponent<Item_Object>().itemData.GetClone((Item)null, false);
			string[] tags2 = new string[1] { "_Upgrade_Bag_SizeUp" };
			Perk randomPerk = GetRandomPerk(tags2);
			if (Random.value > 0.0667f)
			{
				ENT_Player.GetInventory().AddItemToInventoryScreen(new Vector3(0f, 0f, 1f) + Random.insideUnitSphere * 0.01f, clone, true, false, true);
			}
			else
			{
				ENT_Player.GetPlayer().AddPerk(randomPerk, 1, true);
			}
		}

		private static void RandomBinding(EventEntry entry)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			string[] tags = new string[1] { "_Binding_" };
			Perk val = ENT_Player.GetPlayer().AddPerk(GetRandomPerk(tags), 1, true);
			GameObject val2 = new GameObject();
			val2.AddComponent<PerkBabySitter>().StartBabySitting(val);
			entry.relatedObjects.Add((Object)(object)val2);
			((Object)val2).name = "Binding Babysitter: " + ((Object)val).name;
		}

		private static void RandomItem(EventEntry entry)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			Item clone = GetRandomItem().GetComponent<Item_Object>().itemData.GetClone((Item)null, false);
			ENT_Player.GetInventory().AddItemToInventoryScreen(new Vector3(0f, 0f, 1f) + Random.insideUnitSphere * 0.01f, clone, true, false, true);
		}

		private static void RandomArtifact(EventEntry entry)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			string[] tags = new string[1] { "_Artifact_" };
			Item clone = GetRandomItem(tags).GetComponent<Item_Object>().itemData.GetClone((Item)null, false);
			ENT_Player.GetInventory().AddItemToInventoryScreen(new Vector3(0f, 0f, 1f) + Random.insideUnitSphere * 0.01f, clone, true, false, true);
		}

		private static void YoinkItem(EventEntry entry)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			Inventory inventory = ENT_Player.GetInventory();
			if (inventory.bagItems.Count != 0)
			{
				PlayAudio((AudioClip)prefabs["YoinkAudio"], 0f, 0.5f, AudioUtils.GetEffectsMixer());
				Item val = inventory.bagItems[Random.Range(0, ENT_Player.GetInventory().bagItems.Count)];
				inventory.bagItems.Remove(val);
				val.Destroy(true);
				inventory.CalculateEncumberance(true);
			}
		}

		private static void IronKnuckle(EventEntry entry)
		{
			ENT_Player.GetPlayer().RemoveAllPerks(false);
		}

		private static void Jumpscare(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0043: 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)
			GameObject val = Object.Instantiate<GameObject>((GameObject)prefabs["Jumpscare"], ((Component)ENT_Player.playerObject).transform.position, Quaternion.identity);
			entry.relatedObjects.Add((Object)(object)val);
			Transform transform = val.transform;
			transform.localScale *= 6f;
			AudioSource componentInChildren = val.GetComponentInChildren<AudioSource>();
			componentInChildren.outputAudioMixerGroup = AudioUtils.GetEffectsMixer();
			componentInChildren.volume = 0.6f;
			VideoPlayer componentInChildren2 = val.GetComponentInChildren<VideoPlayer>();
			componentInChildren2.Play();
			Renderer component = val.GetComponent<Renderer>();
			component.material.shader = chaosBundle.LoadAsset<Shader>("VideoOverlay");
			val.AddComponent<VideoOverlayThinker>();
			Object.Destroy((Object)(object)val, 0.25f);
		}

		private static void TurboTime(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			PlayAudio((AudioClip)prefabs["TurboTime"], 0f, 0.5f, AudioUtils.GetEffectsMixer());
			((GameEntity)ENT_Player.playerObject).AddForce(Vector3.up * 30f, "");
		}

		private static void FeastMode(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			PlayAudio((AudioClip)prefabs["FeastMode"], 0f, 0.75f, AudioUtils.GetEffectsMixer());
			GameObject val = new GameObject();
			val.AddComponent<FeastModeThinker>().entry = entry;
			entry.relatedObjects.Add((Object)(object)val);
			((Object)val).name = "FeastMode";
		}

		private static void SkyDiamonds(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			PlayAudio((AudioClip)prefabs["SkyDiamonds"], 0f, 0.25f, AudioUtils.GetEffectsMixer());
			GameObject val = new GameObject();
			val.AddComponent<RoachRain>().entry = entry;
			entry.relatedObjects.Add((Object)(object)val);
			((Object)val).name = "SkyDiamonds";
		}

		private static void PirateShip(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>((GameObject)prefabs["PirateShip"]);
			entry.relatedObjects.Add((Object)(object)val);
			val.transform.position = ((Component)ENT_Player.GetPlayer()).transform.position + Vector3.up * 400f;
			val.GetComponent<AudioSource>().volume = 1f;
			val.AddComponent<AudioDistortionFilter>().distortionLevel = 0.25f;
			val.GetComponent<AudioSource>().outputAudioMixerGroup = AudioUtils.GetEffectsMixer();
			val.GetComponent<AudioSource>().maxDistance = 40f;
			val.GetComponent<AudioSource>().minDistance = 25f;
			val.AddComponent<PirateAI>();
			GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
			IndicatorThinker indicatorThinker = gameObject.AddComponent<IndicatorThinker>();
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val2 in array)
			{
				Material[] materials = val2.materials;
				foreach (Material val3 in materials)
				{
					val3.EnableKeyword("_EMISSION");
					val3.SetColor("_EmissionColor", Color.white * 0.75f);
				}
			}
		}

		private static void PlayerLaunch(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			PlayAudio((AudioClip)prefabs["Yahoo"], 0.3f, 0.4f, AudioUtils.GetEffectsMixer());
			((GameEntity)ENT_Player.playerObject).AddForce(((Component)ENT_Player.GetPlayer()).transform.forward * 7f + Vector3.up * 2f, "");
		}

		private static void SpawnBuddies(EventEntry entry)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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)
			Vector3 position = ((Component)ENT_Player.GetPlayer()).transform.position;
			float amount = 6f;
			if (Main.hardMode)
			{
				amount = 15f;
			}
			GameObject entityObject = EntityHolder.GetEntityObject("denizen_drone_buddy");
			if ((Object)(object)entityObject == (Object)null)
			{
				Debug.LogError((object)"[ChaosMod - SpawnBuddies] Unable to find drone buddy (denizen_drone_buddy)");
			}
			else
			{
				SpawnObjectCircle(entityObject, position, entry, amount);
			}
		}

		private static void SpawnFurniture(EventEntry entry)
		{
			//IL_00da: 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)
			float num = 15f;
			if (Main.hardMode)
			{
				num = 30f;
			}
			List<GameObject> entityObjectList = EntityHolder.GetEntityObjectList("prop_");
			if (entityObjectList.Count == 0)
			{
				Debug.LogError((object)"[ChaosMod - SpawnFurniture] Unable to find any props");
				return;
			}
			for (int i = 0; (float)i < num; i++)
			{
				GameObject val = Object.Instantiate<GameObject>(entityObjectList[Random.Range(0, entityObjectList.Count)], ((Component)CL_EventManager.currentLevel).transform);
				entry.relatedObjects.Add((Object)(object)val);
				float num2 = Random.Range(1f, 3f);
				float num3 = Random.Range(1f, 3f);
				if (Random.value > 0.5f)
				{
					num2 = 0f - num2;
				}
				if (Random.value > 0.5f)
				{
					num3 = 0f - num3;
				}
				val.transform.position = ((Component)ENT_Player.GetPlayer()).transform.position + new Vector3(num2, 0f, num3);
			}
		}

		private static void OldSpiceTrain(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00a7: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_0113: 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)
			GameObject val = Object.Instantiate<GameObject>((GameObject)prefabs["Train"]);
			entry.relatedObjects.Add((Object)(object)val);
			Vector2 insideUnitCircle = Random.insideUnitCircle;
			Vector2 normalized = ((Vector2)(ref insideUnitCircle)).normalized;
			Vector3 val2 = new Vector3(normalized.x, 0f, normalized.y);
			Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
			val.transform.position = ((Component)ENT_Player.GetPlayer()).transform.position + Vector3.up / 2f + normalized2 * 200f;
			val.transform.rotation = Quaternion.LookRotation(-normalized2, Vector3.up) * Quaternion.Euler(-90f, 0f, 0f);
			Renderer[] components = ((Component)val.transform).GetComponents<Renderer>();
			Renderer[] array = components;
			foreach (Renderer val3 in array)
			{
				Material[] materials = val3.materials;
				foreach (Material val4 in materials)
				{
					val4.EnableKeyword("_EMISSION");
					val4.SetColor("_EmissionColor", Color.red * 1f);
				}
			}
			AudioSource component = val.GetComponent<AudioSource>();
			component.volume = 0.65f;
			component.outputAudioMixerGroup = AudioUtils.GetEffectsMixer();
			component.clip = (AudioClip)prefabs["OldSpice" + Random.Range(1, 4)];
			component.maxDistance = 40f;
			component.minDistance = 25f;
			component.Play();
			val.AddComponent<TrainAI>();
			GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
			gameObject.AddComponent<LookAtCamera>();
			GameObject gameObject2 = ((Component)val.transform.GetChild(1)).gameObject;
			IndicatorThinker indicatorThinker = gameObject2.AddComponent<IndicatorThinker>();
			indicatorThinker.baseScale = 0.002f;
			indicatorThinker.disappearingDistance = 40f;
			Shader shader = Shader.Find("Unlit/Unlit Transparent Color");
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>();
			foreach (Renderer val5 in componentsInChildren)
			{
				Material[] materials2 = val5.materials;
				foreach (Material val6 in materials2)
				{
					val6.shader = shader;
				}
			}
		}

		private static void JoeBiden(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0043: 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)
			GameObject val = Object.Instantiate<GameObject>((GameObject)prefabs["JoeBiden"], ((Component)ENT_Player.playerObject).transform.position, Quaternion.identity);
			entry.relatedObjects.Add((Object)(object)val);
			Transform transform = val.transform;
			transform.localScale *= 5f;
			val.GetComponentInChildren<AudioSource>().volume = 0.25f;
			val.GetComponentInChildren<AudioSource>().outputAudioMixerGroup = AudioUtils.GetEffectsMixer();
			VideoPlayer componentInChildren = val.GetComponentInChildren<VideoPlayer>();
			componentInChildren.Play();
			Renderer component = val.GetComponent<Renderer>();
			component.material.shader = chaosBundle.LoadAsset<Shader>("VideoOverlay");
			val.AddComponent<VideoOverlayThinker>();
			Object.Destroy((Object)(object)val, 4f);
		}

		private static void RedCarpet(EventEntry entry)
		{
			//IL_0047: 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)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)ENT_Player.GetPlayer()).transform;
			int num = 1;
			GameObject entityObject = EntityHolder.GetEntityObject("denizen_roach_explosive");
			if ((Object)(object)entityObject == (Object)null)
			{
				Debug.LogError((object)"[ChaosMod - RedCarpet] Unable to find explosive roach (denizen_roach_explosive)");
				return;
			}
			for (float num2 = -num; num2 <= (float)num; num2 += 1f)
			{
				for (float num3 = -num; num3 <= (float)num; num3 += 1f)
				{
					GameObject item = Object.Instantiate<GameObject>(entityObject, transform.position + transform.forward + new Vector3(num2 / (float)num, -0.5f, num3 / (float)num), Quaternion.identity, ((Component)CL_EventManager.currentLevel).transform);
					entry.relatedObjects.Add((Object)(object)item);
				}
			}
		}

		private static void HappyBirthday(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			PlayAudio((AudioClip)prefabs["BDay"], 0.08f, 0.5f, AudioUtils.GetEffectsMixer());
			GameObject val = new GameObject();
			val.AddComponent<GiftRain>().entry = entry;
			entry.relatedObjects.Add((Object)(object)val);
			((Object)val).name = "HappyBirthday";
		}

		private static void BBQChickenAlert(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			PlayAudio((AudioClip)prefabs["BBQChicken"], 0.35f, 0.6f, AudioUtils.GetEffectsMixer());
			GameObject val = new GameObject();
			val.AddComponent<BBQChickenThinker>().entry = entry;
			entry.relatedObjects.Add((Object)(object)val);
			((Object)val).name = "BBQChickenAlert";
		}

		private static void DoubleRandomEvent(EventEntry entry)
		{
			RandomEvent(ignoreDouble: true);
			RandomEvent(ignoreDouble: true);
		}

		private static void SpawnShrek(EventEntry entry)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>((GameObject)prefabs["Shrek"], ((Component)Camera.main).transform.position + Random.onUnitSphere * 15f, Quaternion.identity);
			entry.relatedObjects.Add((Object)(object)val);
			Shader val2 = Shader.Find("Unlit/Unlit Transparent Color");
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogError((object)"[ChaosMod - SpawnShrek] Could not find game shader!");
				return;
			}
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>();
			foreach (Renderer val3 in componentsInChildren)
			{
				Material[] materials = val3.materials;
				foreach (Material val4 in materials)
				{
					val4.shader = val2;
				}
			}
			AudioSource component = val.GetComponent<AudioSource>();
			component.volume = 0.6f;
			val.GetComponentInChildren<AudioSource>().outputAudioMixerGroup = AudioUtils.GetEffectsMixer();
			((Component)component).gameObject.GetComponent<AudioDistortionFilter>().distortionLevel = 0.35f;
			val.AddComponent<ShrekAI>();
		}

		private static void PropMagnet(EventEntry entry)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_007d: 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)
			List<CL_Prop> list = Object.FindObjectsByType<CL_Prop>((FindObjectsSortMode)0).ToList();
			foreach (CL_Prop item in list)
			{
				Rigidbody component = ((Component)((Component)item).transform).GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null && ((Component)item).gameObject.activeInHierarchy && (Object)(object)((Component)item).GetComponent<Item_Object>() == (Object)null)
				{
					component.AddForce((((Component)ENT_Player.GetPlayer()).transform.position - ((Component)item).transform.position) * 150f * component.mass);
				}
			}
		}

		private static void ButterFingers(EventEntry entry)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0068: 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_0099: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			if (!ENT_Player.GetPlayer().AreHandsFree())
			{
				PlayAudio((AudioClip)prefabs["ButterfingerSlip"], 0f, 0.5f, AudioUtils.GetEffectsMixer());
				ENT_Player.GetPlayer().DropHang(0.1f, 1f, false, "drop", false);
				ENT_Player.GetInventory().DropItemFromHand(((Component)Camera.main).transform.position + ((Component)Camera.main).transform.forward, 0, false, false);
				ENT_Player.GetInventory().DropItemFromHand(((Component)Camera.main).transform.position + ((Component)Camera.main).transform.forward, 1, false, false);
			}
		}

		private static void Drunk(EventEntry entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			GameObject val = new GameObject();
			val.AddComponent<DrunkTimer>();
			entry.relatedObjects.Add((Object)(object)val);
			((Object)val).name = "Drunk";
			Dictionary<string, float> dictionary = new Dictionary<string, float>();
			dictionary["intoxication"] = 15f;
			BuffContainer blankBuffContainer = GetBlankBuffContainer(dictionary);
			((GameEntity)ENT_Player.GetPlayer()).AddNewBuff(blankBuffContainer);
			GameObject val2 = new GameObject();
			val2.AddComponent<BuffBabySitter>().StartBabySitting(blankBuffContainer, 15f);
			entry.relatedObjects.Add((Object)(object)val2);
			((Object)val2).name = "Buff Babysitter: Drunk";
		}

		private static void LowGravity(EventEntry entry)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			Dictionary<string, float> dictionary = new Dictionary<string, float>();
			dictionary["addGravity"] = -0.5f;
			BuffContainer blankBuffContainer = GetBlankBuffContainer(dictionary);
			((GameEntity)ENT_Player.GetPlayer()).AddNewBuff(blankBuffContainer);
			GameObject val = new GameObject();
			val.AddComponent<BuffBabySitter>().StartBabySitting(blankBuffContainer, 15f);
			entry.relatedObjects.Add((Object)(object)val);
			((Object)val).name = "Buff Babysitter: Low Gravity";
		}

		private static void TurretCircle(EventEntry entry)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)ENT_Player.GetPlayer()).transform.position;
			GameObject entityObject = EntityHolder.GetEntityObject("denizen_turret_basic");
			float amount = 3f;
			if (Main.hardMode)
			{
				amount = 4f;
			}
			SpawnObjectCircle(entityObject, position, entry, amount, 5f, faceAway: true);
		}

		private static void PropLoot(EventEntry entry)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			List<CL_Prop> list = Object.FindObjectsByType<CL_Prop>((FindObjectsSortMode)0).ToList();
			foreach (CL_Prop item in list)
			{
				if (!((Object)(object)((Component)item).GetComponent<Item_Object>() != (Object)null) && ((Component)item).gameObject.activeInHierarchy)
				{
					GameObject val = Object.Instantiate<GameObject>(GetRandomItem(), ((Component)item).transform.position, Quaternion.identity);
					Object.Destroy((Object)(object)((Component)item).gameObject);
				}
			}
		}
	}
	public struct Event
	{
		public string name;

		public float time;

		public Action<EventEntry> action;

		public int cooldown;

		public Event SetEntry(string name, float time, Action<EventEntry> action, int cooldown = 0)
		{
			this.name = name;
			this.time = time;
			this.action = action;
			this.cooldown = cooldown;
			return this;
		}
	}
	public class HouseAI : MonoBehaviour
	{
		private float timeLeft = 30f;

		private void Update()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0080: 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_009a: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)Camera.main).transform.position - ((Component)this).transform.position;
			((Vector3)(ref val)).Normalize();
			((Component)this).transform.rotation = Quaternion.LookRotation(val, Vector3.up) * Quaternion.Euler(90f, 0f, 0f);
			if (Main.hardMode)
			{
				v