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.Configuration;
using BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
using Microsoft.CodeAnalysis;
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("UnkillableRework")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("This plugin is a BepInEx plugin made for Inscryption to Rework Unkillable sigil in Kaycee's Mod.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UnkillableRework")]
[assembly: AssemblyTitle("UnkillableRework")]
[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 UnkillableRework
{
[BepInPlugin("orochiumbra.inscryption.unkillablerework", "UnkillableRework", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class UnkillableRework : BaseUnityPlugin
{
[HarmonyPatch(typeof(DrawCopyOnDeath), "OnDie")]
internal static class UnkillableOnDiePatch
{
[CompilerGenerated]
private sealed class <OpponentUnkillable>d__3 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayableCard deadCard;
private int <drawCopyOnDeathCount>5__1;
private int <i>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <OpponentUnkillable>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = SwitchIfNotView((View)4);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<drawCopyOnDeathCount>5__1 = deadCard.TriggerHandler.triggeredAbilities.Where((Tuple<Ability, AbilityBehaviour> ability) => ability.Item2 is DrawCopyOnDeath).Select(delegate(Tuple<Ability, AbilityBehaviour> ability)
{
AbilityBehaviour item = ability.Item2;
return (DrawCopyOnDeath)(object)((item is DrawCopyOnDeath) ? item : null);
}).Count();
<i>5__2 = 0;
goto IL_0104;
case 2:
<>1__state = -1;
<i>5__2++;
goto IL_0104;
case 3:
<>1__state = -1;
<>2__current = SwitchIfNotView((View)4);
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 5;
return true;
case 5:
{
<>1__state = -1;
return false;
}
IL_0104:
if (<i>5__2 < <drawCopyOnDeathCount>5__1)
{
<>2__current = QueueOpponentCard(deadCard);
<>1__state = 2;
return true;
}
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 3;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <PlayerUnkillable>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayableCard deadCard;
private CardInfo <changedInfo>5__1;
private float <newCardYPosition>5__2;
private GameObject <obj>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PlayerUnkillable>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<changedInfo>5__1 = null;
<obj>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Expected O, but got Unknown
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Expected O, but got Unknown
ref CardInfo reference;
object obj;
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (Singleton<BoardManager>.Instance is BoardManager3D)
{
<newCardYPosition>5__2 = CardDrawPiles3D.Instance.Pile.cardYSpacing * (float)CardDrawPiles3D.Instance.Pile.cards.Count;
<obj>5__3 = CardDrawPiles3D.Instance.Pile.CreateCard();
<obj>5__3.transform.localPosition = new Vector3(0f, <newCardYPosition>5__2, 0f);
<obj>5__3.transform.localEulerAngles = CardDrawPiles3D.Instance.Pile.GetRandomCardEulers(15f);
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
}
goto IL_0107;
case 1:
<>1__state = -1;
Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
<obj>5__3 = null;
goto IL_0107;
case 2:
{
<>1__state = -1;
return false;
}
IL_0107:
reference = ref <changedInfo>5__1;
obj = ((Card)deadCard).Info.Clone();
reference = (CardInfo)((obj is CardInfo) ? obj : null);
<changedInfo>5__1.Mods = new List<CardModificationInfo>(((Card)deadCard).Info.Mods);
Singleton<CardDrawPiles>.Instance.Deck.AddCard(<changedInfo>5__1);
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <QueueOpponentCard>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayableCard card;
private List<CardSlot> <openSlots>5__1;
private List<List<CardInfo>> <turnPlan>5__2;
private List<CardInfo> <addInfo>5__3;
private int <randomSeed>5__4;
private CardSlot <index>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <QueueOpponentCard>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<openSlots>5__1 = null;
<turnPlan>5__2 = null;
<addInfo>5__3 = null;
<index>5__5 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<openSlots>5__1 = Singleton<BoardManager>.Instance.OpponentSlotsCopy.Where((CardSlot slot) => !Singleton<TurnManager>.Instance.Opponent.QueuedSlots.Contains(slot)).ToList();
if (<openSlots>5__1.Count == 0)
{
<turnPlan>5__2 = Singleton<TurnManager>.Instance.Opponent.TurnPlan;
<addInfo>5__3 = new List<CardInfo> { ((Card)card).Info };
<turnPlan>5__2.Add(<addInfo>5__3);
<>2__current = Singleton<TurnManager>.Instance.Opponent.ModifyTurnPlan(<turnPlan>5__2);
<>1__state = 1;
return true;
}
<randomSeed>5__4 = SaveManager.SaveFile.GetCurrentRandomSeed();
<index>5__5 = <openSlots>5__1[SeededRandom.Range(0, <openSlots>5__1.Count, <randomSeed>5__4 + <openSlots>5__1.Count)];
<>2__current = Singleton<TurnManager>.Instance.Opponent.QueueCard(((Card)card).Info, <index>5__5, true, true, true);
<>1__state = 2;
return true;
case 1:
<>1__state = -1;
<turnPlan>5__2 = null;
<addInfo>5__3 = null;
break;
case 2:
<>1__state = -1;
<index>5__5 = null;
break;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <SwitchIfNotView>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public View view;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SwitchIfNotView>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if (Singleton<ViewManager>.Instance.CurrentView == view)
{
return false;
}
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
Singleton<ViewManager>.Instance.SwitchToView(view, false, false);
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[HarmonyPrefix]
private static bool OnDiePatch(ref IEnumerator __result, AbilityBehaviour __instance)
{
if (Active)
{
__result = ((__instance.Card.OpponentCard && UnkillableReworkConfigManager.Instance.QueueEnabled) ? OpponentUnkillable(__instance.Card) : PlayerUnkillable(__instance.Card));
return false;
}
return true;
}
[IteratorStateMachine(typeof(<PlayerUnkillable>d__1))]
private static IEnumerator PlayerUnkillable(PlayableCard deadCard)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PlayerUnkillable>d__1(0)
{
deadCard = deadCard
};
}
[IteratorStateMachine(typeof(<SwitchIfNotView>d__2))]
private static IEnumerator SwitchIfNotView(View view)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SwitchIfNotView>d__2(0)
{
view = view
};
}
[IteratorStateMachine(typeof(<OpponentUnkillable>d__3))]
private static IEnumerator OpponentUnkillable(PlayableCard deadCard)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <OpponentUnkillable>d__3(0)
{
deadCard = deadCard
};
}
[IteratorStateMachine(typeof(<QueueOpponentCard>d__4))]
private static IEnumerator QueueOpponentCard(PlayableCard card)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <QueueOpponentCard>d__4(0)
{
card = card
};
}
}
[HarmonyPatch(typeof(GlobalTriggerHandler), "TriggerCardsOnBoard")]
internal static class UnkillablePreDeathPatch
{
[CompilerGenerated]
private sealed class <PlayerUnkillableAnim>d__1 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PlayableCard deadCard;
private float <newCardYPosition>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PlayerUnkillableAnim>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Invalid comparison between Unknown and I4
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
((Card)deadCard).Anim.SetFaceDown(true, false);
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (Singleton<BoardManager>.Instance is BoardManager3D)
{
<newCardYPosition>5__1 = CardDrawPiles3D.Instance.Pile.cardYSpacing * (float)CardDrawPiles3D.Instance.Pile.cards.Count;
Singleton<CardDrawPiles3D>.Instance.Pile.MoveCardToPile((Card)(object)deadCard, false, 0f, <newCardYPosition>5__1);
if ((int)Singleton<ViewManager>.Instance.CurrentView != 5)
{
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 2;
return true;
}
}
break;
case 2:
<>1__state = -1;
Singleton<ViewManager>.Instance.SwitchToView((View)5, false, false);
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
break;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <PreDeath>d__0 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator enumerator;
public Trigger trigger;
public object[] otherArgs;
private object[] <x>5__1;
private CardSlot <deathSlot>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PreDeath>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<x>5__1 = null;
<deathSlot>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Invalid comparison between Unknown and I4
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = enumerator;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (!Active)
{
return false;
}
if ((int)trigger != 17)
{
return false;
}
if (otherArgs != null)
{
<x>5__1 = otherArgs;
if (<x>5__1.Length >= 1)
{
object obj = <x>5__1[0];
<deathSlot>5__2 = (CardSlot)((obj is CardSlot) ? obj : null);
if (<deathSlot>5__2 != null && (Object)(object)<deathSlot>5__2.Card != (Object)null && <deathSlot>5__2.Card.HasAbility((Ability)14))
{
<>2__current = ((<deathSlot>5__2.Card.OpponentCard && UnkillableReworkConfigManager.Instance.QueueEnabled) ? enumerator : PlayerUnkillableAnim(<deathSlot>5__2.Card));
<>1__state = 2;
return true;
}
}
}
return false;
case 2:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[IteratorStateMachine(typeof(<PreDeath>d__0))]
[HarmonyPostfix]
private static IEnumerator PreDeath(IEnumerator enumerator, Trigger trigger, object[] otherArgs)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PreDeath>d__0(0)
{
enumerator = enumerator,
trigger = trigger,
otherArgs = otherArgs
};
}
[IteratorStateMachine(typeof(<PlayerUnkillableAnim>d__1))]
private static IEnumerator PlayerUnkillableAnim(PlayableCard deadCard)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PlayerUnkillableAnim>d__1(0)
{
deadCard = deadCard
};
}
}
public class UnkillableReworkConfigManager
{
private static UnkillableReworkConfigManager unkillablerework_Instance;
private readonly ConfigFile UnkillableReworkConfigFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "orochiumbra.inscryption.unkillablerework.cfg"), true);
private ConfigEntry<bool> Config_ModEnabled;
private ConfigEntry<bool> Config_AscensionEnabled;
private ConfigEntry<bool> Config_QueueEnabled;
public static UnkillableReworkConfigManager Instance => unkillablerework_Instance ?? (unkillablerework_Instance = new UnkillableReworkConfigManager());
public bool ModEnabled => Config_ModEnabled.Value;
public bool AscensionEnabled => Config_AscensionEnabled.Value;
public bool QueueEnabled => Config_QueueEnabled.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
Config_ModEnabled = UnkillableReworkConfigFile.Bind<bool>("Config", "Enable", false, new ConfigDescription("Enables Unkillable Rework for Part 1.", (AcceptableValueBase)null, Array.Empty<object>()));
Config_AscensionEnabled = UnkillableReworkConfigFile.Bind<bool>("Config", "Ascension Enable", true, new ConfigDescription("Enables Unkillable Rework in Kaycee's Mod.", (AcceptableValueBase)null, Array.Empty<object>()));
Config_QueueEnabled = UnkillableReworkConfigFile.Bind<bool>("Config", "Queue", false, new ConfigDescription("Enables Unkillable Rework for Leshy Queue.", (AcceptableValueBase)null, Array.Empty<object>()));
}
}
[HarmonyPatch(typeof(RuleBookController))]
public static class DrawCopyOnDeathReworkRuleBookPage
{
[HarmonyPrefix]
[HarmonyPatch("SetShown")]
public static bool ResetAlteredDescriptions()
{
AbilityInfo info = AbilitiesUtil.GetInfo((Ability)14);
if (Active)
{
info.rulebookDescription = "When [creature] perishes, a copy of it is shuffled into your deck.";
}
else
{
info.rulebookDescription = AbilityManager.AllAbilities.Find((FullAbility x) => (int)x.Id == 14).BaseRulebookDescription;
}
return true;
}
}
private readonly Harmony harmony = new Harmony("orochiumbra.inscryption.unkillablerework");
private const string PluginGuid = "orochiumbra.inscryption.unkillablerework";
private const string PluginName = "UnkillableRework";
private const string PluginVersion = "1.0.0";
public static ManualLogSource Log;
public static bool Active => SaveFile.IsAscension ? UnkillableReworkConfigManager.Instance.AscensionEnabled : UnkillableReworkConfigManager.Instance.ModEnabled;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
UnkillableReworkConfigManager.Instance.BindConfig();
harmony.PatchAll(Assembly.GetExecutingAssembly());
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "UnkillableRework";
public const string PLUGIN_NAME = "UnkillableRework";
public const string PLUGIN_VERSION = "1.0.0";
}
}