using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using PluginConfig.API; using PluginConfig.API.Decorators; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RADIKILL")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("nkRADIKILL")] [assembly: AssemblyTitle("RADIKILL")] [assembly: AssemblyVersion("1.0.0.0")] [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; } } } public class RadianceConfig { public bool isEnforced = false; public bool isEnabled = false; public float tier = 1f; public float health = 1.5f; public float damage = 1.5f; public float speed = 1.5f; public RadianceConfig() { } public RadianceConfig(bool radIsEnforced, bool radIsEnabled, float radTier, float radHealth, float radDamage, float radSpeed) { isEnforced = radIsEnforced; isEnabled = radIsEnabled; tier = radTier; health = radHealth; damage = radDamage; speed = radSpeed; } } namespace RADIKILL { [BepInPlugin("net.nkmi.radikill", "nkRADIKILL", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static Harmony harmony; public static PluginConfig pluginConfig; internal static ManualLogSource Logger { get; private set; } private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; harmony = new Harmony("net.nkmi.radikill"); harmony.PatchAll(); pluginConfig = new PluginConfig(); pluginConfig.onConfigChanged += delegate { updateEnemies(); }; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)4; Logger.LogInfo((object)"nkRADIKILL loaded :3c"); } public void OnDestroy() { harmony.UnpatchSelf(); } public static void applyRadianceConfig(EnemyIdentifier enemy) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) if (pluginConfig.isEnemyAffected(enemy.enemyType)) { MonoSingleton.Instance.cheatsEnabled = true; RadianceConfig configForEnemy = pluginConfig.getConfigForEnemy(enemy.enemyType); enemy.radianceTier = configForEnemy.tier; enemy.healthBuffModifier = configForEnemy.health; enemy.damageBuffModifier = configForEnemy.damage; enemy.speedBuffModifier = configForEnemy.speed; enemy.UnbuffAll(); if (configForEnemy.isEnabled) { enemy.BuffAll(); } } } public static void updateEnemies() { EnemyIdentifier[] array = Object.FindObjectsOfType(); foreach (EnemyIdentifier enemy in array) { applyRadianceConfig(enemy); } } } [HarmonyPatch] public static class PluginPatches { [HarmonyPrefix] [HarmonyPatch(typeof(EnemyIdentifier), "Start")] private static bool onStart(EnemyIdentifier __instance) { Plugin.applyRadianceConfig(__instance); return true; } } public class PluginConfig { private PluginConfigurator configurator = null; private Dictionary enemyConfigs = new Dictionary(); private RadianceConfig globalRadianceConfig = new RadianceConfig(); public bool enablePlugin = false; public event EventHandler onConfigChanged = null; private void invokeChangedEvent() { this.onConfigChanged?.Invoke(this, EventArgs.Empty); } public bool isEnemyAffected(EnemyType enemyType) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) if (!enablePlugin || !enemyConfigs.ContainsKey(enemyType)) { return false; } if (globalRadianceConfig.isEnforced) { return true; } RadianceConfig radianceConfig = enemyConfigs[enemyType]; return radianceConfig.isEnforced; } public RadianceConfig getConfigForEnemy(EnemyType enemyType) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (globalRadianceConfig.isEnforced && !enemyConfigs[enemyType].isEnforced) { return globalRadianceConfig; } return enemyConfigs[enemyType]; } private string getEnemyClassPanelName(EnemyClass enemyClass) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected I4, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } string result = (int)enemyClass switch { 0 => "Husks", 2 => "Demons", 1 => "Machines", 3 => "Angels", _ => Enum.GetName(typeof(EnemyClass), enemyClass) + "s", }; if (1 == 0) { } return result; } private string getEnemyName(EnemyType enemyType) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); dictionary[(EnemyType)2] = "Hideous Mass"; dictionary[(EnemyType)41] = "Mirror Reaper"; dictionary[(EnemyType)4] = "Malicious Face"; dictionary[(EnemyType)20] = "Sentry"; dictionary[(EnemyType)19] = "Sisyphean Insurrectionist"; if (dictionary.ContainsKey(enemyType)) { return dictionary[enemyType]; } return Enum.GetName(typeof(EnemyType), enemyType); } private List getGlobalConfigExceptions() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (KeyValuePair enemyConfig in enemyConfigs) { if (enemyConfig.Value.isEnforced) { list.Insert(list.Count, getEnemyName(enemyConfig.Key)); } } return list; } private string formatExceptionsString(List exceptions) { if (exceptions.Count == 1) { return "There is 1 enemy overriding these settings: " + exceptions[0]; } string text = $"There are {exceptions.Count} enemies overriding these settings: "; for (int i = 0; i < exceptions.Count; i++) { text += exceptions[i]; if (i != exceptions.Count - 1) { text += ", "; } } return text; } private void buildRadiancePanel(ConfigPanel parent, RadianceConfig radianceConfig, string id, string name) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Expected O, but got Unknown //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Expected O, but got Unknown //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected O, but got Unknown //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Expected O, but got Unknown string id2 = id; RadianceConfig radianceConfig2 = radianceConfig; ConfigPanel val = new ConfigPanel(parent, name, id2 + "_panel"); ConfigHeader header = new ConfigHeader(val, "", 24); ((ConfigField)header).hidden = true; BoolField enforceToggle = new BoolField(val, "Enforce radiance", id2 + "_isEnforced", false); ConfigDivision div = new ConfigDivision(val, id2 + "_radiance_division"); BoolField radianceToggle = new BoolField((ConfigPanel)(object)div, "Enable radiance", id2 + "_isRadiant", true); ConfigDivision slidersDiv = new ConfigDivision((ConfigPanel)(object)div, id2 + "_radiance_sliders"); FloatSliderField radianceTier = new FloatSliderField((ConfigPanel)(object)slidersDiv, "Tier", id2 + "_tier", new Tuple(0.5f, 10f), 1f, 2); FloatSliderField healthScale = new FloatSliderField((ConfigPanel)(object)slidersDiv, "Health", id2 + "_health", new Tuple(0f, 10f), 1.5f, 2); FloatSliderField damageScale = new FloatSliderField((ConfigPanel)(object)slidersDiv, "Damage", id2 + "_damage", new Tuple(0f, 10f), 1.5f, 2); FloatSliderField speedScale = new FloatSliderField((ConfigPanel)(object)slidersDiv, "Speed", id2 + "_speed", new Tuple(0f, 10f), 1.5f, 2); ConfigHeader footer = new ConfigHeader(val, "", 24); ((ConfigField)footer).hidden = true; Action updateHeaders = delegate { //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (!enforceToggle.value || id2 != "global") { ((ConfigField)header).hidden = true; ((ConfigField)footer).hidden = true; } else { List globalConfigExceptions = getGlobalConfigExceptions(); if (globalConfigExceptions.Count == 0) { ((ConfigField)footer).hidden = true; } else { string text = formatExceptionsString(globalConfigExceptions); ((ConfigField)footer).hidden = false; footer.text = text; footer.textColor = Color.red; } } }; Action updateRadianceConfig = delegate { radianceConfig2.isEnforced = enforceToggle.value; radianceConfig2.isEnabled = radianceToggle.value; radianceConfig2.tier = radianceTier.value; radianceConfig2.health = healthScale.value; radianceConfig2.damage = damageScale.value; radianceConfig2.speed = speedScale.value; ((ConfigField)div).interactable = enforceToggle.value; ((ConfigField)slidersDiv).interactable = radianceToggle.value; invokeChangedEvent(); }; enforceToggle.postValueChangeEvent += (PostBoolValueChangeEvent)delegate { updateRadianceConfig(); }; radianceToggle.postValueChangeEvent += (PostBoolValueChangeEvent)delegate { updateRadianceConfig(); }; radianceTier.postValueChangeEvent += (PostFloatSliderValueChangeEvent)delegate { updateRadianceConfig(); }; healthScale.postValueChangeEvent += (PostFloatSliderValueChangeEvent)delegate { updateRadianceConfig(); }; damageScale.postValueChangeEvent += (PostFloatSliderValueChangeEvent)delegate { updateRadianceConfig(); }; speedScale.postValueChangeEvent += (PostFloatSliderValueChangeEvent)delegate { updateRadianceConfig(); }; onConfigChanged += delegate { updateHeaders(); }; updateRadianceConfig(); } private void buildEnemiesPanel(ConfigPanel parent, EnemyClass enemyClass, EnemyType[] enemyTypes) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_003e: 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_0062: 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) string enemyClassPanelName = getEnemyClassPanelName(enemyClass); string text = "Enemies_" + Enum.GetName(typeof(EnemyType), enemyClass); ConfigPanel parent2 = new ConfigPanel(parent, enemyClassPanelName, text); foreach (EnemyType val in enemyTypes) { RadianceConfig radianceConfig = new RadianceConfig(); enemyConfigs[val] = radianceConfig; string name = Enum.GetName(typeof(EnemyType), val); string enemyName = getEnemyName(val); buildRadiancePanel(parent2, radianceConfig, name, enemyName); } } private void buildEnemyPanels(ConfigPanel parent) { EnemyType[] array = new EnemyType[8]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); EnemyType[] enemyTypes = (EnemyType[])(object)array; EnemyType[] array2 = new EnemyType[7]; RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); EnemyType[] enemyTypes2 = (EnemyType[])(object)array2; EnemyType[] array3 = new EnemyType[6]; RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); EnemyType[] enemyTypes3 = (EnemyType[])(object)array3; EnemyType[] array4 = new EnemyType[3]; RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); EnemyType[] enemyTypes4 = (EnemyType[])(object)array4; buildEnemiesPanel(parent, (EnemyClass)0, enemyTypes); buildEnemiesPanel(parent, (EnemyClass)2, enemyTypes3); buildEnemiesPanel(parent, (EnemyClass)1, enemyTypes2); buildEnemiesPanel(parent, (EnemyClass)3, enemyTypes4); } private void buildMenu() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown BoolField val = new BoolField(configurator.rootPanel, "Enable RADIKILL", "isActive", false, true, true); ConfigDivision rootDiv = new ConfigDivision(configurator.rootPanel, "root_div"); ((ConfigField)rootDiv).interactable = val.value; enablePlugin = val.value; val.onValueChange += (BoolValueChangeEventDelegate)delegate(BoolValueChangeEvent e) { ((ConfigField)rootDiv).interactable = e.value; enablePlugin = e.value; invokeChangedEvent(); }; buildRadiancePanel((ConfigPanel)(object)rootDiv, globalRadianceConfig, "global", "Global"); buildEnemyPanels((ConfigPanel)(object)rootDiv); } public PluginConfig() { configurator = PluginConfigurator.Create("nkRADIKILL", "net.nkmi.radikill"); buildMenu(); } } internal static class MyPluginInfo { public const string PLUGIN_GUID = "net.nkmi.radikill"; public const string PLUGIN_NAME = "nkRADIKILL"; public const string PLUGIN_VERSION = "1.0.0"; } }