Decompiled source of NoProcChainsArtifact v1.1.4

plugins/NoProcChainsArtifact.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using ExamplePlugin;
using IL.EntityStates.Bandit2;
using IL.EntityStates.Huntress.HuntressWeapon;
using IL.EntityStates.Toolbot;
using IL.RoR2.Orbs;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Orbs;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoProcChainsArtifact")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c2983795c128c5e39a42783c96ce40080fef5767")]
[assembly: AssemblyProduct("NoProcChainsArtifact")]
[assembly: AssemblyTitle("NoProcChainsArtifact")]
[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 NoProcChainsArtifact
{
	internal static class ILHooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__IL_GenericDamageOrb_OnArrival;

			public static Manipulator <1>__IL_Huntress_ThrowGlaive_FireOrbGlaive;

			public static Manipulator <2>__IL_Bandit2_StealthMode_FireSmokebomb;

			public static Manipulator <3>__IL_Toolbot_ToolbotDashImpact_OnEnter;
		}

		internal static void SetupILHooks()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			object obj = <>O.<0>__IL_GenericDamageOrb_OnArrival;
			if (obj == null)
			{
				Manipulator val = IL_GenericDamageOrb_OnArrival;
				<>O.<0>__IL_GenericDamageOrb_OnArrival = val;
				obj = (object)val;
			}
			GenericDamageOrb.OnArrival += (Manipulator)obj;
			object obj2 = <>O.<1>__IL_Huntress_ThrowGlaive_FireOrbGlaive;
			if (obj2 == null)
			{
				Manipulator val2 = IL_Huntress_ThrowGlaive_FireOrbGlaive;
				<>O.<1>__IL_Huntress_ThrowGlaive_FireOrbGlaive = val2;
				obj2 = (object)val2;
			}
			ThrowGlaive.FireOrbGlaive += (Manipulator)obj2;
			object obj3 = <>O.<2>__IL_Bandit2_StealthMode_FireSmokebomb;
			if (obj3 == null)
			{
				Manipulator val3 = IL_Bandit2_StealthMode_FireSmokebomb;
				<>O.<2>__IL_Bandit2_StealthMode_FireSmokebomb = val3;
				obj3 = (object)val3;
			}
			StealthMode.FireSmokebomb += (Manipulator)obj3;
			object obj4 = <>O.<3>__IL_Toolbot_ToolbotDashImpact_OnEnter;
			if (obj4 == null)
			{
				Manipulator val4 = IL_Toolbot_ToolbotDashImpact_OnEnter;
				<>O.<3>__IL_Toolbot_ToolbotDashImpact_OnEnter = val4;
				obj4 = (object)val4;
			}
			ToolbotDashImpact.OnEnter += (Manipulator)obj4;
		}

		private static void IL_Huntress_ThrowGlaive_FireOrbGlaive(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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.MatchCall<EntityState>(x, "get_gameObject"),
				(Instruction x) => ILPatternMatchingExt.MatchStfld<LightningOrb>(x, "attacker")
			}))
			{
				val.Emit(OpCodes.Ldloc_0);
				val.Emit(OpCodes.Ldarg_0);
				val.Emit<EntityState>(OpCodes.Call, "get_gameObject");
				val.Emit<LightningOrb>(OpCodes.Stfld, "inflictor");
			}
			else
			{
				Log.Error("COULD NOT IL HOOK HUNTRESS FIREORBGLAIVE!");
				Log.Error($"cursor is {val}");
				Log.Error($"il is {il}");
			}
		}

		private static void IL_GenericDamageOrb_OnArrival(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchLdnull(x),
				(Instruction x) => ILPatternMatchingExt.MatchStfld<DamageInfo>(x, "inflictor")
			}))
			{
				val.Index -= 2;
				val.Remove();
				val.Emit(OpCodes.Ldarg_0);
				val.Emit<GenericDamageOrb>(OpCodes.Ldfld, "attacker");
			}
			else
			{
				Log.Error("COULD NOT IL HOOK GENERICDAMAGEORB_ONARRIVAL!");
				Log.Error($"cursor is {val}");
				Log.Error($"il is {il}");
			}
		}

		private static void IL_Toolbot_ToolbotDashImpact_OnEnter(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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.MatchCall<EntityState>(x, "get_gameObject"),
				(Instruction x) => ILPatternMatchingExt.MatchStfld<DamageInfo>(x, "attacker")
			}))
			{
				val.Emit(OpCodes.Dup);
				val.Emit(OpCodes.Ldarg_0);
				val.Emit<EntityState>(OpCodes.Call, "get_gameObject");
				val.Emit<DamageInfo>(OpCodes.Stfld, "inflictor");
			}
			else
			{
				Log.Error("COULD NOT IL HOOK MUL-T DASH IMPACT!");
				Log.Error($"cursor is {val}");
				Log.Error($"il is {il}");
			}
		}

		private static void IL_Bandit2_StealthMode_FireSmokebomb(ILContext il)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			ILLabel label = null;
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<EntityState>(x, "get_isAuthority"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref label),
				(Instruction x) => ILPatternMatchingExt.MatchNewobj<BlastAttack>(x)
			}))
			{
				val.Emit(OpCodes.Dup);
				val.Emit(OpCodes.Ldarg_0);
				val.Emit<EntityState>(OpCodes.Call, "get_gameObject");
				val.Emit<BlastAttack>(OpCodes.Stfld, "inflictor");
			}
			else
			{
				Log.Error("COULD NOT IL HOOK BANDIT SMOKEBOMB!");
				Log.Error($"cursor is {val}");
				Log.Error($"il is {il}");
			}
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public static class ModAssets
	{
		public static AssetBundle AssetBundle;

		public const string BundleName = "unchainedartifacticons";

		public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(NoProcChainsArtifact.PluginInfo.Location), "unchainedartifacticons");

		public static void Init()
		{
			AssetBundle = AssetBundle.LoadFromFile(AssetBundlePath);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("LordVGames.NoProcChainsArtifact", "NoProcChainsArtifact", "1.1.4")]
	public class NoProcChainsArtifact : BaseUnityPlugin
	{
		public const string PluginGUID = "LordVGames.NoProcChainsArtifact";

		public const string PluginAuthor = "LordVGames";

		public const string PluginName = "NoProcChainsArtifact";

		public const string PluginVersion = "1.1.4";

		public List<ArtifactBase> Artifacts = new List<ArtifactBase>();

		public static PluginInfo PluginInfo { get; private set; }

		public void Awake()
		{
			PluginInfo = ((BaseUnityPlugin)this).Info;
			Log.Init(((BaseUnityPlugin)this).Logger);
			ModAssets.Init();
			foreach (Type item in from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(ArtifactBase))
				select type)
			{
				((ArtifactBase)Activator.CreateInstance(item)).Init(((BaseUnityPlugin)this).Config);
			}
		}
	}
	public class ArtifactOfTheUnchained : ArtifactBase
	{
		public static ConfigEntry<bool> AllowEquipmentProcs;

		public static ConfigEntry<bool> AllowSawmerangProcs;

		public static ConfigEntry<bool> AllowElectricBoomerangProcs;

		public static ConfigEntry<bool> AllowFireworkProcs;

		public static ConfigEntry<bool> AllowShurikenProcs;

		public static ConfigEntry<bool> AllowEgoProcs;

		public static ConfigEntry<bool> AllowGloopProcs;

		public static ConfigEntry<bool> AllowAspectPassiveProcs;

		public static ConfigEntry<bool> AllowProcCrits;

		public override string ArtifactLangTokenName => "NO_PROC_CHAINS";

		public override string ArtifactName => "Artifact of the Unchained";

		public override string ArtifactDescription => "Almost all item effects cannot proc your on-hit item effects for you.";

		public override Sprite ArtifactEnabledIcon => ModAssets.AssetBundle.LoadAsset<Sprite>("NoProcChainsArtifactIcon_Enabled.png");

		public override Sprite ArtifactDisabledIcon => ModAssets.AssetBundle.LoadAsset<Sprite>("NoProcChainsArtifactIcon_Disabled.png");

		public override void Init(ConfigFile config)
		{
			CreateLang();
			CreateConfig(config);
			CreateArtifact();
			Hooks();
			if (RiskOfOptionsSupport.ModIsRunning)
			{
				RiskOfOptionsSupport.AddOptions();
			}
		}

		private void CreateConfig(ConfigFile config)
		{
			AllowEquipmentProcs = config.Bind<bool>(ArtifactName, "Allow equipments to proc items", false, "Should damage from equipments be allowed to proc your on-hit items?");
			AllowSawmerangProcs = config.Bind<bool>(ArtifactName, "Allow Sawmerang to proc", true, "Should damage from Sawmerang be allowed to proc your on-hit items? WARNING: This will also disable the equipment's built-in bleed on hit!\nThis setting is completely separate from the general equipment procs setting, meaning you can let sawmerang proc while preventing all other equipments from proccing.");
			AllowElectricBoomerangProcs = config.Bind<bool>(ArtifactName, "Allow Electric Boomerang to proc", true, "Should damage from Electric Boomerang be allowed to proc your on-hit items? WARNING: This will also disable the item's built-in stun on hit!");
			AllowGloopProcs = config.Bind<bool>(ArtifactName, "Allow Genesis Loop to proc items", true, "Should damage from Genesis Loop be allowed to proc your on-hit items?");
			AllowShurikenProcs = config.Bind<bool>(ArtifactName, "Allow Shurikens to proc items", false, "Should damage from Shurikens be allowed to proc your on-hit items?");
			AllowEgoProcs = config.Bind<bool>(ArtifactName, "Allow Egocentrism to proc items", false, "Should damage from Egocentrism be allowed to proc your on-hit items?");
			AllowFireworkProcs = config.Bind<bool>(ArtifactName, "Allow Fireworks to proc items", false, "Should damage from Fireworks be allowed to proc your on-hit items?");
			AllowAspectPassiveProcs = config.Bind<bool>(ArtifactName, "Allow elite passives to proc items", true, "Should damage from perfected & malachite elites' passive attacks be allowed to proc your on-hit items? Twisted's passive can proc, but is internally seen as razorwire, so as far as I know I'm unable to let it proc with the artifact on.");
			AllowProcCrits = config.Bind<bool>(ArtifactName, "Allow item procs to crit", true, "Should damage from item procs be allowed to crit?");
		}

		public override void Hooks()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_OnTakeDamage);
			ILHooks.SetupILHooks();
		}

		private void LogDamageInfo(DamageInfo damageInfo)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			Log.Debug("");
			Log.Debug("");
			Log.Debug("");
			Log.Debug($"attacker is {damageInfo.attacker}");
			Log.Debug($"canRejectForce is {damageInfo.canRejectForce}");
			Log.Debug($"crit is {damageInfo.crit}");
			Log.Debug($"damage is {damageInfo.damage}");
			Log.Debug($"damageColorIndex is {damageInfo.damageColorIndex}");
			Log.Debug($"damageType is {damageInfo.damageType}");
			Log.Debug($"damageType.damageType is {damageInfo.damageType.damageType}");
			Log.Debug($"damageType.damageTypeCombined is {damageInfo.damageType.damageTypeCombined}");
			Log.Debug($"damageType.damageTypeExtended is {damageInfo.damageType.damageTypeExtended}");
			Log.Debug($"delayedDamageSecondHalf is {damageInfo.delayedDamageSecondHalf}");
			Log.Debug($"dotIndex is {damageInfo.dotIndex}");
			Log.Debug($"force is {damageInfo.force}");
			Log.Debug($"inflictor is {damageInfo.inflictor}");
			Log.Debug($"position is {damageInfo.position}");
			Log.Debug($"procChainMask is {damageInfo.procChainMask}");
			Log.Debug($"procChainMask.mask is {damageInfo.procChainMask.mask}");
			Log.Debug($"procCoefficient is {damageInfo.procCoefficient}");
			Log.Debug($"rejected is {damageInfo.rejected}");
		}

		private void SetCoefficientIfFromItem(DamageInfo damageInfo)
		{
			string name = ((Object)damageInfo.inflictor).name;
			if (name == null)
			{
				return;
			}
			switch (name.Length)
			{
			case 17:
			{
				char c = name[0];
				if (c != 'B')
				{
					if (c != 'I' || !(name == "IcicleAura(Clone)"))
					{
						break;
					}
					goto IL_0255;
				}
				if (!(name == "BeamSphere(Clone)"))
				{
					break;
				}
				goto IL_02c7;
			}
			case 23:
				switch (name[0])
				{
				default:
					return;
				case 'D':
					if (!(name == "DaggerProjectile(Clone)"))
					{
						return;
					}
					break;
				case 'L':
					if (!(name == "LampBulletPlayer(Clone)"))
					{
						return;
					}
					break;
				}
				goto IL_0255;
			case 24:
			{
				char c = name[0];
				if (c != 'G')
				{
					if (c != 'M')
					{
						if (c != 'T' || !(name == "ThunderAuraStrike(Clone)"))
						{
							break;
						}
						goto IL_0255;
					}
					if (!(name == "MissileProjectile(Clone)"))
					{
						break;
					}
				}
				else if (!(name == "GoldGatController(Clone)"))
				{
					break;
				}
				goto IL_02c7;
			}
			case 25:
				switch (name[0])
				{
				case 'F':
					if (name == "FireworkProjectile(Clone)" && !AllowFireworkProcs.Value)
					{
						damageInfo.procCoefficient = 0f;
					}
					break;
				case 'S':
					if (name == "ShurikenProjectile(Clone)" && !AllowShurikenProcs.Value)
					{
						damageInfo.procCoefficient = 0f;
					}
					break;
				case 'L':
					if (name == "LunarSunProjectile(Clone)" && !AllowEgoProcs.Value)
					{
						damageInfo.procCoefficient = 0f;
					}
					break;
				}
				break;
			case 30:
				if (!(name == "RunicMeteorStrikeImpact(Clone)"))
				{
					break;
				}
				goto IL_0255;
			case 27:
				if (!(name == "IfritPylonPlayerBody(Clone)"))
				{
					break;
				}
				goto IL_0255;
			case 19:
				if (!(name == "MushroomWard(Clone)"))
				{
					break;
				}
				goto IL_0255;
			case 21:
				if (!(name == "LunarShockwave(Clone)"))
				{
					break;
				}
				goto IL_0255;
			case 36:
				if (name == "VagrantNovaItemBodyAttachment(Clone)" && !AllowGloopProcs.Value)
				{
					damageInfo.procCoefficient = 0f;
				}
				break;
			case 18:
				if (!(name == "MeteorStorm(Clone)"))
				{
					break;
				}
				goto IL_02c7;
			case 31:
				if (!(name == "VendingMachineProjectile(Clone)"))
				{
					break;
				}
				goto IL_02c7;
			case 22:
				if (!(name == "FireballVehicle(Clone)"))
				{
					break;
				}
				goto IL_02c7;
			case 16:
				if (name == "Sawmerang(Clone)" && !AllowSawmerangProcs.Value)
				{
					damageInfo.procCoefficient = 0f;
				}
				break;
			case 29:
				if (!(name == "LunarMissileProjectile(Clone)"))
				{
					break;
				}
				goto IL_02f7;
			case 26:
				if (!(name == "PoisonOrbProjectile(Clone)"))
				{
					break;
				}
				goto IL_02f7;
			case 28:
				if (!(name == "PoisonStakeProjectile(Clone)"))
				{
					break;
				}
				goto IL_02f7;
			case 20:
			case 32:
			case 33:
			case 34:
			case 35:
				break;
				IL_02f7:
				if (!AllowAspectPassiveProcs.Value)
				{
					damageInfo.procCoefficient = 0f;
				}
				break;
				IL_02c7:
				if (!AllowEquipmentProcs.Value)
				{
					damageInfo.procCoefficient = 0f;
				}
				break;
				IL_0255:
				damageInfo.procCoefficient = 0f;
				break;
			}
		}

		private bool IsDamageBrokenWithoutInflictor(DamageInfo damageInfo)
		{
			switch (((Object)damageInfo.attacker).name)
			{
			case "CrocoBody(Clone)":
				if (damageInfo.damageType.damageTypeCombined == 4096)
				{
					return true;
				}
				break;
			case "Executioner2Body(Clone)":
				if (damageInfo.damageType.damageTypeCombined == 393216)
				{
					return true;
				}
				break;
			case "NemesisEnforcerBody(Clone)":
				if (damageInfo.damageType.damageTypeCombined == 131104)
				{
					return true;
				}
				break;
			case "MinerBody(Clone)":
			{
				ulong damageTypeCombined = damageInfo.damageType.damageTypeCombined;
				if (damageTypeCombined == 131072 || damageTypeCombined == 131104)
				{
					return true;
				}
				break;
			}
			case "SulfurPodBody(Clone)":
			case "ShrineBlood(Clone)":
				return true;
			}
			switch (damageInfo.damageType.damageTypeCombined)
			{
			case 131104uL:
				if (AllowEquipmentProcs.Value)
				{
					return true;
				}
				break;
			case 131328uL:
				if ((double)damageInfo.procCoefficient == 0.75)
				{
					return true;
				}
				break;
			}
			return false;
		}

		private void HealthComponent_OnTakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			if (!base.ArtifactEnabled)
			{
				orig.Invoke(self, damageInfo);
			}
			else if ((Object)(object)damageInfo.inflictor == (Object)null && (Object)(object)damageInfo.attacker == (Object)null)
			{
				orig.Invoke(self, damageInfo);
			}
			else if (damageInfo.procChainMask.mask != 0)
			{
				if (!AllowProcCrits.Value)
				{
					damageInfo.crit = false;
				}
				if (damageInfo.procChainMask.mask == 8388608 && AllowElectricBoomerangProcs.Value)
				{
					orig.Invoke(self, damageInfo);
					return;
				}
				damageInfo.procCoefficient = 0f;
				orig.Invoke(self, damageInfo);
			}
			else if ((Object)(object)damageInfo.inflictor == (Object)null)
			{
				if (IsDamageBrokenWithoutInflictor(damageInfo))
				{
					orig.Invoke(self, damageInfo);
					return;
				}
				if (!AllowProcCrits.Value)
				{
					damageInfo.crit = false;
				}
				damageInfo.procCoefficient = 0f;
				orig.Invoke(self, damageInfo);
			}
			else
			{
				SetCoefficientIfFromItem(damageInfo);
				orig.Invoke(self, damageInfo);
			}
		}
	}
	public static class RiskOfOptionsSupport
	{
		private static bool? _modexists;

		public static bool ModIsRunning
		{
			get
			{
				if (!_modexists.HasValue)
				{
					_modexists = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
				}
				return _modexists.Value;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddOptions()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			ModSettingsManager.SetModIcon(ModAssets.AssetBundle.LoadAsset<Sprite>("RoOIcon.png"));
			ModSettingsManager.SetModDescription("Adds an artifact that disables proc chains and prevents most items from starting a proc chain.");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowEquipmentProcs));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowSawmerangProcs));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowElectricBoomerangProcs));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowGloopProcs));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowShurikenProcs));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowEgoProcs));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowFireworkProcs));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowAspectPassiveProcs));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowProcCrits));
		}
	}
}
namespace ExamplePlugin
{
	public abstract class ArtifactBase
	{
		public ArtifactDef ArtifactDef;

