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 ExamplePlugin;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
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("NoProcChainsArtifact")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+49758afd82634977545bd2ca5d235e59fdf10fd5")]
[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 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.0.0")]
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.0.0";
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();
IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes()
where !type.IsAbstract && type.IsSubclassOf(typeof(ArtifactBase))
select type;
foreach (Type item in enumerable)
{
ArtifactBase artifactBase = (ArtifactBase)Activator.CreateInstance(item);
artifactBase.Init(((BaseUnityPlugin)this).Config);
}
}
}
public class ArtifactOfTheUnchained : ArtifactBase
{
public static ConfigEntry<bool> AllowEquipmentProcs;
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)
{
CreateConfig(config);
CreateLang();
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?");
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?");
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?");
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_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_OnTakeDamage);
}
private void LogDamageInfo(DamageInfo damageInfo)
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: 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($"procCoefficient is {damageInfo.procCoefficient}");
Log.Debug($"rejected is {damageInfo.rejected}");
}
private bool IsInflictorFromItem(string inflictor)
{
switch (inflictor)
{
case "IcicleAura(Clone) (UnityEngine.GameObject)":
case "DaggerProjectile(Clone) (UnityEngine.GameObject)":
case "RunicMeteorStrikeImpact(Clone) (UnityEngine.GameObject)":
return true;
case "ShurikenProjectile(Clone) (UnityEngine.GameObject)":
return !AllowShurikenProcs.Value;
case "LunarSunProjectile(Clone) (UnityEngine.GameObject)":
return !AllowEgoProcs.Value;
case "VagrantNovaItemBodyAttachment(Clone) (UnityEngine.GameObject)":
return !AllowGloopProcs.Value;
case "GoldGatController(Clone) (UnityEngine.GameObject)":
case "MissileProjectile(Clone) (UnityEngine.GameObject)":
case "MeteorStorm(Clone) (UnityEngine.GameObject)":
case "Sawmerang(Clone) (UnityEngine.GameObject)":
case "VendingMachineProjectile(Clone) (UnityEngine.GameObject)":
case "FireballVehicle(Clone) (UnityEngine.GameObject)":
return !AllowEquipmentProcs.Value;
case "LunarMissileProjectile(Clone) (UnityEngine.GameObject)":
case "PoisonOrbProjectile(Clone) (UnityEngine.GameObject)":
case "PoisonStakeProjectile(Clone) (UnityEngine.GameObject)":
return !AllowAspectPassiveProcs.Value;
default:
return false;
}
}
private void HealthComponent_OnTakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
{
if (!base.ArtifactEnabled)
{
orig.Invoke(self, damageInfo);
return;
}
if (damageInfo.procChainMask.mask != 0)
{
damageInfo.procCoefficient = 0f;
if (!AllowProcCrits.Value)
{
damageInfo.crit = false;
}
}
else if ((Object)(object)damageInfo.inflictor == (Object)null)
{
if (AllowEquipmentProcs.Value && damageInfo.damageType.damageTypeCombined == 131104)
{
orig.Invoke(self, damageInfo);
return;
}
if (!AllowProcCrits.Value)
{
damageInfo.crit = false;
}
damageInfo.procCoefficient = 0f;
}
else if (IsInflictorFromItem(((object)damageInfo.inflictor).ToString()))
{
damageInfo.procCoefficient = 0f;
}
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_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected O, but got Unknown
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: 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.AllowShurikenProcs));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowEgoProcs));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ArtifactOfTheUnchained.AllowGloopProcs));
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();
}
}