Decompiled source of DebugMod v0.3.2
DebugMod.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using DebugMod.Helpers; using DebugMod.Hitbox; using DebugMod.MonoBehaviours; using DebugMod.SaveStates; using DebugMod.UI; using DebugMod.UI.Canvas; using GlobalEnums; using GlobalSettings; using HarmonyLib; using InControl; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.ResourceManagement.ResourceProviders; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("DebugMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.2.0")] [assembly: AssemblyInformationalVersion("0.3.2+130f11519e99c846d25d0e8bdafd1ea6f4d062b5")] [assembly: AssemblyProduct("DebugMod")] [assembly: AssemblyTitle("DebugMod")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/hk-speedrunning/Silksong.DebugMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace DebugMod { [HarmonyPatch] public static class BindableFunctions { [CompilerGenerated] private sealed class <AdvanceMyFrame>d__73 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <AdvanceMyFrame>d__73(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; TimeScale.Frozen = false; <>2__current = (object)new WaitForFixedUpdate(); <>1__state = 1; return true; case 1: <>1__state = -1; TimeScale.Frozen = true; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static string saveLevelStateAction; internal static int frameCounter; [BindableMethod(name = "Kill All", category = "Cheats")] public static void KillAll() { int num = 0; HealthManager[] array = Object.FindObjectsByType<HealthManager>((FindObjectsSortMode)0); foreach (HealthManager val in array) { if (!val.isDead) { val.Die((float?)null, (AttackTypes)1, true); num++; } } DebugMod.LogConsole($"Killing {num} HealthManagers in scene!"); } [BindableMethod(name = "Infinite Jump", category = "Cheats")] public static void ToggleInfiniteJump() { PlayerData.instance.infiniteAirJump = !PlayerData.instance.infiniteAirJump; DebugMod.LogConsole("Infinite Jump set to " + PlayerData.instance.infiniteAirJump.ToString().ToUpper()); } [BindableMethod(name = "Infinite Silk", category = "Cheats")] public static void ToggleInfiniteSilk() { DebugMod.infiniteSilk = !DebugMod.infiniteSilk; DebugMod.LogConsole("Infinite Silk set to " + DebugMod.infiniteSilk.ToString().ToUpper()); } [BindableMethod(name = "Infinite HP", category = "Cheats")] public static void ToggleInfiniteHP() { DebugMod.infiniteHP = !DebugMod.infiniteHP; DebugMod.LogConsole("Infinite HP set to " + DebugMod.infiniteHP.ToString().ToUpper()); } [BindableMethod(name = "Infinite Tools", category = "Cheats")] public static void ToggleInfiniteTools() { DebugMod.infiniteTools = !DebugMod.infiniteTools; DebugMod.LogConsole("Infinite Tools set to " + DebugMod.infiniteTools.ToString().ToUpper()); } [BindableMethod(name = "Invincibility", category = "Cheats")] public static void ToggleInvincibility() { DebugMod.playerInvincible = !DebugMod.playerInvincible; DebugMod.LogConsole("Invincibility set to " + DebugMod.playerInvincible.ToString().ToUpper()); PlayerData.instance.isInvincible = DebugMod.playerInvincible; } [BindableMethod(name = "Noclip", category = "Cheats")] public static void ToggleNoclip() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) DebugMod.noclip = !DebugMod.noclip; if (DebugMod.noclip) { DebugMod.LogConsole("Enabled noclip"); DebugMod.noclipPos = DebugMod.RefKnight.transform.position; } else { DebugMod.LogConsole("Disabled noclip"); Rigidbody2D component = DebugMod.RefKnight.GetComponent<Rigidbody2D>(); component.constraints = (RigidbodyConstraints2D)(component.constraints & -4); } } [BindableMethod(name = "Toggle Hero Collider", category = "Cheats")] public static void ToggleHeroCollider() { //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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!((Behaviour)DebugMod.RefHeroCollider).enabled) { ((Behaviour)DebugMod.RefHeroCollider).enabled = true; ((Behaviour)DebugMod.RefHeroBox).enabled = true; DebugMod.LogConsole("Enabled hero collider" + (DebugMod.noclip ? " and disabled noclip" : "")); DebugMod.noclip = false; Rigidbody2D component = DebugMod.RefKnight.GetComponent<Rigidbody2D>(); component.constraints = (RigidbodyConstraints2D)(component.constraints & -4); } else { ((Behaviour)DebugMod.RefHeroCollider).enabled = false; ((Behaviour)DebugMod.RefHeroBox).enabled = false; DebugMod.LogConsole("Disabled hero collider" + (DebugMod.noclip ? "" : " and enabled noclip")); DebugMod.noclip = true; DebugMod.noclipPos = DebugMod.RefKnight.transform.position; } } [BindableMethod(name = "Give Rosaries", category = "Consumables")] public static void GiveRosaries() { HeroController.instance.AddGeo(1000); DebugMod.LogConsole("Giving player 1000 rosaries"); } [BindableMethod(name = "Give Shell Shards", category = "Consumables")] public static void GiveShellShards() { HeroController.instance.AddShards(100); DebugMod.LogConsole("Giving player 100 shell shards"); } private static void SetCollectable(string name, int amount) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (CollectableItemManager.IsInHiddenMode()) { ManagerSingleton<CollectableItemManager>.Instance.AffectItemData(name, (ItemAffectingDelegate)delegate(ref Data data) { data.AmountWhileHidden = amount; }); } else { ManagerSingleton<CollectableItemManager>.Instance.AffectItemData(name, (ItemAffectingDelegate)delegate(ref Data data) { data.Amount = amount; }); } } [BindableMethod(name = "Give Memory Lockets", category = "Consumables")] public static void GiveMemoryLockets() { SetCollectable("Crest Socket Unlocker", 20); DebugMod.LogConsole("Set player memory lockets to 20"); } [BindableMethod(name = "Give Craftmetal", category = "Consumables")] public static void GiveCraftmetal() { SetCollectable("Tool Metal", 8); DebugMod.LogConsole("Set player craftmetal to 8"); } [BindableMethod(name = "Give Silkeater", category = "Consumables")] public static void GiveSilkeater() { CollectableItemManager.GetItemByName("Silk Grub").AddAmount(1); DebugMod.LogConsole("Giving player a silkeater"); } [BindableMethod(name = "Toggle HP Bars", category = "Enemies")] public static void ToggleEnemyHPBars() { EnemiesPanel.hpBars = !EnemiesPanel.hpBars; if (EnemiesPanel.hpBars) { DebugMod.LogConsole("Enabled HP bars"); } else { DebugMod.LogConsole("Disabled HP bars"); } } [BindableMethod(name = "Give Mask", category = "Masks & Spools")] public static void GiveMask() { if (PlayerData.instance.maxHealthBase < 10) { HeroController.instance.MaxHealth(); HeroController.instance.AddToMaxHealth(1); HudHelper.RefreshMasks(); DebugMod.LogConsole("Added Mask"); } else { DebugMod.LogConsole("You have the maximum number of masks"); } } [BindableMethod(name = "Give Spool", category = "Masks & Spools")] public static void GiveSpool() { if (PlayerData.instance.silkMax < 18) { HeroController.instance.AddToMaxSilk(1); HudHelper.RefreshSpool(); DebugMod.LogConsole("Added Spool"); } else { DebugMod.LogConsole("You have the maximum number of spools"); } PlayerData.instance.IsSilkSpoolBroken = false; EventRegister.SendEvent("SPOOL UNBROKEN", (GameObject)null); } [BindableMethod(name = "Take Away Mask", category = "Masks & Spools")] public static void TakeAwayMask() { if (PlayerData.instance.maxHealthBase > 1) { PlayerData instance = PlayerData.instance; instance.maxHealth--; PlayerData instance2 = PlayerData.instance; instance2.maxHealthBase--; PlayerData.instance.health = Math.Min(PlayerData.instance.health, PlayerData.instance.maxHealth); HudHelper.RefreshMasks(); DebugMod.LogConsole("Took Away Mask"); } else { DebugMod.LogConsole("You have the minimum number of masks"); } } [BindableMethod(name = "Take Away Spool", category = "Masks & Spools")] public static void TakeAwaySpool() { if (PlayerData.instance.silkMax > 9) { PlayerData instance = PlayerData.instance; instance.silkMax--; PlayerData.instance.silk = Math.Min(PlayerData.instance.silk, PlayerData.instance.silkMax); HudHelper.RefreshSpool(); DebugMod.LogConsole("Removed Spool"); } else { DebugMod.LogConsole("You have the minimum number of spools"); } } private static bool CanModifyHealth(int health) { if (health <= 0) { DebugMod.LogConsole("Cannot add/take health: health is too low"); return false; } if (HeroController.instance.cState.dead) { DebugMod.LogConsole("Cannot add/take health: player is dead"); return false; } if (!GameManager.instance.IsGameplayScene()) { DebugMod.LogConsole("Cannot add/take health: not a gameplay scene"); return false; } return true; } [BindableMethod(name = "Add Health", category = "Masks & Spools")] public static void AddHealth() { if (CanModifyHealth(PlayerData.instance.health + 1)) { HeroController.instance.AddHealth(1); HudHelper.RefreshMasks(); DebugMod.LogConsole("Added Health"); } } [BindableMethod(name = "Take Health", category = "Masks & Spools")] public static void TakeHealth() { if (CanModifyHealth(PlayerData.instance.health - 1)) { HeroController.instance.TakeHealth(1); HudHelper.RefreshMasks(); DebugMod.LogConsole("Took health"); } } [BindableMethod(name = "Add Silk", category = "Masks & Spools")] public static void AddSilk() { HeroController.instance.AddSilk(1, true); DebugMod.LogConsole("Added Silk"); } [BindableMethod(name = "Take Silk", category = "Masks & Spools")] public static void TakeSilk() { HeroController.instance.TakeSilk(1); DebugMod.LogConsole("Attempting to take silk"); } [BindableMethod(name = "Add Lifeblood", category = "Masks & Spools")] public static void Lifeblood() { EventRegister.SendEvent("ADD BLUE HEALTH", (GameObject)null); DebugMod.LogConsole("Attempting to add lifeblood"); } [BindableMethod(name = "Toggle Act 3", category = "Misc")] public static void ToggleAct3() { PlayerData.instance.blackThreadWorld = !PlayerData.instance.blackThreadWorld; DebugMod.LogConsole("Act 3 world is now " + (PlayerData.instance.blackThreadWorld ? "enabled" : "disabled")); } [BindableMethod(name = "Set Hazard Respawn", category = "Misc")] public static void SetHazardRespawn() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 position = DebugMod.RefKnight.transform.position; HeroController.instance.SetHazardRespawn(position, false); Vector3 val = position; DebugMod.LogConsole("Manual respawn point on this map set to" + ((object)(Vector3)(ref val)).ToString()); } [BindableMethod(name = "Hazard Respawn", category = "Misc")] public static void Respawn() { if (GameManager.instance.IsGameplayScene() && !HeroController.instance.cState.dead && PlayerData.instance.health > 0) { if (((object)(UIState)(ref UIManager.instance.uiState)).ToString() == "PAUSED") { ((MonoBehaviour)ManagerSingleton<InputHandler>.Instance).StartCoroutine(GameManager.instance.PauseGameToggle(false)); GameManager.instance.HazardRespawn(); DebugMod.LogConsole("Closing Pause Menu and respawning..."); } else if (((object)(UIState)(ref UIManager.instance.uiState)).ToString() == "PLAYING") { HeroController.instance.RelinquishControl(); GameManager.instance.HazardRespawn(); HeroController.instance.RegainControl(); DebugMod.LogConsole("Respawn signal sent"); } else { DebugMod.LogConsole("Respawn requested in some weird conditions, abort, ABORT"); } } } [BindableMethod(name = "Damage Self", category = "Misc")] public static void SelfDamage() { if (PlayerData.instance.health <= 0) { DebugMod.LogConsole("Cannot damage self: health <= 0"); return; } if (HeroController.instance.cState.dead) { DebugMod.LogConsole("Cannot damage self: player is dead"); return; } if (!GameManager.instance.IsGameplayScene()) { DebugMod.LogConsole("Cannot damage self: not a gameplay scene"); return; } if (HeroController.instance.cState.recoiling) { DebugMod.LogConsole("Cannot damage self: player is recoiling"); return; } if (HeroController.instance.cState.invulnerable) { DebugMod.LogConsole("Cannot damage self: player is invulnerable"); return; } HeroController.instance.DamageSelf(1); DebugMod.LogConsole("Attempting self damage"); } [BindableMethod(name = "Kill Self", category = "Misc")] public static void KillSelf() { if (!HeroController.instance.cState.dead && !HeroController.instance.cState.transitioning) { ((MonoBehaviour)HeroController.instance).StartCoroutine(HeroController.instance.Die(false, false)); DebugMod.LogConsole("Killed player"); } } [BindableMethod(name = "Break Cocoon", category = "Misc")] public static void BreakCocoon() { HeroController instance = HeroController.instance; if (instance != null) { instance.CocoonBroken(); } EventRegister.SendEvent("BREAK HERO CORPSE", (GameObject)null); } [BindableMethod(name = "Reset Scene Data", category = "Misc")] public static void ResetCurrentScene() { saveLevelStateAction = GameManager.instance.GetSceneNameString(); DebugMod.LogConsole("Clearing scene data from this scene, re-enter scene or warp to apply changes"); } [BindableMethod(name = "Block Scene Data Changes", category = "Misc")] public static void BlockCurrentSceneChanges() { saveLevelStateAction = "block"; DebugMod.LogConsole("Scene data changes made since entering this scene will not be saved"); } [HarmonyPatch(typeof(GameManager), "SaveLevelState")] [HarmonyPrefix] private static bool GameManager_SaveLevelState_Prefix() { if (saveLevelStateAction == "block") { saveLevelStateAction = null; return false; } return true; } [HarmonyPatch(typeof(GameManager), "SaveLevelState")] [HarmonyPostfix] private static void GameManager_SaveLevelState_Postfix() { if (saveLevelStateAction != null && saveLevelStateAction != "block") { ((PersistentItemDataCollection<bool, SerializableBoolData>)(object)SceneData.instance.persistentBools).scenes.Remove(saveLevelStateAction); ((PersistentItemDataCollection<int, SerializableIntData>)(object)SceneData.instance.persistentInts).scenes.Remove(saveLevelStateAction); ((PersistentItemDataCollection<int, SerializableIntData>)(object)SceneData.instance.geoRocks).scenes.Remove(saveLevelStateAction); saveLevelStateAction = null; } } [BindableMethod(name = "Lock Keybinds", category = "Misc")] public static void ToggleLockKeyBinds() { DebugMod.KeyBindLock = !DebugMod.KeyBindLock; DebugMod.LogConsole((DebugMod.KeyBindLock ? "Removing" : "Adding") + " the ability to use keybinds"); } [BindableMethod(name = "Reset Cheats", category = "Misc")] public static void Reset() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) PlayerData instance = PlayerData.instance; HeroController instance2 = HeroController.instance; GameCameras instance3 = GameCameras.instance; DebugMod.extraNailDamage = 0; PlayerData.instance.nailUpgrades = 0; PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE"); GameObject gameObject = ((Component)DebugMod.RefKnight.transform.Find("HeroLight")).gameObject; Color color = gameObject.GetComponent<SpriteRenderer>().color; color.a = 0.7f; gameObject.GetComponent<SpriteRenderer>().color = color; tk2dSprite component = DebugMod.RefKnight.GetComponent<tk2dSprite>(); color = ((tk2dBaseSprite)component).color; color.a = 1f; ((tk2dBaseSprite)component).color = color; TimeScale.Reset(); instance3.tk2dCam.ZoomFactor = 1f; ((Renderer)instance2.vignette).enabled = false; EnemiesPanel.hpBars = false; instance.infiniteAirJump = false; DebugMod.infiniteSilk = false; DebugMod.infiniteHP = false; instance.isInvincible = false; DebugMod.noclip = false; } [BindableMethod(name = "Toggle All UI", category = "Mod UI", allowLock = false)] public static void ToggleAllPanels() { bool flag = !DebugMod.settings.InfoPanelVisible && !DebugMod.settings.EnemiesPanelVisible && !DebugMod.settings.MainPanelVisible && !DebugMod.settings.ConsoleVisible && !DebugMod.settings.SaveStatePanelVisible; DebugMod.settings.InfoPanelVisible = flag; DebugMod.settings.MainPanelVisible = flag; DebugMod.settings.EnemiesPanelVisible = flag; DebugMod.settings.ConsoleVisible = flag; DebugMod.settings.SaveStatePanelVisible = flag; } [BindableMethod(name = "Toggle Main Panel", category = "Mod UI")] public static void ToggleMainPanel() { DebugMod.settings.MainPanelVisible = !DebugMod.settings.MainPanelVisible; } [BindableMethod(name = "Toggle Enemies Panel", category = "Mod UI")] public static void ToggleEnemiesPanel() { DebugMod.settings.EnemiesPanelVisible = !DebugMod.settings.EnemiesPanelVisible; } [BindableMethod(name = "Toggle Console Panel", category = "Mod UI")] public static void ToggleConsolePanel() { DebugMod.settings.ConsoleVisible = !DebugMod.settings.ConsoleVisible; } [BindableMethod(name = "Toggle Info Panel", category = "Mod UI")] public static void ToggleInfoPanel() { DebugMod.settings.InfoPanelVisible = !DebugMod.settings.InfoPanelVisible; } [BindableMethod(name = "Toggle Savestates Panel", category = "Mod UI")] public static void ToggleSaveStatePanel() { DebugMod.settings.SaveStatePanelVisible = !DebugMod.settings.SaveStatePanelVisible; if (!DebugMod.settings.SaveStatePanelVisible) { SaveStatesPanel.Instance.CancelSelectState(); } } [BindableMethod(name = "Expand/Collapse Savestates", category = "Mod UI")] public static void ToggleExpandedSaveStatePanel() { SaveStatesPanel.Instance.ToggleView(); } [BindableMethod(name = "Toggle Cursor", category = "Mod UI")] public static void ToggleAlwaysShowCursor() { DebugMod.settings.ShowCursorWhileUnpaused = !DebugMod.settings.ShowCursorWhileUnpaused; if (DebugMod.settings.ShowCursorWhileUnpaused) { DebugMod.LogConsole("Showing cursor while unpaused"); } else { DebugMod.LogConsole("Not showing cursor while unpaused"); } } [BindableMethod(name = "Quickslot (save)", category = "Savestates")] public static void SaveState() { SaveStateManager.SetQuickState(SaveStateManager.SaveNewState()); } [BindableMethod(name = "Quickslot (load)", category = "Savestates")] public static void LoadState() { SaveStateManager.LoadState(SaveStateManager.GetQuickState()); } [BindableMethod(name = "Quickslot save to file", category = "Savestates")] public static void CurrentSaveStateToFile() { SaveStatesPanel.Instance.EnterSelectState(SelectOperation.QuickslotToFile); } [BindableMethod(name = "Load file to quickslot", category = "Savestates")] public static void CurrentSlotToSaveMemory() { SaveStatesPanel.Instance.EnterSelectState(SelectOperation.FileToQuickslot); } [BindableMethod(name = "Save new state to file", category = "Savestates")] public static void NewSaveStateToFile() { SaveStatesPanel.Instance.EnterSelectState(SelectOperation.SaveToFile); } [BindableMethod(name = "Load new state from file", category = "Savestates")] public static void LoadFromFile() { SaveStatesPanel.Instance.EnterSelectState(SelectOperation.LoadFromFile); } [BindableMethod(name = "Next Save Page", category = "Savestates")] public static void NextStatePage() { SaveStatesPanel.Instance.NextPage(); } [BindableMethod(name = "Prev Save Page", category = "Savestates")] public static void PrevStatePage() { SaveStatesPanel.Instance.PrevPage(); } [BindableMethod(name = "Load Quickslot On Death", category = "Savestates")] public static void LoadStateOnDeath() { DebugMod.stateOnDeath = !DebugMod.stateOnDeath; DebugMod.LogConsole("Quickslot savestate will now" + (DebugMod.stateOnDeath ? " be" : " no longer") + " loaded on death"); } [BindableMethod(name = "Override Lockout", category = "Savestates")] public static void OverrideLoadLockout() { DebugMod.overrideLoadLockout = !DebugMod.overrideLoadLockout; DebugMod.LogConsole("Savestate lockout override set to " + DebugMod.overrideLoadLockout); } [BindableMethod(name = "Give All", category = "Skills")] public static void GiveAllSkills() { PlayerData.instance.hasDash = true; PlayerData.instance.hasBrolly = true; PlayerData.instance.hasWalljump = true; PlayerData.instance.hasHarpoonDash = true; PlayerData.instance.hasDoubleJump = true; PlayerData.instance.hasSuperJump = true; PlayerData.instance.hasNeedolin = true; PlayerData.instance.UnlockedFastTravelTeleport = true; PlayerData.instance.hasNeedolinMemoryPowerup = true; PlayerData.instance.hasChargeSlash = true; PlayerData.instance.nailUpgrades = 4; PlayerData.instance.silkRegenMax = 3; PlayerData.instance.ToolKitUpgrades = 4; PlayerData.instance.ToolPouchUpgrades = 4; DebugMod.extraNailDamage = 0; DebugMod.LogConsole("Giving player all skills and upgrades"); } [BindableMethod(name = "Give Swift Step", category = "Skills")] public static void ToggleSwiftStep() { if (!PlayerData.instance.hasDash) { PlayerData.instance.hasDash = true; DebugMod.LogConsole("Giving player Swift Step"); } else { PlayerData.instance.hasDash = false; DebugMod.LogConsole("Taking away Swift Step"); } } [BindableMethod(name = "Give Drifter's Cloak", category = "Skills")] public static void ToggleDriftersCloak() { if (!PlayerData.instance.hasBrolly) { PlayerData.instance.hasBrolly = true; DebugMod.LogConsole("Giving player Drifter's Cloak"); } else { PlayerData.instance.hasBrolly = false; DebugMod.LogConsole("Taking away Drifter's Cloak"); } } [BindableMethod(name = "Give Cling Grip", category = "Skills")] public static void ToggleClingGrip() { if (!PlayerData.instance.hasWalljump) { PlayerData.instance.hasWalljump = true; DebugMod.LogConsole("Giving player Cling Grip"); } else { PlayerData.instance.hasWalljump = false; DebugMod.LogConsole("Taking away Cling Grip"); } } [BindableMethod(name = "Give Needolin", category = "Skills")] public static void ToggleNeedolin() { if (!PlayerData.instance.hasNeedolin) { PlayerData.instance.hasNeedolin = true; DebugMod.LogConsole("Giving player Needolin"); return; } PlayerData.instance.hasNeedolin = false; PlayerData.instance.UnlockedFastTravelTeleport = false; PlayerData.instance.hasNeedolinMemoryPowerup = false; DebugMod.LogConsole("Taking away Needolin and any upgrades"); } [BindableMethod(name = "Give Clawline", category = "Skills")] public static void ToggleClawline() { if (!PlayerData.instance.hasHarpoonDash) { PlayerData.instance.hasHarpoonDash = true; DebugMod.LogConsole("Giving player Clawline"); } else { PlayerData.instance.hasHarpoonDash = false; DebugMod.LogConsole("Taking away Clawline"); } } [BindableMethod(name = "Give Faydown Cloak", category = "Skills")] public static void ToggleFaydownCloak() { if (!PlayerData.instance.hasDoubleJump) { PlayerData.instance.hasDoubleJump = true; DebugMod.LogConsole("Giving player Faydown Cloak"); } else { PlayerData.instance.hasDoubleJump = false; DebugMod.LogConsole("Taking away Faydown Cloak"); } } [BindableMethod(name = "Give Silk Soar", category = "Skills")] public static void ToggleSilkSoar() { if (!PlayerData.instance.hasSuperJump) { PlayerData.instance.hasSuperJump = true; DebugMod.LogConsole("Giving player Silk Soar"); } else { PlayerData.instance.hasSuperJump = false; DebugMod.LogConsole("Taking away Silk Soar"); } } [BindableMethod(name = "Give Beastling Call", category = "Skills")] public static void ToggleBeastlingCall() { if (!PlayerData.instance.hasNeedolin && !PlayerData.instance.UnlockedFastTravelTeleport) { PlayerData.instance.hasNeedolin = true; PlayerData.instance.UnlockedFastTravelTeleport = true; DebugMod.LogConsole("Giving player Needolin with Beastling Call"); } else if (PlayerData.instance.hasNeedolin && !PlayerData.instance.UnlockedFastTravelTeleport) { PlayerData.instance.UnlockedFastTravelTeleport = true; DebugMod.LogConsole("Giving player Beastling Call"); } else { PlayerData.instance.UnlockedFastTravelTeleport = false; DebugMod.LogConsole("Taking away Beastling Call"); } } [BindableMethod(name = "Give Elegy of the Deep", category = "Skills")] public static void ToggleElegyOfTheDeep() { if (!PlayerData.instance.hasNeedolin && !PlayerData.instance.hasNeedolinMemoryPowerup) { PlayerData.instance.hasNeedolin = true; PlayerData.instance.hasNeedolinMemoryPowerup = true; DebugMod.LogConsole("Giving player Needolin with Elegy of the Deep"); } else if (PlayerData.instance.hasNeedolin && !PlayerData.instance.hasNeedolinMemoryPowerup) { PlayerData.instance.hasNeedolinMemoryPowerup = true; DebugMod.LogConsole("Giving player Elegy of the Deep"); } else { PlayerData.instance.hasNeedolinMemoryPowerup = false; DebugMod.LogConsole("Taking away Elegy of the Deep"); } } [BindableMethod(name = "Give Needle Strike", category = "Skills")] public static void ToggleNeedleStrike() { if (!PlayerData.instance.hasChargeSlash) { PlayerData.instance.hasChargeSlash = true; DebugMod.LogConsole("Giving player Needle Strike"); } else { PlayerData.instance.hasChargeSlash = false; DebugMod.LogConsole("Taking away Needle Strike"); } } [BindableMethod(name = "Increase Timescale", category = "Time")] public static void TimescaleUp() { TimeScale.CustomTimeScale = Mathf.Round(TimeScale.CustomTimeScale * 10f + 1f) / 10f; } [BindableMethod(name = "Decrease Timescale", category = "Time")] public static void TimescaleDown() { TimeScale.CustomTimeScale = Mathf.Round(TimeScale.CustomTimeScale * 10f - 1f) / 10f; } [BindableMethod(name = "Freeze Game", category = "Time")] public static void PauseGameNoUI() { TimeScale.Frozen = !TimeScale.Frozen; if (TimeScale.Frozen) { frameCounter = 0; DebugMod.LogConsole("Game Frozen"); } else { DebugMod.LogConsole("Game Unfrozen"); } } [BindableMethod(name = "Force Pause", category = "Time")] public static void ForcePause() { try { if (PlayerData.instance.disablePause || GameManager.instance.TimeSlowed || (UIManager.instance.ignoreUnpause && DebugMod.GetSceneName() != "Menu_Title" && DebugMod.GM.IsGameplayScene())) { GameManager.instance.timeSlowedCount = 0; UIManager.instance.ignoreUnpause = false; PlayerData.instance.disablePause = false; UIManager.instance.TogglePauseGame(); DebugMod.LogConsole("Forcing Pause Menu because pause is disabled"); } else { DebugMod.LogConsole("Game does not report that Pause is disabled, requesting it normally."); UIManager.instance.TogglePauseGame(); } DebugMod.forcePaused = !GameManager.instance.isPaused; } catch (Exception ex) { DebugMod.LogConsole("Error while attempting to pause, check ModLog.txt"); DebugMod.Log("Error while attempting force pause:\n" + ex); } } [BindableMethod(name = "Advance Frame", category = "Time")] public static void AdvanceFrame() { if (!TimeScale.Frozen) { TimeScale.Frozen = true; } frameCounter++; ((MonoBehaviour)GameManager.instance).StartCoroutine(AdvanceMyFrame()); } [IteratorStateMachine(typeof(<AdvanceMyFrame>d__73))] private static IEnumerator AdvanceMyFrame() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <AdvanceMyFrame>d__73(0); } [BindableMethod(name = "Reset Frame Counter", category = "Time")] public static void ResetFrameCounter() { DebugMod.LogConsole($"Frame Counter reset (was {frameCounter})"); frameCounter = 0; } [BindableMethod(name = "Unlock All Tools", category = "Tools")] public static void UnlockAllTools() { ToolItemManager.UnlockAllTools(); DebugMod.LogConsole("Unlocked all tools"); } [BindableMethod(name = "Unlock All Crests", category = "Tools")] public static void UnlockAllCrests() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) ToolItemManager.UnlockAllCrests(); if (Object.op_Implicit((Object)(object)ManagerSingleton<ToolItemManager>.Instance) && Object.op_Implicit((Object)(object)ManagerSingleton<ToolItemManager>.Instance.crestList)) { foreach (ToolCrest item in (NamedScriptableObjectList<ToolCrest>)(object)ManagerSingleton<ToolItemManager>.Instance.crestList) { item.slots = item.slots.Select(delegate(SlotInfo slotInfo) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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) SlotInfo result2 = slotInfo; result2.IsLocked = false; return result2; }).ToArray(); Data saveData = item.SaveData; if (saveData.Slots != null) { saveData.Slots = saveData.Slots.Select(delegate(SlotData slot) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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) SlotData result = slot; result.IsUnlocked = true; return result; }).ToList(); } item.SaveData = saveData; } } DebugMod.LogConsole("Unlocked all crests"); } [BindableMethod(name = "Craft Tools", category = "Tools")] public static void CraftTools() { ToolItemManager.TryReplenishTools(true, (ReplenishMethod)0); DebugMod.LogConsole("Crafted new tools"); } [BindableMethod(name = "Increase Needle Damage", category = "Upgrades")] public static void IncreaseNeedleDamage() { if (PlayerData.instance.nailDamage == 0) { PlayerData.instance.nailUpgrades = 0; DebugMod.extraNailDamage = 0; DebugMod.LogConsole("Resetting needle damage to 5"); } else if (PlayerData.instance.nailUpgrades == 4 || DebugMod.extraNailDamage < 0) { DebugMod.extraNailDamage += 4; DebugMod.LogConsole("Adding 4 extra needle damage"); } else { PlayerData instance = PlayerData.instance; instance.nailUpgrades++; DebugMod.LogConsole("Adding needle upgrade"); } PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE"); } [BindableMethod(name = "Decrease Needle Damage", category = "Upgrades")] public static void DecreaseNeedleDamage() { if (PlayerData.instance.nailUpgrades == 0 || DebugMod.extraNailDamage > 0) { DebugMod.extraNailDamage -= 4; if (DebugMod.extraNailDamage < -5) { DebugMod.extraNailDamage = -5; DebugMod.LogConsole("Setting needle damage to 0"); } else { DebugMod.LogConsole("Reducing nail damage by 4"); } } else { PlayerData instance = PlayerData.instance; instance.nailUpgrades--; DebugMod.LogConsole("Removing needle upgrade"); } PlayMakerFSM.BroadcastEvent("UPDATE NAIL DAMAGE"); } [BindableMethod(name = "Increment Tool Pouch", category = "Upgrades")] public static void IncrementPouches() { if (PlayerData.instance.ToolPouchUpgrades < 4) { PlayerData instance = PlayerData.instance; instance.ToolPouchUpgrades++; DebugMod.LogConsole($"Increasing tool pouch level (now {PlayerData.instance.ToolPouchUpgrades})"); } else { PlayerData.instance.ToolPouchUpgrades = 0; DebugMod.LogConsole("Resetting tool pouch level"); } } [BindableMethod(name = "Increment Crafting Kit", category = "Upgrades")] public static void IncrementKits() { if (PlayerData.instance.ToolKitUpgrades < 4) { PlayerData instance = PlayerData.instance; instance.ToolKitUpgrades++; DebugMod.LogConsole($"Increasing crafting kit level (now {PlayerData.instance.ToolKitUpgrades})"); } else { PlayerData.instance.ToolKitUpgrades = 0; DebugMod.LogConsole("Resetting crafting kit level"); } } [BindableMethod(name = "Give Silk Heart", category = "Upgrades")] public static void IncrementSilkHeart() { if (PlayerData.instance.silkRegenMax < 3) { PlayerData instance = PlayerData.instance; instance.silkRegenMax++; DebugMod.LogConsole($"Giving player Silk Heart (now {PlayerData.instance.silkRegenMax})"); } else { PlayerData.instance.silkRegenMax = 0; DebugMod.LogConsole("Taking away all Silk Hearts"); } } [BindableMethod(name = "Show Hitboxes", category = "Visual")] public static void ShowHitboxes() { if (++DebugMod.settings.ShowHitBoxes > 2) { DebugMod.settings.ShowHitBoxes = 0; } DebugMod.LogConsole("Toggled show hitboxes: " + DebugMod.settings.ShowHitBoxes); } [BindableMethod(name = "Force Camera Follow", category = "Visual")] public static void ForceCameraFollow() { if (!DebugMod.cameraFollow) { DebugMod.LogConsole("Forcing camera follow"); DebugMod.cameraFollow = true; } else { DebugMod.cameraFollow = false; DebugMod.RefCamera.isGameplayScene = true; DebugMod.LogConsole("Returning camera to normal settings"); } } [BindableMethod(name = "Preview Cocoon Position", category = "Visual")] public static void PreviewCocoonPosition() { CocoonPreviewer cocoonPreviewer = ((Component)GameManager.instance).GetComponent<CocoonPreviewer>() ?? ((Component)GameManager.instance).gameObject.AddComponent<CocoonPreviewer>(); if (!cocoonPreviewer.previewEnabled) { cocoonPreviewer.previewEnabled = true; DebugMod.LogConsole("Enabled cocoon spawn point preview"); } else { cocoonPreviewer.previewEnabled = false; DebugMod.LogConsole("Disabled cocoon spawn point preview"); } } [BindableMethod(name = "Toggle Vignette", category = "Visual")] public static void ToggleVignette() { VisualMaskHelper.ToggleVignette(); } [BindableMethod(name = "Deactivate Visual Masks", category = "Visual")] public static void DoDeactivateVisualMasks() { VisualMaskHelper.ToggleAllMasks(); } [BindableMethod(name = "Clear White Screen", category = "Visual")] public static void ClearWhiteScreen() { PlayMakerFSM obj = FSMUtility.LocateMyFSM(((Component)HeroController.instance).gameObject, "Dream Return"); obj.SetState("GET UP"); obj.SendEvent("FINISHED"); FSMUtility.LocateMyFSM(GameObject.Find("Blanker White"), "Blanker Control").SendEvent("FADE OUT"); HeroController.instance.EnableRenderer(); } [BindableMethod(name = "Toggle Hero Light", category = "Visual")] public static void ToggleHeroLight() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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) GameObject gameObject = ((Component)DebugMod.RefKnight.transform.Find("HeroLight")).gameObject; Color color = gameObject.GetComponent<SpriteRenderer>().color; if (Math.Abs(color.a) > 0f) { color.a = 0f; gameObject.GetComponent<SpriteRenderer>().color = color; DebugMod.LogConsole("Rendering HeroLight invisible..."); } else { color.a = 0.7f; gameObject.GetComponent<SpriteRenderer>().color = color; DebugMod.LogConsole("Rendering HeroLight visible..."); } } [BindableMethod(name = "Toggle HUD", category = "Visual")] public static void ToggleHUD() { if (((Component)GameCameras.instance.hudCanvasSlideOut).gameObject.activeInHierarchy) { ((Component)GameCameras.instance.hudCanvasSlideOut).gameObject.SetActive(false); DebugMod.LogConsole("Disabling HUD..."); } else { ((Component)GameCameras.instance.hudCanvasSlideOut).gameObject.SetActive(true); DebugMod.LogConsole("Enabling HUD..."); } } [BindableMethod(name = "Reset Camera Zoom", category = "Visual")] public static void ResetZoom() { GameCameras.instance.tk2dCam.ZoomFactor = 1f; DebugMod.LogConsole("Zoom factor was reset"); } [BindableMethod(name = "Zoom In", category = "Visual")] public static void ZoomIn() { float zoomFactor = GameCameras.instance.tk2dCam.ZoomFactor; GameCameras.instance.tk2dCam.ZoomFactor = zoomFactor + zoomFactor * 0.05f; DebugMod.LogConsole("Zoom level increased to: " + GameCameras.instance.tk2dCam.ZoomFactor); } [BindableMethod(name = "Zoom Out", category = "Visual")] public static void ZoomOut() { float zoomFactor = GameCameras.instance.tk2dCam.ZoomFactor; GameCameras.instance.tk2dCam.ZoomFactor = zoomFactor - zoomFactor * 0.05f; DebugMod.LogConsole("Zoom level decreased to: " + GameCameras.instance.tk2dCam.ZoomFactor); } [BindableMethod(name = "Hide Hero", category = "Visual")] public static void HideHero() { //IL_000c: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) tk2dSprite component = DebugMod.RefKnight.GetComponent<tk2dSprite>(); Color color = ((tk2dBaseSprite)component).color; if (Math.Abs(color.a) > 0f) { color.a = 0f; ((tk2dBaseSprite)component).color = color; DebugMod.LogConsole("Rendering Hero sprite invisible..."); } else { color.a = 1f; ((tk2dBaseSprite)component).color = color; DebugMod.LogConsole("Rendering Hero sprite visible..."); } } [BindableMethod(name = "Toggle Camera Shake", category = "Visual")] public static void ToggleCameraShake() { bool flag = !((Behaviour)GameCameras.instance.cameraShakeFSM).enabled; ((Behaviour)GameCameras.instance.cameraShakeFSM).enabled = flag; DebugMod.LogConsole((flag ? "Enabling" : "Disabling") + " Camera Shake..."); } } [AttributeUsage(AttributeTargets.Method, Inherited = false)] public class BindableMethod : Attribute { public string name; public string category; public bool allowLock = true; } public class BindAction { public string Name { get; } public string Category { get; } public bool AllowLock { get; } public Action Action { get; } public BindAction(string name, string category, bool allowLock, Action action) { Name = name; Category = category; AllowLock = allowLock; Action = action; } public BindAction(BindableMethod attribute, MethodInfo method) { Name = attribute.name; Category = attribute.category; AllowLock = attribute.allowLock; Action = (Action)Delegate.CreateDelegate(typeof(Action), method); } } [BepInDependency("org.silksong-modding.modlist", "0.2.0")] [HarmonyPatch] [BepInPlugin("io.github.hk-speedrunning.debugmod", "DebugMod", "0.3.2")] public class DebugMod : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<ILogSource, bool> <>9__55_0; public static LogCallback <>9__55_1; public static Action <>9__55_2; internal bool <Awake>b__55_0(ILogSource x) { return x is UnityLogSource; } internal void <Awake>b__55_1(string condition, string stackTrace, LogType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 bool flag = (((int)type == 0 || (int)type == 4) ? true : false); if (flag && condition.Contains("Exception")) { LogError(("[UNITY] " + condition + "\n" + stackTrace).Trim()); } } internal void <Awake>b__55_2() { UICommon.LoadResources(); GUIController.Instance.BuildMenus(); SceneWatcher.Init(); LogConsole("New session started " + DateTime.Now); } } private static GameManager _gm; private static InputHandler _ih; private static HeroController _hc; private static GameObject _refKnight; private static CameraController _refCamera; private static Collider2D _refHeroCollider; private static Collider2D _refHeroBox; internal static IEnumerator CurrentHazardCoro; internal static IEnumerator CurrentInvulnCoro; internal static DebugMod instance; public static readonly string ModBaseDirectory = Path.Combine(Application.persistentDataPath, "DebugModData"); private static float _loadTime; private static float _unloadTime; private static bool _loadingChar; internal static HitInstance? lastHit; internal static int lastDamage; [CanBeNull] internal static DamageScalingConfig lastScaling; internal static int lastScaleLevel; internal static bool stateOnDeath; internal static bool infiniteHP; internal static bool infiniteSilk; internal static bool infiniteTools; internal static bool playerInvincible; internal static bool noclip; internal static Vector3 noclipPos; internal static bool cameraFollow; public static bool KeyBindLock; internal static bool savestateFixes = true; public static bool overrideLoadLockout = false; internal static int extraNailDamage; internal static bool forcePaused; internal static readonly Dictionary<string, BindAction> bindActions = new Dictionary<string, BindAction>(); internal static readonly Dictionary<MethodInfo, BindAction> bindsByMethod = new Dictionary<MethodInfo, BindAction>(); internal static readonly Dictionary<KeyCode, int> alphaKeyDict = new Dictionary<KeyCode, int>(); public const string Id = "io.github.hk-speedrunning.debugmod"; internal static GameManager GM { get { if (!((Object)(object)_gm != (Object)null)) { return _gm = GameManager.SilentInstance; } return _gm; } } internal static InputHandler IH { get { if (!((Object)(object)_ih != (Object)null)) { return _ih = GM.inputHandler; } return _ih; } } internal static HeroController HC { get { if (!((Object)(object)_hc != (Object)null)) { return _hc = HeroController.instance; } return _hc; } } internal static GameObject RefKnight { get { if (!((Object)(object)_refKnight != (Object)null)) { return _refKnight = ((Component)HC).gameObject; } return _refKnight; } } internal static CameraController RefCamera { get { if (!((Object)(object)_refCamera != (Object)null)) { return _refCamera = GM.cameraCtrl; } return _refCamera; } } internal static Collider2D RefHeroCollider { get { if (!((Object)(object)_refHeroCollider != (Object)null)) { return _refHeroCollider = RefKnight.GetComponent<Collider2D>(); } return _refHeroCollider; } } internal static Collider2D RefHeroBox { get { if (!((Object)(object)_refHeroBox != (Object)null)) { return _refHeroBox = ((Component)RefKnight.transform.Find("HeroBox")).GetComponent<Collider2D>(); } return _refHeroBox; } } public static Settings settings { get; set; } = new Settings(); public static string Name => "DebugMod"; public static string Version => "0.3.2"; internal static event Action<string, KeyCode?> bindUpdated; public void Awake() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) LoadSettings(); if (settings.LogUnityExceptions && !Logger.Sources.Any((ILogSource x) => x is UnityLogSource)) { object obj = <>c.<>9__55_1; if (obj == null) { LogCallback val = delegate(string condition, string stackTrace, LogType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Invalid comparison between Unknown and I4 bool flag = (((int)type == 0 || (int)type == 4) ? true : false); if (flag && condition.Contains("Exception")) { LogError(("[UNITY] " + condition + "\n" + stackTrace).Trim()); } }; <>c.<>9__55_1 = val; obj = (object)val; } Application.logMessageReceived += (LogCallback)obj; } bindActions.Clear(); MethodInfo[] methods = typeof(BindableFunctions).GetMethods(BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(BindableMethod), inherit: false); if (customAttributes.Any()) { BindableMethod bindableMethod = (BindableMethod)customAttributes[0]; BindAction value = new BindAction(bindableMethod, methodInfo); bindActions.Add(bindableMethod.name, value); bindsByMethod.Add(methodInfo, value); } } if (settings.FirstRun || settings.binds == null) { Log("First run detected, setting default binds"); settings.FirstRun = false; settings.binds = new Dictionary<string, KeyCode>(); settings.binds.Add("Toggle All UI", (KeyCode)283); } int num = (settings.NumPadForSaveStates ? 256 : 48); alphaKeyDict.Clear(); for (int j = 0; j < 10; j++) { alphaKeyDict.Add((KeyCode)(num + j), j); } SaveStateManager.Initialize(); TimeScale.Initialize(); new Harmony("io.github.hk-speedrunning.debugmod").PatchAll(); SceneManager.activeSceneChanged += LevelActivated; ModHooks.AfterSavegameLoadHook += LoadCharacter; ModHooks.NewGameHook += NewCharacter; ModHooks.BeforeSceneLoadHook += OnLevelUnload; ModHooks.TakeHealthHook += PlayerDamaged; ModHooks.ApplicationQuitHook += SaveSettings; ModHooks.FinishedLoadingModsHook += delegate { UICommon.LoadResources(); GUIController.Instance.BuildMenus(); SceneWatcher.Init(); LogConsole("New session started " + DateTime.Now); }; KeyBindLock = false; Log("Initialized"); } private void OnEnable() { TimeScale.Initialize(); } private void OnDisable() { TimeScale.Reset(); } private void OnDestroy() { TimeScale.Release(); } public DebugMod() { instance = this; } private void LoadSettings() { try { if (!Directory.Exists(ModBaseDirectory)) { Directory.CreateDirectory(ModBaseDirectory); } string path = Path.Combine(ModBaseDirectory, "Settings.json"); if (File.Exists(path)) { settings = JsonConvert.DeserializeObject<Settings>(File.ReadAllText(path)); Log("Loaded settings"); } } catch (Exception arg) { LogError($"Error loading settings: {arg}"); } } private void SaveSettings() { try { File.WriteAllText(Path.Combine(ModBaseDirectory, "Settings.json"), JsonConvert.SerializeObject((object)settings, (Formatting)1)); Log("Saved settings"); } catch (Exception arg) { LogError($"Error saving settings: {arg}"); } } public static void UpdateBind(string name, KeyCode? key) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (key.HasValue) { settings.binds[name] = key.Value; } else { settings.binds.Remove(name); } DebugMod.bindUpdated?.Invoke(name, key); } private int PlayerDamaged(int damageAmount) { int num = ((!infiniteHP) ? damageAmount : 0); if (stateOnDeath && PlayerData.instance.health - num <= 0) { SaveStateManager.LoadState(SaveStateManager.GetQuickState()); LogConsole("Lethal damage prevented, savestate loading"); return 0; } return num; } [HarmonyPatch(typeof(HeroController), "HazardRespawn")] [HarmonyPostfix] public static void OnHazardRespawn(HeroController __instance, IEnumerator __result) { CurrentHazardCoro = __result; } [HarmonyPatch(typeof(HeroController), "Invulnerable")] [HarmonyPostfix] public static void OnInvulnerable(HeroController __instance, IEnumerator __result) { CurrentInvulnCoro = __result; } private void NewCharacter() { LoadCharacter(null); } private void LoadCharacter(SaveGameData saveGameData) { ConsolePanel.Instance?.Reset(); playerInvincible = false; infiniteHP = false; infiniteSilk = false; noclip = false; extraNailDamage = 0; lastHit = null; lastDamage = 0; lastScaling = null; lastScaleLevel = 0; _loadingChar = true; } private void LevelActivated(Scene sceneFrom, Scene sceneTo) { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) string name = ((Scene)(ref sceneTo)).name; if (_loadingChar) { TimeSpan timeSpan = TimeSpan.FromSeconds(PlayerData.instance.playTime); string text = $"{Math.Floor(timeSpan.TotalHours):00}.{timeSpan.Minutes:00}"; int profileID = PlayerData.instance.profileID; LogConsole("New savegame loaded. Profile playtime " + text + " Completion: " + PlayerData.instance.completionPercentage + " Save slot: " + profileID + " Game Version: " + PlayerData.instance.version); _loadingChar = false; } if (Object.op_Implicit((Object)(object)GM) && GM.IsGameplayScene()) { _loadTime = Time.realtimeSinceStartup; LogConsole("New scene loaded: " + name); PlayerDeathWatcher.Reset(); VisualMaskHelper.OnSceneChange(sceneTo); } } private string OnLevelUnload(string toScene) { _unloadTime = Time.realtimeSinceStartup; return toScene; } public static string GetSceneName() { if ((Object)(object)GM == (Object)null) { LogWarn("GameManager reference is null in GetSceneName"); return ""; } return GM.GetSceneNameString(); } public static float GetLoadTime() { return (float)Math.Round(_loadTime - _unloadTime, 2); } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] private static int Get_NailDamage(int nailDamage) { return nailDamage + extraNailDamage; } [HarmonyPatch(typeof(HealthManager), "TakeDamage")] [HarmonyPrefix] private static void TakeDamage(HealthManager __instance, HitInstance hitInstance) { //IL_0001: 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_0008: 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_0022: 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_004a: 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_006c: 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_0078: Invalid comparison between Unknown and I4 HitInstance val = __instance.ApplyDamageScaling(hitInstance); lastHit = val; lastDamage = (__instance.damageOverride ? 1 : Mathf.RoundToInt((float)val.DamageDealt * val.Multiplier)); lastScaling = __instance.damageScaling; int num = hitInstance.DamageScalingLevel - 1; if (hitInstance.IsUsingNeedleDamageMult) { num = PlayerData.instance.nailUpgrades; } else if (Object.op_Implicit((Object)(object)hitInstance.RepresentingTool) && (int)hitInstance.RepresentingTool.Type != 3) { num = PlayerData.instance.ToolKitUpgrades; } lastScaleLevel = num; } [HarmonyPatch(typeof(SurfaceWaterRegion), "OnTriggerEnter2D")] [HarmonyPrefix] private static void OnTriggerEnter2D_Prefix(Collider2D collision) { if (Object.op_Implicit((Object)(object)((Component)collision).gameObject.GetComponent<HeroController>()) && playerInvincible) { PlayerData.instance.isInvincible = false; } } [HarmonyPatch(typeof(SurfaceWaterRegion), "OnTriggerEnter2D")] [HarmonyPostfix] private static void OnTriggerEnter2D_Postfix() { if (playerInvincible) { PlayerData.instance.isInvincible = true; } } [HarmonyPatch(typeof(HeroWaterController), "TumbleOut")] [HarmonyPrefix] private static bool HeroWaterController_TumbleOut_Prefix(HeroWaterController __instance) { if (SaveState.loadingSavestate == null) { return true; } __instance.ExitedWater(true); return false; } [HarmonyPatch(typeof(HeroController), "TakeDamage")] [HarmonyPrefix] private static bool HeroController_TakeDamage(GameObject go, HazardType hazardType) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if (playerInvincible && !noclip && (int)hazardType == 4 && ((Object)go).name.Contains("Lava Box")) { HeroController.instance.ShroomBounce(); return false; } return true; } [HarmonyPatch(typeof(HeroController), "DoSpecialDamage")] [HarmonyPrefix] private static bool HeroController_DoSpecialDamage() { return !playerInvincible; } [PublicAPI] public static void AddToKeyBindList(Type BindableFunctionsClass) { MethodInfo[] methods = BindableFunctionsClass.GetMethods(BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { BindableMethod customAttribute = methodInfo.GetCustomAttribute<BindableMethod>(inherit: false); if (customAttribute != null) { Log("Recieved Action: " + customAttribute.name + " (from " + BindableFunctionsClass.Name + ")"); bindActions.Add(customAttribute.name, new BindAction(customAttribute, methodInfo)); } } } [PublicAPI] public static void AddActionToKeyBindList(Action method, string name, string category) { AddActionToKeyBindList(method, name, category, allowLock: true); } [PublicAPI] public static void AddActionToKeyBindList(Action method, string name, string category, bool allowLock) { Log("Received Action: " + name); bindActions.Add(name, new BindAction(name, category, allowLock, method)); } public static void LogDebug(string message) { ((BaseUnityPlugin)instance).Logger.LogDebug((object)message); } public static void Log(string message) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } public static void LogWarn(string message) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)message); } public static void LogError(string message) { ((BaseUnityPlugin)instance).Logger.LogError((object)message); } public static void LogConsole(string message) { ConsolePanel.Instance.AddLine(message); } } [HarmonyPatch] public class GUIController : MonoBehaviour { public Vector3 hazardLocation; public string respawnSceneWatch; private static readonly HitboxViewer hitboxes = new HitboxViewer(); private KeyCode keyWarning; private Resolution resolution; public GameObject canvas; private static GUIController _instance; private readonly Array allKeyCodes = Enum.GetValues(typeof(KeyCode)); private readonly List<KeyCode> UnbindableKeys = new List<KeyCode> { (KeyCode)323 }; public static GUIController Instance { get { //IL_001c: 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_0031: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { DebugMod.Log("Creating new GUIController"); GameObject val = new GameObject("GUIController"); _instance = val.AddComponent<GUIController>(); Object.DontDestroyOnLoad((Object)val); } return _instance; } } public static bool ForceHideUI() { if (DebugMod.GM.IsNonGameplayScene()) { return true; } if (SaveState.loadingSavestate != null) { return true; } return false; } public void Awake() { //IL_0006: 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) hazardLocation = PlayerData.instance.hazardRespawnLocation; respawnSceneWatch = PlayerData.instance.respawnScene; } public void BuildMenus() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) try { if (Object.op_Implicit((Object)(object)canvas)) { Object.Destroy((Object)(object)canvas); } canvas = new GameObject("DebugModCanvas"); canvas.AddComponent<Canvas>().renderMode = (RenderMode)0; canvas.AddComponent<GraphicRaycaster>(); Object.DontDestroyOnLoad((Object)(object)canvas); MainPanel.BuildPanel(); EnemiesPanel.BuildPanel(); ConsolePanel.BuildPanel(); InfoPanel.BuildPanel(); SaveStatesPanel.BuildPanel(); CanvasButton.BuildHoverBorder(); KeybindDialog.BuildPanel(); ConfirmDialog.BuildPanel(); resolution = Screen.currentResolution; } catch (Exception arg) { DebugMod.LogError($"Error building UI: {arg}"); } } public void Update() { //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) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_0474: 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_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_0321: 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_032b: 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_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: 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_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)DebugMod.GM == (Object)null) { return; } if (Object.op_Implicit((Object)(object)canvas)) { int width = ((Resolution)(ref resolution)).width; Resolution currentResolution = Screen.currentResolution; if (width == ((Resolution)(ref currentResolution)).width) { int height = ((Resolution)(ref resolution)).height; currentResolution = Screen.currentResolution; if (height == ((Resolution)(ref currentResolution)).height) { goto IL_0060; } } resolution = Screen.currentResolution; BuildMenus(); } goto IL_0060; IL_0060: MainPanel instance = MainPanel.Instance; if (instance != null) { instance.ActiveSelf = DebugMod.settings.MainPanelVisible; } EnemiesPanel instance2 = EnemiesPanel.Instance; if (instance2 != null) { instance2.ActiveSelf = DebugMod.settings.EnemiesPanelVisible; } ConsolePanel instance3 = ConsolePanel.Instance; if (instance3 != null) { instance3.ActiveSelf = DebugMod.settings.ConsoleVisible; } InfoPanel instance4 = InfoPanel.Instance; if (instance4 != null) { instance4.ActiveSelf = DebugMod.settings.InfoPanelVisible; } SaveStatesPanel instance5 = SaveStatesPanel.Instance; if (instance5 != null) { instance5.ActiveSelf = SaveStatesPanel.ShouldBeVisible; } if (ForceHideUI()) { foreach (CanvasNode rootNode in CanvasNode.rootNodes) { rootNode.ActiveSelf = false; } } else { CanvasNode.UpdateAll(); } GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject; if (Object.op_Implicit((Object)(object)currentSelectedGameObject) && (Object)(object)((Component)currentSelectedGameObject.transform.parent).gameObject == (Object)(object)canvas && !Object.op_Implicit((Object)(object)currentSelectedGameObject.GetComponent<InputField>())) { EventSystem.current.SetSelectedGameObject((GameObject)null); } if (DebugMod.GetSceneName() == "Menu_Title") { return; } if (!CanvasTextField.AnyFieldFocused) { HandleKeybinds(); } if (DebugMod.infiniteSilk && PlayerData.instance.silk < PlayerData.instance.silkMax && PlayerData.instance.health > 0 && (Object)(object)HeroController.instance != (Object)null && !HeroController.instance.cState.dead && GameManager.instance.IsGameplayScene()) { PlayerData.instance.silk = PlayerData.instance.silkMax; HeroController.instance.AddSilk(1, false); } if (DebugMod.infiniteTools && Object.op_Implicit((Object)(object)ManagerSingleton<ToolItemManager>.Instance) && Object.op_Implicit((Object)(object)ManagerSingleton<ToolItemManager>.Instance.toolItems)) { foreach (ToolItem item in (NamedScriptableObjectList<ToolItem>)(object)ManagerSingleton<ToolItemManager>.Instance.toolItems) { if (Object.op_Implicit((Object)(object)item)) { Data savedData = item.SavedData; int amountLeft = savedData.AmountLeft; savedData.AmountLeft = ToolItemManager.GetToolStorageAmount(item); item.SavedData = savedData; AttackToolBinding? attackToolBinding = ToolItemManager.GetAttackToolBinding(item); if (attackToolBinding.HasValue && amountLeft != savedData.AmountLeft) { ToolItemManager.ReportBoundAttackToolUpdated(attackToolBinding.Value); } } } } if (DebugMod.playerInvincible && PlayerData.instance != null) { PlayerData.instance.isInvincible = true; } if (DebugMod.noclip) { Vector3 val = Vector3.zero; float num = (Input.GetKey((KeyCode)304) ? 40f : 20f) * DebugMod.settings.NoClipSpeedModifier * Time.deltaTime; if (((OneAxisInputControl)DebugMod.IH.inputActions.Left).IsPressed) { val += Vector3.left * num; } if (((OneAxisInputControl)DebugMod.IH.inputActions.Right).IsPressed) { val += Vector3.right * num; } if (((OneAxisInputControl)DebugMod.IH.inputActions.Up).IsPressed) { val += Vector3.up * num; } if (((OneAxisInputControl)DebugMod.IH.inputActions.Down).IsPressed) { val += Vector3.down * num; } DebugMod.noclipPos += val; if ((int)HeroController.instance.transitionState == 0 && SaveState.loadingSavestate == null) { DebugMod.RefKnight.transform.position = DebugMod.noclipPos; Rigidbody2D component = DebugMod.RefKnight.GetComponent<Rigidbody2D>(); component.constraints = (RigidbodyConstraints2D)(component.constraints | 3); } else { DebugMod.noclipPos = DebugMod.RefKnight.transform.position; Rigidbody2D component2 = DebugMod.RefKnight.GetComponent<Rigidbody2D>(); component2.constraints = (RigidbodyConstraints2D)(component2.constraints & -4); } } if (DebugMod.cameraFollow) { DebugMod.RefCamera.isGameplayScene = false; DebugMod.RefCamera.SnapTo(DebugMod.RefKnight.transform.position.x, DebugMod.RefKnight.transform.position.y); } if (PlayerData.instance.hazardRespawnLocation != hazardLocation) { hazardLocation = PlayerData.instance.hazardRespawnLocation; DebugMod.LogConsole("Hazard Respawn location updated: " + ((object)(Vector3)(ref hazardLocation)).ToString()); } if (!string.IsNullOrEmpty(respawnSceneWatch) && respawnSceneWatch != PlayerData.instance.respawnScene) { respawnSceneWatch = PlayerData.instance.respawnScene; DebugMod.LogConsole("Save Respawn updated, new scene: " + PlayerData.instance.respawnScene.ToString() + ", Map Zone: " + GameManager.instance.GetCurrentMapZone() + ", Respawn Marker: " + PlayerData.instance.respawnMarkerName.ToString()); } if (HitboxViewer.State != DebugMod.settings.ShowHitBoxes) { if (DebugMod.settings.ShowHitBoxes != 0) { hitboxes.Load(); } else if (HitboxViewer.State != 0 && DebugMod.settings.ShowHitBoxes == 0) { hitboxes.Unload(); } } } private void HandleKeybinds() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Invalid comparison between Unknown and I4 //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Invalid comparison between Unknown and I4 //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_00b9: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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) for (int i = 0; i < DebugMod.settings.binds.Count; i++) { KeyValuePair<string, KeyCode> keyValuePair = DebugMod.settings.binds.ElementAt(i); string key = keyValuePair.Key; KeyCode value = keyValuePair.Value; if (!DebugMod.bindActions.ContainsKey(key)) { continue; } if ((int)value == 0) { foreach (KeyCode allKeyCode in allKeyCodes) { if (!Input.GetKeyDown(allKeyCode) || UnbindableKeys.Contains(allKeyCode)) { continue; } if (keyWarning != allKeyCode) { foreach (string key2 in DebugMod.bindActions.Keys) { if (DebugMod.settings.binds.TryGetValue(key2, out var value2) && value2 == allKeyCode) { DebugMod.LogConsole($"{(object)allKeyCode} already bound to {key2}, press again to confirm"); keyWarning = allKeyCode; } } if (keyWarning == allKeyCode) { break; } } keyWarning = (KeyCode)0; if ((int)allKeyCode == 27) { DebugMod.UpdateBind(key, null); i--; DebugMod.LogWarn("The key " + Enum.GetName(typeof(KeyCode), (object)allKeyCode) + " has been unbound from " + key); } else if ((int)allKeyCode != 27) { DebugMod.UpdateBind(key, (KeyCode?)allKeyCode); } break; } } else { if (!Input.GetKeyDown(value)) { continue; } try { if (DebugMod.bindActions.TryGetValue(key, out var value3) && (!DebugMod.KeyBindLock || (DebugMod.KeyBindLock && !value3.AllowLock))) { value3.Action(); } } catch (Exception ex) { DebugMod.LogError("Error running keybind method " + key + ":\n" + ex.ToString()); } } } } [HarmonyPatch(typeof(InputHandler), "SetCursorVisible")] [HarmonyPrefix] private static void SetCursorVisible(ref bool value) { if (DebugMod.settings.ShowCursorWhileUnpaused) { UIManager.instance.inputModule.allowMouseInput = true; value = true; } } } [HarmonyPatch] internal static class ModHooks { [CompilerGenerated] private sealed class <GameManager_LoadFirstScene>d__37 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public IEnumerator orig; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GameManager_LoadFirstScene>d__37(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = orig; <>1__state = 1; return true; case 1: <>1__state = -1; ModHooks.NewGameHook?.Invoke(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static bool finishedLoadingModsInvoked; public static event Action<SaveGameData> AfterSavegameLoadHook; public static event Action ApplicationQuitHook; public static event Action BeforePlayerDeadHook; public static event Func<string, string> BeforeSceneLoadHook; public static event Action<GameObject> ColliderCreateHook; public static event Action CursorHook; private static event Action finishedLoadingModsHook; public static event Action FinishedLoadingModsHook { add { finishedLoadingModsHook += value; if (finishedLoadingModsInvoked) { value(); } } remove { finishedLoadingModsHook -= value; } } public static event Action NewGameHook; public static event Func<int, int> TakeHealthHook; [HarmonyPatch(typeof(GameManager), "SetLoadedGameData", new Type[] { typeof(SaveGameData), typeof(int) })] [HarmonyPostfix] private static void GameManager_SetLoadedGameData(SaveGameData saveGameData) { ModHooks.AfterSavegameLoadHook?.Invoke(saveGameData); } [HarmonyPatch(typeof(GameManager), "OnApplicationQuit")] [HarmonyPostfix] private static void GameManager_OnApplicationQuit() { ModHooks.ApplicationQuitHook?.Invoke(); } [HarmonyPatch(typeof(GameManager), "PlayerDead")] [HarmonyPrefix] private static void GameManager_PlayerDead() { ModHooks.BeforePlayerDeadHook?.Invoke(); } [HarmonyPatch(typeof(GameManager), "BeginSceneTransition")] [HarmonyPrefix] private static void GameManager_BeginSceneTransition(SceneLoadInfo info) { if (ModHooks.BeforeSceneLoadHook != null) { info.SceneName = ModHooks.BeforeSceneLoadHook(info.SceneName); } } [HarmonyPatch(typeof(GameManager), "LoadScene")] [HarmonyPrefix] private static void GameManager_LoadScene(ref string destScene) { if (ModHooks.BeforeSceneLoadHook != null) { destScene = ModHooks.BeforeSceneLoadHook(destScene); } } [HarmonyPatch(typeof(GameManager), "LoadSceneAdditive")] [HarmonyPrefix] private static void GameManager_LoadSceneAdditive(ref string destScene) { if (ModHooks.BeforeSceneLoadHook != null) { destScene = ModHooks.BeforeSceneLoadHook(destScene); } } [HarmonyPatch(typeof(PlayMakerUnity2DProxy), "Start")] [HarmonyPostfix] private static void PlayMakerUnity2DProxy_Start(PlayMakerUnity2DProxy __instance) { ModHooks.ColliderCreateHook?.Invoke(((Component)__instance).gameObject); } [HarmonyPatch(typeof(InputHandler), "Update")] [HarmonyPostfix] private static void InputHandler_Update() { ModHooks.CursorHook?.Invoke(); } [HarmonyPatch(typeof(OnScreenDebugInfo), "Awake")] [HarmonyPrefix] private static void OnScreenDebugInfo_Awake() { if (!finishedLoadingModsInvoked) { finishedLoadingModsInvoked = true; ModHooks.finishedLoadingModsHook?.Invoke(); } } [IteratorStateMachine(typeof(<GameManager_LoadFirstScene>d__37))] [HarmonyPatch(typeof(GameManager), "LoadFirstScene")] [HarmonyPostfix] private static IEnumerator GameManager_LoadFirstScene(IEnumerator orig) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <GameManager_LoadFirstScene>d__37(0) { orig = orig }; } [HarmonyPatch(typeof(GameManager), "OnWillActivateFirstLevel")] [HarmonyPostfix] private static void GameManager_OnWillActivateFirstLevel() { ModHooks.NewGameHook?.Invoke(); } [HarmonyPatch(typeof(PlayerData), "TakeHealth")] [HarmonyPrefix] private static void PlayerData_TakeHealth(ref int amount) { if (ModHooks.TakeHealthHook != null) { amount = ModHooks.TakeHealthHook(amount); } } } public static class PlayerDeathWatcher { public static bool playerDead; static PlayerDeathWatcher() { ModHooks.BeforePlayerDeadHook += SetPlayerDead; } private static void SetPlayerDead() { playerDead = true; LogDeathDetails(); } public static void Reset() { playerDead = false; } public static void LogDeathDetails() { DebugMod.LogConsole(string.Concat(new string[4] { "Hero death detected. Game playtime: ", PlayerData.instance.playTime.ToString(), " Respawn scene: ", PlayerData.instance.respawnScene.ToString() })); } } public class Settings { [JsonProperty(ItemConverterType = typeof(StringEnumConverter))] public Dictionary<string, KeyCode> binds = new Dictionary<string, KeyCode>(); public bool FirstRun = true; public bool MainPanelVisible = true; public string MainPanelCurrentTab; public bool EnemiesPanelVisible = true; public bool ConsoleVisible = true; public bool InfoPanelVisible = true; public bool SaveStatePanelVisible = true; public bool SaveStatePanelExpanded; public bool NumPadForSaveStates; public int ShowHitBoxes; public int MaxSavePages = 10; public float NoClipSpeedModifier = 1f; public bool ShowCursorWhileUnpaused; public bool SaveStateGlitchFixes = true; public bool LogUnityExceptions = true; public bool AltInfoPanel; public bool ExpandedInfoPanel; } } namespace DebugMod.UI { public class CanvasDialog : CanvasPanel { private CanvasNode anchor; private Vector2 anchorPos; private bool initialClickEnded; public CanvasDialog(string name) : base(name) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) base.ActiveSelf = false; base.OnUpdate += Update; UICommon.AddBackground(this); Get<CanvasImage>("Background").SetImage(UICommon.dialogBG); } private void Update() { //IL_0036: 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) if (initialClickEnded && !IsMouseOver() && (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))) { Hide(); } else if (anchor != null && (anchor.Position != anchorPos || !anchor.ActiveInHierarchy)) { Hide(); } if (Input.GetMouseButtonUp(0)) { initialClickEnded = true; } } protected bool TryToggle(CanvasNode anchor) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) if (base.ActiveInHierarchy && this.anchor == anchor) { Hide(); return false; } this.anchor = anchor; anchorPos = anchor.Position; initialClickEnded = false; float num = (int)(anchor.Position.x + anchor.Size.x - (float)UICommon.Margin); float num2 = num + base.Size.x - (float)(Screen.width - UICommon.Margin); if (num2 > 0f) { num -= num2; } float num3 = (int)(anchor.Position.y + anchor.Size.y - (float)UICommon.Margin); float num4 = num3 + base.Size.y - (float)(Screen.height - UICommon.Margin); if (num4 > 0f) { num3 -= num4; } base.LocalPosition = new Vector2(num, num3); base.ActiveSelf = true; return true; } public void Hide() { anchor = null; base.ActiveSelf = false; } } public class ConfirmDialog : CanvasDialog { private readonly CanvasText prompt; private Action onAccept; private Action onReject; public static int PanelWidth => UICommon.ScaleWidth(150); public static int PromptHeight => UICommon.ScaleHeight(18); public static ConfirmDialog Instance { get; private set; } public static void BuildPanel() { Instance = new ConfirmDialog(); Instance.Build(); } public ConfirmDialog() : base("ConfirmDialog") { //IL_0017: Unknown result type (might be due to invalid IL or missing references) base.Size = new Vector2((float)PanelWidth, 0f); using PanelBuilder panelBuilder = new PanelBuilder(this); panelBuilder.DynamicLength = true; panelBuilder.Padding = UICommon.Margin; prompt = panelBuilder.AppendFixed(new CanvasText("Prompt", (HorizontalWrapMode)0), PromptHeight); prompt.Alignment = (TextAnchor)4; using PanelBuilder panelBuilder2 = new PanelBuilder(panelBuilder.AppendFixed(new CanvasPanel("Row"), UICommon.ControlHeight)); panelBuilder2.Horizontal = true; panelBuilder2.InnerPadding = UICommon.Margin; CanvasButton canvasButton = panelBuilder2.AppendFlex(new CanvasButton("Yes")); canvasButton.Text.Text = "Yes"; canvasButton.OnClicked += delegate { onAccept(); Hide(); }; CanvasButton canvasButton2 = panelBuilder2.AppendFlex(new CanvasButton("No")); canvasButton2.Text.Text = "No"; canvasButton2.OnClicked += delegate { onReject(); Hide(); }; } public void Toggle(CanvasNode anchor, string prompt, Action onAccept, Action onReject) { if (TryToggle(anchor)) { this.prompt.Text = prompt; this.onAccept = onAccept; this.onReject = onReject; } } } public class ConsolePanel : CanvasPanel { public const int MAX_LINES = 15; private static readonly List<string> history = new List<string>(); private readonly List<CanvasText> lines = new List<CanvasText>(); public static ConsolePanel Instance { get; private set; } public static void BuildPanel() { Instance = new ConsolePanel(); Instance.Build(); } public ConsolePanel() : base("ConsolePanel") { //IL_002f: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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) base.LocalPosition = new Vector2((float)UICommon.ScreenMargin, (float)(Screen.height - UICommon.ScreenMargin - UICommon.ConsoleHeight)); base.Size = new Vector2((float)UICommon.LeftSideWidth, (float)UICommon.ConsoleHeight); CanvasBorder canvasBorder = Add(new CanvasBorder("Border")); canvasBorder.LocalPosition = new Vector2(0f, (float)UICommon.Margin / 2f); canvasBorder.Size = new Vector2(base.Size.x, base.Size.y - (float)UICommon.Margin); canvasBorder.Sides = BorderSides.LEFT; canvasBorder.Color = UICommon.iconColor; float num = (base.Size.y - (float)(UICommon.Margin * 2)) / 15f; for (int i = 0; i < 15; i++) { CanvasText canvasText = Add(new CanvasText(i.ToString(), (HorizontalWrapMode)0)); canvasText.LocalPosition = new Vector2((float)UICommon.Margin, (float)UICommon.Margin + num * (float)i); canvasText.Size = new Vector2(base.Size.x - (float)(UICommon.Margin * 2), num); lines.Add(canvasText); } } private void UpdateText() { int i = 0; for (int j = Math.Max(history.Count - 15, 0); j < history.Count; j++) { lines[i].Text = history[j]; i++; } for (; i < 15; i++) { lines[i].Text = ""; } } public void Reset() { history.Clear(); UpdateText(); } public void AddLine(string chatLine) { while (history.Count > 1000) { history.RemoveAt(0); } for (int num = WrapIndex(chatLine); num != -1; num = WrapIndex(chatLine)) { int num2 = chatLine.LastIndexOf(' ', num, num); if (num2 == -1) { break; } history.Add(chatLine.Substring(0, num2)); chatLine = chatLine.Substring(num2 + 1); } history.Add(chatLine); UpdateText(); } private int WrapIndex(string message) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) CanvasText canvasText = lines[0]; int num = 0; char[] array = message.ToCharArray(); CharacterInfo val = default(CharacterInfo); for (int i = 0; i < array.Length; i++) { char c = array[i]; canvasText.Font.GetCharacterInfo(c, ref val, canvasText.FontSize); num += ((CharacterInfo)(ref val)).advance; if ((float)num >= canvasText.Size.x) { return i; } } return -1; } } public class EnemiesPanel : CanvasPanel { public static readonly List<EnemyHandle> enemyPool = new List<EnemyHandle>(); public static bool hpBars; private readonly List<CanvasPanel> listings = new List<CanvasPanel>(); private readonly CanvasPanel listingsPanel; public static int ListingHeight => UICommon.ScaleHeight(16); public static EnemiesPanel Instance { get; private set; } public static void BuildPanel() { Instance = new EnemiesPanel(); Instance.Build(); } public EnemiesPanel() : base("EnemiesPanel") { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028d: 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_02dc: Unknown result type (might be due to invalid IL or missing references) EnemiesPanel enemiesPanel = this; base.LocalPosition = new Vector2((float)(Screen.width - UICommon.ScreenMargin - UICommon.RightSideWidth), (float)(UICommon.MainPanelHeight + UICommon.ScreenMargin * 2)); base.Size = new Vector2((float)UICommon.RightSideWidth, (float)(Screen.height - UICommon.MainPanelHeight - UICommon.ScreenMargin * 3)); base.OnUpdate += Update; UICommon.AddBackground(this); using PanelBuilder panelBuilder = new PanelBuilder(this); panelBuilder.OuterPadding = ContentMargin(UICommon.Margin); panelBuilder.InnerPadding = UICommon.Margin; CanvasScrollView canvasScrollView = panelBuilder.AppendFlex(new CanvasScrollView("ListingsScrollView")); canvasScrollView.Margin = new Vector2(-1f, -1f); listingsPanel = canvasScrollView.SetContent(new CanvasPanel("Listings")); listingsPanel.Size = canvasScrollView.Size; using PanelBuilder panelBuilder2 = new PanelBuilder(listingsPanel); panelBuilder2.DynamicLength = true; panelBuilder2.InnerPadding = UICommon.Margin; for (int i = 0; i < 100; i++) { int index = listings.Count; CanvasPanel canvasPanel = panelBuilder2.AppendFixed(new CanvasPanel($"{index + 1}"), ListingHeight); canvasPanel.CollapseMode = CollapseMode.Deny; listings.Add(canvasPanel); using PanelBuilder panelBuilder3 = new PanelBuilder(canvasPanel); panelBuilder3.Horizontal = true; CanvasText enemyName = panelBuilder3.AppendFlex(new CanvasText("EnemyName", (HorizontalWrapMode)0)); enemyName.Alignment = (TextAnchor)3; enemyName.OnUpdate += delegate { if (enemyPool.Count > index) { enemyName.Text = enemyPool[index].Name; } }; CanvasText enemyHp = panelBuilder3.AppendFixed(new CanvasText("EnemyHP", (HorizontalWrapMode)0), UICommon.ScaleWidth(80)); enemyHp.Alignment = (TextAnchor)3; enemyHp.OnUpdate += delegate { if (enemyPool.Count > index) { enemyHp.Text = $"{enemyPool[index].HP}/{enemyPool[index].MaxHP}"; } }; CanvasButton canvasButton = panelBuilder3.AppendSquare(new CanvasButton("Delete")); canvasButton.ImageOnly(UICommon.images["IconX"]); canvasButton.OnClicked += delegate { if (enemyPool.Count > index) { EnemyHandle enemyHandle3 = enemyPool[index]; Object.DestroyImmediate((Object)(object)((Component)enemyHandle3).gameObject); DebugMod.LogConsole("Destroyed " + enemyHandle3.Name); } }; panelBuilder3.AppendPadding(UICommon.Margin); CanvasButton canvasButton2 = panelBuilder3.AppendSquare(new CanvasButton("Clone")); canvasButton2.ImageOnly(UICommon.images["IconPlus"]); canvasButton2.OnClicked += delegate { //IL_002f: 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) if (enemyPool.Count > index) { EnemyHandle enemyHandle2 = enemyPool[index]; Object.Instantiate<GameObject>(((Component)enemyHandle2).gameObject, ((Component)enemyHandle2).transform.position, ((Component)enemyHandle2).transform.rotation); DebugMod.LogConsole("Cloned " + enemyHandle2.Name); } }; panelBuilder3.AppendPadding(UICommon.Margin); CanvasButton canvasButton3 = panelBuilder3.AppendSquare(new CanvasButton("InfiniteHealth")); canvasButton3.ImageOnly(UICommon.images["IconShield"]); canvasButton3.OnClicked += delegate { if (enemyPool.Count > index) { EnemyHandle enemyHandle = enemyPool[index]; enemyHandle.HP = 9999; DebugMod.LogConsole("Set " + enemyHandle.Name + " HP to 9999"); } }; } using PanelBuilder panelBuilder4 = new PanelBuilder(panelBuilder.AppendFixed(new CanvasPanel("Footer"), UICommon.ControlHeight)); panelBuilder4.Horizontal = true; panelBuilder4.AppendPadding(UICommon.Margin); CanvasText overflow = panelBuilder4.AppendFlex(new CanvasText("Overflow", (HorizontalWrapMode)0)); overflow.Alignment = (TextAnchor)3; overflow.OnUpdate += delegate { if (enemyPool.Count == 0) { overflow.Text = "No enemies detected"; } else if (enemyPool.Count > enemiesPanel.listings.Count) { overflow.Text = $"... and {enemyPool.Count - enemiesPanel.listings.Count} more"; } else { overflow.Text = ""; } }; CanvasButton hpBarsButton = panelBuilder4.AppendFixed(new CanvasButton("HPBars"), UICommon.ScaleWidth(100)); hpBarsButton.Text.Text = "HP Bars"; hpBarsButton.OnUpdate += delegate { hpBarsButton.Toggled = hpBars; }; hpBarsButton.OnClicked += BindableFunctions.ToggleEnemyHPBars; UICommon.AppendKeybindButton(panelBuilder4, DebugMod.bindActions["Toggle HP Bars"]); } private void Update() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00ca: Unknown result type (might be due to invalid IL or missing references) enemyPool.RemoveAll((EnemyHandle handle) => !Object.op_Implicit((Object)(object)handle) && !((Component)handle).gameObject.activeSelf); int num = (ActivelyUpdating() ? enemyPool.Count : 0); for (int i = 0; i < listings.Count; i++) { listings[i].ActiveSelf = i < num; } CanvasPanel canvasPanel = ((enemyPool.Count > 0) ? listings[enemyPool.Count - 1] : listings[0]); listingsPanel.Size = new Vector2(listingsPanel.Size.x, canvasPanel.LocalPosition.y + canvasPanel.Size.y); } public static bool ActivelyUpdating() { if (Object.op_Implicit((Object)(object)HeroController.instance) && !HeroController.instance.cState.transitioning) { return GameManager.instance.IsGameplayScene(); } return false; } } public class InfoPanel : CanvasPanel { private float x; private float y; private float labelWidth; private float infoWidth; private float lineGap; private int counter; public static int ListingHeight => UICommon.ScaleHeight(20); public static InfoPanel Instance { get; private set; } public static void BuildPanel() { Instance = new InfoPanel(); Instance.Build(); } public InfoPanel() : base("InfoPanel") { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_08af: Unknown result type (might be due to invalid IL or missing references) //IL_08d3: Unknown result type (might be due to invalid IL or missing references) //IL_08e4: Unknown result type (might be due to in