		public abstract string ArtifactName { get; }

		public abstract string ArtifactLangTokenName { get; }

		public abstract string ArtifactDescription { get; }

		public abstract Sprite ArtifactEnabledIcon { get; }

		public abstract Sprite ArtifactDisabledIcon { get; }

		public bool ArtifactEnabled => RunArtifactManager.instance.IsArtifactEnabled(ArtifactDef);

		public abstract void Init(ConfigFile config);

		protected void CreateLang()
		{
			LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_NAME", ArtifactName);
			LanguageAPI.Add("ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION", ArtifactDescription);
		}

		protected void CreateArtifact()
		{
			ArtifactDef = ScriptableObject.CreateInstance<ArtifactDef>();
			ArtifactDef.cachedName = "ARTIFACT_" + ArtifactLangTokenName;
			ArtifactDef.nameToken = "ARTIFACT_" + ArtifactLangTokenName + "_NAME";
			ArtifactDef.descriptionToken = "ARTIFACT_" + ArtifactLangTokenName + "_DESCRIPTION";
			ArtifactDef.smallIconSelectedSprite = ArtifactEnabledIcon;
			ArtifactDef.smallIconDeselectedSprite = ArtifactDisabledIcon;
			ContentAddition.AddArtifactDef(ArtifactDef);
		}

		public abstract void Hooks();
	}
}