using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using PluginConfig.API; using PluginConfig.API.Fields; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("CybergrindPowerups")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CybergrindPowerups")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ccbdd6f0-7249-4d79-9587-2c2fa81d9d51")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] public static class EnemyList { public static List AllEnemies = new List { (EnemyType)3, (EnemyType)13, (EnemyType)14, (EnemyType)15, (EnemyType)6, (EnemyType)1, (EnemyType)20, (EnemyType)4, (EnemyType)0, (EnemyType)7, (EnemyType)2, (EnemyType)5, (EnemyType)26, (EnemyType)12, (EnemyType)9, (EnemyType)21, (EnemyType)31, (EnemyType)33, (EnemyType)34, (EnemyType)19, (EnemyType)39, (EnemyType)40, (EnemyType)38, (EnemyType)41 }; } public class EnemySettings { public BoolField enabled; public IntField requiredCount; public EnemySettings(ConfigPanel panel, EnemyType enemy) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0049: 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_0080: Expected O, but got Unknown enabled = new BoolField(panel, ((int)enemy == 19) ? "Sisyphean Insurrectionist" : GetEnemyDisplayName(enemy), ((object)(EnemyType)(ref enemy)).ToString().ToLower() + "_enabled", true); requiredCount = new IntField(panel, GetEnemyDisplayName(enemy) + " Count", ((object)(EnemyType)(ref enemy)).ToString().ToLower() + "_required_count", 1); } private string GetEnemyDisplayName(EnemyType enemy) { //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_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 EnemyType val = enemy; EnemyType val2 = val; if ((int)val2 <= 6) { if ((int)val2 == 2) { return "Hideous Mass"; } if ((int)val2 == 6) { return "Streetcleaner"; } } else { if ((int)val2 == 7) { return "Swordsmachine"; } if ((int)val2 == 19) { return "Sisyphean"; } } return ((object)(EnemyType)(ref enemy)).ToString(); } } [BepInPlugin("yourname.cybergrindpowerups", "Cybergrind Powerups", "1.0.0")] public class Plugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static IntValueChangeEventDelegate <>9__15_0; public static BoolValueChangeEventDelegate <>9__15_1; public static BoolValueChangeEventDelegate <>9__15_2; internal void b__15_0(IntValueChangeEvent changeEvent) { if (OrbSpawnChance.value < 0) { OrbSpawnChance.value = 0; } if (OrbSpawnChance.value > 100) { OrbSpawnChance.value = 100; } } internal void b__15_1(BoolValueChangeEvent changeEvent) { if (SpawnOnPlayer.value) { SpawnAtEnemySpawn.value = false; } } internal void b__15_2(BoolValueChangeEvent changeEvent) { if (SpawnAtEnemySpawn.value) { SpawnOnPlayer.value = false; } } } [CompilerGenerated] private sealed class d__17 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Plugin <>4__this; private GameObject[] 5__1; private GameObject[] <>s__2; private int <>s__3; private GameObject 5__4; private DualWieldPickup 5__5; private SpawnableObject[] 5__6; private SpawnableObject[] <>s__7; private int <>s__8; private SpawnableObject 5__9; private string 5__10; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>s__2 = null; 5__4 = null; 5__5 = null; 5__6 = null; <>s__7 = null; 5__9 = null; 5__10 = null; <>1__state = -2; } private bool MoveNext() { //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; goto IL_0052; case 1: <>1__state = -1; goto IL_0052; case 2: <>1__state = -1; goto IL_0188; case 3: { <>1__state = -1; goto IL_02c4; } IL_0052: if ((Object)(object)GameStateManager.Instance == (Object)null) { <>2__current = null; <>1__state = 1; return true; } goto IL_0190; IL_0190: if ((Object)(object)RuntimeDualWieldPrefab == (Object)null) { 5__1 = Resources.FindObjectsOfTypeAll(); <>s__2 = 5__1; for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++) { 5__4 = <>s__2[<>s__3]; if (!((Object)(object)5__4 == (Object)null) && ((Object)5__4).name.Contains("DualWield")) { 5__5 = 5__4.GetComponent(); if (!((Object)(object)5__5 == (Object)null)) { RuntimeDualWieldPrefab = Object.Instantiate(5__4); Object.DontDestroyOnLoad((Object)(object)RuntimeDualWieldPrefab); RuntimeDualWieldPrefab.SetActive(false); Log.LogInfo((object)"[SUCCESS] Cached Dual Wield Orb"); break; } } } <>s__2 = null; if ((Object)(object)RuntimeDualWieldPrefab == (Object)null) { <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; } goto IL_0188; } goto IL_02cc; IL_02cc: if ((Object)(object)RedSoulOrbSpawnable == (Object)null) { 5__6 = Resources.FindObjectsOfTypeAll(); <>s__7 = 5__6; for (<>s__8 = 0; <>s__8 < <>s__7.Length; <>s__8++) { 5__9 = <>s__7[<>s__8]; if (!((Object)(object)5__9 == (Object)null)) { 5__10 = ((!string.IsNullOrEmpty(5__9.objectName)) ? 5__9.objectName : ((Object)5__9).name); if (5__10 == "Red Soul Orb") { RedSoulOrbSpawnable = 5__9; Log.LogInfo((object)"[SUCCESS] Cached Red Soul Orb"); break; } 5__10 = null; 5__9 = null; } } <>s__7 = null; if ((Object)(object)RedSoulOrbSpawnable == (Object)null) { <>2__current = (object)new WaitForSeconds(1f); <>1__state = 3; return true; } goto IL_02c4; } Log.LogInfo((object)"[SUCCESS] Powerups cached"); return false; IL_02c4: 5__6 = null; goto IL_02cc; IL_0188: 5__1 = null; goto IL_0190; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static ManualLogSource Log; public static Plugin Instance; public static BoolField EnableDualWieldOrb; public static BoolField EnableRedSoulOrb; public static BoolField EnableOrbSpawnChance; public static IntField OrbSpawnChance; public static BoolField SpawnOnPlayer; public static BoolField SpawnAtEnemySpawn; public static GameObject RuntimeDualWieldPrefab; public static SpawnableObject RedSoulOrbSpawnable; public static List SpawnedPowerups = new List(); public static Dictionary EnemyConfigs = new Dictionary(); public static PluginConfigurator PluginConfigInstance; private bool lastSpawnOnPlayer; private bool lastSpawnAtEnemySpawn; private void Awake() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Cybergrind Powerups loaded!"); Harmony val = new Harmony("yourname.cybergrindpowerups"); val.PatchAll(); ((MonoBehaviour)this).StartCoroutine(CachePowerups()); PluginConfigInstance = PluginConfigurator.Create("Cybergrind Powerups", "yourname.cybergrindpowerups"); ConfigPanel val2 = new ConfigPanel(PluginConfigInstance.rootPanel, "Powerup Settings", "powerup_settings"); ConfigPanel val3 = new ConfigPanel(PluginConfigInstance.rootPanel, "Spawn Settings", "spawn_settings"); ConfigPanel panel = new ConfigPanel(PluginConfigInstance.rootPanel, "Enemy Settings", "enemy_settings"); EnableDualWieldOrb = new BoolField(val2, "Dual Wield power-up", "enable_dual_wield_orb", true); EnableRedSoulOrb = new BoolField(val2, "Red Soul Orb power-up", "enable_red_soul_orb", true); EnableOrbSpawnChance = new BoolField(val2, "Enable Orb Spawn Chance", "enable_orb_spawn_chance", false); OrbSpawnChance = new IntField(val2, "Orb Spawn Chance (%)", "orb_spawn_chance", 100); IntField orbSpawnChance = OrbSpawnChance; object obj = <>c.<>9__15_0; if (obj == null) { IntValueChangeEventDelegate val4 = delegate { if (OrbSpawnChance.value < 0) { OrbSpawnChance.value = 0; } if (OrbSpawnChance.value > 100) { OrbSpawnChance.value = 100; } }; <>c.<>9__15_0 = val4; obj = (object)val4; } orbSpawnChance.onValueChange += (IntValueChangeEventDelegate)obj; SpawnOnPlayer = new BoolField(val3, "Spawn power-ups on player", "spawn_on_player", true); SpawnAtEnemySpawn = new BoolField(val3, "Spawn power-ups at enemy spawn", "spawn_enemy_spawn", false); BoolField spawnOnPlayer = SpawnOnPlayer; object obj2 = <>c.<>9__15_1; if (obj2 == null) { BoolValueChangeEventDelegate val5 = delegate { if (SpawnOnPlayer.value) { SpawnAtEnemySpawn.value = false; } }; <>c.<>9__15_1 = val5; obj2 = (object)val5; } spawnOnPlayer.onValueChange += (BoolValueChangeEventDelegate)obj2; BoolField spawnAtEnemySpawn = SpawnAtEnemySpawn; object obj3 = <>c.<>9__15_2; if (obj3 == null) { BoolValueChangeEventDelegate val6 = delegate { if (SpawnAtEnemySpawn.value) { SpawnOnPlayer.value = false; } }; <>c.<>9__15_2 = val6; obj3 = (object)val6; } spawnAtEnemySpawn.onValueChange += (BoolValueChangeEventDelegate)obj3; if (SpawnOnPlayer.value && SpawnAtEnemySpawn.value) { SpawnAtEnemySpawn.value = false; } foreach (EnemyType allEnemy in EnemyList.AllEnemies) { EnemyConfigs[allEnemy] = new EnemySettings(panel, allEnemy); } } private void Update() { WaveTracker.Update(); if (OrbSpawnChance != null) { if (OrbSpawnChance.value < 0) { OrbSpawnChance.value = 0; } if (OrbSpawnChance.value > 100) { OrbSpawnChance.value = 100; } } if (!lastSpawnOnPlayer && SpawnOnPlayer.value) { SpawnAtEnemySpawn.value = false; } if (!lastSpawnAtEnemySpawn && SpawnAtEnemySpawn.value) { SpawnOnPlayer.value = false; } lastSpawnOnPlayer = SpawnOnPlayer.value; lastSpawnAtEnemySpawn = SpawnAtEnemySpawn.value; } [IteratorStateMachine(typeof(d__17))] private IEnumerator CachePowerups() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__17(0) { <>4__this = this }; } } public static class PowerupSpawner { public static void SpawnDualWield(Vector3 position) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Plugin.RuntimeDualWieldPrefab == (Object)null) { Plugin.Log.LogError((object)"[POWERUP] Runtime DualWield is NULL"); return; } GameObject val = Object.Instantiate(Plugin.RuntimeDualWieldPrefab, position, Quaternion.identity); Plugin.SpawnedPowerups.Add(val); val.SetActive(true); Plugin.Log.LogInfo((object)"[POWERUP] Spawned Dual Wield Orb"); } public static void SpawnRedSoulOrb(Vector3 position) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Plugin.RedSoulOrbSpawnable == (Object)null) { Plugin.Log.LogError((object)"[POWERUP] RedSoulOrbSpawnable is NULL"); return; } GameObject val = Object.Instantiate(Plugin.RedSoulOrbSpawnable.gameObject, position, Quaternion.identity); Plugin.SpawnedPowerups.Add(val); val.SetActive(true); Plugin.Log.LogInfo((object)"[POWERUP] Spawned Red Soul Orb"); } } [HarmonyPatch(typeof(EndlessGrid))] [HarmonyPatch("SpawnOnGrid")] public class SpawnHook { public static void Postfix(GameObject __result, bool enemy) { //IL_002d: 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) if (enemy && !((Object)(object)__result == (Object)null)) { EnemyIdentifier componentInChildren = __result.GetComponentInChildren(); if (!((Object)(object)componentInChildren == (Object)null)) { WaveTracker.RegisterEnemy(componentInChildren.enemyType, ((Component)componentInChildren).transform.position); } } } } public static class WaveTracker { public static Dictionary CurrentWaveEnemies = new Dictionary(); private static int lastWave = -1; private static EndlessGrid cachedGrid; private static bool orbTriggeredThisWave = false; private static bool rollAttemptedThisWave = false; public static void Update() { if ((Object)(object)cachedGrid == (Object)null) { cachedGrid = Object.FindObjectOfType(); } if ((Object)(object)cachedGrid == (Object)null || cachedGrid.currentWave == lastWave) { return; } lastWave = cachedGrid.currentWave; CurrentWaveEnemies.Clear(); orbTriggeredThisWave = false; rollAttemptedThisWave = false; foreach (GameObject spawnedPowerup in Plugin.SpawnedPowerups) { if ((Object)(object)spawnedPowerup != (Object)null) { Object.Destroy((Object)(object)spawnedPowerup); } } Plugin.SpawnedPowerups.Clear(); Plugin.Log.LogInfo((object)("[CybergrindPowerups] New Wave: " + lastWave)); } public static void RegisterEnemy(EnemyType type, Vector3 enemyPosition) { //IL_0006: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!CurrentWaveEnemies.ContainsKey(type)) { CurrentWaveEnemies[type] = 0; } CurrentWaveEnemies[type]++; CheckEnemyConditions(type, enemyPosition); } private static void CheckEnemyConditions(EnemyType type, Vector3 enemyPosition) { //IL_001f: 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_005d: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) if (orbTriggeredThisWave || rollAttemptedThisWave || !Plugin.EnemyConfigs.ContainsKey(type)) { return; } EnemySettings enemySettings = Plugin.EnemyConfigs[type]; if (!enemySettings.enabled.value || !CurrentWaveEnemies.ContainsKey(type)) { return; } int num = CurrentWaveEnemies[type]; int num2 = enemySettings.requiredCount.value; if (num2 < 1) { num2 = 1; enemySettings.requiredCount.value = 1; } if (num != num2) { return; } rollAttemptedThisWave = true; if (Plugin.EnableOrbSpawnChance.value) { int num3 = Random.Range(0, 100); if (num3 >= Plugin.OrbSpawnChance.value) { Plugin.Log.LogInfo((object)("[ROLL FAILED] " + num3 + "/" + Plugin.OrbSpawnChance.value)); return; } Plugin.Log.LogInfo((object)("[ROLL SUCCESS] " + num3 + "/" + Plugin.OrbSpawnChance.value)); } orbTriggeredThisWave = true; Plugin.Log.LogInfo((object)("[ORB CONDITION MET] " + ((object)(EnemyType)(ref type)).ToString() + " reached " + num)); Vector3 position; if (Plugin.SpawnOnPlayer.value) { position = ((Component)MonoSingleton.Instance).transform.position + Vector3.up * 2f; } else { if (!Plugin.SpawnAtEnemySpawn.value) { Plugin.Log.LogInfo((object)"[POWERUP] No spawn mode enabled"); return; } position = enemyPosition + Vector3.up * 1f; } if (Plugin.EnableDualWieldOrb.value) { PowerupSpawner.SpawnDualWield(position); } if (Plugin.EnableRedSoulOrb.value) { PowerupSpawner.SpawnRedSoulOrb(position); } } private static Vector3 GetRandomEnemySpawnPosition() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cachedGrid == (Object)null) { cachedGrid = Object.FindObjectOfType(); } if ((Object)(object)cachedGrid == (Object)null) { return ((Component)MonoSingleton.Instance).transform.position; } return ((Component)cachedGrid).transform.position + Vector3.up * 3f; } }