using System;
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;
[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("ProcLimiter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ProcLimiter")]
[assembly: AssemblyTitle("ProcLimiter")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ProcLimiter;
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.RiskOfBrainrot.ProcLimiter", "ProcLimiter", "1.0.0")]
public class ProcLimiterPlugin : BaseUnityPlugin
{
public const string guid = "com.RiskOfBrainrot.ProcLimiter";
public const string teamName = "RiskOfBrainrot";
public const string modName = "ProcLimiter";
public const string version = "1.0.0";
public static PluginInfo PInfo { get; private set; }
internal static ConfigFile CustomConfigFile { get; private set; }
public static ConfigEntry<bool> DoBands { get; set; }
public static ConfigEntry<bool> DoChronic { get; set; }
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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\ProcSolver.cfg", true);
DoBands = CustomConfigFile.Bind<bool>("Proc Limiter", "Bands Damage Source", true, "Should Proc Limiter disable band procs on non-skill or non-equipment sources?");
DoChronic = CustomConfigFile.Bind<bool>("Proc Limiter", "Chronix Expansion Damage Source", true, "Should Proc Limiter disable chronic expansion buff extension on non-skill or non-equipment sources?");
if (DoBands.Value)
{
GlobalEventManager.ProcessHitEnemy += new Manipulator(AddBandsSkillRequirement);
LanguageAPI.Add("ITEM_ICERING_DESC", "Hits from <style=cIsUtility>skills or equipment</style> that deal <style=cIsDamage>more than 400% damage</style> also blast enemies with a <style=cIsDamage>runic ice blast</style>, <style=cIsUtility>slowing</style> them by <style=cIsUtility>80%</style> for <style=cIsUtility>3s</style> <style=cStack>(+3s per stack)</style> and dealing <style=cIsDamage>250%</style> <style=cStack>(+250% per stack)</style> TOTAL damage. Recharges every <style=cIsUtility>10</style> seconds.");
LanguageAPI.Add("ITEM_FIRERING_DESC", "Hits from <style=cIsUtility>skills or equipment</style> that deal <style=cIsDamage>more than 400% damage</style> also blast enemies with a <style=cIsDamage>runic flame tornado</style>, dealing <style=cIsDamage>300%</style> <style=cStack>(+300% per stack)</style> TOTAL damage over time. Recharges every <style=cIsUtility>10</style> seconds.");
LanguageAPI.Add("ITEM_ELEMENTALRINGVOID_DESC", "Hits from <style=cIsUtility>skills or equipment</style> that deal <style=cIsDamage>more than 400% damage</style> also fire a black hole that <style=cIsUtility>draws enemies within 15m into its center</style>. Lasts <style=cIsUtility>5</style> seconds before collapsing, dealing <style=cIsDamage>100%</style> <style=cStack>(+100% per stack)</style> TOTAL damage. Recharges every <style=cIsUtility>20</style> seconds. <style=cIsVoid>Corrupts all Runald's and Kjaro's Bands</style>.");
}
if (DoChronic.Value)
{
GlobalEventManager.ProcessHitEnemy += new Manipulator(AddChronicSkillRequirement);
LanguageAPI.Add("ITEM_ICERING_DESC", "Hits from <style=cIsUtility>skills or equipment</style> that deal <style=cIsDamage>more than 400% damage</style> also blast enemies with a <style=cIsDamage>runic ice blast</style>, <style=cIsUtility>slowing</style> them by <style=cIsUtility>80%</style> for <style=cIsUtility>3s</style> <style=cStack>(+3s per stack)</style> and dealing <style=cIsDamage>250%</style> <style=cStack>(+250% per stack)</style> TOTAL damage. Recharges every <style=cIsUtility>10</style> seconds.");
LanguageAPI.Add("ITEM_FIRERING_DESC", "Hits from <style=cIsUtility>skills or equipment</style> that deal <style=cIsDamage>more than 400% damage</style> also blast enemies with a <style=cIsDamage>runic flame tornado</style>, dealing <style=cIsDamage>300%</style> <style=cStack>(+300% per stack)</style> TOTAL damage over time. Recharges every <style=cIsUtility>10</style> seconds.");
LanguageAPI.Add("ITEM_ELEMENTALRINGVOID_DESC", "Hits from <style=cIsUtility>skills or equipment</style> that deal <style=cIsDamage>more than 400% damage</style> also fire a black hole that <style=cIsUtility>draws enemies within 15m into its center</style>. Lasts <style=cIsUtility>5</style> seconds before collapsing, dealing <style=cIsDamage>100%</style> <style=cStack>(+100% per stack)</style> TOTAL damage. Recharges every <style=cIsUtility>20</style> seconds. <style=cIsVoid>Corrupts all Runald's and Kjaro's Bands</style>.");
}
}
private void AddChronicSkillRequirement(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "RoR2.DLC2Content/Items", "IncreaseDamageOnMultikill"),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "RoR2.Inventory", "GetItemCount")
}))
{
val.Emit(OpCodes.Ldarg_1);
val.EmitDelegate<Func<int, DamageInfo, int>>((Func<int, DamageInfo, int>)((int itemCount, DamageInfo damageInfo) => (((DamageTypeCombo)(ref damageInfo.damageType)).IsDamageSourceSkillBased || (int)damageInfo.damageType.damageSource == 64) ? itemCount : 0));
}
}
private void AddBandsSkillRequirement(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 12),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "RoR2.ProcChainMask", "HasProc")
}))
{
val.Emit(OpCodes.Ldarg_1);
val.EmitDelegate<Func<bool, DamageInfo, bool>>((Func<bool, DamageInfo, bool>)((bool cantProc, DamageInfo damageInfo) => cantProc || (!((DamageTypeCombo)(ref damageInfo.damageType)).IsDamageSourceSkillBased && (int)damageInfo.damageType.damageSource != 64)));
}
}
}