Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of ConfigEgocentrismEdit v1.0.0
ConfigEgocentrism.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using On.RoR2; using R2API.Utils; using RoR2; using RoR2.Projectile; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: AssemblyCompany("ConfigEgocentrism")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ConfigEgocentrism")] [assembly: AssemblyTitle("ConfigEgocentrism")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ConfigEgocentrism { [BepInPlugin("Judgy.ConfigEgocentrism", "ConfigEgocentrism", "1.2.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class ConfigEgocentrismPlugin : BaseUnityPlugin { public const string PluginGUID = "Judgy.ConfigEgocentrism"; public const string PluginAuthor = "Judgy"; public const string PluginName = "ConfigEgocentrism"; public const string PluginVersion = "1.2.1"; private List<ItemTier> TransformInvalidItemTiers; private static ConfigEntry<bool> ConfigProjectilesEnabled { get; set; } private static ConfigEntry<float> ConfigProjectilesIntervalBase { get; set; } private static ConfigEntry<float> ConfigProjectilesIntervalStackMult { get; set; } private static ConfigEntry<float> ConfigProjectilesIntervalStackExponent { get; set; } private static ConfigEntry<float> ConfigProjectilesDamageBase { get; set; } private static ConfigEntry<float> ConfigProjectilesDamageStackMult { get; set; } private static ConfigEntry<float> ConfigProjectilesDamageStackExponent { get; set; } private static ConfigEntry<float> ConfigProjectilesMaxAmountBase { get; set; } private static ConfigEntry<float> ConfigProjectilesMaxAmountStackMult { get; set; } private static ConfigEntry<float> ConfigProjectilesMaxAmountStackExponent { get; set; } private static ConfigEntry<string> ConfigProjectilesMaxAmountRoundingMode { get; set; } private static ConfigEntry<float> ConfigProjectilesRangeBase { get; set; } private static ConfigEntry<float> ConfigProjectilesRangeStackMult { get; set; } private static ConfigEntry<float> ConfigProjectilesRangeStackExponent { get; set; } private static ConfigEntry<bool> ConfigTransformEnabled { get; set; } private static ConfigEntry<float> ConfigTransformIntervalBase { get; set; } private static ConfigEntry<float> ConfigTransformIntervalStackMult { get; set; } private static ConfigEntry<float> ConfigTransformIntervalStackExponent { get; set; } private static ConfigEntry<float> ConfigTransformAmountBase { get; set; } private static ConfigEntry<float> ConfigTransformAmountStackMult { get; set; } private static ConfigEntry<float> ConfigTransformAmountStackExponent { get; set; } private static ConfigEntry<string> ConfigTransformAmountRoundingMode { get; set; } private static ConfigEntry<string> ConfigTransformItemFilter { get; set; } private static ConfigEntry<string> ConfigPluginVersion { get; set; } public void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); CreateConfig(); BuildItemFilters(); SetupHooks(); Log.LogInfo("Awake done."); } private void CreateConfig() { //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Expected O, but got Unknown ConfigProjectilesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Feature Toggle", "Projectiles Enabled", true, "Enables the generation of projectiles."); ConfigTransformEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Feature Toggle", "Transform Enabled", true, "Enables the transformation of other items."); ConfigProjectilesIntervalBase = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Interval", "Interval Base", 3f, "Sets the base interval between each generation of projectiles (in seconds).\nFormula: _Base_ / (Stack * StackMult)^StackExponent"); ConfigProjectilesIntervalStackMult = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Interval", "Interval Stack Multiplier", 1f, "Sets the stack multiplier in projectiles interval formula.\nOnly accepts positive values or 0.0. Default value used if input is negative.\nFormula: Base / (Stack * _StackMult_)^StackExponent"); ConfigProjectilesIntervalStackExponent = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Interval", "Interval Stack Exponent", 1f, "Sets the stack exponent in projectiles interval formula.\nOnly accepts positive values or 0.0. Default value used if input is negative.\nFormula: Base / (Stack * StackMult)^_StackExponent_"); ConfigProjectilesDamageBase = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Damage", "Damage Base", 3.6f, "Sets the base damage multiplier of projectiles.\nFormula: _Base_ + (Stack * StackMult)^StackExponent"); ConfigProjectilesDamageStackMult = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Damage", "Damage Stack Multiplier", 0f, "Sets the stack multiplier in projectiles damage formula.\nFormula: Base + (Stack * _StackMult_)^StackExponent"); ConfigProjectilesDamageStackExponent = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Damage", "Damage Stack Exponent", 1f, "Sets the stack exponent in projectiles damage formula.\nFormula: Base + (Stack * StackMult)^_StackExponent_"); ConfigProjectilesMaxAmountBase = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Max Amount", "Max Amount Base", 2f, "Sets the base max amount of projectiles.\nFormula: _Base_ + (Stack * StackMult)^StackExponent"); ConfigProjectilesMaxAmountStackMult = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Max Amount", "Max Amount Stack Multiplier", 1f, "Sets the stack multiplier in projectiles max amount formula.\nFormula: Base + (Stack * _StackMult_)^StackExponent"); ConfigProjectilesMaxAmountStackExponent = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Max Amount", "Max Amount Stack Exponent", 1f, "Sets the stack multiplier in projectiles max amount formula.\nFormula: Base + (Stack * StackMult)^_StackExponent_"); ConfigProjectilesMaxAmountRoundingMode = ((BaseUnityPlugin)this).Config.Bind<string>("Projectiles Max Amount", "Max Amount Rounding Mode", Utils.RoundingMode.AlwaysDown.ToString(), new ConfigDescription("Sets the rounding mode when calculating projectiles max amount.", (AcceptableValueBase)(object)new AcceptableValueList<string>(Enum.GetNames(typeof(Utils.RoundingMode))), Array.Empty<object>())); ConfigProjectilesRangeBase = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Range", "Range Base", 15f, "Sets the base targeting range of projectiles.\nFormula: _Base_ + (Stack * StackMult)^StackExponent"); ConfigProjectilesRangeStackMult = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Range", "Range Stack Mutliplier", 0f, "Sets the stack multiplier in projectiles range formula.\nFormula: Base + (Stack * _StackMult_)^StackExponent"); ConfigProjectilesRangeStackExponent = ((BaseUnityPlugin)this).Config.Bind<float>("Projectiles Range", "Range Stack Exponent", 1f, "Sets the stack exponent in projectiles range formula.\nFormula: Base + (Stack * StackMult)^_StackExponent_"); ConfigTransformIntervalBase = ((BaseUnityPlugin)this).Config.Bind<float>("Transform Interval", "Interval Base", 60f, "Sets the base interval between each item transform (in seconds).\nFormula: _Base_ / (Stack * StackMult)^StackExponent"); ConfigTransformIntervalStackMult = ((BaseUnityPlugin)this).Config.Bind<float>("Transform Interval", "Interval Stack Multiplier", 0f, "Sets the stack multiplier in item transform interval formula.\nOnly accepts positive values or 0.0. Default value used if input is negative.\nFormula: Base / (Stack * _StackMult_)^StackExponent"); ConfigTransformIntervalStackExponent = ((BaseUnityPlugin)this).Config.Bind<float>("Transform Interval", "Interval Stack Exponent", 0f, "Sets the stack exponent in item transform interval formula.\nOnly accepts positive values or 0.0. Default value used if input is negative.\nFormula: Base / (Stack * StackMult)^_StackExponent_"); ConfigTransformAmountBase = ((BaseUnityPlugin)this).Config.Bind<float>("Transform Item Amount", "Transform Amount Base", 1f, "Sets the base number of items transformed at each iteration.\nFormula: _Base_ + (Stack * StackMult)^StackExponent"); ConfigTransformAmountStackMult = ((BaseUnityPlugin)this).Config.Bind<float>("Transform Item Amount", "Transform Amount Stack Multiplier", 0f, "Sets the stack multiplier in transform item amount formula.\nFormula: Base + (Stack * _StackMult_)^StackExponent"); ConfigTransformAmountStackExponent = ((BaseUnityPlugin)this).Config.Bind<float>("Transform Item Amount", "Transform Amount Stack Exponent", 1f, "Sets the stack exponent in transform item amount formula.\nFormula: Base + (Stack * StackMult)^_StackExponent_"); ConfigTransformAmountRoundingMode = ((BaseUnityPlugin)this).Config.Bind<string>("Transform Item Amount", "Transform Amount Rounding Mode", Utils.RoundingMode.AlwaysDown.ToString(), new ConfigDescription("Sets the rounding mode when calculating item transform amount.", (AcceptableValueBase)(object)new AcceptableValueList<string>(Enum.GetNames(typeof(Utils.RoundingMode))), Array.Empty<object>())); ConfigTransformItemFilter = ((BaseUnityPlugin)this).Config.Bind<string>("Transform Item Filter", "Filter", "untiered", "Filters Item Tiers to NOT transform. Avoid removing `untiered` from that list to not lose character passives, artifacts and other hidden stuff.\r\nFormat : tier1,tier2,tier3\r\nValid Tiers: untiered,white,green,red,blue,yellow,voidwhite,voidgreen,voidred,voidyellow"); ConfigTransformItemFilter.SettingChanged += RebuildItemFiltersEvent; ConfigPluginVersion = ((BaseUnityPlugin)this).Config.Bind<string>("zMiscellaneous", "Plugin Version", "0.0.0", "Plugin Version, used for cleaning old configs entries.\nAvoid editing this unless you want duplicate config entries."); if (ConfigPluginVersion.Value == (string)((ConfigEntryBase)ConfigPluginVersion).DefaultValue) { ConfigCleanup(); } ConfigPluginVersion.Value = "1.2.1"; } private void ConfigCleanup() { Log.LogWarning("Old Config data cleaned up. This should only get triggered once ever."); Reflection.GetPropertyValue<Dictionary<ConfigDefinition, string>>((object)((BaseUnityPlugin)this).Config, "OrphanedEntries").Clear(); ((BaseUnityPlugin)this).Config.Save(); } private void RebuildItemFiltersEvent(object s, EventArgs e) { BuildItemFilters(); } private void BuildItemFilters() { TransformInvalidItemTiers = new List<ItemTier>(); string[] array = ConfigTransformItemFilter.Value.Split(new char[1] { ',' }); foreach (string text in array) { if (!string.IsNullOrWhiteSpace(text)) { if (Enum.TryParse<Utils.ItemTierLookup>(text.Trim().ToLower(), out var result)) { TransformInvalidItemTiers.Add((ItemTier)result); } else { Log.LogDebug("TransformItemFilter: Invalid tier input `" + text + "`"); } } } Log.LogInfo($"TransformItemFilter: Filter List built ({TransformInvalidItemTiers.Count} filters)"); } private void SetupHooks() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown LunarSunBehavior.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, LunarSunBehavior self) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Invalid comparison between Unknown and I4 //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) CharacterBody fieldValue = Reflection.GetFieldValue<CharacterBody>((object)self, "body"); GameObject fieldValue2 = Reflection.GetFieldValue<GameObject>((object)self, "projectilePrefab"); int fieldValue3 = Reflection.GetFieldValue<int>((object)self, "stack"); float num = Reflection.GetFieldValue<float>((object)self, "projectileTimer"); float num2 = Reflection.GetFieldValue<float>((object)self, "transformTimer"); Xoroshiro128Plus fieldValue4 = Reflection.GetFieldValue<Xoroshiro128Plus>((object)self, "transformRng"); if (ConfigProjectilesEnabled.Value) { num += Time.fixedDeltaTime; float projectilesInterval = GetProjectilesInterval(fieldValue3); int num3 = (int)(num / projectilesInterval); for (int i = 0; i < num3; i++) { if (!fieldValue.master.IsDeployableLimited((DeployableSlot)16)) { num -= num; ProjectileSphereTargetFinder component = fieldValue2.GetComponent<ProjectileSphereTargetFinder>(); if (Object.op_Implicit((Object)(object)component)) { component.lookRange = GetProjectilesRange(fieldValue3); } else { Log.LogError("LunarSunBehavior: Unable to modify projectile Range (ProjectileSphereTargetFinder component not found)"); } FireProjectileInfo val = default(FireProjectileInfo); val.projectilePrefab = fieldValue2; val.crit = fieldValue.RollCrit(); val.damage = fieldValue.damage * GetProjectilesDamage(fieldValue3); val.damageColorIndex = (DamageColorIndex)3; val.force = 0f; val.owner = ((Component)self).gameObject; val.position = fieldValue.transform.position; val.rotation = Quaternion.identity; FireProjectileInfo val2 = val; ProjectileManager.instance.FireProjectile(val2); } else { num = 0f; } } } if (ConfigTransformEnabled.Value) { num2 += Time.fixedDeltaTime; if (num2 > GetTransformInterval(fieldValue3)) { num2 = 0f; if (Object.op_Implicit((Object)(object)fieldValue.master) && Object.op_Implicit((Object)(object)fieldValue.inventory)) { int transformAmount = GetTransformAmount(fieldValue3); for (int j = 0; j < transformAmount; j++) { List<ItemIndex> list = new List<ItemIndex>(fieldValue.inventory.itemAcquisitionOrder); ItemIndex val3 = (ItemIndex)(-1); Util.ShuffleList<ItemIndex>(list, fieldValue4); foreach (ItemIndex item in list) { if (item != Items.LunarSun.itemIndex) { ItemDef itemDef = ItemCatalog.GetItemDef(item); if (Object.op_Implicit((Object)(object)itemDef) && !TransformInvalidItemTiers.Contains(itemDef.tier)) { val3 = item; break; } } } if ((int)val3 != -1) { fieldValue.inventory.RemoveItem(val3, 1); fieldValue.inventory.GiveItem(Items.LunarSun, 1); CharacterMasterNotificationQueue.PushItemTransformNotification(fieldValue.master, val3, Items.LunarSun.itemIndex, (TransformationType)4); } } } } } Reflection.SetFieldValue<float>((object)self, "projectileTimer", num); Reflection.SetFieldValue<float>((object)self, "transformTimer", num2); }; LunarSunBehavior.GetMaxProjectiles += (hook_GetMaxProjectiles)((orig_GetMaxProjectiles orig, Inventory inventory) => GetProjectilesMaxAmount(inventory.GetItemCount(Items.LunarSun))); } private float GetProjectilesInterval(int stack) { float value = ConfigProjectilesIntervalBase.Value; float positiveConfigFloat = Utils.GetPositiveConfigFloat(ConfigProjectilesIntervalStackMult); float positiveConfigFloat2 = Utils.GetPositiveConfigFloat(ConfigProjectilesIntervalStackExponent); return Utils.GetDividingFormulaValue(value, stack, positiveConfigFloat, positiveConfigFloat2); } private float GetProjectilesDamage(int stack) { float value = ConfigProjectilesDamageBase.Value; float value2 = ConfigProjectilesDamageStackMult.Value; float value3 = ConfigProjectilesDamageStackExponent.Value; return Utils.GetAdditionalFormulaValue(value, stack, value2, value3); } private int GetProjectilesMaxAmount(int stack) { float value = ConfigProjectilesMaxAmountBase.Value; float value2 = ConfigProjectilesMaxAmountStackMult.Value; float value3 = ConfigProjectilesMaxAmountStackExponent.Value; return Utils.Round(Utils.GetAdditionalFormulaValue(value, stack, value2, value3), ConfigProjectilesMaxAmountRoundingMode.Value); } private float GetProjectilesRange(int stack) { float value = ConfigProjectilesRangeBase.Value; float value2 = ConfigProjectilesRangeStackMult.Value; float value3 = ConfigProjectilesRangeStackExponent.Value; return Utils.GetAdditionalFormulaValue(value, stack, value2, value3); } private float GetTransformInterval(int stack) { float value = ConfigTransformIntervalBase.Value; float positiveConfigFloat = Utils.GetPositiveConfigFloat(ConfigTransformIntervalStackMult); float positiveConfigFloat2 = Utils.GetPositiveConfigFloat(ConfigTransformIntervalStackExponent); return Utils.GetDividingFormulaValue(value, stack, positiveConfigFloat, positiveConfigFloat2); } private int GetTransformAmount(int stack) { float value = ConfigTransformAmountBase.Value; float value2 = ConfigTransformAmountStackMult.Value; float value3 = ConfigTransformAmountStackExponent.Value; return Utils.Round(Utils.GetAdditionalFormulaValue(value, stack, value2, value3), ConfigTransformAmountRoundingMode.Value); } } internal static class Log { internal static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void LogDebug(object data) { _logSource.LogDebug(data); } internal static void LogError(object data) { _logSource.LogError(data); } internal static void LogFatal(object data) { _logSource.LogFatal(data); } internal static void LogInfo(object data) { _logSource.LogInfo(data); } internal static void LogMessage(object data) { _logSource.LogMessage(data); } internal static void LogWarning(object data) { _logSource.LogWarning(data); } } public static class Utils { public enum ItemTierLookup { white, green, red, blue, yellow, untiered, voidwhite, voidgreen, voidred, voidyellow } public enum RoundingMode { AlwaysDown, AlwaysUp, Closest } public static int Round(float f, string roundingModeStr, int defaultVal = 0) { RoundingMode roundingMode = RoundingMode.AlwaysDown; if (Enum.TryParse<RoundingMode>(roundingModeStr, out var result)) { roundingMode = result; } switch (roundingMode) { case RoundingMode.AlwaysDown: return Mathf.FloorToInt(f); case RoundingMode.AlwaysUp: return Mathf.CeilToInt(f); case RoundingMode.Closest: return Mathf.RoundToInt(f); default: Log.LogError("Rounding mode \"" + roundingModeStr + "\" not implemented. Returning default value (" + defaultVal + ")"); return defaultVal; } } public static float GetPositiveConfigFloat(ConfigEntry<float> config) { if (config.Value >= 0f) { return config.Value; } return (float)((ConfigEntryBase)config).DefaultValue; } public static float GetAdditionalFormulaValue(float baseVal, int stack, float stackMult, float stackExponent) { return baseVal + Mathf.Pow((float)stack * stackMult, stackExponent); } public static float GetDividingFormulaValue(float baseVal, int stack, float stackMult, float stackExponent) { float num = Mathf.Pow((float)stack * stackMult, stackExponent); if (num <= 0f) { num = 1f; } return baseVal / num; } } }