Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ProcSolver v1.1.5
ProcSolver.dll
Decompiled 5 months agousing System; using System.Collections; 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 IL.RoR2; using Mono.Cecil.Cil; using MonoMod.Cil; using R2API; using RoR2; using RoR2BepInExPack.Utilities; 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 = "")] [assembly: AssemblyCompany("ProcSolver")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ProcSolver")] [assembly: AssemblyTitle("ProcSolver")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ProcSolver; [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.RiskOfBrainrot.ProcSolver", "ProcSolver", "1.1.5")] public class ProcSolverPlugin : BaseUnityPlugin { public const string guid = "com.RiskOfBrainrot.ProcSolver"; public const string teamName = "RiskOfBrainrot"; public const string modName = "ProcSolver"; public const string version = "1.1.5"; public static FixedConditionalWeakTable<DamageInfo, MoreDamageInfoStats> moreDamageInfoStats = new FixedConditionalWeakTable<DamageInfo, MoreDamageInfoStats>(); public static ModdedProcType ProccedBySkill; public static readonly uint exemptProcTypes = 926613109u; public static readonly uint ChainProcTypes = 163909770u; public static PluginInfo PInfo { get; private set; } internal static ConfigFile CustomConfigFile { get; private set; } public static ConfigEntry<bool> BandsDamageSourceRequirement { get; set; } public static ConfigEntry<int> MaxChainLength { get; set; } public static ConfigEntry<int> AutoplayChainLength { get; set; } public static ConfigEntry<float> AutoplayProcRate { get; set; } public static ConfigEntry<float> ChainProcRate { get; set; } private static int maxChainLength => MaxChainLength.Value; private static int allowedChainDepthOnAutoplay => AutoplayChainLength.Value; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\ProcSolver.cfg", true); BandsDamageSourceRequirement = CustomConfigFile.Bind<bool>("Proc Solver : Bands", "Bands Damage Source", true, "Should Proc Patcher disable band procs on non-skill or non-equipment sources?"); MaxChainLength = CustomConfigFile.Bind<int>("Proc Solver : Proc Chains", "Max Proc Chain Length Initiated By Skill Or Equipment", 3, "When a proc chain is initiated from a skill or equipment, how many times can proc items be recursively triggered before the chain is cut off. Set to -1 to uncap proc chains, or 0 to disallow entirely. For example: If this number is 3, then a chain would be SKILL > PROC > PROC > PROC. "); AutoplayChainLength = CustomConfigFile.Bind<int>("Proc Solver : Proc Chains", "Max Proc Chain Length Initiated By Items (Autoplay)", 1, "When a proc chain is initiated from an item, how many times can proc items be recursively triggered before the chain is cut off. Set to -1 to uncap proc chains, or 0 to disallow entirely. For example: If this number is 1, then a chain would be ITEM > PROC. "); ChainProcRate = CustomConfigFile.Bind<float>("Proc Solver : Proc Rate", "Proc Rate Modifier On Proc Chains Initiated By Skill Or Equipment", 1f, "Proc chain items will proc other items at a reduced rate based on this modifier. For example: If this number is 0.5, then ATG Missile has a 12.5% chance to proc Ukulele instead of 25%."); AutoplayProcRate = CustomConfigFile.Bind<float>("Proc Solver : Proc Rate", "Proc Rate Modifier On Proc Chains Initiated By Items (Autoplay)", 0.5f, "Proc chain items will proc other items at a reduced rate based on this modifier. For example: If this number is 0.2, then Ceremonial Dagger has a 5% chance to proc Ukulele instead of 25%."); ProccedBySkill = ProcTypeAPI.ReserveProcType(); HealthComponent.TakeDamage += new Manipulator(AddProcRateMod); GlobalEventManager.OnHitEnemy += new Manipulator(AddProcRateMod); } public static float GetProcRateMod(DamageInfo damageInfo) { if (damageInfo == null) { return 1f; } return moreDamageInfoStats.GetOrCreateValue(damageInfo).procRate; } private void AddProcRateMod(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0009: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.Emit(OpCodes.Ldarg_1); val.EmitDelegate<Action<DamageInfo>>((Action<DamageInfo>)delegate(DamageInfo damageInfo) { MoreDamageInfoStats orCreateValue = moreDamageInfoStats.GetOrCreateValue(damageInfo); orCreateValue.procRate = GetProcRate(damageInfo); if (orCreateValue.procRate == 0f && ((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)26)) { ((ProcChainMask)(ref damageInfo.procChainMask)).RemoveProc((ProcType)26); } }); } private static float GetProcRate(DamageInfo damageInfo) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (maxChainLength < 0) { return 1f; } if (maxChainLength == 0) { return 0f; } float procCoefficient = damageInfo.procCoefficient; if (((DamageTypeCombo)(ref damageInfo.damageType)).IsDamageSourceSkillBased || (int)damageInfo.damageType.damageSource == 64) { ProcTypeAPI.AddModdedProc(ref damageInfo.procChainMask, ProccedBySkill); return Mathf.Max(procCoefficient, 1f); } int num = GetProcChainDepth(damageInfo.procChainMask); bool flag = ProcTypeAPI.HasModdedProc(damageInfo.procChainMask, ProccedBySkill); if (flag) { num--; } else if (allowedChainDepthOnAutoplay >= 0) { num += Mathf.Max(0, maxChainLength - allowedChainDepthOnAutoplay); } if (num >= maxChainLength) { return 0f; } return procCoefficient * (flag ? ChainProcRate.Value : AutoplayProcRate.Value); } public static int GetProcChainDepth(ProcChainMask procChainMask) { //IL_0004: 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_002b: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0027: Unknown result type (might be due to invalid IL or missing references) int num = 1; for (ProcType val = (ProcType)0; (int)val < 29; val = (ProcType)(val + 1)) { if ((ulong)(procChainMask.mask & ChainProcTypes) != 0) { num++; } } BitArray moddedMask = ProcTypeAPI.GetModdedMask(procChainMask); for (int i = 1; i < moddedMask.Count; i++) { if (moddedMask.Get(i)) { num++; } } return num; } } public class MoreDamageInfoStats { public float procRate = 1f; public int procChainDepth = 0; public bool isAutoplay = false; }