Decompiled source of CHAOS TIME v1.0.0

CHAOS TIME.dll

Decompiled 2 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.SceneManagement;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace V1Boom
{
	public enum ChaosMode
	{
		Basic,
		Normal,
		Hard,
		Chaos,
		Custom
	}
	public enum HudCorner
	{
		TopLeft,
		TopCenter,
		TopRight,
		MiddleLeft,
		MiddleRight,
		BottomLeft,
		BottomCenter,
		BottomRight
	}
	[BepInPlugin("com.yourname.v1boom", "V1 Chaos", "9.1.0")]
	public class ChaosPlugin : BaseUnityPlugin
	{
		private class Effect
		{
			public string Name;

			public string Detail = "";

			public float Duration;

			public float Weight = 1f;

			public int Tier = 1;

			public bool NoCombo;

			public float Period;

			public Func<bool> Available;

			public Action Start;

			public Action Stop;

			public Action OnExpire;

			public Action Pulse;

			public Action<float> Tick;
		}

		private class Active
		{
			public Effect E;

			public float Left;

			public float PulseLeft;
		}

		private class Saved
		{
			public object Obj;

			public string Member;

			public object Orig;
		}

		private class HudElem
		{
			public HudCorner Corner;

			public float X;

			public float Y;

			public float Scale = 1f;

			public float Opacity = 1f;

			public HudElem(HudCorner corner, float x, float y)
			{
				Corner = corner;
				X = x;
				Y = y;
			}
		}

		private class Tuning
		{
			public float StartGap = 20f;

			public float MinGap = 6f;

			public float Escalation = 0.93f;

			public float DurationMult = 1f;

			public float RadiantPct = 6f;

			public float VolatilePct = 6f;

			public float SandedPct = 4f;

			public float BossLoadPct = 10f;

			public float SwarmLoadPct = 25f;

			public float BossMult = 1f;

			public float SwarmMult = 1f;

			public float TeleMult = 1f;

			public int Overload = 3;

			public float[] TierMult = new float[4] { 1f, 1f, 1f, 1f };

			public int Budget = 5;

			public float RageSpeed = 1f;

			public int RageStartLevel = 2;

			public int RageMax = 3;

			public bool RageLock = false;

			public float TrialDiff = 1f;

			public int Punish = 1;
		}

		private class PresetInfo
		{
			public string Title;

			public Color Color;

			public string[] Lines;

			public Tuning S;
		}

		private class RageNote
		{
			public string Label;

			public float Delta;

			public float Born;
		}

		private enum TrialKind
		{
			Kills,
			NoDamage,
			Airtime,
			ClearRoom,
			AirKills,
			StyleSprint
		}

		private class Trial
		{
			public TrialKind Kind;

			public string Text;

			public float Goal;

			public float Progress;

			public float TimeLeft;

			public float TimeTotal;

			public float LastHp;

			public float StartStyle;

			public int StartKills;

			public int KillsSeen;
		}

		private const string ExplosionPath = "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion.prefab";

		private const bool RequireStatsManager = true;

		private static readonly string[] NonLevelScenes = new string[2] { "bootstrap", "intro" };

		private static readonly float[] TierCost = new float[4] { 1f, 2f, 3f, 5f };

		private const float EyeCheckEvery = 45f;

		private const float EyeChance = 0.03f;

		private const float EyeCooldownSecs = 480f;

		private const float EyeQuietFirst = 60f;

		private float eyeTimer;

		private float eyeCooldown;

		private bool chaosEnabled = true;

		private bool autoMode = true;

		private bool showBar = true;

		private bool trialsOn = true;

		private readonly List<Effect> effects = new List<Effect>();

		private readonly List<Active> actives = new List<Active>();

		private readonly List<Active> scheduled = new List<Active>();

		private readonly Dictionary<string, Saved> saved = new Dictionary<string, Saved>();

		private readonly HashSet<string> warned = new HashSet<string>();

		private Effect fxBoss;

		private Effect fxSwarm;

		private Effect fxTele;

		private Effect fxLock;

		private bool startFailed;

		private Effect last;

		private int lastTier;

		private float interval = 20f;

		private float nextRoll = 20f;

		private float gapTotal = 20f;

		private float graceLeft;

		private float heat;

		private float punishUntil;

		private Effect pendingFx;

		private float pendingLeft;

		private bool hud;

		private bool wasInLevel;

		private bool prevDead;

		private bool diedFlag;

		private GameObject explosionPrefab;

		private float playClock;

		private float levelSeconds;

		private Type statsType;

		private bool levelLive;

		private string lastSceneKey = "";

		private float levelCheckTimer;

		private float scanTimer;

		private float volTimer;

		private bool sandLogged;

		private int aliveCount;

		private int totalKills;

		private bool bossAlive;

		private HashSet<int> prevAlive = new HashSet<int>();

		private readonly HashSet<int> seen = new HashSet<int>();

		private readonly Dictionary<EnemyIdentifier, Vector3> volatileEnemies = new Dictionary<EnemyIdentifier, Vector3>();

		private readonly List<Vector3> crumbs = new List<Vector3>();

		private float crumbTimer;

		private bool timeActive;

		private bool stutter;

		private bool dizzy;

		private bool blackout;

		private float timeTarget = 1f;

		private float carpetDist;

		private Vector3 carpetOrigin;

		private Vector3 carpetDir;

		private readonly List<KeyValuePair<Transform, Vector3>> giants = new List<KeyValuePair<Transform, Vector3>>();

		private Vector3 baseGravity;

		private readonly List<Effect> forced = new List<Effect>();

		private static HashSet<int> lockedSlots;

		private bool weaponLockReady;

		private Object gunObj;

		private static readonly string[] SlotNames = new string[6] { "?", "REVOLVER", "SHOTGUN", "NAILGUN", "RAILCANNON", "ROCKET LAUNCHER" };

		private const string EyeName = "ISeeYou";

		private const float EyeVolume = 1f;

		private const float EyeKillRadius = 120f;

		private const float ScareTotal = 3.4f;

		private const int Strips = 28;

		private float scareLeft;

		private float scareTick;

		private Texture2D scareTex;

		private Texture2D eyeTex;

		private Texture2D noiseTex;

		private Texture2D scanTex;

		private Rect scareUV = new Rect(0f, 0f, 1f, 1f);

		private Color32[] noisePix;

		private readonly float[] stripOff = new float[28];

		private bool eyeSearched;

		private AudioClip scream;

		private readonly HudElem hudTime = new HudElem(HudCorner.TopCenter, 0f, 14f);

		private readonly HudElem hudRage = new HudElem(HudCorner.TopCenter, 0f, 86f);

		private readonly HudElem hudEvents = new HudElem(HudCorner.MiddleLeft, 18f, 0f);

		private readonly HudElem hudTrial = new HudElem(HudCorner.BottomCenter, 0f, 150f);

		private static readonly Color Ink = new Color(0.04f, 0.04f, 0.05f, 0.6f);

		private static readonly Color EdgeRed = new Color(0.85f, 0.16f, 0.1f, 1f);

		private static readonly Color Cream = new Color(0.96f, 0.93f, 0.84f, 1f);

		private static readonly Color Cyan = new Color(0.3f, 0.9f, 1f, 1f);

		private static readonly Color[] TierColors = (Color[])(object)new Color[4]
		{
			new Color(0.35f, 0.9f, 0.5f),
			new Color(1f, 0.85f, 0.2f),
			new Color(1f, 0.5f, 0.1f),
			new Color(1f, 0.15f, 0.15f)
		};

		private string banner = "";

		private float bannerLeft;

		private Color bannerColor = new Color(1f, 0.25f, 0.2f);

		private GUIStyle stTitle;

		private GUIStyle stBody;

		private GUIStyle stSmall;

		private GUIStyle stSmallR;

		private GUIStyle stRight;

		private GUIStyle stLevel;

		private GUIStyle stBig;

		private readonly List<GUIStyle> allStyles = new List<GUIStyle>();

		private Texture2D panelFill;

		private Texture2D panelEdge;

		private Texture2D skinTime;

		private Texture2D skinRage;

		private Texture2D skinEvents;

		private Texture2D skinTrial;

		private Font gameFont;

		private int fontTries;

		private ChaosMode mode = ChaosMode.Normal;

		private readonly Dictionary<ChaosMode, PresetInfo> presets = new Dictionary<ChaosMode, PresetInfo>();

		private readonly Tuning custom = new Tuning();

		private readonly Dictionary<string, bool> effectEnabled = new Dictionary<string, bool>();

		private Action<bool> pushAuto;

		private Action refreshMenu;

		private static readonly Dictionary<string, string> EffectInfo = new Dictionary<string, string>
		{
			{ "SLOW-MO", "time slows down" },
			{ "HYPERSPEED", "time speeds up" },
			{ "TIME STUTTER", "time flickers between fast and slow" },
			{ "FREEZE FRAME", "time nearly stops for a moment" },
			{ "MOON GRAVITY", "you float" },
			{ "HEAVY GRAVITY", "you fall fast" },
			{ "MEGA JUMP", "you jump much higher" },
			{ "EXPLOSION RING", "a ring of explosions around you" },
			{ "EXPLOSION RAIN", "explosions fall around you" },
			{ "CARPET BOMB", "a line of explosions in front of you" },
			{ "ENEMY FIREWORKS", "every enemy explodes" },
			{ "GIANT ENEMIES", "enemies grow huge" },
			{ "TINY ENEMIES", "enemies shrink" },
			{ "RADIANT WAVE", "half the enemies turn radiant" },
			{ "SAND WAVE", "half the enemies turn sanded" },
			{ "SWARM", "a pack of enemies appears" },
			{ "A BOSS APPEARS", "a boss spawns near you" },
			{ "DIZZY", "the camera sways" },
			{ "BLACKOUT", "the screen fades to near black and back" },
			{ "BLEED", "you slowly lose health" },
			{ "KAMIKAZE", "a 5 second timer, then you explode" },
			{ "1 HP", "your health drops to 1" },
			{ "COIN FLIP", "full heal or 1 HP" },
			{ "SECOND WIND", "full heal" },
			{ "WEAPON JAM", "your guns can't fire" },
			{ "WEAPON SWITCH JAM", "you can't switch weapons" },
			{ "ARM JAM", "no punching or parrying" },
			{ "STUMP JAM", "the whiplash stops working" },
			{ "LEGS OFF", "you can't walk or jump" },
			{ "WEAPON LOCK", "you can only use 2-3 random weapons" },
			{ "TELEPORT", "you are moved somewhere else in the level" },
			{ "OVERLOAD", "several effects at once" }
		};

		private static readonly float[] LevelStart = new float[4] { 0f, 100f, 250f, 475f };

		private const float ScaleTop = 525f;

		private static readonly float[] MutMult = new float[4] { 0.7f, 1f, 1.5f, 2.5f };

		private static readonly float[] TrialMult = new float[4] { 0.8f, 1f, 1.2f, 1.5f };

		private static readonly float[] BudgetMult = new float[4] { 1f, 1f, 1f, 1f };

		private const float StyleWindowSecs = 12f;

		private const float KillWindowSecs = 6f;

		private const float DeathHit = 125f;

		private const float LowHp = 15f;

		private const float LowHpHit = 25f;

		private const float TrialWinBonus = 40f;

		private const float TrialFailHit = 30f;

		private float ragePts;

		private int lifeDeaths;

		private int shownLevel = 1;

		private float styleTimer;

		private float styleBase = -1f;

		private float lowHpTimer;

		private float saveTimer;

		private float rankTimer;

		private float killWindowLeft;

		private int killWindowKills;

		private bool lowHpArmed = true;

		private bool rageLoaded;

		private bool rageInit;

		private bool resetRageRequested;

		private bool styleSearched;

		private bool rankAwarded;

		private bool rankLogged;

		private string styleMember;

		private string killsMember;

		private Object statsObj;

		private Action pushResetOff;

		private readonly List<RageNote> recent = new List<RageNote>();

		private Trial trial;

		private float trialTimer = 40f;

		private int trialStreak;

		private float explodeLeft;

		private float lastAirClock = -10f;

		private static readonly string[][] Punishments = new string[4][]
		{
			new string[4] { "HEAVY GRAVITY", "BLEED", "DIZZY", "TIME STUTTER" },
			new string[5] { "WEAPON JAM", "LEGS OFF", "BLACKOUT", "EXPLOSION RAIN", "SWARM" },
			new string[6] { "1 HP", "A BOSS APPEARS", "SWARM", "ARM JAM", "LEGS OFF", "EXPLODE" },
			new string[6] { "1 HP", "A BOSS APPEARS", "EXPLODE", "OVERLOAD", "KAMIKAZE", "SWARM" }
		};

		private const BindingFlags AnyInstance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly string[] EnemyJunk = new string[12]
		{
			"corpse", "ragdoll", "gib", "spawner", "statue", "effect", "blood", "limb", "icon", "hud",
			"healthbar", "bossbar"
		};

		private static readonly string[] BossWords = new string[25]
		{
			"minos", "minotaur", "gabriel", "sisyphus", "insurrection", "rodent", "cancer", "mindflayer", "hideous", "leviathan",
			"ferryman", "gutterman", "guttertank", "cerberus", "swordsmachine", "mandalore", "mirror", "reaper", "prime", "flesh",
			"panopticon", "earthmover", "brain", "wicked", "geryon"
		};

		private static readonly string[] FightWords = new string[14]
		{
			"minos", "gabriel", "sisyphus", "insurrection", "leviathan", "mirror", "reaper", "earthmover", "panopticon", "wicked",
			"geryon", "brain", "flesh", "prime"
		};

		private readonly List<string> bossKeys = new List<string>();

		private readonly List<string> swarmKeys = new List<string>();

		private string dualKey;

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

		private string lastBossKey;

		private bool scanned;

		private readonly Dictionary<string, AudioClip> tones = new Dictionary<string, AudioClip>();

		private Tuning Cfg => (mode == ChaosMode.Custom) ? custom : presets[mode].S;

		private int RageLevel
		{
			get
			{
				if (Cfg.RageLock)
				{
					return 4;
				}
				int num = ((ragePts >= LevelStart[3]) ? 4 : ((ragePts >= LevelStart[2]) ? 3 : ((!(ragePts >= LevelStart[1])) ? 1 : 2)));
				return Mathf.Min(num, RageCapLevel());
			}
		}

		private float RageSize => 525f;

		private float RageShown => Cfg.RageLock ? 525f : ragePts;

		private static string SavePath => Path.Combine(Paths.ConfigPath, "V1Chaos_rage.txt");

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			baseGravity = Physics.gravity;
			statsType = GameType("StatsManager");
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion.prefab");
			val.Completed += delegate(AsyncOperationHandle<GameObject> op)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Invalid comparison between Unknown and I4
				if ((int)op.Status == 1)
				{
					explosionPrefab = op.Result;
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Could not load explosion prefab, check the path!");
				}
			};
			BuildPresets();
			BuildEffects();
			LoadRage();
			PatchWeaponSwitch();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"V1 Chaos 9.1 loaded. K roll | J auto | L cancel all | F7 probe | F8 diagnostics | F9 pools");
		}

		private void Start()
		{
			LoadSkins();
			try
			{
				BuildMenu();
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Settings menu not available, using defaults: " + ex.Message));
			}
			SyncRageToMode();
		}

		private void OnApplicationQuit()
		{
			SaveRage();
		}

		private static bool ContainsMenu(string name)
		{
			return !string.IsNullOrEmpty(name) && name.ToLowerInvariant().Contains("menu");
		}

		private static bool IsNonLevel(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return true;
			}
			string text = name.ToLowerInvariant();
			if (text.Contains("menu"))
			{
				return true;
			}
			string[] nonLevelScenes = NonLevelScenes;
			foreach (string text2 in nonLevelScenes)
			{
				if (text == text2)
				{
					return true;
				}
			}
			return false;
		}

		private string DescribeScenes()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder stringBuilder = new StringBuilder();
			StringBuilder stringBuilder2 = stringBuilder.Append("active='");
			Scene val = SceneManager.GetActiveScene();
			stringBuilder2.Append(((Scene)(ref val)).name).Append("'");
			string staticString = GetStaticString("SceneHelper", "CurrentScene");
			if (staticString != null)
			{
				stringBuilder.Append(" helper='").Append(staticString).Append("'");
			}
			stringBuilder.Append(" loaded=[");
			for (int i = 0; i < SceneManager.sceneCount; i++)
			{
				if (i > 0)
				{
					stringBuilder.Append(", ");
				}
				val = SceneManager.GetSceneAt(i);
				stringBuilder.Append(((Scene)(ref val)).name);
			}
			stringBuilder.Append("]");
			return stringBuilder.ToString();
		}

		private bool SceneLooksLikeLevel()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			Scene val = SceneManager.GetActiveScene();
			if (IsNonLevel(((Scene)(ref val)).name))
			{
				return false;
			}
			string staticString = GetStaticString("SceneHelper", "CurrentScene");
			if (!string.IsNullOrEmpty(staticString) && IsNonLevel(staticString))
			{
				return false;
			}
			for (int i = 0; i < SceneManager.sceneCount; i++)
			{
				val = SceneManager.GetSceneAt(i);
				if (ContainsMenu(((Scene)(ref val)).name))
				{
					return false;
				}
			}
			return true;
		}

		private void ResetTimer()
		{
			nextRoll = Cfg.StartGap;
			gapTotal = nextRoll;
		}

		private void ClearRun()
		{
			seen.Clear();
			prevAlive.Clear();
			volatileEnemies.Clear();
			scheduled.Clear();
			aliveCount = 0;
			bossAlive = false;
			heat = 0f;
			pendingFx = null;
			scareLeft = 0f;
			trial = null;
			explodeLeft = 0f;
		}

		private void EvaluateLevel()
		{
			string text = DescribeScenes();
			bool flag = statsType == null || Object.FindObjectOfType(statsType) != (Object)null;
			bool flag2 = SceneLooksLikeLevel() && flag;
			if (text != lastSceneKey || flag2 != levelLive)
			{
				lastSceneKey = text;
				levelLive = flag2;
				StopAll();
				ClearRun();
				crumbs.Clear();
				last = null;
				ResetTimer();
				SaveRage();
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Scenes: " + text + " | statsManager=" + ((statsType == null) ? "n/a" : flag.ToString()) + " -> " + (flag2 ? "LEVEL (chaos on)" : "NOT a level (chaos off)")));
			}
		}

		private void LogDiagnostics()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("DIAG " + DescribeScenes() + " | live=" + levelLive + " | mode=" + mode.ToString() + " | rage level " + RageLevel + " pts " + ragePts.ToString("0.0") + "/" + (int)RageSize + " | alive=" + aliveCount + " kills=" + totalKills + " eyeCooldown=" + eyeCooldown.ToString("0") + " | boss=" + bossKeys.Count + " swarm=" + swarmKeys.Count + " dual=" + (dualKey ?? "none") + " | font=" + (((Object)(object)gameFont != (Object)null) ? ((Object)gameFont).name : "default") + " | lockReady=" + weaponLockReady));
			LogStyleStatus();
			Show("DIAG LOGGED", 2f);
		}

		private void OnLevelStart()
		{
			ResetTimer();
			ScanKeysOnce();
			FindFont(force: false);
			SyncRageToMode();
			shownLevel = RageLevel;
			ResetTick();
			LogStyleStatus();
			levelSeconds = 0f;
			eyeTimer = 0f;
			graceLeft = (diedFlag ? 8f : 10f);
			diedFlag = false;
			trialTimer = Random.Range(25f, 60f);
			if ((Object)(object)scream == (Object)null)
			{
				scream = MakeScreamClip();
			}
			if ((Object)(object)eyeTex == (Object)null)
			{
				eyeTex = MakeEyeTexture();
			}
			scheduled.Clear();
			forced.Clear();
			if (RageLevel >= MinLevelOf(fxSwarm) && Random.value < Cfg.SwarmLoadPct / 100f * LevelOdds(fxSwarm))
			{
				forced.Add(fxSwarm);
			}
			if (RageLevel >= MinLevelOf(fxBoss) && Random.value < Cfg.BossLoadPct / 100f * LevelOdds(fxBoss))
			{
				forced.Add(fxBoss);
			}
		}

		private void Trigger(Effect e)
		{
			for (int num = actives.Count - 1; num >= 0; num--)
			{
				if (actives[num].E == e)
				{
					actives[num].E.Stop?.Invoke();
					actives.RemoveAt(num);
				}
			}
			startFailed = false;
			e.Start?.Invoke();
			if (e.Duration > 0f && !startFailed)
			{
				actives.Add(new Active
				{
					E = e,
					Left = e.Duration * Cfg.DurationMult
				});
			}
		}

		private void StopAll()
		{
			foreach (Active active in actives)
			{
				active.E.Stop?.Invoke();
			}
			actives.Clear();
			RestoreEverything();
		}

		private float CostOf(Effect e)
		{
			return TierCost[Mathf.Clamp(e.Tier, 0, 3)];
		}

		private float UsedBudget()
		{
			float num = 0f;
			foreach (Active active in actives)
			{
				num += CostOf(active.E);
			}
			return num;
		}

		private float BudgetCap()
		{
			return Mathf.Round((float)Cfg.Budget * BudgetMult[RageLevel - 1]);
		}

		private float RoomLeft()
		{
			return BudgetCap() - UsedBudget() - heat;
		}

		private float WeightOf(Effect e)
		{
			Tuning cfg = Cfg;
			float num = e.Weight * cfg.TierMult[e.Tier] * LevelOdds(e);
			if (e == fxBoss)
			{
				num *= cfg.BossMult;
			}
			else if (e == fxSwarm)
			{
				num *= cfg.SwarmMult;
			}
			else if (e == fxTele)
			{
				num *= cfg.TeleMult;
			}
			return num;
		}

		private bool Allowed(Effect e, float room)
		{
			if (!IsEnabled(e) || WeightOf(e) <= 0f)
			{
				return false;
			}
			if (RageLevel < MinLevelOf(e))
			{
				return false;
			}
			if (e.Available != null && !e.Available())
			{
				return false;
			}
			if (e.Tier >= 2 && (graceLeft > 0f || lastTier >= 2 || Time.unscaledTime < punishUntil))
			{
				return false;
			}
			return CostOf(e) <= room + 0.001f;
		}

		private Effect PickEffect()
		{
			float room = RoomLeft();
			float num = 0f;
			foreach (Effect effect in effects)
			{
				if (effect != last && Allowed(effect, room))
				{
					num += WeightOf(effect);
				}
			}
			if (num <= 0f)
			{
				return null;
			}
			float num2 = Random.value * num;
			Effect result = null;
			foreach (Effect effect2 in effects)
			{
				if (effect2 != last && Allowed(effect2, room))
				{
					result = effect2;
					num2 -= WeightOf(effect2);
					if (num2 <= 0f)
					{
						return effect2;
					}
				}
			}
			return result;
		}

		private void Roll(bool manual = false)
		{
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			if (pendingFx != null)
			{
				return;
			}
			nextRoll = Cfg.StartGap;
			gapTotal = nextRoll;
			float room = RoomLeft();
			Effect effect = null;
			for (int i = 0; i < forced.Count; i++)
			{
				if (Allowed(forced[i], room))
				{
					effect = forced[i];
					forced.RemoveAt(i);
					break;
				}
			}
			if (effect == null)
			{
				effect = PickEffect();
			}
			if (effect == null)
			{
				if (manual)
				{
					Show("NO ROOM FOR MORE CHAOS", 2f);
				}
				return;
			}
			last = effect;
			lastTier = effect.Tier;
			if (effect.Tier >= 2)
			{
				pendingFx = effect;
				pendingLeft = 0.8f;
				Show("INCOMING: " + effect.Name, 0.8f, TierColor(effect.Tier));
			}
			else
			{
				Fire(effect);
			}
		}

		private void Fire(Effect e)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			Show(e.Name, 3f, TierColor(e.Tier));
			if (e.Duration <= 0f)
			{
				heat += CostOf(e);
			}
			Trigger(e);
		}

		private bool CanScare()
		{
			return levelSeconds >= 60f && eyeCooldown <= 0f && scareLeft <= 0f && !bossAlive && trial == null && pendingFx == null && explodeLeft <= 0f && Time.unscaledTime >= punishUntil;
		}

		private void UpdateEye(float dt)
		{
			if (eyeCooldown > 0f)
			{
				eyeCooldown -= dt;
			}
			eyeTimer += dt;
			if (!(eyeTimer < 45f))
			{
				eyeTimer = 0f;
				if (CanScare() && Random.value < 0.03f)
				{
					eyeCooldown = 480f;
					SaveRage();
					TriggerScare();
				}
			}
		}

		private void ScanEnemies()
		{
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			if (seen.Count > 5000)
			{
				seen.Clear();
			}
			Tuning cfg = Cfg;
			float num = MutMult[RageLevel - 1];
			HashSet<int> hashSet = new HashSet<int>();
			HashSet<int> hashSet2 = new HashSet<int>();
			bool flag = false;
			EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
			foreach (EnemyIdentifier val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				int instanceID = ((Object)val).GetInstanceID();
				if (val.dead)
				{
					if (prevAlive.Contains(instanceID) && hashSet2.Add(instanceID))
					{
						AddKill();
					}
					continue;
				}
				hashSet.Add(instanceID);
				if (IsFight(((Object)val).name))
				{
					flag = true;
				}
				if (seen.Add(instanceID))
				{
					if (Random.value < cfg.RadiantPct * num / 100f && TryInvoke(val, "BuffAll"))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Radiant: " + ((Object)val).name));
					}
					if (Random.value < cfg.SandedPct * num / 100f && Sandify(val))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Sanded: " + ((Object)val).name));
					}
					if (Random.value < cfg.VolatilePct * num / 100f)
					{
						volatileEnemies[val] = ((Component)val).transform.position;
					}
				}
			}
			foreach (int item in prevAlive)
			{
				if (!hashSet.Contains(item) && !hashSet2.Contains(item))
				{
					AddKill();
				}
			}
			prevAlive = hashSet;
			aliveCount = hashSet.Count;
			bossAlive = flag;
		}

		private void CheckVolatile()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if (volatileEnemies.Count == 0)
			{
				return;
			}
			List<EnemyIdentifier> list = new List<EnemyIdentifier>(volatileEnemies.Keys);
			foreach (EnemyIdentifier item in list)
			{
				if ((Object)(object)item == (Object)null)
				{
					Boom(volatileEnemies[item]);
					volatileEnemies.Remove(item);
				}
				else if (item.dead)
				{
					Boom(((Component)item).transform.position);
					volatileEnemies.Remove(item);
				}
				else
				{
					volatileEnemies[item] = ((Component)item).transform.position;
				}
			}
		}

		private void Update()
		{
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			Keyboard current = Keyboard.current;
			if (current != null)
			{
				if (((ButtonControl)current.f7Key).wasPressedThisFrame)
				{
					DumpProbe();
				}
				if (((ButtonControl)current.f8Key).wasPressedThisFrame)
				{
					LogDiagnostics();
				}
			}
			if (resetRageRequested)
			{
				resetRageRequested = false;
				ResetRage();
				pushResetOff?.Invoke();
			}
			levelCheckTimer -= unscaledDeltaTime;
			if (levelCheckTimer <= 0f)
			{
				levelCheckTimer = 0.25f;
				EvaluateLevel();
			}
			bool flag = false;
			if (chaosEnabled && levelLive)
			{
				NewMovement instance = MonoSingleton<NewMovement>.Instance;
				bool flag2 = (Object)(object)instance != (Object)null && instance.dead;
				if (flag2 && !prevDead)
				{
					OnDeath();
				}
				prevDead = flag2;
				flag = (Object)(object)instance != (Object)null && !flag2;
			}
			else
			{
				prevDead = false;
			}
			hud = flag;
			if (flag != wasInLevel)
			{
				wasInLevel = flag;
				if (flag)
				{
					OnLevelStart();
				}
			}
			if (!flag)
			{
				StopAll();
				ClearRun();
				ResetTimer();
				return;
			}
			if (scareLeft > 0f)
			{
				scareLeft -= unscaledDeltaTime;
				scareTick -= unscaledDeltaTime;
				if (scareTick <= 0f)
				{
					scareTick = 1f / 14f;
					RerollTape();
				}
			}
			if (current != null)
			{
				if (((ButtonControl)current.jKey).wasPressedThisFrame)
				{
					autoMode = !autoMode;
					pushAuto?.Invoke(autoMode);
					Show(autoMode ? "CHAOS: AUTO ON" : "CHAOS: AUTO OFF", 2f);
				}
				if (((ButtonControl)current.lKey).wasPressedThisFrame)
				{
					StopAll();
					pendingFx = null;
					Show("ALL CLEAR", 2f);
				}
				if (((ButtonControl)current.f9Key).wasPressedThisFrame)
				{
					LogPools();
					Show("POOLS LOGGED", 2f);
				}
				if (((ButtonControl)current.f10Key).wasPressedThisFrame && ((ButtonControl)current.leftCtrlKey).isPressed && ((ButtonControl)current.leftShiftKey).isPressed && scareLeft <= 0f)
				{
					TriggerScare();
				}
				if (((ButtonControl)current.kKey).wasPressedThisFrame)
				{
					Roll(manual: true);
					return;
				}
			}
			if (Time.timeScale <= 0.001f)
			{
				return;
			}
			playClock += unscaledDeltaTime;
			levelSeconds += unscaledDeltaTime;
			if (bannerLeft > 0f)
			{
				bannerLeft -= unscaledDeltaTime;
			}
			heat = Mathf.Max(0f, heat - 0.6f * unscaledDeltaTime);
			if (graceLeft > 0f)
			{
				graceLeft -= unscaledDeltaTime;
			}
			scanTimer -= unscaledDeltaTime;
			if (scanTimer <= 0f)
			{
				scanTimer = 0.5f;
				ScanEnemies();
			}
			volTimer -= unscaledDeltaTime;
			if (volTimer <= 0f)
			{
				volTimer = 0.2f;
				CheckVolatile();
			}
			crumbTimer -= unscaledDeltaTime;
			if (crumbTimer <= 0f)
			{
				crumbTimer = 0.5f;
				Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
				if (crumbs.Count != 0)
				{
					Vector3 val = position - crumbs[crumbs.Count - 1];
					if (!(((Vector3)(ref val)).sqrMagnitude > 36f))
					{
						goto IL_04db;
					}
				}
				crumbs.Add(position);
				if (crumbs.Count > 300)
				{
					crumbs.RemoveAt(Random.Range(0, crumbs.Count - 1));
				}
			}
			goto IL_04db;
			IL_04db:
			UpdateRage(unscaledDeltaTime);
			UpdateTrials(unscaledDeltaTime);
			UpdateEye(unscaledDeltaTime);
			for (int num = scheduled.Count - 1; num >= 0; num--)
			{
				scheduled[num].Left -= unscaledDeltaTime;
				if (!(scheduled[num].Left > 0f))
				{
					Effect e = scheduled[num].E;
					scheduled.RemoveAt(num);
					if (IsEnabled(e))
					{
						Fire(e);
					}
				}
			}
			if (pendingFx != null)
			{
				pendingLeft -= unscaledDeltaTime;
				if (pendingLeft <= 0f)
				{
					Effect e2 = pendingFx;
					pendingFx = null;
					Fire(e2);
				}
			}
			for (int num2 = actives.Count - 1; num2 >= 0; num2--)
			{
				Active active = actives[num2];
				active.E.Tick?.Invoke(unscaledDeltaTime);
				if (active.E.Pulse != null)
				{
					active.PulseLeft -= unscaledDeltaTime;
					if (active.PulseLeft <= 0f)
					{
						active.PulseLeft = active.E.Period;
						active.E.Pulse();
					}
				}
				active.Left -= unscaledDeltaTime;
				if (active.Left <= 0f)
				{
					actives.RemoveAt(num2);
					active.E.Stop?.Invoke();
					active.E.OnExpire?.Invoke();
				}
			}
			if (autoMode && pendingFx == null)
			{
				nextRoll -= unscaledDeltaTime;
				if (nextRoll <= 0f)
				{
					Roll();
				}
			}
		}

		private void LateUpdate()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			if (Time.timeScale > 0.001f)
			{
				if (timeActive)
				{
					Time.timeScale = timeTarget;
				}
				else if (stutter)
				{
					Time.timeScale = ((Mathf.Sin(Time.unscaledTime * 6f) > 0f) ? 1.8f : 0.25f);
				}
			}
			if (dizzy)
			{
				Camera main = Camera.main;
				if (!((Object)(object)main == (Object)null))
				{
					Vector3 eulerAngles = ((Component)main).transform.eulerAngles;
					eulerAngles.z = 18f * Mathf.Sin(Time.unscaledTime * 2.2f);
					((Component)main).transform.eulerAngles = eulerAngles;
				}
			}
		}

		private Effect Add(string name, float duration, Action start, Action stop = null, float weight = 1f, bool noCombo = false, int tier = 1)
		{
			Effect effect = new Effect
			{
				Name = name,
				Duration = duration,
				Start = start,
				Stop = stop,
				Weight = weight,
				NoCombo = noCombo,
				Tier = tier
			};
			effects.Add(effect);
			return effect;
		}

		private static Effect Every(Effect e, float period, Action pulse)
		{
			e.Period = period;
			e.Pulse = pulse;
			return e;
		}

		private void BuildEffects()
		{
			Add("SLOW-MO", 8f, delegate
			{
				timeTarget = 0.4f;
				timeActive = true;
			}, ResetTime, 1f, noCombo: false, 0);
			Add("HYPERSPEED", 8f, delegate
			{
				timeTarget = 1.6f;
				timeActive = true;
			}, ResetTime, 1f, noCombo: false, 0);
			Add("TIME STUTTER", 8f, delegate
			{
				stutter = true;
			}, ResetTime);
			Add("FREEZE FRAME", 1.5f, delegate
			{
				timeTarget = 0.03f;
				timeActive = true;
			}, ResetTime);
			Add("MOON GRAVITY", 10f, delegate
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				Physics.gravity = baseGravity * 0.3f;
			}, delegate
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				Physics.gravity = baseGravity;
			}, 1f, noCombo: false, 0);
			Add("HEAVY GRAVITY", 10f, delegate
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				Physics.gravity = baseGravity * 2.5f;
			}, delegate
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				Physics.gravity = baseGravity;
			});
			Add("MEGA JUMP", 10f, delegate
			{
				OverrideAll("NewMovement", "jumpPower", (object c) => Convert.ToSingle(c) * 2.2f);
			}, delegate
			{
				RestoreAll("NewMovement", "jumpPower");
			}, 1f, noCombo: false, 0);
			Add("EXPLOSION RING", 0f, delegate
			{
				//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_002c: 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_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)
				Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
				for (int i = 0; i < 8; i++)
				{
					float num = (float)i * MathF.PI * 2f / 8f;
					Boom(position + new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num)) * 9f);
				}
			});
			Every(Add("EXPLOSION RAIN", 8f, null), 0.35f, delegate
			{
				//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_0011: 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_0019: 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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: 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_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: 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)
				Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
				Vector2 insideUnitCircle = Random.insideUnitCircle;
				Vector2 val = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(6f, 22f);
				Boom(position + new Vector3(val.x, 0f, val.y));
			});
			Every(Add("CARPET BOMB", 3f, delegate
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: 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)
				carpetDir = FlatForward();
				carpetOrigin = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
				carpetDist = 4f;
			}), 0.12f, delegate
			{
				//IL_0015: 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_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				carpetDist += 3.5f;
				Boom(carpetOrigin + carpetDir * carpetDist);
			});
			Add("ENEMY FIREWORKS", 0f, delegate
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
				foreach (EnemyIdentifier val in array)
				{
					if ((Object)(object)val != (Object)null && !val.dead)
					{
						Boom(((Component)val).transform.position);
					}
				}
			}, null, 1f, noCombo: false, 0);
			Add("GIANT ENEMIES", 12f, delegate
			{
				ScaleEnemies(2.2f);
			}, RestoreScales);
			Add("TINY ENEMIES", 12f, delegate
			{
				ScaleEnemies(0.4f);
			}, RestoreScales, 1f, noCombo: false, 0);
			Add("RADIANT WAVE", 0f, delegate
			{
				EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
				foreach (EnemyIdentifier val in array)
				{
					if ((Object)(object)val != (Object)null && !val.dead && Random.value < 0.5f)
					{
						TryInvoke(val, "BuffAll");
					}
				}
			});
			Add("SAND WAVE", 0f, delegate
			{
				EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
				foreach (EnemyIdentifier val in array)
				{
					if ((Object)(object)val != (Object)null && !val.dead && Random.value < 0.5f)
					{
						Sandify(val);
					}
				}
			});
			fxSwarm = Add("SWARM", 0f, SpawnSwarm, null, 1.5f);
			fxBoss = Add("A BOSS APPEARS", 0f, SpawnBoss, null, 0.8f, noCombo: true, 2);
			Add("DIZZY", 10f, delegate
			{
				dizzy = true;
			}, delegate
			{
				dizzy = false;
				ResetRoll();
			});
			Add("BLACKOUT", 8f, delegate
			{
				blackout = true;
			}, delegate
			{
				blackout = false;
			}, 1f, noCombo: false, 2);
			Every(Add("BLEED", 8f, null, null, 1f, noCombo: false, 2), 0.5f, delegate
			{
				NewMovement instance = MonoSingleton<NewMovement>.Instance;
				if ((Object)(object)instance != (Object)null && !instance.dead)
				{
					instance.GetHurt(4, false, 1f, false, false, 0.35f, true);
				}
			});
			Add("KAMIKAZE", 5f, null, null, 1f, noCombo: false, 3).OnExpire = ExplodeNow;
			Add("1 HP", 0f, delegate
			{
				SetHp(1);
			}, null, 0.6f, noCombo: false, 2);
			Add("COIN FLIP", 0f, delegate
			{
				bool flag = Random.value < 0.5f;
				SetHp((!flag) ? 1 : 100);
				Show(flag ? "COIN FLIP: FULL HEAL" : "COIN FLIP: 1 HP", 3f);
			}, null, 0.8f);
			Add("SECOND WIND", 0f, delegate
			{
				SetHp(100);
			}, null, 0.7f, noCombo: false, 0);
			Add("WEAPON JAM", 8f, delegate
			{
				OverrideAll("GunControl", "activated", (object c) => false);
			}, delegate
			{
				RestoreAll("GunControl", "activated");
			}, 1f, noCombo: false, 2);
			Add("WEAPON SWITCH JAM", 10f, delegate
			{
				OverrideAll("GunControl", "enabled", (object c) => false);
			}, delegate
			{
				RestoreAll("GunControl", "enabled");
			});
			Add("ARM JAM", 8f, delegate
			{
				OverrideAll("FistControl", "activated", (object c) => false);
				OverrideAll("FistControl", "enabled", (object c) => false);
				OverrideAll("Punch", "enabled", (object c) => false);
			}, delegate
			{
				RestoreAll("FistControl", "activated");
				RestoreAll("FistControl", "enabled");
				RestoreAll("Punch", "enabled");
			}, 1f, noCombo: false, 2);
			Add("STUMP JAM", 8f, delegate
			{
				OverrideAll("HookArm", "enabled", (object c) => false);
			}, delegate
			{
				RestoreAll("HookArm", "enabled");
			}, 1f, noCombo: false, 2);
			Add("LEGS OFF", 7f, delegate
			{
				OverrideAll("NewMovement", "walkSpeed", (object c) => Convert.ToSingle(c) * 0.05f);
				OverrideAll("NewMovement", "jumpPower", (object c) => 0f);
			}, delegate
			{
				RestoreAll("NewMovement", "walkSpeed");
				RestoreAll("NewMovement", "jumpPower");
			}, 1f, noCombo: false, 2);
			fxLock = Add("WEAPON LOCK", 12f, StartWeaponLock, StopWeaponLock);
			fxLock.Available = () => weaponLockReady;
			fxTele = Add("TELEPORT", 0f, DoTeleport, null, 0.15f);
			Add("OVERLOAD", 0f, delegate
			{
				float room = RoomLeft();
				List<Effect> list = effects.FindAll((Effect x) => !x.NoCombo && x.Tier <= 2 && Allowed(x, room));
				for (int num = 0; num < Cfg.Overload; num++)
				{
					if (list.Count <= 0)
					{
						break;
					}
					int index = Random.Range(0, list.Count);
					Effect e = list[index];
					list.RemoveAt(index);
					if (!(CostOf(e) > room))
					{
						room -= CostOf(e);
						Trigger(e);
					}
				}
			}, null, 1f, noCombo: true, 2);
		}

		private void ExplodeNow()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			NewMovement instance = MonoSingleton<NewMovement>.Instance;
			if (!((Object)(object)instance == (Object)null) && !instance.dead)
			{
				Boom(((Component)instance).transform.position);
				instance.GetHurt(9999, false, 1f, true, false, 0.35f, true);
			}
		}

		private static string SlotName(int s)
		{
			return (s > 0 && s < SlotNames.Length) ? SlotNames[s] : ("SLOT " + s);
		}

		private void PatchWeaponSwitch()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			try
			{
				Type type = GameType("GunControl");
				if (type == null)
				{
					Warn("GunControl type not found: WEAPON LOCK disabled.");
					return;
				}
				Harmony val = new Harmony("com.yourname.v1boom.lock");
				HarmonyMethod val2 = new HarmonyMethod(typeof(ChaosPlugin).GetMethod("SwitchPrefix", BindingFlags.Static | BindingFlags.NonPublic));
				int num = 0;
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (!(methodInfo.Name != "SwitchWeapon"))
					{
						ParameterInfo[] parameters = methodInfo.GetParameters();
						if (parameters.Length != 0 && !(parameters[0].ParameterType != typeof(int)))
						{
							val.Patch((MethodBase)methodInfo, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
							num++;
						}
					}
				}
				weaponLockReady = num > 0;
				((BaseUnityPlugin)this).Logger.LogInfo((object)("WEAPON LOCK: patched " + num + " SwitchWeapon method(s)."));
				if (!weaponLockReady)
				{
					Warn("WEAPON LOCK disabled: no usable SwitchWeapon(int, ...) method found. Press F7 for details.");
				}
			}
			catch (Exception ex)
			{
				Warn("WEAPON LOCK disabled: " + ex.Message);
			}
		}

		private static bool SwitchPrefix(object[] __args)
		{
			HashSet<int> hashSet = lockedSlots;
			if (hashSet == null || __args == null || __args.Length == 0 || !(__args[0] is int))
			{
				return true;
			}
			return hashSet.Contains((int)__args[0]);
		}

		private Object FindGun()
		{
			if (gunObj == (Object)null)
			{
				Type type = GameType("GunControl");
				if (type != null)
				{
					gunObj = Object.FindObjectOfType(type);
				}
			}
			return gunObj;
		}

		private List<int> OwnedSlots()
		{
			List<int> list = new List<int>();
			Object val = FindGun();
			if (val == (Object)null)
			{
				return list;
			}
			if (!(GetMember(val, "slots") is IList list2))
			{
				return list;
			}
			for (int i = 0; i < list2.Count; i++)
			{
				if (list2[i] is IList { Count: >0 })
				{
					list.Add(i + 1);
				}
			}
			return list;
		}

		private int CurrentSlot()
		{
			object member = GetMember(FindGun(), "currentSlot");
			return (member is int) ? ((int)member) : (-1);
		}

		private bool CallSwitch(int slot)
		{
			Object val = FindGun();
			if (val == (Object)null)
			{
				return false;
			}
			object obj = ((GetMember(val, "slots") is IList list && slot - 1 < list.Count) ? list[slot - 1] : null);
			MethodInfo[] methods = ((object)val).GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.Name != "SwitchWeapon")
				{
					continue;
				}
				ParameterInfo[] parameters = methodInfo.GetParameters();
				if (parameters.Length == 0 || parameters[0].ParameterType != typeof(int))
				{
					continue;
				}
				object[] array = new object[parameters.Length];
				array[0] = slot;
				bool flag = true;
				for (int j = 1; j < parameters.Length; j++)
				{
					Type parameterType = parameters[j].ParameterType;
					if (parameterType == typeof(bool))
					{
						array[j] = false;
						continue;
					}
					if (obj != null && parameterType.IsInstanceOfType(obj))
					{
						array[j] = obj;
						continue;
					}
					if (parameters[j].HasDefaultValue)
					{
						array[j] = parameters[j].DefaultValue;
						continue;
					}
					flag = false;
					break;
				}
				if (flag)
				{
					try
					{
						methodInfo.Invoke(val, array);
						return true;
					}
					catch (Exception ex)
					{
						Warn("SwitchWeapon failed: " + ex.Message);
					}
				}
			}
			return false;
		}

		private void StartWeaponLock()
		{
			List<int> list = OwnedSlots();
			if (list.Count < 3)
			{
				Warn("WEAPON LOCK skipped: need at least 3 owned weapon slots, found " + list.Count + ". Press F7 for details.");
				startFailed = true;
				return;
			}
			int num = ((list.Count >= 5) ? 3 : 2);
			HashSet<int> hashSet = new HashSet<int>();
			while (hashSet.Count < num)
			{
				hashSet.Add(list[Random.Range(0, list.Count)]);
			}
			lockedSlots = hashSet;
			List<string> list2 = new List<string>();
			foreach (int item in hashSet)
			{
				list2.Add(SlotName(item));
			}
			fxLock.Detail = string.Join(" / ", list2.ToArray());
			int num2 = CurrentSlot();
			if (num2 <= 0 || hashSet.Contains(num2))
			{
				return;
			}
			using HashSet<int>.Enumerator enumerator2 = hashSet.GetEnumerator();
			if (enumerator2.MoveNext())
			{
				int current2 = enumerator2.Current;
				CallSwitch(current2);
			}
		}

		private void StopWeaponLock()
		{
			lockedSlots = null;
			fxLock.Detail = "";
		}

		private void SpawnBoss()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			string text = RandomKey(bossKeys, lastBossKey);
			if (text == null)
			{
				Warn("No boss prefabs found in the catalog. Press F9 and check the log.");
				return;
			}
			lastBossKey = text;
			string text2 = Path.GetFileNameWithoutExtension(text).ToUpperInvariant();
			Show("A BOSS APPEARS: " + text2, 3f, TierColor(2));
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Spawning boss: " + text));
			WithPrefab(text, delegate(GameObject prefab)
			{
				SpawnAhead(prefab, 22f, 0f);
			});
		}

		private void SpawnSwarm()
		{
			if (swarmKeys.Count == 0)
			{
				Warn("No swarm prefabs found in the catalog. Press F9 and check the log.");
				return;
			}
			for (int i = 0; i < 3; i++)
			{
				string text = RandomKey(swarmKeys, null);
				int copies = Random.Range(3, 5);
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Swarm: " + copies + " x " + text));
				WithPrefab(text, delegate(GameObject prefab)
				{
					for (int j = 0; j < copies; j++)
					{
						SpawnAhead(prefab, Random.Range(8f, 20f), Random.Range(-12f, 12f));
					}
				});
			}
		}

		private void ScaleEnemies(float factor)
		{
			//IL_003b: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
			foreach (EnemyIdentifier val in array)
			{
				if (!((Object)(object)val == (Object)null) && !val.dead)
				{
					giants.Add(new KeyValuePair<Transform, Vector3>(((Component)val).transform, ((Component)val).transform.localScale));
					Transform transform = ((Component)val).transform;
					transform.localScale *= factor;
				}
			}
		}

		private void RestoreScales()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			for (int num = giants.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)giants[num].Key != (Object)null)
				{
					giants[num].Key.localScale = giants[num].Value;
				}
			}
			giants.Clear();
		}

		private bool Sandify(EnemyIdentifier en)
		{
			if (TryInvoke(en, "Sandify"))
			{
				return true;
			}
			if (SetMember(en, "sandified", true))
			{
				return true;
			}
			if (!sandLogged)
			{
				sandLogged = true;
				Type type = ((object)en).GetType();
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (Has(methodInfo.Name, "sand"))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("SAND member (method): " + methodInfo.Name));
					}
				}
				FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (Has(fieldInfo.Name, "sand"))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("SAND member (field): " + fieldInfo.Name));
					}
				}
			}
			return false;
		}

		private bool FindSpot(out Vector3 spot)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			Vector3 me = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
			List<Vector3> list = new List<Vector3>(crumbs);
			EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
			foreach (EnemyIdentifier val in array)
			{
				if ((Object)(object)val != (Object)null && !val.dead)
				{
					list.Add(((Component)val).transform.position);
				}
			}
			Type type = GameType("CheckPoint");
			if (type != null)
			{
				Object[] array2 = Object.FindObjectsOfType(type);
				foreach (Object val2 in array2)
				{
					Component val3 = (Component)(object)((val2 is Component) ? val2 : null);
					if ((Object)(object)val3 != (Object)null)
					{
						list.Add(val3.transform.position);
					}
				}
			}
			list.RemoveAll(delegate(Vector3 v)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val4 = v - me;
				return ((Vector3)(ref val4)).sqrMagnitude < 144f;
			});
			if (list.Count == 0)
			{
				spot = Vector3.zero;
				return false;
			}
			spot = list[Random.Range(0, list.Count)];
			return true;
		}

		private void DoTeleport()
		{
			//IL_002c: 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_0037: 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)
			//IL_0048: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			if (!FindSpot(out var spot))
			{
				Show("TELEPORT FAILED", 2f);
				return;
			}
			NewMovement instance = MonoSingleton<NewMovement>.Instance;
			Vector3 position = spot + Vector3.up * 0.5f;
			((Component)instance).transform.position = position;
			Rigidbody component = ((Component)instance).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.position = position;
				component.velocity = Vector3.zero;
			}
		}

		private void ResetTime()
		{
			timeActive = false;
			stutter = false;
			if (Time.timeScale > 0.001f)
			{
				Time.timeScale = 1f;
			}
		}

		private void ResetRoll()
		{
			//IL_001a: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if (!((Object)(object)main == (Object)null))
			{
				Vector3 eulerAngles = ((Component)main).transform.eulerAngles;
				eulerAngles.z = 0f;
				((Component)main).transform.eulerAngles = eulerAngles;
			}
		}

		private void TriggerScare()
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			scareLeft = 3.4f;
			scareTick = 0f;
			if ((Object)(object)scareTex == (Object)null && !eyeSearched)
			{
				eyeSearched = true;
				FindLoadedEye();
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Scare picture: " + (((Object)(object)scareTex != (Object)null) ? ("game texture '" + ((Object)scareTex).name + "' " + ((Texture)scareTex).width + "x" + ((Texture)scareTex).height) : "code-drawn eye")));
			PlayScare();
			Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
			float num = 14400f;
			int num2 = 0;
			EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
			foreach (EnemyIdentifier val in array)
			{
				if ((Object)(object)val == (Object)null || val.dead)
				{
					continue;
				}
				Vector3 val2 = ((Component)val).transform.position - position;
				if (!(((Vector3)(ref val2)).sqrMagnitude > num))
				{
					if (!TryInvoke(val, "InstaKill"))
					{
						Boom(((Component)val).transform.position);
					}
					num2++;
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)("The eye killed " + num2 + " enemies."));
		}

		private void PlayScare()
		{
			bool flag = false;
			if ((Object)(object)scream == (Object)null)
			{
				scream = MakeScreamClip();
			}
			PlayClip2D(scream, 1f);
		}

		private void RerollTape()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			EnsureTapeTextures();
			for (int i = 0; i < noisePix.Length; i++)
			{
				byte b = (byte)Random.Range(0, 256);
				noisePix[i] = new Color32(b, b, b, byte.MaxValue);
			}
			noiseTex.SetPixels32(noisePix);
			noiseTex.Apply(false);
			for (int j = 0; j < 28; j++)
			{
				stripOff[j] = ((Random.value < 0.2f) ? Random.Range(-0.06f, 0.06f) : Random.Range(-0.005f, 0.005f));
			}
		}

		private void EnsureTapeTextures()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (!((Object)(object)noiseTex != (Object)null))
			{
				noiseTex = new Texture2D(192, 108, (TextureFormat)4, false);
				((Texture)noiseTex).filterMode = (FilterMode)0;
				((Texture)noiseTex).wrapMode = (TextureWrapMode)1;
				noisePix = (Color32[])(object)new Color32[20736];
				scanTex = new Texture2D(1, 4, (TextureFormat)4, false);
				((Texture)scanTex).filterMode = (FilterMode)0;
				((Texture)scanTex).wrapMode = (TextureWrapMode)0;
				scanTex.SetPixels((Color[])(object)new Color[4]
				{
					new Color(0f, 0f, 0f, 0.5f),
					Color.clear,
					Color.clear,
					Color.clear
				});
				scanTex.Apply();
			}
		}

		private static Rect CoverUV(Texture2D tex, Rect uv)
		{
			//IL_0039: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Rect)(ref uv)).width * (float)((Texture)tex).width / Mathf.Max(1f, ((Rect)(ref uv)).height * (float)((Texture)tex).height);
			float num2 = (float)Screen.width / (float)Screen.height;
			Rect result = uv;
			if (num > num2)
			{
				float num3 = ((Rect)(ref uv)).width * num2 / num;
				((Rect)(ref result)).x = ((Rect)(ref uv)).x + (((Rect)(ref uv)).width - num3) * 0.5f;
				((Rect)(ref result)).width = num3;
			}
			else
			{
				float num4 = ((Rect)(ref uv)).height * num / num2;
				((Rect)(ref result)).y = ((Rect)(ref uv)).y + (((Rect)(ref uv)).height - num4) * 0.5f;
				((Rect)(ref result)).height = num4;
			}
			return result;
		}

		private static Rect ZoomUV(Rect r, float z)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			float num = ((Rect)(ref r)).width / z;
			float num2 = ((Rect)(ref r)).height / z;
			return new Rect(((Rect)(ref r)).x + (((Rect)(ref r)).width - num) * 0.5f, ((Rect)(ref r)).y + (((Rect)(ref r)).height - num2) * 0.5f, num, num2);
		}

		private void DrawScare()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_0100: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type != 7)
			{
				return;
			}
			EnsureTapeTextures();
			float num = 3.4f - scareLeft;
			float num2 = Mathf.Min(1f, num / 0.04f) * Mathf.Clamp01(scareLeft / 0.6f);
			float num3 = Screen.width;
			float num4 = Screen.height;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(0f, 0f, num3, num4);
			GUI.color = new Color(0f, 0f, 0f, num2);
			GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture);
			Texture2D val2 = scareTex;
			Rect uv = scareUV;
			if ((Object)(object)val2 == (Object)null)
			{
				if ((Object)(object)eyeTex == (Object)null)
				{
					eyeTex = MakeEyeTexture();
				}
				val2 = eyeTex;
				((Rect)(ref uv))..ctor(0f, 0f, 1f, 1f);
			}
			Rect val3 = ZoomUV(CoverUV(val2, uv), 1f + 0.1f * (num / 3.4f));
			float num5 = 0.012f * num3;
			GUI.color = new Color(1f, 0.25f, 0.25f, 0.45f * num2);
			GUI.DrawTextureWithTexCoords(new Rect(0f - num5, 0f, num3, num4), (Texture)(object)val2, val3, true);
			GUI.color = new Color(0.25f, 0.4f, 1f, 0.45f * num2);
			GUI.DrawTextureWithTexCoords(new Rect(num5, 0f, num3, num4), (Texture)(object)val2, val3, true);
			float num6 = Mathf.Repeat(Time.unscaledTime * 0.32f, 1.3f) - 0.15f;
			GUI.color = new Color(1f, 1f, 1f, num2);
			Rect val4 = default(Rect);
			Rect val5 = default(Rect);
			for (int i = 0; i < 28; i++)
			{
				float num7 = (float)i / 28f;
				float num8 = (float)(i + 1) / 28f;
				float num9 = stripOff[i];
				if (num8 > num6 && num7 < num6 + 0.12f)
				{
					num9 += 0.05f * Mathf.Sin(Time.unscaledTime * 31f + (float)i);
				}
				((Rect)(ref val4))..ctor(num9 * num3, num7 * num4, num3, (num8 - num7) * num4 + 1f);
				((Rect)(ref val5))..ctor(((Rect)(ref val3)).x, ((Rect)(ref val3)).y + ((Rect)(ref val3)).height * (1f - num8), ((Rect)(ref val3)).width, ((Rect)(ref val3)).height * (num8 - num7));
				GUI.DrawTextureWithTexCoords(val4, (Texture)(object)val2, val5, true);
			}
			GUI.color = new Color(1f, 1f, 1f, 0.3f * num2);
			GUI.DrawTexture(val, (Texture)(object)noiseTex, (ScaleMode)0, true);
			float num10 = Mathf.Clamp01(num6) * num4;
			float num11 = (Mathf.Clamp01(num6 + 0.12f) - Mathf.Clamp01(num6)) * num4;
			if (num11 > 1f)
			{
				GUI.color = new Color(1f, 1f, 1f, 0.5f * num2);
				GUI.DrawTextureWithTexCoords(new Rect(0f, num10, num3, num11), (Texture)(object)noiseTex, new Rect(0f, Random.value * 0.8f, 1f, 0.2f), true);
			}
			GUI.color = new Color(1f, 1f, 1f, num2);
			GUI.DrawTextureWithTexCoords(val, (Texture)(object)scanTex, new Rect(0f, 0f, 1f, num4 / 4f), true);
			GUI.color = Color.white;
		}

		private void SetSprite(Sprite sp)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//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)
			Texture2D texture = sp.texture;
			Rect textureRect = sp.textureRect;
			scareTex = texture;
			scareUV = new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height);
		}

		private void FindLoadedEye()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(Texture2D));
			foreach (Object val in array)
			{
				if (Has(val.name, "ISeeYou"))
				{
					scareTex = (Texture2D)val;
					scareUV = new Rect(0f, 0f, 1f, 1f);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Found loaded texture: " + val.name));
					return;
				}
			}
			Object[] array2 = Resources.FindObjectsOfTypeAll(typeof(Sprite));
			foreach (Object val2 in array2)
			{
				if (Has(val2.name, "ISeeYou"))
				{
					SetSprite((Sprite)val2);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Found loaded sprite: " + val2.name));
					break;
				}
			}
		}

		private void LoadEyeAsset(string key)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<IList<IResourceLocation>> val = Addressables.LoadResourceLocationsAsync((object)key, typeof(Texture2D));
			val.Completed += delegate(AsyncOperationHandle<IList<IResourceLocation>> lo)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Invalid comparison between Unknown and I4
				//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_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)
				if ((int)lo.Status == 1 && lo.Result != null && lo.Result.Count > 0)
				{
					AsyncOperationHandle<Texture2D> val2 = Addressables.LoadAssetAsync<Texture2D>((object)key);
					val2.Completed += delegate(AsyncOperationHandle<Texture2D> op)
					{
						//IL_0003: Unknown result type (might be due to invalid IL or missing references)
						//IL_0009: Invalid comparison between Unknown and I4
						//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)
						if ((int)op.Status == 1 && !((Object)(object)op.Result == (Object)null))
						{
							scareTex = op.Result;
							scareUV = new Rect(0f, 0f, 1f, 1f);
						}
					};
				}
				else
				{
					AsyncOperationHandle<Sprite> val3 = Addressables.LoadAssetAsync<Sprite>((object)key);
					val3.Completed += delegate(AsyncOperationHandle<Sprite> op)
					{
						//IL_0003: Unknown result type (might be due to invalid IL or missing references)
						//IL_0009: Invalid comparison between Unknown and I4
						if ((int)op.Status == 1 && (Object)(object)op.Result != (Object)null)
						{
							SetSprite(op.Result);
						}
					};
				}
			};
		}

		private Texture2D MakeEyeTexture()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: 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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(512, 256, (TextureFormat)4, false);
			((Texture)val).filterMode = (FilterMode)1;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			Color[] array = (Color[])(object)new Color[131072];
			Color val2 = default(Color);
			for (int i = 0; i < 256; i++)
			{
				for (int j = 0; j < 512; j++)
				{
					float num = (((float)j + 0.5f) / 512f * 2f - 1f) * 2f;
					float num2 = ((float)i + 0.5f) / 256f * 2f - 1f;
					float num3 = 0.9f * (1f - num * num / 4f) - Mathf.Abs(num2);
					if (num3 <= 0f)
					{
						array[i * 512 + j] = Color.clear;
						continue;
					}
					float num4 = Mathf.Sqrt(num * num + num2 * num2);
					((Color)(ref val2))..ctor(0.3f - 0.1f * num4, 0.02f, 0.02f);
					if (num4 < 0.62f)
					{
						val2 = Color.Lerp(new Color(1f, 0.2f, 0.05f), new Color(0.45f, 0f, 0f), num4 / 0.62f);
					}
					if (Mathf.Abs(num) < 0.07f && Mathf.Abs(num2) < 0.58f)
					{
						val2 = Color.black;
					}
					val2.a = Mathf.Clamp01(num3 * 25f);
					array[i * 512 + j] = val2;
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private AudioClip MakeScreamClip()
		{
			int num = 149940;
			float[] array = new float[num * 2];
			Random random = new Random(666);
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			float num5 = 0f;
			float num6 = 0f;
			float num7 = 0f;
			float num8 = 0f;
			float num9 = 0f;
			float num10 = 0f;
			float num11 = 0f;
			float num12 = 0f;
			float num13 = 0.0001f;
			for (int i = 0; i < num; i++)
			{
				float num14 = (float)i / 44100f;
				float num15 = num14 / 3.4f;
				float num16 = 1f + 0.012f * Mathf.Sin(5.6548667f * num14) + 0.004f * Mathf.Sin(39.58407f * num14);
				float num17 = (float)(random.NextDouble() * 2.0 - 1.0);
				float num18 = num17 * Mathf.Exp((0f - num14) * 16f) * 0.9f + Mathf.Sin(MathF.PI * 96f * num14) * Mathf.Exp((0f - num14) * 4.5f) * 1.1f;
				num2 += MathF.PI * 110f * num16 / 44100f;
				num3 += 366.12122f * num16 / 44100f;
				num4 += 488.70615f * num16 / 44100f;
				float num19 = 0.75f + 0.25f * Mathf.Sin(32.67256f * num14);
				float num20 = Mathf.Lerp(0.35f, 1f, num15);
				float num21 = (Mathf.Sin(num2) + 0.5f * Mathf.Sin(2f * num2) + Mathf.Sin(num3) + 0.5f * Mathf.Sin(2f * num3) + 0.7f * Mathf.Sin(num4)) * 0.22f * num19 * num20;
				num6 += 2.2675737E-05f / Mathf.Lerp(1.15f, 0.55f, num15);
				float num22 = num6 % 1f;
				float num23 = Mathf.Exp((0f - num22) * 26f) + ((num22 > 0.3f) ? (0.6f * Mathf.Exp((0f - (num22 - 0.3f)) * 26f)) : 0f);
				float num24 = num23 * Mathf.Sin(MathF.PI * 104f * num14) * 0.8f;
				if (i % 4800 == 0)
				{
					num11 = (float)random.NextDouble();
					num11 *= num11;
					num12 = (float)random.NextDouble();
					num12 *= num12;
				}
				num9 += (num11 - num9) * 0.0015f;
				num10 += (num12 - num10) * 0.0015f;
				float num25 = (float)(random.NextDouble() * 2.0 - 1.0);
				float num26 = (float)(random.NextDouble() * 2.0 - 1.0);
				num7 += 0.25f * (num25 - num7);
				num8 += 0.25f * (num26 - num8);
				float num27 = Mathf.Clamp01((num14 - 0.3f) / 0.8f);
				float num28 = (num25 - num7) * num9 * num27 * 0.9f;
				float num29 = (num26 - num8) * num10 * num27 * 0.9f;
				float num30 = Mathf.Lerp(2300f, 650f, Mathf.Clamp01(num14 / 0.45f));
				float num31 = ((num14 < 0.45f) ? Mathf.Exp((0f - num14) * 3f) : 0f);
				float num32 = Mathf.Lerp(480f, 2600f, Mathf.Pow(Mathf.Clamp01((num14 - 1f) / 2.4f), 1.6f));
				float num33 = Mathf.Clamp01((num14 - 1f) / 1.4f) * 0.55f;
				float num34 = 1f + 0.03f * Mathf.Sin(MathF.PI * 14f * num14);
				num5 += MathF.PI * 2f * ((num31 > 0f) ? num30 : num32) * num34 * num16 / 44100f;
				float num35 = (float)Math.Tanh(2.5f * Mathf.Sin(num5)) * (num31 * 0.7f + num33 * 0.35f);
				float num36 = Mathf.Clamp01((3.4f - num14) / 0.5f);
				float num37 = num18 + num21 + num24 + num35;
				float num38 = (float)Math.Tanh((num37 + num28 * 0.9f) * 1.1f) * num36;
				float num39 = (float)Math.Tanh((num37 + num29 * 0.9f) * 1.1f) * num36;
				array[2 * i] = num38;
				array[2 * i + 1] = num39;
				num13 = Mathf.Max(new float[3]
				{
					num13,
					Mathf.Abs(num38),
					Mathf.Abs(num39)
				});
			}
			float num40 = 0.92f / num13;
			for (int j = 0; j < array.Length; j++)
			{
				array[j] *= num40;
			}
			AudioClip val = AudioClip.Create("v1chaos_eye", num, 2, 44100, false);
			val.SetData(array, 0);
			return val;
		}

		private static Color TierColor(int tier)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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)
			return TierColors[Mathf.Clamp(tier, 0, 3)];
		}

		private void Show(string text, float seconds)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			Show(text, seconds, new Color(1f, 0.25f, 0.2f));
		}

		private void Show(string text, float seconds, Color color)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			banner = text;
			bannerLeft = seconds;
			bannerColor = color;
		}

		private void FindFont(bool force)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			if (((Object)(object)gameFont != (Object)null && !force) || (!force && fontTries >= 5))
			{
				return;
			}
			fontTries++;
			Font val = null;
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(Font));
			foreach (Object val2 in array)
			{
				if (force)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("FONT: " + val2.name));
				}
				if ((Object)(object)val == (Object)null && Has(val2.name, "vcr"))
				{
					val = (Font)val2;
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				gameFont = val;
				foreach (GUIStyle allStyle in allStyles)
				{
					allStyle.font = gameFont;
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)("HUD font: " + ((Object)val).name));
			}
			else if (force || fontTries >= 5)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"HUD font: no VCR font found, using the default (press F7 to list all fonts)");
			}
		}

		private Texture2D LoadSkin(string file)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			try
			{
				string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
				string path = Path.Combine(Path.Combine(directoryName, "V1ChaosSkin"), file);
				if (!File.Exists(path))
				{
					return null;
				}
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				((Texture)val).filterMode = (FilterMode)0;
				if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
				{
					return null;
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded custom HUD art: " + file));
				return val;
			}
			catch (Exception ex)
			{
				Warn("Could not load HUD art " + file + ": " + ex.Message);
				return null;
			}
		}

		private void LoadSkins()
		{
			skinTime = LoadSkin("time.png");
			skinRage = LoadSkin("rage.png");
			skinEvents = LoadSkin("events.png");
			skinTrial = LoadSkin("trial.png");
		}

		private GUIStyle MakeStyle(int size, TextAnchor anchor)
		{
			//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_0018: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0039: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = size,
				fontStyle = (FontStyle)1,
				alignment = anchor,
				wordWrap = false,
				clipping = (TextClipping)0
			};
			if ((Object)(object)gameFont != (Object)null)
			{
				val.font = gameFont;
			}
			allStyles.Add(val);
			return val;
		}

		private static Texture2D MakePanelTexture(bool edgeOnly)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false);
			((Texture)val).filterMode = (FilterMode)0;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			Color[] array = (Color[])(object)new Color[1024];
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					int num = j;
					int num2 = 31 - j;
					int num3 = i;
					int num4 = 31 - i;
					if (num + num3 < 10 || num2 + num3 < 10 || num + num4 < 10 || num2 + num4 < 10)
					{
						array[i * 32 + j] = Color.clear;
						continue;
					}
					bool flag = Mathf.Min(Mathf.Min(num, num2), Mathf.Min(num3, num4)) < 2 || num + num3 < 12 || num2 + num3 < 12 || num + num4 < 12 || num2 + num4 < 12;
					array[i * 32 + j] = ((!edgeOnly) ? Color.white : (flag ? Color.white : Color.clear));
				}
			}
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private void EnsureHud()
		{
			if (stTitle == null)
			{
				stTitle = MakeStyle(24, (TextAnchor)3);
				stBody = MakeStyle(17, (TextAnchor)3);
				stSmall = MakeStyle(13, (TextAnchor)3);
				stSmallR = MakeStyle(13, (TextAnchor)5);
				stRight = MakeStyle(17, (TextAnchor)5);
				stLevel = MakeStyle(34, (TextAnchor)5);
				stBig = MakeStyle(44, (TextAnchor)4);
				panelFill = MakePanelTexture(edgeOnly: false);
				panelEdge = MakePanelTexture(edgeOnly: true);
			}
		}

		private static void Fill(Rect r, Color c, float a)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = new Color(c.r, c.g, c.b, c.a * a);
			GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture);
		}

		private static void Label(Rect r, string text, GUIStyle st, Color c, float a)
		{
			//IL_001e: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			st.normal.textColor = new Color(0f, 0f, 0f, 0.8f * a);
			GUI.Label(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, st);
			st.normal.textColor = new Color(c.r, c.g, c.b, c.a * a);
			GUI.Label(r, text, st);
		}

		private static void DrawPanel(Rect r, Texture2D tex, float corner)
		{
			//IL_014c: 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)
			float num = Mathf.Min(new float[3]
			{
				corner,
				((Rect)(ref r)).width * 0.5f,
				((Rect)(ref r)).height * 0.5f
			});
			float num2 = num / (float)((Texture)tex).width;
			float num3 = num / (float)((Texture)tex).height;
			float[] array = new float[4]
			{
				((Rect)(ref r)).x,
				((Rect)(ref r)).x + num,
				((Rect)(ref r)).xMax - num,
				((Rect)(ref r)).xMax
			};
			float[] array2 = new float[4]
			{
				((Rect)(ref r)).y,
				((Rect)(ref r)).y + num,
				((Rect)(ref r)).yMax - num,
				((Rect)(ref r)).yMax
			};
			float[] array3 = new float[4]
			{
				0f,
				num2,
				1f - num2,
				1f
			};
			float[] array4 = new float[4]
			{
				1f,
				1f - num3,
				num3,
				0f
			};
			Rect val = default(Rect);
			Rect val2 = default(Rect);
			for (int i = 0; i < 3; i++)
			{
				for (int j = 0; j < 3; j++)
				{
					((Rect)(ref val))..ctor(array[j], array2[i], array[j + 1] - array[j], array2[i + 1] - array2[i]);
					((Rect)(ref val2))..ctor(array3[j], array4[i + 1], array3[j + 1] - array3[j], array4[i] - array4[i + 1]);
					GUI.DrawTextureWithTexCoords(val, (Texture)(object)tex, val2, true);
				}
			}
		}

		private void DrawBox(Rect r, Texture2D skin, Color accent, float a)
		{
			//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_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_008c: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)skin != (Object)null)
			{
				GUI.color = new Color(1f, 1f, 1f, a);
				DrawPanel(r, skin, 12f);
				return;
			}
			GUI.color = new Color(Ink.r, Ink.g, Ink.b, Ink.a * a);
			DrawPanel(r, panelFill, 12f);
			GUI.color = new Color(accent.r, accent.g, accent.b, a);
			DrawPanel(r, panelEdge, 12f);
		}

		private static Vector2 AnchorPos(HudElem h, float w, float hh)
		{
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			float num = w * h.Scale;
			float num2 = hh * h.Scale;
			float num3 = Screen.width;
			float num4 = Screen.height;
			float num5;
			float num6;
			switch (h.Corner)
			{
			case HudCorner.TopLeft:
				num5 = h.X;
				num6 = h.Y;
				break;
			case HudCorner.TopCenter:
				num5 = (num3 - num) * 0.5f + h.X;
				num6 = h.Y;
				break;
			case HudCorner.TopRight:
				num5 = num3 - num - h.X;
				num6 = h.Y;
				break;
			case HudCorner.MiddleLeft:
				num5 = h.X;
				num6 = (num4 - num2) * 0.5f + h.Y;
				break;
			case HudCorner.MiddleRight:
				num5 = num3 - num - h.X;
				num6 = (num4 - num2) * 0.5f + h.Y;
				break;
			case HudCorner.BottomLeft:
				num5 = h.X;
				num6 = num4 - num2 - h.Y;
				break;
			case HudCorner.BottomCenter:
				num5 = (num3 - num) * 0.5f + h.X;
				num6 = num4 - num2 - h.Y;
				break;
			default:
				num5 = num3 - num - h.X;
				num6 = num4 - num2 - h.Y;
				break;
			}
			return new Vector2(num5, num6);
		}

		private static void Begin(HudElem h, float w, float hh)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = AnchorPos(h, w, hh);
			GUI.matrix = Matrix4x4.TRS(new Vector3(val.x, val.y, 0f), Quaternion.identity, new Vector3(h.Scale, h.Scale, 1f));
		}

		private static void End()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			GUI.matrix = Matrix4x4.identity;
		}

		private void DrawTimeBar()
		{
			//IL_003f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: 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_01bc: 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_01e5: 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_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			HudElem hudElem = hudTime;
			float opacity = hudElem.Opacity;
			Begin(hudElem, 560f, 58f);
			bool flag = pendingFx != null;
			Color accent = (flag ? TierColor(pendingFx.Tier) : EdgeRed);
			DrawBox(new Rect(0f, 0f, 560f, 58f), skinTime, accent, opacity);
			string text = "";
			string text2;
			float num;
			Color c;
			if (flag)
			{
				text2 = "INCOMING: " + pendingFx.Name;
				num = Mathf.Clamp01(pendingLeft / 0.8f);
				c = TierColor(pendingFx.Tier);
			}
			else if (autoMode)
			{
				text2 = "NEXT CHAOS";
				text = Mathf.CeilToInt(nextRoll) + "S";
				num = Mathf.Clamp01(nextRoll / Mathf.Max(0.01f, gapTotal));
				c = ((num > 0.5f) ? Color.Lerp(Color.yellow, Color.green, (num - 0.5f) * 2f) : Color.Lerp(Color.red, Color.yellow, num * 2f));
			}
			else
			{
				text2 = "AUTO OFF   [K] ROLL   [J] AUTO";
				num = 0f;
				c = Color.gray;
			}
			Label(new Rect(16f, 3f, 460f, 24f), text2, stBody, Cream, opacity);
			Label(new Rect(464f, 3f, 80f, 24f), text, stRight, Cream, opacity);
			Rect r = default(Rect);
			((Rect)(ref r))..ctor(14f, 31f, 532f, 18f);
			Fill(r, Color.black, 0.6f * opacity);
			Fill(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, (((Rect)(ref r)).width - 4f) * num, ((Rect)(ref r)).height - 4f), c, opacity);
			for (int i = 1; i < 10; i++)
			{
				Fill(new Rect(((Rect)(ref r)).x + ((Rect)(ref r)).width * (float)i / 10f - 1f, ((Rect)(ref r)).y, 2f, ((Rect)(ref r)).height), Color.black, 0.55f * opacity);
			}
			End();
		}

		private void DrawRage()
		{
			//IL_002a: 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_0072: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			HudElem hudElem = hudRage;
			float opacity = hudElem.Opacity;
			Begin(hudElem, 460f, 134f);
			int rageLevel = RageLevel;
			Color val = TierColor(rageLevel - 1);
			if (rageLevel == 4)
			{
				val.a = 0.8f + 0.2f * Mathf.Sin(Time.unscaledTime * 4f);
			}
			DrawBox(new Rect(0f, 0f, 460f, 134f), skinRage, val, opacity);
			Label(new Rect(16f, 4f, 140f, 40f), "RAGE", stTitle, Cream, opacity);
			Label(new Rect(290f, 2f, 154f, 42f), (rageLevel == 4) ? "DIE" : ("LV " + rageLevel), stLevel, val, opacity);
			Rect r = default(Rect);
			((Rect)(ref r))..ctor(14f, 46f, 432f, 24f);
			Fill(r, Color.black, 0.6f * opacity);
			float rageShown = RageShown;
			int num = RageCapLevel();
			float num2 = ((Rect)(ref r)).width - 4f;
			Rect r2 = default(Rect);
			for (int i = 0; i < 4; i++)
			{
				float num3 = LevelStart[i];
				float num4 = ((i < 3) ? LevelStart[i + 1] : 525f);
				float num5 = ((Rect)(ref r)).x + 2f + num2 * num3 / 525f;
				float num6 = ((Rect)(ref r)).x + 2f + num2 * num4 / 525f;
				Color c = TierColor(i);
				((Rect)(ref r2))..ctor(num5, ((Rect)(ref r)).y + 2f, num6 - num5, ((Rect)(ref r)).height - 4f);
				Fill(r2, c, 0.14f * opacity);
				float num7 = Mathf.Clamp(rageShown, num3, num4) - num3;
				if (num7 > 0f)
				{
					Fill(new Rect(num5, ((Rect)(ref r2)).y, (num6 - num5) * num7 / (num4 - num3), ((Rect)(ref r2)).height), c, opacity);
				}
				if (i + 1 > num)
				{
					Fill(r2, Color.black, 0.55f * opacity);
				}
				if (i > 0)
				{
					Fill(new Rect(num5 - 1f, ((Rect)(ref r)).y, 2f, ((Rect)(ref r)).height), Color.black, 0.85f * opacity);
				}
				Label(new Rect(num5 + 2f, ((Rect)(ref r)).yMax + 1f, 60f, 16f), (i == 3) ? "DIE" : (i + 1).ToString(), stSmall, c, opacity * 0.9f);
			}
			float num8 = ((Rect)(ref r)).x + 2f + num2 * Mathf.Clamp01(rageShown / 525f);
			Fill(new Rect(num8 - 1.5f, ((Rect)(ref r)).y - 3f, 3f, ((Rect)(ref r)).height + 6f), Cream, opacity);
			string text = (Cfg.RageLock ? "LOCKED ON DIE: EVERYTHING IS UNLOCKED" : NextUnlockText());
			Label(new Rect(16f, 90f, 320f, 18f), text, stSmall, Cream, opacity * 0.85f);
			if (!Cfg.RageLock)
			{
				Label(new Rect(330f, 90f, 114f, 18f), Mathf.FloorToInt(rageShown) + " / " + 525, stSmallR, Cream, opacity * 0.7f);
			}
			float num9 = 16f;
			int num10 = 0;
			int num11 = recent.Count - 1;
			while (num11 >= 0 && num10 < 3)
			{
				RageNote rageNote = recent[num11];
				float num12 = Time.unscaledTime - rageNote.Born;
				if (!(num12 > 9f))
				{
					string text2 = ((rageNote.Delta >= 0f) ? "+" : "") + rageNote.Delta.ToString("0.#") + " " + rageNote.Label;
					Label(new Rect(num9, 112f, 142f, 18f), text2, stSmall, (rageNote.Delta >= 0f) ? TierColor(0) : TierColor(3), opacity * Mathf.Clamp01((9f - num12) / 2f));
					num9 += 142f;
					num10++;
				}
				num11--;
			}
			End();
		}

		private void DrawEvents()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: 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_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: 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_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			HudElem hudElem = hudEvents;
			float opacity = hudElem.Opacity;
			int num = Mathf.Min(actives.Count, 8);
			int num2 = Mathf.Max(1, num + ((pendingFx != null) ? 1 : 0) + ((actives.Count > 8) ? 1 : 0));
			float num3 = 36f + (float)num2 * 34f + 8f;
			Begin(hudElem, 390f, num3);
			DrawBox(new Rect(0f, 0f, 390f, num3), skinEvents, EdgeRed, opacity);
			float num4 = BudgetCap();
			float num5 = Mathf.Min(num4, UsedBudget() + heat);
			Label(new Rect(16f, 3f, 150f, 30f), "CHAOS", stTitle, Cream, opacity);
			Label(new Rect(214f, 3f, 160f, 30f), "LOAD " + Mathf.CeilToInt(num5) + "/" + (int)num4, stRight, Cream, opacity * 0.8f);
			Fill(new Rect(14f, 34f, 362f, 2f), EdgeRed, opacity);
			float num6 = 38f;
			if (pendingFx != null)
			{
				float num7 = ((Mathf.Sin(Time.unscaledTime * 12f) > 0f) ? 1f : 0.35f);
				Color c = TierColor(pendingFx.Tier);
				Fill(new Rect(12f, num6 + 4f, 4f, 24f), c, opacity);
				Label(new Rect(24f, num6, 350f, 26f), "INCOMING: " + pendingFx.Name, stBody, c, opacity * num7);
				num6 += 34f;
			}
			if (actives.Count == 0 && pendingFx == null)
			{
				Label(new Rect(24f, num6, 350f, 26f), "NO ACTIVE EFFECTS", stBody, Cream, opacity * 0.5f);
			}
			for (int i = 0; i < num; i++)
			{
				Active active = actives[i];
				Color c2 = TierColor(active.E.Tier);
				Fill(new Rect(12f, num6 + 4f, 4f, 24f), c2, opacity);
				string text = active.E.Name + (string.IsNullOrEmpty(active.E.Detail) ? "" : ("  " + active.E.Detail));
				Label(new Rect(24f, num6, 290f,