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.Configuration;
using BepInEx.Logging;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BossVariety")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f7ccefffcb445aa1d34c6176b84c9419790e738a")]
[assembly: AssemblyProduct("BossVariety")]
[assembly: AssemblyTitle("BossVariety")]
[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 BossVariety
{
[BepInPlugin("OakPrime.BossVariety", "BossVariety", "1.0.2")]
public class RespawnForBoss : BaseUnityPlugin
{
public const string PluginGUID = "OakPrime.BossVariety";
public const string PluginAuthor = "OakPrime";
public const string PluginName = "BossVariety";
public const string PluginVersion = "1.0.2";
public static ManualLogSource logger;
private Queue<GameObject> _prevBosses = new Queue<GameObject>();
private int MAX_QUEUE_COUNT = 2;
public void Awake()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
try
{
logger = ((BaseUnityPlugin)this).Logger;
Log.Init(logger);
ConfigFile val = new ConfigFile(Paths.ConfigPath + "\\OakPrime.BossVariety.cfg", true);
ConfigEntry<int> val2 = val.Bind<int>("Main", "Boss Ban Pool Size", 2, "Amount of previous bosses that will be excluded from current stage's boss pool. 1 = No repeats across 2 stages, 2 = No repeats across 3 stages, etc. At values above 2, you risk banning the stage's entire boss pool, in which case the mod will allow repeats that stage");
val2.Value = Math.Clamp(val2.Value, 0, 5);
MAX_QUEUE_COUNT = val2.Value;
CombatDirector.SetNextSpawnAsBoss += (Manipulator)delegate(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
ILCursor val3 = new ILCursor(il);
ILLabel val6 = default(ILLabel);
int num5 = default(int);
int num4 = default(int);
if (!val3.TryGotoNext(new Func<Instruction, bool>[4]
{
(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0),
(Instruction x) => ILPatternMatchingExt.MatchBle(x, ref val6),
(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num5),
(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num4)
}))
{
Log.LogInstrNotFound(il);
}
else
{
val3.Index += 3;
val3.EmitDelegate<Func<WeightedSelection<DirectorCard>, WeightedSelection<DirectorCard>>>((Func<WeightedSelection<DirectorCard>, WeightedSelection<DirectorCard>>)delegate(WeightedSelection<DirectorCard> weightedSelection)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
if (_prevBosses.Count <= 0)
{
return weightedSelection;
}
List<int> list = new List<int>();
bool flag = false;
foreach (GameObject prevBoss in _prevBosses)
{
Log.LogDebug("Repeat boss is banned this stage: " + ((Object)prevBoss).name);
}
for (int i = 0; i < weightedSelection.Count; i++)
{
ChoiceInfo<DirectorCard> choice = weightedSelection.GetChoice(i);
if (_prevBosses.Contains(choice.value.spawnCard.prefab))
{
list.Add(i);
}
else
{
flag = true;
}
}
if (flag)
{
for (int num2 = list.Count - 1; num2 >= 0; num2--)
{
int num3 = list[num2];
Log.LogDebug("Stopping repeat boss from spawning: " + ((Object)weightedSelection.GetChoice(num3).value.spawnCard.prefab).name);
weightedSelection.RemoveChoice(num3);
}
}
else
{
Log.LogDebug("Only repeat bosses are available this stage.");
}
return weightedSelection;
});
MethodReference val5 = default(MethodReference);
MethodReference val4 = default(MethodReference);
int num = default(int);
if (!val3.TryGotoNext(new Func<Instruction, bool>[3]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val5),
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val4),
(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num)
}))
{
Log.LogInstrNotFound(il);
}
else
{
val3.Index += 2;
val3.EmitDelegate<Func<DirectorCard, DirectorCard>>((Func<DirectorCard, DirectorCard>)delegate(DirectorCard directorCard)
{
Log.LogDebug("Adding boss to ban pool: " + ((Object)directorCard.spawnCard.prefab).name);
_prevBosses.Enqueue(directorCard.spawnCard.prefab);
while (_prevBosses.Count > MAX_QUEUE_COUNT)
{
Log.LogDebug("Removing boss from ban pool: " + ((Object)_prevBosses.Dequeue()).name);
}
return directorCard;
});
}
}
};
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)(ex.Message + " - " + ex.StackTrace));
}
}
}
internal static class Log
{
internal static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void LogDebug(object data)
{
_logSource.LogDebug(data);
}
internal static void LogError(object data)
{
_logSource.LogError(data);
}
internal static void LogFatal(object data)
{
_logSource.LogFatal(data);
}
internal static void LogInfo(object data)
{
_logSource.LogInfo(data);
}
internal static void LogMessage(object data)
{
_logSource.LogMessage(data);
}
internal static void LogWarning(object data)
{
_logSource.LogWarning(data);
}
internal static void LogInstrNotFound(ILContext il)
{
LogError("GoToNext instructions not found at method: " + (object)il.Method);
}
}
}