using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using ChaosMod.Events; using ChaosMod.UI; using DG.Tweening; using DarkMachine.UI; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ChaosMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ChaosMod")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("8da1cd7b-300c-4747-ac63-98141c78df4b")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyVersion("1.0.0.0")] namespace ChaosMod { [BepInPlugin("nachariah.whiteknuckle.chaosmod", "ChaosMod", "1.2.1")] public class Plugin : BaseUnityPlugin { public const string pluginGuid = "nachariah.whiteknuckle.chaosmod"; public const string pluginVersion = "1.2.1"; public static Dictionary difficultyTimers = new Dictionary(); private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"[ChaosMod - Awake] Patching..."); Harmony val = new Harmony("nachariah.whiteknuckle.chaosmod"); val.PatchAll(); EventManager.LoadBundle(); EventManager.FillList(); SceneManager.sceneLoaded += OnSceneLoaded; difficultyTimers.Add(0, 20f); difficultyTimers.Add(1, 10f); difficultyTimers.Add(2, 5f); difficultyTimers.Add(3, 2f); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (((Scene)(ref scene)).name == "Game-Main") { CommandConsole.hasCheated = true; CL_GameManager.gamemode.allowAchievements = false; CL_GameManager.gamemode.allowCheatedScores = false; Main.GameStart(); } else if (((Scene)(ref scene)).name == "Main-Menu") { ChaosUI.LoadMenuMenu(); } } } public static class Main { private static bool active = false; public static bool hardMode = false; private static float timeMax = 10f; private static float timeLeft; public static int pauseThreshold = 0; private static bool inCutscene = false; private static float timeSinceStart = 0f; public static void MainUpdate() { if (!active || pauseThreshold > 0) { return; } if (OS_Manager.IsAnyComputerInUse()) { timeSinceStart = 0f; return; } float num = Time.deltaTime; if (timeSinceStart < 5f) { timeSinceStart += num; num *= timeSinceStart / 5f; } timeLeft -= num; if (hardMode && !ChaosSettings.customTimer) { timeLeft -= num; } if (timeLeft < 0f) { EventManager.RandomEvent(); timeLeft = timeMax; } ChaosUI.instance.SetTimer(timeLeft / timeMax); } private static void StartChaos() { EventManager.FillList(); EventManager.eventsOnCooldown.Clear(); hardMode = CL_GameManager.IsHardmode(); float value; if (ChaosSettings.customTimer) { timeMax = ChaosSettings.customTimerValue; } else if (Plugin.difficultyTimers.TryGetValue(ChaosSettings.difficulty, out value)) { timeMax = value; } else { timeMax = 10f; } timeLeft = timeMax; ChaosUI.ShowUI(); pauseThreshold = 0; timeSinceStart = 0f; active = true; } public static void GameStart() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) if (active) { active = false; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "Game-Main") { StartChaos(); } } public static void AddPause(bool b = true, bool cutscene = false) { if (cutscene) { if (inCutscene == b) { return; } inCutscene = b; } if (b) { pauseThreshold++; } else { pauseThreshold--; } Debug.Log((object)("[ChaosMod - AddPause] Add: " + b + " | Pause Count: " + pauseThreshold)); if (pauseThreshold != 0) { timeLeft = timeMax; timeSinceStart = 0f; ChaosUI.instance.SetTimer(0f); ChaosUI.instance.RemoveAllEntries(); } } } public static class ChaosSettings { public static int difficulty = 1; public static bool customTimer = false; public static float customTimerValue = 10f; public static float loggerYOffset = 0f; public static Dictionary eventEnabled = new Dictionary(); public static void Load() { difficulty = PlayerPrefs.GetInt("Chaos_Difficulty", 1); customTimer = PlayerPrefs.GetInt("Chaos_CustomTimer", 0) == 1; customTimerValue = PlayerPrefs.GetFloat("Chaos_CustomTimerValue", 10f); loggerYOffset = PlayerPrefs.GetFloat("Chaos_LoggerYOffset", 0f); foreach (string item in eventEnabled.Keys.ToList()) { eventEnabled[item] = PlayerPrefs.GetInt("Chaos_Event_" + item, 1) == 1; } } public static void Save() { PlayerPrefs.SetInt("Chaos_Difficulty", difficulty); PlayerPrefs.SetInt("Chaos_CustomTimer", customTimer ? 1 : 0); PlayerPrefs.SetFloat("Chaos_CustomTimerValue", customTimerValue); PlayerPrefs.SetFloat("Chaos_LoggerYOffset", loggerYOffset); foreach (KeyValuePair item in eventEnabled) { PlayerPrefs.SetInt("Chaos_Event_" + item.Key, item.Value ? 1 : 0); } PlayerPrefs.Save(); } } public class ForceMonitor : MonoBehaviour { private bool active = false; public UT_PlayerForceMover RelatedMover; public void Initialize(UT_PlayerForceMover mover) { RelatedMover = mover; if (mover.active) { active = true; Main.AddPause(); } } private void OnEnable() { if (Object.op_Implicit((Object)(object)RelatedMover) && RelatedMover.active) { active = true; Main.AddPause(); } } private void OnDisable() { if (Object.op_Implicit((Object)(object)RelatedMover) && RelatedMover.active) { active = false; Main.AddPause(b: false); } } public void ChangeState(bool b) { if (active != b) { active = b; Main.AddPause(b); } } } public class TakeOverMonitor : MonoBehaviour { private bool active = false; public UT_PlayerTakeOver RelatedMover; public void Initialize(UT_PlayerTakeOver mover) { RelatedMover = mover; if (mover.active) { active = true; Main.AddPause(); } } private void OnEnable() { if (Object.op_Implicit((Object)(object)RelatedMover) && RelatedMover.active) { active = true; Main.AddPause(); } } private void OnDisable() { if (Object.op_Implicit((Object)(object)RelatedMover) && RelatedMover.active) { active = false; Main.AddPause(b: false); } } public void ChangeState(bool b) { if (active != b) { active = b; Main.AddPause(b); } } } } namespace ChaosMod.UI { public class ChaosUI : MonoBehaviour { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func <>9__27_0; public static UnityAction <>9__33_0; public static UnityAction <>9__33_1; public static UnityAction <>9__33_3; public static UnityAction <>9__33_4; internal bool b__27_0(Event e) { bool value; return ChaosSettings.eventEnabled.TryGetValue(e.name, out value) && value; } internal void b__33_0(int i) { ChaosSettings.difficulty = i; ChaosSettings.Save(); } internal void b__33_1(float b) { ChaosSettings.customTimerValue = b; ChaosSettings.Save(); } internal void b__33_3(float v) { ChaosSettings.loggerYOffset = v; ChaosSettings.Save(); } internal void b__33_4() { ChaosUIHelpers.SetAllToggles(!ChaosSettings.eventEnabled["Perk Overdose"]); } } public static ChaosUI instance; public TMP_FontAsset ticketingFont = null; private static GameObject chaosSettingsPage; private static List contentColumns = new List(); private static GameObject toggleTemplate; private static GameObject sliderTemplate; private static GameObject textTemplate; private static GameObject dropdownTemplate; private static GameObject buttonTemplate; public static Dictionary nameTruncates = new Dictionary(); private GameObject canvasObj; private RectTransform bgRect; private RectTransform fillRect; private RectTransform listRoot; private static GameObject root = null; private readonly List entries = new List(); public static List EventToggles = new List(); private static Dictionary difficultyDict = null; public static void ShowUI() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)instance == (Object)null) { GameObject val = new GameObject("ChaosTimer"); instance = val.AddComponent(); instance.CreateUI(); if ((Object)(object)root != (Object)null) { root.SetActive(false); } } } private void CreateUI() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) canvasObj = new GameObject(); canvasObj.transform.parent = ((Component)this).transform; Canvas val = canvasObj.AddComponent(); val.renderMode = (RenderMode)0; val.sortingOrder = 999; canvasObj.AddComponent().uiScaleMode = (ScaleMode)1; GameObject val2 = new GameObject("Background"); val2.transform.parent = canvasObj.transform; Image val3 = val2.AddComponent(); ((Graphic)val3).color = new Color(0f, 0f, 0f, 0.3f); bgRect = ((Graphic)val3).rectTransform; bgRect.anchorMin = Vector2.zero; bgRect.anchorMax = Vector2.right; bgRect.pivot = Vector2.right / 2f; bgRect.sizeDelta = new Vector2(0f, 4f); bgRect.anchoredPosition = new Vector2(0f, 0f); GameObject val4 = new GameObject("Background"); val4.transform.parent = val2.transform; Image val5 = val4.AddComponent(); ((Graphic)val5).color = new Color(1f, 1f, 1f, 0.6f); val5.type = (Type)3; val5.fillMethod = (FillMethod)0; val5.fillOrigin = 0; val5.fillAmount = 0f; fillRect = ((Graphic)val5).rectTransform; fillRect.anchorMin = Vector2.zero; fillRect.anchorMax = Vector2.up; fillRect.pivot = Vector2.up / 2f; RectTransform obj = fillRect; Rect rect = bgRect.rect; obj.sizeDelta = new Vector2(((Rect)(ref rect)).width, 0f); fillRect.anchoredPosition = Vector2.zero; GameObject val6 = new GameObject("EventList"); val6.transform.SetParent(canvasObj.transform, false); listRoot = val6.AddComponent(); listRoot.anchorMin = new Vector2(1f, 0f); listRoot.anchorMax = new Vector2(1f, 0f); listRoot.pivot = new Vector2(1f, 0f); listRoot.sizeDelta = new Vector2(100f, 0f); listRoot.anchoredPosition = new Vector2(-4f, 25f); ticketingFont = FindTicketingFont(); } public void SetTimer(float value) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)fillRect == (Object)null) && !((Object)(object)bgRect == (Object)null)) { value = Mathf.Clamp01(value); Rect rect = bgRect.rect; float width = ((Rect)(ref rect)).width; fillRect.sizeDelta = new Vector2(width * value, 0f); } } public EventEntry AddEntry(string name, float time, bool doubleEvent) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)listRoot == (Object)null) { return null; } GameObject val = new GameObject(name); val.transform.SetParent((Transform)(object)listRoot, false); EventEntry eventEntry = val.AddComponent(); eventEntry.Wake(name, time, this, doubleEvent); entries.Insert(0, eventEntry); RepositionEntries(); return eventEntry; } public void RemoveEntry(EventEntry entry) { if (entries.Remove(entry)) { RepositionEntries(); } } public void RemoveAllEntries() { foreach (EventEntry entry in entries) { Object.Destroy((Object)(object)((Component)entry).gameObject); } RepositionEntries(); } private void RepositionEntries() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) float num = ChaosSettings.loggerYOffset; for (int i = 0; i < entries.Count; i++) { entries[i].SetTargetPosition(new Vector2(0f, num)); num += entries[i].Height + 6f; } } private static void LoadNameTruncates() { nameTruncates["You are playing in IRON KNUCKLE mode. No perks for you!"] = "IRON KNUCKLE MODE"; nameTruncates["Will you be my buddy?"] = "Be my buddy?"; nameTruncates["I'll take that, it's mine now"] = "I'll Take That"; nameTruncates["Give up, you're surrounded"] = "You're Surrounded"; } private static TMP_FontAsset FindTicketingFont() { TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll(); foreach (TMP_FontAsset val in array) { if (((Object)val).name == "Ticketing SDF") { return val; } } Debug.LogWarning((object)"[Chaos - FindTicketingFont] Ticketing SDF font not found"); return null; } public static void SetEndScreens() { string text = "Chaos Mod"; if (difficultyDict == null) { difficultyDict = new Dictionary(); difficultyDict.Add(0, "Easy"); difficultyDict.Add(1, "Normal"); difficultyDict.Add(2, "Hard"); difficultyDict.Add(3, "IMPOSSIBLE"); } string value; if (ChaosSettings.customTimer) { text = text + " | " + ChaosSettings.customTimerValue.ToString("0.##") + "s Timer"; } else if (difficultyDict.TryGetValue(ChaosSettings.difficulty, out value)) { text = text + " | " + value; } if (EventManager.Events.Count == 0) { EventManager.FillList(); } bool value2; List list = EventManager.Events.Where((Event e) => ChaosSettings.eventEnabled.TryGetValue(e.name, out value2) && value2).ToList(); if (EventManager.Events.Count != list.Count) { text = text + " | " + list.Count + " Event"; if (list.Count != 1) { text += "s"; } } CL_GameManager.gMan.statManager.GetScoreScreen(false).SetTip(text); CL_GameManager.gMan.statManager.GetScoreScreen(true).SetTip(text); if (CL_GameManager.curDeathType != null) { CL_GameManager.gMan.statManager.GetScoreScreen(false).SetDeathText(CL_GameManager.curDeathType.deathText); } } public void FlashScreen(Color color, float duration = 0.15f) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)canvasObj == (Object)null)) { GameObject val = new GameObject("ScreenFlash"); val.transform.SetParent(canvasObj.transform, false); Image val2 = val.AddComponent(); ((Graphic)val2).color = color; RectTransform rectTransform = ((Graphic)val2).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; ((MonoBehaviour)this).StartCoroutine(FlashRoutine(val2, duration)); } } private IEnumerator FlashRoutine(Image flash, float duration) { Color start = ((Graphic)flash).color; float t = 0f; while (t < duration) { t += Time.deltaTime; Color c = start; c.a = Mathf.Lerp(start.a, 0f, t / duration); ((Graphic)flash).color = c; yield return null; } Object.Destroy((Object)(object)((Component)flash).gameObject); } public static void LoadMenuMenu() { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Expected O, but got Unknown if ((Object)(object)root == (Object)null) { root = new GameObject("ChaosMainMenuUI"); Object.DontDestroyOnLoad((Object)(object)root); Canvas val = root.AddComponent(); val.renderMode = (RenderMode)0; val.sortingOrder = 1; root.AddComponent().uiScaleMode = (ScaleMode)1; root.AddComponent(); TMP_FontAsset font = FindTicketingFont(); CreateText(root.transform, "CHAOS MOD v1.2.1", font, 14f, (TextAlignmentOptions)260, new Vector2(1f, 1f), new Vector2(-5f, -30f), new Vector2(250f, 30f)); LoadNameTruncates(); } root.SetActive(true); GameObject val2 = GameObject.Find("Canvas - Main Menu/Main Menu/Support Menu/"); GameObject val3 = Object.Instantiate(((Component)val2.transform.Find("Update Info")).gameObject); val3.transform.parent = val2.transform; val3.transform.SetAsFirstSibling(); val3.transform.localScale = Vector3.one; ((Graphic)val3.GetComponent()).color = new Color(0.5f, 0.5f, 1f, 1f); TextMeshProUGUI component = ((Component)val3.transform.GetChild(0)).GetComponent(); ((TMP_Text)component).text = "Chaos Settings"; ((Graphic)component).color = new Color(1f, 1f, 1f, 0.25f); ColorBlock colors = default(ColorBlock); ((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0.75f); ((ColorBlock)(ref colors)).highlightedColor = new Color(0.2406f, 0.2406f, 1f, 0.9f); ((ColorBlock)(ref colors)).pressedColor = new Color(0.0991f, 0.0991f, 1f, 1f); ((ColorBlock)(ref colors)).selectedColor = new Color(0f, 0f, 1f, 1f); ((ColorBlock)(ref colors)).disabledColor = new Color(0.7843f, 0.7843f, 0.7843f, 0.502f); ((ColorBlock)(ref colors)).colorMultiplier = 1f; ((ColorBlock)(ref colors)).fadeDuration = 0.1f; Button component2 = val3.GetComponent