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 BepInEx.Logging; using HarmonyLib; using StateLogger; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.SceneManagement; using UnityEngine.UI; using flanne; using flanne.Player; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Final")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Final")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("53e96529-a751-4a99-acae-2243ab77ca54")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace StateLogger { [BepInPlugin("lucas.statelogger", "State Logger", "2.0.0")] public class GameStateMonitor : BaseUnityPlugin { private const string PluginGuid = "lucas.statelogger"; private const string PluginName = "State Logger"; private const string PluginVersion = "2.0.0"; internal static ManualLogSource Log; public static State CurrentState; private Harmony harmony; private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; harmony = new Harmony("lucas.statelogger"); PatchAllStateSubclasses(); } private void PatchAllStateSubclasses() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown Type typeFromHandle = typeof(State); HashSet patched = new HashSet(); HarmonyMethod postfix = new HarmonyMethod(typeof(GameStateMonitor).GetMethod("EnterPostfix", BindingFlags.Static | BindingFlags.NonPublic)); HarmonyMethod postfix2 = new HarmonyMethod(typeof(GameStateMonitor).GetMethod("ExitPostfix", BindingFlags.Static | BindingFlags.NonPublic)); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type[] types; try { types = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types; } if (types == null) { continue; } Type[] array = types; foreach (Type type in array) { if (!(type == null) && !type.IsAbstract && typeFromHandle.IsAssignableFrom(type)) { TryPatchMethod(type, "Enter", postfix, patched); TryPatchMethod(type, "Exit", postfix2, patched); } } } } private void TryPatchMethod(Type type, string methodName, HarmonyMethod postfix, HashSet patched) { MethodInfo method; try { method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } catch { return; } if (method == null || method.IsAbstract || patched.Contains(method)) { return; } try { harmony.Patch((MethodBase)method, (HarmonyMethod)null, postfix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); patched.Add(method); } catch (Exception ex) { Log.LogWarning((object)("Failed to patch " + type.FullName + "." + methodName + ": " + ex.Message)); } } private static void EnterPostfix(State __instance) { CurrentState = __instance; } private static void ExitPostfix(State __instance) { if ((Object)(object)CurrentState == (Object)(object)__instance) { CurrentState = null; } } } } namespace Final { public class ActionManager { private GameAction currentExecutingAction = null; private bool executionToggle = true; public List Actions { get; } = new List(); public bool ExecutingActions { get; private set; } = false; public void AddAction(GameAction action) { Actions.Add(action); SyncDisplay(); } public void StartExecuting() { ExecutingActions = true; } public void Tick() { if (ExecutingActions && Actions.Count > 0) { if (executionToggle) { currentExecutingAction = Actions[0]; SyncDisplay(); currentExecutingAction.execute(); currentExecutingAction.Complete = true; if (currentExecutingAction.Complete) { currentExecutingAction = null; Actions.RemoveAt(0); } executionToggle = false; } else { executionToggle = true; } } if (ExecutingActions && Actions.Count == 0) { ExecutingActions = false; executionToggle = false; } } public void SyncDisplay() { Main.Instance.uiAssetLoader.SyncActionDisplay(Actions); } } [BepInPlugin("com.yourname.myplugin", "Plugin", "1.0.0")] public class Main : BaseUnityPlugin { internal static ManualLogSource Log; private static readonly HashSet PausingStateNames = new HashSet { "PauseState", "PowerupMenuState", "DevilDealState", "GunEvoMenuState", "ChestState", "OptionsState", "SynergyUIState" }; public bool placementMode = false; public List InjectedUIComponents = new List(); public PlacementManager placementManager = new PlacementManager(); public ActionManager actionManager = new ActionManager(); public ImageRipper imageRipper = new ImageRipper(); public ScreenLogger screenLogger = new ScreenLogger(); public UIControl uiAssetLoader = new UIControl(); public GameObject _enemyUIInstance = null; public GameObject canvasObj = null; public string pendingEnemyName = ""; private bool firstFightStateDetected = false; public static Main Instance { get; private set; } private void Awake() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("com.yourname.myplugin"); val.PatchAll(); placementManager = new PlacementManager(); Patches.CatalogEnemyPrefabs(); uiAssetLoader.Start(); } private void Update() { //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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "Battle" && !firstFightStateDetected) { FirstFightState(); firstFightStateDetected = true; } activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name != "Battle") { firstFightStateDetected = false; } activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name == "Battle" && ((ButtonControl)current.tabKey).wasPressedThisFrame && !actionManager.ExecutingActions) { GameObject val = GameObject.Find("MainUIInjection"); if ((Object)(object)val == (Object)null) { GameObject val2 = uiAssetLoader.MakeMainUI(canvasObj.transform); val2.transform.SetAsFirstSibling(); if ((Object)(object)val2 != (Object)null) { ((Object)val2).name = "MainUIInjection"; } } else { placementManager.CancelPlacement(); Object.Destroy((Object)(object)val); uiAssetLoader.UnsetDisplayBox(); actionManager.StartExecuting(); } } placementManager.Update(); TimeControl(); actionManager.SyncDisplay(); } private void FixedUpdate() { actionManager.Tick(); } private void FirstFightState() { canvasObj = GameObject.Find("Canvas"); imageRipper.FightSceneRip(); Patches.GatherResources(); GameObject val = uiAssetLoader.CreateActionDisplayUI(canvasObj.transform); GameObject val2 = uiAssetLoader.CreateDisplayBox(canvasObj.transform); val.transform.SetAsFirstSibling(); val2.transform.SetAsFirstSibling(); } private void TimeControl() { string text = ((object)GameStateMonitor.CurrentState)?.GetType().Name; bool flag = text != null && PausingStateNames.Contains(text); if (text == "TransitionToRetryState" && firstFightStateDetected) { firstFightStateDetected = false; } else if (flag || (Object)(object)GameObject.Find("MainUIInjection") != (Object)null) { Time.timeScale = 0f; } else { Time.timeScale = 1f; } } } public class GameAction { public string Name { get; set; } public bool Complete { get; set; } = false; public Action action { get; set; } public GameAction(string name) { Name = name; } public void execute() { action?.Invoke(); } } public class ImageRipper { public Image GenericBox; public Image ScrollHandle; public Image ScrollBar; public TMP_FontAsset[] fonts; public TMP_FontAsset Lantern; public TMP_FontAsset Express; public Color LanternRed; public Color ButtonBlue; public void FightSceneRip() { GenericBox = GameObject.Find("PauseMenu").GetComponent(); ScrollHandle = GameObject.Find("Canvas/SynergiesUI/Scroll View/Scrollbar/Sliding Area/Handle").GetComponent(); ScrollBar = GameObject.Find("Canvas/SynergiesUI/Scroll View/Scrollbar").GetComponent(); fonts = Resources.FindObjectsOfTypeAll(); GameObject gameObject = ((Component)GameObject.Find("ShootControls").transform.Find("Keybind")).gameObject; TMP_FontAsset[] array = fonts; foreach (TMP_FontAsset val in array) { if (((Object)val).name == "Lantern") { Lantern = val; } else if (((Object)val).name == "Express") { Express = val; } } ColorUtility.TryParseHtmlString("#fd5161", ref LanternRed); ColorUtility.TryParseHtmlString("#293448", ref ButtonBlue); } } public static class Patches { [HarmonyPatch(typeof(PlayerXP), "Awake")] public static class PlayerXP_Awake_Patch { public static PlayerXP Instance { get; private set; } [HarmonyPostfix] private static void Postfix(PlayerXP __instance) { Instance = __instance; } } [HarmonyPatch(typeof(PlayerBuffs))] public class PlayerBuffsPatch { public static PlayerBuffs Instance { get; private set; } [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPostfix(PlayerBuffs __instance) { Instance = __instance; } [HarmonyPatch("OnDestroy")] [HarmonyPrefix] private static void OnDestroyPrefix(PlayerBuffs __instance) { if ((Object)(object)Instance == (Object)(object)__instance) { Instance = null; } } } [HarmonyPatch(typeof(PlayerController))] public class PlayerControllerPatch { public static PlayerController Instance { get; private set; } [HarmonyPatch(typeof(PlayerController), "Awake")] [HarmonyPostfix] private static void AwakePostfix(PlayerController __instance) { Instance = __instance; } } [HarmonyPatch(typeof(ReloadState))] public class ReloadState_Enter_Patch { [HarmonyPatch("Enter")] [HarmonyPrefix] private static bool Prefix(ReloadState __instance) { if (Time.timeScale == 1f) { return true; } FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerState), "owner"); object value = fieldInfo.GetValue(__instance); MethodInfo methodInfo = AccessTools.Method(value.GetType(), "ChangeState", (Type[])null, (Type[])null).MakeGenericMethod(typeof(IdleState)); methodInfo.Invoke(value, null); return false; } } [HarmonyPatch(typeof(Gun))] public class GunPatch { public static Gun Instance { get; private set; } [HarmonyPatch("LoadGun")] [HarmonyPrefix] private static void LoadGunPrefix(Gun __instance) { Instance = __instance; } [HarmonyPatch("StartShooting")] [HarmonyPrefix] private static bool StartShootingPrefix() { if (Time.timeScale == 1f) { return true; } return false; } } public static Dictionary enemyPrefabs = new Dictionary(); public static GunEvolution[] GunEvolutions; public static GunData[] Guns; public static Powerup[] AllPowerups; public static void GatherResources() { GunEvolutions = Resources.FindObjectsOfTypeAll(); Guns = Resources.FindObjectsOfTypeAll(); AllPowerups = Resources.FindObjectsOfTypeAll(); } public static void CatalogEnemyPrefabs() { AIComponent[] array = Resources.FindObjectsOfTypeAll(); AIComponent[] array2 = array; foreach (AIComponent val in array2) { if (!enemyPrefabs.ContainsKey(((Object)((Component)val).gameObject).name)) { enemyPrefabs.Add(((Object)((Component)val).gameObject).name, ((Component)val).gameObject); } } } public static float GetXPToNextLevel(PlayerXP PlayerXPInstance) { FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerXP), "xp"); float num = (float)fieldInfo.GetValue(PlayerXPInstance); float num2 = PlayerXPInstance.level + 1; if (num2 < 20f) { return num2 * 10f - 5f - num + 0.1f; } if (num2 < 40f) { return num2 * 13f - 6f - num + 0.1f; } if (num2 < 60f) { return num2 * 16f - 8f - num + 0.1f; } return num2 * num2 - num + 0.1f; } public static void LVUP() { PlayerXP_Awake_Patch.Instance.GainXP(GetXPToNextLevel(PlayerXP_Awake_Patch.Instance)); } } public class PlacementManager { private GameObject enemyUIInstance; private string pendingEnemyName = ""; public bool PlacementMode { get; private set; } = false; public void Update() { if (PlacementMode) { Keyboard current = Keyboard.current; if (((ButtonControl)current.leftCtrlKey).wasPressedThisFrame) { CancelPlacement(); } else if (Mouse.current.leftButton.wasPressedThisFrame) { PlaceEnemy(); } } } public void StartPlacement(string enemyName) { pendingEnemyName = enemyName; PlacementMode = true; } private void PlaceEnemy() { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0085: 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_012f: Unknown result type (might be due to invalid IL or missing references) Vector2 val = ((InputControl)(object)((Pointer)Mouse.current).position).ReadValue(); Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3(val.x, val.y, Camera.main.nearClipPlane)); worldPos.z = 0f; string selectedEnemyName = pendingEnemyName; GameObject previewObj = new GameObject(selectedEnemyName + "_PlacementPreview"); previewObj.transform.position = worldPos; if (Patches.enemyPrefabs.TryGetValue(selectedEnemyName, out var value)) { SpriteRenderer componentInChildren = value.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { SpriteRenderer val2 = previewObj.AddComponent(); val2.sprite = componentInChildren.sprite; ((Renderer)val2).sortingLayerID = ((Renderer)componentInChildren).sortingLayerID; ((Renderer)val2).sortingOrder = ((Renderer)componentInChildren).sortingOrder; val2.color = new Color(1f, 1f, 1f, 0.5f); previewObj.transform.localScale = value.transform.localScale; } } GameAction gameAction = new GameAction("SpawnEnemy"); gameAction.action = delegate { //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) if (Patches.enemyPrefabs.TryGetValue(selectedEnemyName, out var value2)) { Object.Instantiate(value2, worldPos, Quaternion.identity); } if ((Object)(object)previewObj != (Object)null) { Object.Destroy((Object)(object)previewObj); } }; Main.Instance.actionManager.AddAction(gameAction); } public void CancelPlacement() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown PlacementMode = false; pendingEnemyName = ""; if ((Object)(object)enemyUIInstance != (Object)null) { Object.Destroy((Object)(object)enemyUIInstance); enemyUIInstance = null; } GameObject val = GameObject.Find("MainUIInjection"); if (!((Object)(object)val != (Object)null)) { return; } foreach (Transform item in val.transform) { Transform val2 = item; if (((Object)val2).name != "EnemiesUI") { ((Component)val2).gameObject.SetActive(true); } } } } public class ScreenLogger { private class DummyRunner : MonoBehaviour { } private TextMeshProUGUI _text; private MonoBehaviour _runner; public void LogToScreen(string message, float duration = 1f, float fadeTime = 1f) { if ((Object)(object)_text == (Object)null) { CreateUI(); } if (!((Object)(object)_text == (Object)null)) { ((TMP_Text)_text).text = message; ((TMP_Text)_text).alpha = 1f; _runner.StopAllCoroutines(); _runner.StartCoroutine(FadeOut(duration, fadeTime)); } } private void CreateUI() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown //IL_00d6: 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_010e: 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_0130: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Canvas"); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"ScreenLogger: Canvas not found."); return; } _runner = val.GetComponent(); if ((Object)(object)_runner == (Object)null) { _runner = (MonoBehaviour)(object)val.AddComponent(); } GameObject val2 = new GameObject("ScreenLoggerText"); val2.transform.SetParent(val.transform, false); _text = val2.AddComponent(); ((TMP_Text)_text).fontSize = 28f; ((TMP_Text)_text).alignment = (TextAlignmentOptions)514; ((Graphic)_text).raycastTarget = false; ((TMP_Text)_text).font = Main.Instance.imageRipper.Lantern; ((Graphic)_text).color = Main.Instance.imageRipper.LanternRed; RectTransform rectTransform = ((TMP_Text)_text).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 0.2f); rectTransform.anchorMax = new Vector2(0.5f, 0.2f); rectTransform.anchoredPosition = Vector2.zero; rectTransform.sizeDelta = new Vector2(800f, 100f); } private IEnumerator FadeOut(float delay, float fadeTime) { yield return (object)new WaitForSecondsRealtime(delay); float t = 0f; while (t < fadeTime) { t += Time.unscaledDeltaTime; ((TMP_Text)_text).alpha = Mathf.Lerp(1f, 0f, t / fadeTime); yield return null; } ((TMP_Text)_text).alpha = 0f; } } public class UIControl { public string mainBundlePath = Path.Combine(Paths.PluginPath, "CreativeMode/20mtdbundle"); public AssetBundle mainBundle; private GameObject actionDisplayInstance = null; private Transform actionDisplayContent = null; private readonly List actionDisplayBoxes = new List(); private GameObject displayBoxInstance = null; private string[] ButtonBoxNames = new string[3] { "PowerUps", "Enemies", "Guns" }; private const float ActionDisplayBoxDefaultWidth = 160f; private const float ActionDisplayBoxDefaultHeight = 30f; private const float ActionDisplayBoxSpacing = 4f; private const float ActionDisplayTextMaxFontSize = 10f; private const float ActionDisplayTextMinFontSize = 4f; private const float ActionDisplayTextHorizontalPadding = 4f; private const float ActionDisplayTextVerticalPadding = 2f; private const float ActionDisplayVisibleAreaScale = 0.95f; private Color PanelButtonColor; public void Start() { //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) mainBundle = LoadBundleSafe(mainBundlePath); PanelButtonColor = ParseColor("#293448"); } private AssetBundle LoadBundleSafe(string path) { AssetBundle val = AssetBundle.LoadFromFile(path); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("Failed to load asset bundle at " + path)); } return val; } private GameObject LoadPrefab(AssetBundle bundle, string assetName) { if ((Object)(object)bundle == (Object)null) { Main.Log.LogError((object)("Asset bundle is null, cannot load '" + assetName + "'")); return null; } GameObject val = bundle.LoadAsset(assetName); if ((Object)(object)val == (Object)null) { Main.Log.LogError((object)("Could not load '" + assetName + "' from bundle!")); } return val; } private Color ParseColor(string hex) { //IL_000a: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); ColorUtility.TryParseHtmlString(hex, ref result); return result; } private T FindComponent(Transform root, string path) where T : Component { Transform val = root.Find(path); if ((Object)(object)val == (Object)null) { Main.Log.LogError((object)("Could not find '" + path + "' under '" + ((Object)root).name + "'")); return default(T); } T component = ((Component)val).GetComponent(); if ((Object)(object)component == (Object)null) { Main.Log.LogError((object)("'" + path + "' has no " + typeof(T).Name + " component")); } return component; } private void StyleBackground(Transform uiRoot) { Image val = FindComponent(uiRoot, "BG"); if (!((Object)(object)val == (Object)null)) { val.sprite = Main.Instance.imageRipper.GenericBox.sprite; val.type = (Type)1; } } private void StyleScrollbar(Transform uiRoot) { //IL_005f: 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) Image val = FindComponent(uiRoot, "Scrollbar"); Image val2 = FindComponent(uiRoot, "Scrollbar/Sliding Area/Handle"); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { val.sprite = Main.Instance.imageRipper.ScrollBar.sprite; ((Graphic)val).color = ((Graphic)Main.Instance.imageRipper.ScrollBar).color; val2.sprite = Main.Instance.imageRipper.ScrollHandle.sprite; ((Graphic)val2).color = ((Graphic)Main.Instance.imageRipper.ScrollHandle).color; } } private Button StyleMenuButton(Transform uiRoot, string buttonName) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) Button val = FindComponent