using System;
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.Bootstrap;
using IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RiskyMod.Tweaks.RunScaling;
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.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("NoBossRepeat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoBossRepeat")]
[assembly: AssemblyTitle("NoBossRepeat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace NoBossRepeat
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.Moffein.NoBossRepeat", "NoBossRepeat", "1.0.0")]
public class NoBossRepeat : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Func<Instruction, bool> <>9__2_3;
public static Func<bool, ChoiceInfo<DirectorCard>, bool> <>9__2_1;
public static Func<Instruction, bool> <>9__2_4;
public static Func<DirectorCard, DirectorCard> <>9__2_2;
public static Manipulator <>9__2_0;
internal void <Awake>b__2_0(ILContext il)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
bool flag2 = true;
ILCursor val = new ILCursor(il);
if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallvirt<DirectorCard>(x, "IsAvailable")
}))
{
val.Emit(OpCodes.Ldloc_3);
val.EmitDelegate<Func<bool, ChoiceInfo<DirectorCard>, bool>>((Func<bool, ChoiceInfo<DirectorCard>, bool>)((bool flag, ChoiceInfo<DirectorCard> choice) => (!flag || choice.value == null || !((Object)(object)choice.value.spawnCard != (Object)null) || !previousCards.Contains(choice.value.spawnCard.prefab)) && flag));
if (val.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCall<CombatDirector>(x, "PrepareNewMonsterWave")
}))
{
val.EmitDelegate<Func<DirectorCard, DirectorCard>>((Func<DirectorCard, DirectorCard>)delegate(DirectorCard card)
{
if (card != null && (Object)(object)card.spawnCard != (Object)null)
{
if (previousCards.Count > 0 && previousCards.Count + 1 > maxStages)
{
previousCards.RemoveAt(0);
}
previousCards.Add(card.spawnCard.prefab);
}
return card;
});
flag2 = false;
}
}
if (flag2)
{
Debug.LogError((object)"NoBossRepeat: IL Hook failed");
}
}
internal bool <Awake>b__2_3(Instruction x)
{
return ILPatternMatchingExt.MatchCallvirt<DirectorCard>(x, "IsAvailable");
}
internal bool <Awake>b__2_1(bool flag, ChoiceInfo<DirectorCard> choice)
{
//IL_0007: 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)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (flag && choice.value != null && (Object)(object)choice.value.spawnCard != (Object)null && previousCards.Contains(choice.value.spawnCard.prefab))
{
return false;
}
return flag;
}
internal bool <Awake>b__2_4(Instruction x)
{
return ILPatternMatchingExt.MatchCall<CombatDirector>(x, "PrepareNewMonsterWave");
}
internal DirectorCard <Awake>b__2_2(DirectorCard card)
{
if (card != null && (Object)(object)card.spawnCard != (Object)null)
{
if (previousCards.Count > 0 && previousCards.Count + 1 > maxStages)
{
previousCards.RemoveAt(0);
}
previousCards.Add(card.spawnCard.prefab);
}
return card;
}
}
public static int maxStages = 2;
public static List<GameObject> previousCards = new List<GameObject>();
public void Awake()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
bool flag2 = true;
if (Chainloader.PluginInfos.ContainsKey("com.RiskyLives.RiskyMod"))
{
flag2 = !RiskyModAppliedFix();
}
if (!flag2)
{
Debug.LogError((object)"NoBossRepeat: RiskyMod already applied this change. Code will not be run.");
return;
}
Run.onRunStartGlobal += Run_onRunStartGlobal;
object obj = <>c.<>9__2_0;
if (obj == null)
{
Manipulator val = delegate(ILContext il)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
bool flag3 = true;
ILCursor val2 = new ILCursor(il);
if (val2.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCallvirt<DirectorCard>(x, "IsAvailable")
}))
{
val2.Emit(OpCodes.Ldloc_3);
val2.EmitDelegate<Func<bool, ChoiceInfo<DirectorCard>, bool>>((Func<bool, ChoiceInfo<DirectorCard>, bool>)((bool flag, ChoiceInfo<DirectorCard> choice) => (!flag || choice.value == null || !((Object)(object)choice.value.spawnCard != (Object)null) || !previousCards.Contains(choice.value.spawnCard.prefab)) && flag));
if (val2.TryGotoNext(new Func<Instruction, bool>[1]
{
(Instruction x) => ILPatternMatchingExt.MatchCall<CombatDirector>(x, "PrepareNewMonsterWave")
}))
{
val2.EmitDelegate<Func<DirectorCard, DirectorCard>>((Func<DirectorCard, DirectorCard>)delegate(DirectorCard card)
{
if (card != null && (Object)(object)card.spawnCard != (Object)null)
{
if (previousCards.Count > 0 && previousCards.Count + 1 > maxStages)
{
previousCards.RemoveAt(0);
}
previousCards.Add(card.spawnCard.prefab);
}
return card;
});
flag3 = false;
}
}
if (flag3)
{
Debug.LogError((object)"NoBossRepeat: IL Hook failed");
}
};
<>c.<>9__2_0 = val;
obj = (object)val;
}
CombatDirector.SetNextSpawnAsBoss += (Manipulator)obj;
}
private void Run_onRunStartGlobal(Run obj)
{
previousCards.Clear();
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
private bool RiskyModAppliedFix()
{
return NoBossRepeat.enabled;
}
}
}
namespace R2API.Utils
{
[AttributeUsage(AttributeTargets.Assembly)]
public class ManualNetworkRegistrationAttribute : Attribute
{
}
}