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.Configuration;
using BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Ascension;
using InscryptionAPI.Card;
using InscryptionAPI.Helpers;
using Microsoft.CodeAnalysis;
using Sirenix.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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("NodeBane")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A BepInEx plugin made for Inscryption to limit a card from entering Campfire, Mycologists, Copy Card node twice.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NodeBane")]
[assembly: AssemblyTitle("NodeBane")]
[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 NodeBane
{
[BepInPlugin("orochiumbra.inscryption.nodebane", "NodeBane", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class NodeBane : BaseUnityPlugin
{
public static class DisableDecals
{
public static AscensionChallenge Id { get; private set; }
public static void Register()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
Id = ChallengeManager.Add("orochiumbra.inscryption.nodebane", StringExtensions.SplitPascalCase("DisableDecals"), "Remove Extra Decals for Cards affected by Node Bane.", 0, Asset.LoadTexture("NoDecal_Challenge"), Asset.LoadTexture("NoDecal_Active_Challenge"), 0, false).Challenge.challengeType;
}
}
public static class DisableNodeBane
{
public static AscensionChallenge Id { get; private set; }
public static void Register()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected I4, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected I4, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Expected I4, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
Id = ChallengeManager.Add("orochiumbra.inscryption.nodebane", StringExtensions.SplitPascalCase("DisableNodeBane"), "Remove restrictions on Campfire, Mycologists, Copy Card nodes.", -10, Asset.LoadTexture("NoBane_Challenge"), Asset.LoadTexture("NoBane_Active_Challenge"), 0, false).SetIncompatibleChallengeGetterStatic((AscensionChallenge[])(object)new AscensionChallenge[3]
{
(AscensionChallenge)(int)DisableDecals.Id,
(AscensionChallenge)(int)StrictMerge.Id,
(AscensionChallenge)(int)TrueBane.Id
}).Challenge.challengeType;
}
}
public static class StrictMerge
{
public static AscensionChallenge Id { get; private set; }
public static void Register()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected I4, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
Id = ChallengeManager.Add("orochiumbra.inscryption.nodebane", StringExtensions.SplitPascalCase("StrictMerge"), "Modified cards will not be allowed to be modified again after Mycologists nodes.", 10, Asset.LoadTexture("StrictMerge_Challenge"), Asset.LoadTexture("StrictMerge_Active_Challenge"), 0, false).SetIncompatibleChallengeGetterStatic((AscensionChallenge[])(object)new AscensionChallenge[1] { (AscensionChallenge)(int)TrueBane.Id }).Challenge.challengeType;
}
}
public static class TrueBane
{
public static AscensionChallenge Id { get; private set; }
public static void Register()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
Id = ChallengeManager.Add("orochiumbra.inscryption.nodebane", StringExtensions.SplitPascalCase("TrueBane"), "A card can only ever enter one of the Campfire, Mycologists, Copy Card nodes.", 20, Asset.LoadTexture("TrueBane_Challenge"), Asset.LoadTexture("TrueBane_Active_Challenge"), 0, false).Challenge.challengeType;
}
}
public class NodeBaneConfigManager
{
private static NodeBaneConfigManager nodebane_Instance;
private readonly ConfigFile NodeBaneConfigFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "orochiumbra.inscryption.nodebane.cfg"), true);
private ConfigEntry<bool> Config_ExtraDecals;
private ConfigEntry<bool> Config_ModEnabled;
private ConfigEntry<bool> Config_StrictMerge;
private ConfigEntry<bool> Config_TrueBane;
public static NodeBaneConfigManager Instance => nodebane_Instance ?? (nodebane_Instance = new NodeBaneConfigManager());
public bool ExtraDecals => Config_ExtraDecals.Value;
public bool ModEnabled => Config_ModEnabled.Value;
public bool StrictMyco => Config_StrictMerge.Value;
public bool TrueBane => Config_TrueBane.Value;
internal void BindConfig()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Expected O, but got Unknown
Config_ExtraDecals = NodeBaneConfigFile.Bind<bool>("Config", "Decals", true, new ConfigDescription("PART 1 ONLY - Enable Extra Decals for Cards affected by Node Bane.", (AcceptableValueBase)null, Array.Empty<object>()));
Config_ModEnabled = NodeBaneConfigFile.Bind<bool>("Config", "Active", true, new ConfigDescription("PART 1 ONLY - Enables Node Bane.", (AcceptableValueBase)null, Array.Empty<object>()));
Config_StrictMerge = NodeBaneConfigFile.Bind<bool>("Config", "Strict", false, new ConfigDescription("PART 1 ONLY - Modified cards will not be allowed to be modified again after Mycologists nodes.", (AcceptableValueBase)null, Array.Empty<object>()));
Config_TrueBane = NodeBaneConfigFile.Bind<bool>("Config", "Hard", false, new ConfigDescription("PART 1 ONLY - A card can only ever enter one of the Campfire, Mycologists, Copy Card nodes.", (AcceptableValueBase)null, Array.Empty<object>()));
}
}
private const string PluginGuid = "orochiumbra.inscryption.nodebane";
private const string PluginName = "NodeBane";
private const string PluginVersion = "1.0.0";
internal static ManualLogSource Log;
private Harmony harmony = new Harmony("orochiumbra.inscryption.nodebane");
public const string FlameModId = "NodeBane_Flame";
public const string MergeModId = "NodeBane_Merge";
public const string PaintModId = "NodeBane_Paint";
public static bool Decals => SaveFile.IsAscension ? (!AscensionSaveData.Data.ChallengeIsActive(DisableDecals.Id)) : NodeBaneConfigManager.Instance.ExtraDecals;
public static bool Active => SaveFile.IsAscension ? (!AscensionSaveData.Data.ChallengeIsActive(DisableNodeBane.Id)) : NodeBaneConfigManager.Instance.ModEnabled;
public static bool Strict => SaveFile.IsAscension ? AscensionSaveData.Data.ChallengeIsActive(StrictMerge.Id) : NodeBaneConfigManager.Instance.StrictMyco;
public static bool Hard => SaveFile.IsAscension ? AscensionSaveData.Data.ChallengeIsActive(TrueBane.Id) : NodeBaneConfigManager.Instance.TrueBane;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
harmony.PatchAll(typeof(NodeBane));
NodeBaneConfigManager.Instance.BindConfig();
DisableDecals.Register();
TrueBane.Register();
StrictMerge.Register();
DisableNodeBane.Register();
}
[HarmonyPatch(typeof(CardStatBoostSequencer), "ApplyModToCard")]
[HarmonyPrefix]
public static bool MarkFlameCardsPatch(CardInfo card)
{
//IL_0013: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
if (!Active)
{
Singleton<ChallengeActivationUI>.Instance.ShowActivation(DisableNodeBane.Id);
return true;
}
if (CardExtensions.LacksTrait(card, (Trait)19))
{
CardModificationInfo val = new CardModificationInfo
{
singletonId = "NodeBane_Flame"
};
if (Decals && !card.Mods.Exists((CardModificationInfo x) => x.DecalIds.Exists((string y) => y.Contains("decal_smoke_abilityhole"))))
{
val.DecalIds.Add("decal_smoke_abilityhole");
}
if (!card.HasFlameMod())
{
card.Mods.Add(val);
if (Hard)
{
Singleton<ChallengeActivationUI>.Instance.ShowActivation(TrueBane.Id);
}
}
}
return true;
}
[HarmonyPatch(typeof(CardStatBoostSequencer), "GetValidCards")]
[HarmonyPostfix]
public static List<CardInfo> GetFlameCardsPatch(List<CardInfo> __result)
{
if (Active)
{
__result.RemoveAll((CardInfo x) => x.HasFlameMod());
}
return __result;
}
[HarmonyPatch(typeof(DuplicateMergeSequencer), "MergeCards")]
[HarmonyPostfix]
public static void MarkMergeCardsPatch(CardInfo card1, CardInfo card2, ref CardInfo __result)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
if (!Active)
{
Singleton<ChallengeActivationUI>.Instance.ShowActivation(DisableNodeBane.Id);
return;
}
if (Strict)
{
Singleton<ChallengeActivationUI>.Instance.ShowActivation(StrictMerge.Id);
__result.Mods.AddRange((from mod in card2.Mods
where mod.singletonId != null && mod.singletonId.StartsWith("NodeBane_")
where !card1.Mods.Any((CardModificationInfo card1Mod) => card1Mod.singletonId == mod.singletonId)
select mod).ToList());
}
if (!__result.HasMergeMod())
{
__result.Mods.Add(new CardModificationInfo
{
singletonId = "NodeBane_Merge"
});
if (Hard)
{
Singleton<ChallengeActivationUI>.Instance.ShowActivation(TrueBane.Id);
}
}
}
[HarmonyPatch(typeof(DuplicateMergeSequencer), "GetValidDuplicateCards")]
[HarmonyPostfix]
public static void GetMergeCardsPatch(ref List<CardInfo> __result)
{
if (!Active)
{
return;
}
List<CardInfo> list = RunState.DeckList.FindAll((CardInfo x) => !x.HasMergeMod());
List<CardInfo> list2 = new List<CardInfo>();
foreach (CardInfo card in list)
{
if (list.Count((CardInfo x) => ((Object)x).name == ((Object)card).name) > 1)
{
list2.Add(card);
}
}
__result = list2;
}
[HarmonyPatch(typeof(CopyCardSequencer), "CreateCloneCard")]
[HarmonyPostfix]
public static void MarkPaintCardsPatch(ref CardInfo __result, CardInfo cardToCopy)
{
//IL_0023: 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_0034: Expected O, but got Unknown
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
if (!Active)
{
Singleton<ChallengeActivationUI>.Instance.ShowActivation(DisableNodeBane.Id);
return;
}
CardModificationInfo val = new CardModificationInfo
{
singletonId = "NodeBane_Paint"
};
if (!__result.HasPaintMod())
{
__result.Mods.Add(val);
if (Hard)
{
Singleton<ChallengeActivationUI>.Instance.ShowActivation(TrueBane.Id);
}
}
if (Decals && !cardToCopy.Mods.Exists((CardModificationInfo x) => x.DecalIds.Exists((string y) => y.StartsWith("decal_blood_"))))
{
val.DecalIds.Add(AlternatingBloodDecal.GetBloodDecalId());
}
if (!cardToCopy.HasPaintMod())
{
cardToCopy.Mods.Add(val);
}
}
[HarmonyPatch(typeof(CopyCardSequencer), "GetValidCards")]
[HarmonyPostfix]
public static List<CardInfo> GetPaintCardsPatch(List<CardInfo> __result)
{
if (Active)
{
__result.RemoveAll((CardInfo x) => x.HasPaintMod());
}
return __result;
}
}
internal class Asset
{
private static Assembly _assembly;
public static Assembly CurrentAssembly => _assembly ?? (_assembly = Assembly.GetExecutingAssembly());
public static Texture2D LoadTexture(string name)
{
return TextureHelper.GetImageAsTexture((name + (name.EndsWith(".png") ? "" : ".png")).ToLowerInvariant(), CurrentAssembly, (FilterMode)0);
}
public static Sprite LoadSprite(string name)
{
return TextureHelper.ConvertTexture(TextureHelper.GetImageAsTexture((name + (name.EndsWith(".png") ? "" : ".png")).ToLowerInvariant(), CurrentAssembly, (FilterMode)0), (Vector2?)null);
}
}
public static class NodeBaneSingletonManager
{
public static bool HasFlameMod(this CardInfo card)
{
return ((card == null) ? null : card.Mods?.Any((CardModificationInfo mod) => (!NodeBane.Hard) ? (mod?.singletonId == "NodeBane_Flame") : (mod != null && mod.singletonId?.StartsWith("NodeBane_") == true))).GetValueOrDefault();
}
public static bool HasMergeMod(this CardInfo card)
{
return ((card == null) ? null : card.Mods?.Any((CardModificationInfo mod) => (!NodeBane.Hard) ? (mod?.singletonId == "NodeBane_Merge") : (mod != null && mod.singletonId?.StartsWith("NodeBane_") == true))).GetValueOrDefault();
}
public static bool HasPaintMod(this CardInfo card)
{
return ((card == null) ? null : card.Mods?.Any((CardModificationInfo mod) => (!NodeBane.Hard) ? (mod?.singletonId == "NodeBane_Paint") : (mod != null && mod.singletonId?.StartsWith("NodeBane_") == true))).GetValueOrDefault();
}
public static string UpdateSingletonId(CardInfo card, string modToAdd)
{
string text = card.Mods.Find((CardModificationInfo x) => x.singletonId.StartsWith("NodeBane"))?.singletonId ?? "NodeBane";
if (!text.Contains(modToAdd))
{
text = text + "_" + modToAdd;
}
return text;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "NodeBane";
public const string PLUGIN_NAME = "NodeBane";
public const string PLUGIN_VERSION = "1.0.0";
}
}