using System;
using System.Collections;
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 HG.Reflection;
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.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ArtifactOfTheUnchained")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+40039f4b5bc1f69b654be86cf4b3df244588d087")]
[assembly: AssemblyProduct("ArtifactOfTheUnchained")]
[assembly: AssemblyTitle("ArtifactOfTheUnchained")]
[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 ArtifactOfTheUnchainedMod
{
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();
}
public class ArtifactOfTheUnchained : ArtifactBase
{
public override string ArtifactLangTokenName => "UNCHAINED";
public override string ArtifactName => "Artifact of the Unchained";
public override string ArtifactDescription => "Nerfs proc chains and procs caused by items such as fireworks, all depending on how you've configured the mod.";
public override Sprite ArtifactEnabledIcon => Assets.AssetBundle.LoadAsset<Sprite>("NoProcChainsArtifactIcon_Enabled.png");
public override Sprite ArtifactDisabledIcon => Assets.AssetBundle.LoadAsset<Sprite>("NoProcChainsArtifactIcon_Disabled.png");
public override void Init(ConfigFile config)
{
CreateLang();
CreateArtifact();
Hooks();
if (ModSupport.RiskOfOptions.ModIsRunning)
{
ModSupport.RiskOfOptions.AddOptions();
}
}
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_TakeDamage_Artifact);
}
private void HealthComponent_TakeDamage_Artifact(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
{
if (!base.ArtifactEnabled)
{
orig.Invoke(self, damageInfo);
return;
}
DamageRelated.DebugLogDamageInfo(damageInfo, loggingBeforeChanges: true);
DamageRelated.HealthComponent_TakeDamage(damageInfo);
orig.Invoke(self, damageInfo);
DamageRelated.DebugLogDamageInfo(damageInfo, loggingBeforeChanges: false);
}
}
public static class Assets
{
public static AssetBundle AssetBundle;
public const string BundleName = "unchainedartifacticons";
public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(Plugin.PluginInfo.Location), "unchainedartifacticons");
public static void Init()
{
AssetBundle = AssetBundle.LoadFromFile(AssetBundlePath);
}
}
public static class ConfigOptions
{
public static ConfigEntry<bool> ArtifactlessMode;
public static ConfigEntry<string> ItemProcNerfBodyBlacklist;
internal static string[] ItemProcNerfBodyBlacklistArray;
public static ConfigEntry<float> ProcFromItemDamageNerfToPercent;
public static ConfigEntry<float> ProcFromItemCoefficientNerfToPercent;
public static ConfigEntry<int> ProcChainAmountLimit;
public static ConfigEntry<float> ProcChainDamageNerfToPercent;
public static ConfigEntry<float> ProcChainCoefficientNerfToPercent;
public static ConfigEntry<bool> PreventAllItemChaining;
internal static void ItemProcNerfBodyBlacklist_SettingChanged(object sender, EventArgs e)
{
ItemProcNerfBodyBlacklistArray = ItemProcNerfBodyBlacklist.Value.Split(',');
}
public static void BindConfigEntries(ConfigFile Config, ArtifactBase artifactInstance)
{
ArtifactlessMode = Config.Bind<bool>(artifactInstance.ArtifactName, "Run without requiring artifact", false, "Should the effects of the artifact always be on without needing to activate it?");
ItemProcNerfBodyBlacklist = Config.Bind<string>(artifactInstance.ArtifactName, "Blacklist for DamageSource-less characters", "", "Modded characters that have not been completely updated for the latest RoR2 version or rely on SeekersPatcher will be missing a \"DamageSource\" on their skills. This causes the artifact to see damage from those modded characters as damage from items, thus nerfing any procs from those skills. Add a survivor's internal body name (i.e CommandoBody) here, separating each one with a comma and no spaces, to add those survivors to a blacklist excluding them from damage nerfs for procs from items. \n\nNOTE: This will make survivors added here stronger than other survivors, due to some of their damage not being nerfed, but it's better than consistently having barely any damage.");
ItemProcNerfBodyBlacklist.SettingChanged += ItemProcNerfBodyBlacklist_SettingChanged;
ItemProcNerfBodyBlacklistArray = ItemProcNerfBodyBlacklist.Value.Split(',');
ProcFromItemDamageNerfToPercent = Config.Bind<float>(artifactInstance.ArtifactName, "Nerf damage for procs from items", 0.2f, "Should damage for procs caused by items (i.e. fireworks or royal capacitor) be nerfed to a percent of what it would normally be? I.E. 0.2 is 20% of the normal damage, 0.02 is 2%, and 1 is vanilla behavior as there is no change.");
ProcFromItemCoefficientNerfToPercent = Config.Bind<float>(artifactInstance.ArtifactName, "Nerf proc coefficient for procs from items", 1f, "Should the proc coefficient for procs caused by items (i.e. fireworks or royal capacitor) be nerfed to a percent of what it would normally be? I.E. 0.1 is 20% of the normal proc coefficient, and 1 is vanilla behavior as there is no change.");
ProcChainAmountLimit = Config.Bind<int>(artifactInstance.ArtifactName, "Proc chaining limit", 1, "The limit for how many times on-hit proc items can proc other on-hit proc items. 1 means item procs cannot chain into any other items, i.e. an atg hit can proc your other on-hit proc items, then those procs will not proc anything else. Set to -1 for vanilla behavior.");
ProcChainDamageNerfToPercent = Config.Bind<float>(artifactInstance.ArtifactName, "Nerf chained procs damage", 0.05f, "Should damage from chained procs (i.e. atg procced by a charged perforator hit) be reduced to a percent of what they would normally do? I.E. 0.2 is 20% of the normal damage, 0.02 is 2%, and 1 is vanilla behavior as there is no change.");
ProcChainCoefficientNerfToPercent = Config.Bind<float>(artifactInstance.ArtifactName, "Nerf chained procs proc coefficient", 1f, "Should the proc coefficients for chained procs (i.e. polylute from an atg) be reduced to a percent of what they would normally are? I.E. 0.1 is 10% of the normal proc coefficient, and 1 is vanilla behavior as there is no change.");
PreventAllItemChaining = Config.Bind<bool>(artifactInstance.ArtifactName, "Prevent ALL items from proccing other items", false, "Should not just procs from other procs but item procs from ANY item be blocked? This means that ONLY damage from skills can proc your items.");
}
}
internal static class DamageRelated
{
public static ModdedProcType ProccedByItem;
public static ModdedProcType ProccedByProc;
internal static void HealthComponent_TakeDamage(DamageInfo damageInfo)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)damageInfo.attacker) || ((DamageTypeCombo)(ref damageInfo.damageType)).IsDamageSourceSkillBased)
{
return;
}
int procCountInChain = GetProcCountInChain(damageInfo.procChainMask);
if (procCountInChain > 0)
{
if (ProcTypeAPI.HasModdedProc(damageInfo.procChainMask, ProccedByProc))
{
NerfProcFromProc(damageInfo, procCountInChain);
return;
}
ProcTypeAPI.AddModdedProc(ref damageInfo.procChainMask, ProccedByProc);
}
if (ProcTypeAPI.HasModdedProc(damageInfo.procChainMask, ProccedByItem))
{
if (!Main.IsAttackerBlacklisted(damageInfo.attacker))
{
NerfProcFromItem(damageInfo);
}
}
else
{
ProcTypeAPI.AddModdedProc(ref damageInfo.procChainMask, ProccedByItem);
}
}
private static void NerfProcFromProc(DamageInfo damageInfo, int procsInChain)
{
if (procsInChain > ConfigOptions.ProcChainAmountLimit.Value && ConfigOptions.ProcChainAmountLimit.Value != -1)
{
damageInfo.procCoefficient = 0f;
Log.NerfedProc(Main.NerfLoggingMessages.ProcChainBlocked);
}
else
{
damageInfo.procCoefficient *= ConfigOptions.ProcChainCoefficientNerfToPercent.Value;
Log.NerfedProc(Main.NerfLoggingMessages.ProcChainCoefficientNerf);
}
damageInfo.damage *= ConfigOptions.ProcChainDamageNerfToPercent.Value;
Log.NerfedProc(Main.NerfLoggingMessages.ProcChainDamageNerf);
}
private static void NerfProcFromItem(DamageInfo damageInfo)
{
damageInfo.procCoefficient *= ConfigOptions.ProcFromItemCoefficientNerfToPercent.Value;
Log.NerfedProc(Main.NerfLoggingMessages.ProcFrontItemDamageNerf);
damageInfo.damage *= ConfigOptions.ProcFromItemDamageNerfToPercent.Value;
Log.NerfedProc(Main.NerfLoggingMessages.ProcFrontItemCoefficientNerf);
}
internal static int GetProcCountInChain(ProcChainMask procChainMask)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Invalid comparison between Unknown and I4
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
for (ProcType val = (ProcType)0; (int)val < 24; val = (ProcType)(val + 1))
{
if (((ProcChainMask)(ref procChainMask)).HasProc(val))
{
num++;
}
}
BitArray moddedMask = ProcTypeAPI.GetModdedMask(procChainMask);
for (int i = 2; i < moddedMask.Count; i++)
{
if (moddedMask.Get(i))
{
num++;
}
}
return num;
}
internal static void DebugLogDamageInfo(DamageInfo damageInfo, bool loggingBeforeChanges)
{
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object 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);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void NerfedProc(string message)
{
if (Main.AllowLoggingNerfs)
{
Info(message);
}
}
}
public static class Main
{
internal static class NerfLoggingMessages
{
internal static string ProcChainDamageNerf;
internal static string ProcChainCoefficientNerf;
internal static string ProcChainBlocked;
internal static string ProcFrontItemDamageNerf;
internal static string ProcFrontItemCoefficientNerf;
}
public static List<ArtifactBase> Artifacts = new List<ArtifactBase>();
internal static bool AllowLoggingNerfs = false;
public static void HealthComponent_TakeDamage_Artifactless(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
{
DamageRelated.DebugLogDamageInfo(damageInfo, loggingBeforeChanges: true);
DamageRelated.HealthComponent_TakeDamage(damageInfo);
orig.Invoke(self, damageInfo);
DamageRelated.DebugLogDamageInfo(damageInfo, loggingBeforeChanges: false);
}
[ConCommand(/*Could not decode attribute arguments.*/)]
internal static void CCToggleLoggingNerfs(ConCommandArgs args)
{
AllowLoggingNerfs = !AllowLoggingNerfs;
string text = ((!AllowLoggingNerfs) ? Language.GetString("ARTIFACT_UNCHAINED_SANITY_CHECK_DISABLED") : Language.GetString("ARTIFACT_UNCHAINED_SANITY_CHECK_ENABLED"));
Chat.AddMessage(text);
Log.Info(text);
}
internal static void SetupLanguageSpecificStrings()
{
NerfLoggingMessages.ProcChainDamageNerf = Language.GetStringFormatted("ARTIFACT_UNCHAINED_PROC_CHAIN_DAMAGE_NERF", Array.Empty<object>());
NerfLoggingMessages.ProcChainCoefficientNerf = Language.GetStringFormatted("ARTIFACT_UNCHAINED_PROC_CHAIN_COEFFICIENT_NERF", Array.Empty<object>());
NerfLoggingMessages.ProcChainBlocked = Language.GetStringFormatted("ARTIFACT_UNCHAINED_PROC_CHAIN_BLOCKED", Array.Empty<object>());
NerfLoggingMessages.ProcFrontItemCoefficientNerf = Language.GetStringFormatted("ARTIFACT_UNCHAINED_ITEM_PROC_DAMAGE_NERF", Array.Empty<object>());
NerfLoggingMessages.ProcFrontItemDamageNerf = Language.GetStringFormatted("ARTIFACT_UNCHAINED_ITEM_PROC_COEFFICIENT_NERF", Array.Empty<object>());
}
internal static bool IsAttackerBlacklisted(GameObject attackerGameObject)
{
if (Utility.IsNullOrWhiteSpace(ConfigOptions.ItemProcNerfBodyBlacklist.Value))
{
return false;
}
if (Utility.IsNullOrWhiteSpace(((Object)attackerGameObject).name))
{
return false;
}
string value = ((Object)attackerGameObject).name.Substring(0, ((Object)attackerGameObject).name.Length - 7);
if (ConfigOptions.ItemProcNerfBodyBlacklistArray.Contains(value))
{
return true;
}
return false;
}
}
internal static class ModSupport
{
public static class RiskOfOptions
{
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
ModSettingsManager.SetModIcon(Assets.AssetBundle.LoadAsset<Sprite>("RoOIcon.png"));
ModSettingsManager.SetModDescription("Adds an artifact that prevents your items from proccing your on-hit items for you.");
ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ConfigOptions.ItemProcNerfBodyBlacklist));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.ProcFromItemDamageNerfToPercent));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.ProcFromItemCoefficientNerfToPercent));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.ProcChainDamageNerfToPercent));
ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(ConfigOptions.ProcChainCoefficientNerfToPercent));
ModSettingsManager.AddOption((BaseOption)new IntFieldOption(ConfigOptions.ProcChainAmountLimit));
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ConfigOptions.PreventAllItemChaining));
}
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("LordVGames.ArtifactOfTheUnchained", "ArtifactOfTheUnchained", "2.3.1")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static hook_TakeDamage <0>__HealthComponent_TakeDamage_Artifactless;
}
public const string PluginGUID = "LordVGames.ArtifactOfTheUnchained";
public const string PluginAuthor = "LordVGames";
public const string PluginName = "ArtifactOfTheUnchained";
public const string PluginVersion = "2.3.1";
public static PluginInfo PluginInfo { get; private set; }
public void Awake()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
PluginInfo = ((BaseUnityPlugin)this).Info;
Log.Init(((BaseUnityPlugin)this).Logger);
Assets.Init();
Main.SetupLanguageSpecificStrings();
DamageRelated.ProccedByItem = ProcTypeAPI.ReserveProcType();
DamageRelated.ProccedByProc = ProcTypeAPI.ReserveProcType();
foreach (Type item in from type in Assembly.GetExecutingAssembly().GetTypes()
where !type.IsAbstract && type.IsSubclassOf(typeof(ArtifactBase))
select type)
{
ArtifactBase artifactBase = (ArtifactBase)Activator.CreateInstance(item);
ConfigOptions.BindConfigEntries(((BaseUnityPlugin)this).Config, artifactBase);
if (ConfigOptions.ArtifactlessMode.Value)
{
object obj = <>O.<0>__HealthComponent_TakeDamage_Artifactless;
if (obj == null)
{
hook_TakeDamage val = Main.HealthComponent_TakeDamage_Artifactless;
<>O.<0>__HealthComponent_TakeDamage_Artifactless = val;
obj = (object)val;
}
HealthComponent.TakeDamage += (hook_TakeDamage)obj;
}
else
{
artifactBase.Init(((BaseUnityPlugin)this).Config);
}
}
}
}
}