using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using DiskCardGame;
using DiskCardGame.CompositeRules;
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("L33pBotMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Placeholder description")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("L33pBotMod")]
[assembly: AssemblyTitle("L33pBotMod")]
[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 L33pB0tMod
{
[BepInPlugin("tvflabs.inscryption.L33pB0tMod", "L33pB0tMod", "1.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Opponent), "QueueNewCards")]
private class Opponent_QueueNewCards_Patch
{
private static IEnumerator Postfix(IEnumerator values, bool doTween, bool changeView, Opponent __instance)
{
if (constantSpamMode.Value)
{
bool didAnything = false;
while (values.MoveNext())
{
yield return values.Current;
}
if (didAnything || __instance.NumTurnsTaken >= __instance.TurnPlan.Count)
{
yield break;
}
int i;
for (i = 0; i < Singleton<BoardManager>.Instance.OpponentQueueSlots.Count; i++)
{
PlayableCard playableCard = __instance.Queue.Find((PlayableCard x) => x.QueuedSlot.Index == i);
if ((Object)(object)playableCard == (Object)null)
{
CardInfo cardToQueue = CardLoader.GetCardByName("LeapBot");
if (__instance is Part1Opponent)
{
cardToQueue = CardLoader.GetCardByName(((Object)Part1LeapBot).name);
}
yield return __instance.QueueCard(cardToQueue, Singleton<BoardManager>.Instance.OpponentSlotsCopy[i], doTween, changeView, true);
}
}
}
else
{
yield return values;
}
}
}
[HarmonyPatch(typeof(Opponent), "SpawnOpponent")]
private class Opponent_SpawnOpponent_Patch
{
private static void Postfix(Opponent __instance, EncounterData encounterData, Opponent __result)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Expected O, but got Unknown
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Expected O, but got Unknown
if (!constantSpamMode.Value && (Object)(object)__result != (Object)null)
{
CompositeRuleTriggerHandler val = ((Component)__result).gameObject.GetComponent<CompositeRuleTriggerHandler>();
if ((Object)(object)val == (Object)null)
{
val = ((Component)__result).gameObject.AddComponent<CompositeRuleTriggerHandler>();
}
CompositeBattleRule val2 = new CompositeBattleRule();
val2.trigger = (Trigger)0;
val2.effect = (Effect)new OpponentSpawnLeapBot();
val.AddRule(val2);
CompositeBattleRule val3 = new CompositeBattleRule();
val3.trigger = (Trigger)4;
val3.effect = (Effect)new OpponentSpawnLeapBot();
val.AddRule(val3);
CompositeBattleRule val4 = new CompositeBattleRule();
val4.trigger = (Trigger)11;
val4.effect = (Effect)new OpponentSpawnLeapBot();
val.AddRule(val4);
}
}
}
[HarmonyPatch(typeof(CompositeRuleTriggerHandler), "BreakInfiniteLoop")]
private class CompositeRuleTriggerHandler_BreakInfiniteLoop_Patch
{
private static IEnumerator Postfix(IEnumerator values, CompositeRuleTriggerHandler __instance)
{
if (!constantSpamMode.Value && (Object)(object)Singleton<TurnManager>.Instance.Opponent != (Object)null && !(Singleton<TurnManager>.Instance.Opponent is CanvasBossOpponent))
{
__instance.triggersThisTurn = 0;
__instance.rules.RemoveAt(__instance.rules.Count - 1);
__instance.triggeringDisabled = true;
CustomCoroutine.WaitOnConditionThenExecute((Func<bool>)(() => Singleton<GlobalTriggerHandler>.Instance.StackSize == 0), (Action)delegate
{
__instance.triggeringDisabled = false;
});
}
else
{
yield return values;
}
}
}
[HarmonyPatch(typeof(CompositeRuleTriggerHandler), "ExecuteRulesWithTrigger")]
private class CompositeRuleTriggerHandler_ExecuteRulesWithTrigger_Patch
{
private static IEnumerator Postfix(IEnumerator values, CompositeRuleTriggerHandler __instance, Trigger t, PlayableCard card = null)
{
//IL_0015: 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)
if (!constantSpamMode.Value && (Object)(object)Singleton<TurnManager>.Instance.Opponent != (Object)null && !(Singleton<TurnManager>.Instance.Opponent is CanvasBossOpponent))
{
for (int i = 0; i < __instance.rules.Count; i++)
{
if (__instance.triggeringDisabled)
{
continue;
}
CompositeBattleRule rule = __instance.rules[i];
if (rule.trigger == t && rule.effect.CanExecute())
{
__instance.triggersThisTurn++;
if (__instance.triggersThisTurn >= 30)
{
yield return __instance.BreakInfiniteLoop();
continue;
}
AudioController.Instance.PlaySound2D("oil_painting_activated", (MixerGroup)4, 1f, 0f, new Pitch((Variation)0), (Repetition)null, (Randomization)null, (Distortion)null, false);
yield return (object)new WaitForSeconds(0.5f);
yield return rule.effect.Execute(card);
yield return (object)new WaitForSeconds(0.4f);
Singleton<ViewManager>.Instance.SwitchToView((View)1, false, false);
}
}
}
else
{
yield return values;
}
}
}
[HarmonyPatch(typeof(OpponentSpawnLeapBot), "Execute")]
private class OpponentSpawnLeapBot_Execute_Patch
{
private static IEnumerator Postfix(IEnumerator values, OpponentSpawnLeapBot __instance, PlayableCard triggeringCard)
{
if (!constantSpamMode.Value && (Object)(object)Singleton<TurnManager>.Instance.Opponent != (Object)null && !(Singleton<TurnManager>.Instance.Opponent is CanvasBossOpponent) && Singleton<TurnManager>.Instance.Opponent is Part1Opponent)
{
List<CardSlot> validSlots = Singleton<BoardManager>.Instance.OpponentSlotsCopy.FindAll((CardSlot x) => (Object)(object)x.Card == (Object)null);
if (validSlots.Count > 0)
{
Singleton<ViewManager>.Instance.SwitchToView((View)4, false, false);
yield return (object)new WaitForSeconds(0.1f);
CardSlot slot = validSlots[Random.Range(0, validSlots.Count)];
yield return Singleton<BoardManager>.Instance.CreateCardInSlot(CardLoader.GetCardByName(((Object)Part1LeapBot).name), slot, 0.15f, true);
yield return (object)new WaitForSeconds(0.25f);
}
}
else
{
yield return values;
}
}
}
private Harmony harmony = new Harmony("tvflabs.inscryption.L33pB0tMod");
private const string PluginGuid = "tvflabs.inscryption.L33pB0tMod";
private const string PluginName = "L33pB0tMod";
private const string PluginVersion = "1.1.0";
private const string PluginPrefix = "L33pB0tMod";
private static ConfigEntry<bool> constantSpamMode;
private static CardInfo Part1LeapBot;
private static CardInfo LeapBotTail;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded L33pB0tMod!");
constantSpamMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ConstantSpamMode", false, "When enabled, the usual Unfinished Boss rules are replaced with a single, simpler rule: Every turn, play a L33pB0t in every empty queue space");
LeapBotTail = CardManager.New("L33pB0tMod", "Tail_Bot", "Scrap Metal", 0, 2, (string)null);
CardExtensions.SetBaseAttackAndHealth(LeapBotTail, (int?)0, (int?)2);
CardExtensions.SetCardComplexity(LeapBotTail, (CardComplexity)0);
CardExtensions.SetCardTemple(LeapBotTail, (CardTemple)0);
CardExtensions.SetDisplayedName(LeapBotTail, "Scrap Metal");
CardExtensions.SetPortrait(LeapBotTail, "ScrapMetal.png");
Part1LeapBot = CardManager.New("L33pB0tMod", "Part1LeapBot", "L33pB0t", 0, 2, (string)null);
CardExtensions.AddAbilities(Part1LeapBot, (Ability[])(object)new Ability[1] { (Ability)23 });
CardExtensions.SetBaseAttackAndHealth(Part1LeapBot, (int?)0, (int?)2);
CardExtensions.SetCardComplexity(Part1LeapBot, (CardComplexity)1);
CardExtensions.SetCardTemple(Part1LeapBot, (CardTemple)0);
CardExtensions.SetDisplayedName(Part1LeapBot, "L33pB0t");
CardExtensions.SetStrafeFlipsPortrait(Part1LeapBot, false);
CardExtensions.SetPortraitAndEmission(Part1LeapBot, "Part1LeapBot.png", "Part1LeapBot_e.png");
CardExtensions.SetPixelPortrait(Part1LeapBot, "Part1LeapBot_p.png");
CardExtensions.SetTail(Part1LeapBot, LeapBotTail, (IEnumerable<CardModificationInfo>)null);
harmony.PatchAll();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "L33pBotMod";
public const string PLUGIN_NAME = "L33pBotMod";
public const string PLUGIN_VERSION = "1.0.0";
}
}