using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using OpenShot.Events; using OpenShot.UI; using Shooterlatro.Gameplay; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("RandomBossRushMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Chains boss rounds back-to-back with randomized per-round modifiers (target size, spawn density, round duration).")] [assembly: AssemblyFileVersion("1.2.1.0")] [assembly: AssemblyInformationalVersion("1.2.1+4135dd1490a61fe647f2a0e54287f36471f5cf7f")] [assembly: AssemblyProduct("RandomBossRushMod")] [assembly: AssemblyTitle("RandomBossRushMod")] [assembly: AssemblyVersion("1.2.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 RandomBossRushMod { [HarmonyPatch] public static class RoundSelectManager_HandleSelection_Patch { private static MethodBase TargetMethod() { return AccessTools.Method(AccessTools.TypeByName("RoundSelectManager"), "HandleSelection", (Type[])null, (Type[])null); } private static void Postfix(object __instance) { if (__instance != null && RandomBossRushPlugin.Enabled.Value && RandomBossRushPlugin.ForceBossRounds.Value) { Type type = AccessTools.TypeByName("RoundContext"); object value = Enum.ToObject(AccessTools.TypeByName("RoundType"), 2); AccessTools.Field(type, "SelectedType").SetValue(null, value); object value2 = Traverse.Create(__instance).Field("_scenario").GetValue(); string text = ((value2 != null) ? Traverse.Create(value2).Field("BossKey").GetValue() : null); AccessTools.Field(type, "SelectedBossKey").SetValue(null, text); RandomBossRushPlugin.Log.LogInfo((object)("[RandomBossRush] Forced boss round, key=" + (text ?? "(none resolved)"))); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.liamgaming.randombossrushmod", "Random Boss Rush Mod", "1.2.1")] public class RandomBossRushPlugin : BaseUnityPlugin { public const string PluginGuid = "com.liamgaming.randombossrushmod"; public const string PluginName = "Random Boss Rush Mod"; public const string PluginVersion = "1.2.1"; private static readonly Random Rng = new Random(); public static ManualLogSource Log { get; private set; } public static ConfigEntry Enabled { get; private set; } public static ConfigEntry ForceBossRounds { get; private set; } public static ConfigEntry RandomizeScale { get; private set; } public static ConfigEntry RandomizeTargetCount { get; private set; } public static ConfigEntry RandomizeDuration { get; private set; } public static ConfigEntry MinTargetScale { get; private set; } public static ConfigEntry MaxTargetScale { get; private set; } public static ConfigEntry MaxActiveTargetsVariance { get; private set; } public static ConfigEntry RoundDurationVariance { get; private set; } public static ConfigEntry SmallBias { get; private set; } private void Awake() { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Expected O, but got Unknown //IL_02ef: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Master toggle for boss chaining + random modifiers."); ForceBossRounds = ((BaseUnityPlugin)this).Config.Bind("General", "ForceBossRounds", true, "Force every round selection into a boss round."); RandomizeScale = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "RandomizeScale", true, "Randomize target scale on spawn."); RandomizeTargetCount = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "RandomizeTargetCount", true, "Randomize max active targets each round."); RandomizeDuration = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "RandomizeDuration", true, "Randomize round duration each round."); MinTargetScale = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "MinTargetScale", 0.55f, new ConfigDescription("Smallest random target scale.", (AcceptableValueBase)(object)new AcceptableValueRange(0.2f, 1f), Array.Empty())); MaxTargetScale = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "MaxTargetScale", 1.3f, new ConfigDescription("Largest random target scale.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 2.5f), Array.Empty())); MaxActiveTargetsVariance = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "MaxActiveTargetsVariance", 3, new ConfigDescription("Random +/- max active targets.", (AcceptableValueBase)(object)new AcceptableValueRange(0, 10), Array.Empty())); RoundDurationVariance = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "RoundDurationVariance", 5f, new ConfigDescription("Random +/- seconds on round timer.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 20f), Array.Empty())); SmallBias = ((BaseUnityPlugin)this).Config.Bind("Modifiers", "SmallBias", 0.5f, new ConfigDescription("0 = prefer large targets, 1 = prefer small (beta skew).", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); ModMenu.Tab("Random Boss Rush").Toggle(Enabled).Bool("Force Boss Rounds", ForceBossRounds) .Info("— Per-round modifiers —") .Bool("Random Scale", RandomizeScale) .Slider("Min Scale", MinTargetScale, 0.05f, "F2") .Slider("Max Scale", MaxTargetScale, 0.05f, "F2") .Slider("Small Bias", SmallBias, 0.05f, "F2") .Bool("Random Target Count", RandomizeTargetCount) .Int("Target Variance", MaxActiveTargetsVariance, 1) .Bool("Random Duration", RandomizeDuration) .Slider("Duration ±s", RoundDurationVariance, 1f, "F0") .Button("Chaos Preset", (Action)ApplyChaosPreset) .Button("Mild Preset", (Action)ApplyMildPreset); new Harmony("com.liamgaming.randombossrushmod").PatchAll(); GameEvents.OnTargetSpawned += HandleTargetSpawned; GameEvents.OnTargetSpawnerStarted += HandleTargetSpawnerStarted; Log.LogInfo((object)"Random Boss Rush Mod v1.2.1 loaded (OpenShot 2.0.0)."); } private static void ApplyChaosPreset() { ForceBossRounds.Value = true; RandomizeScale.Value = true; RandomizeTargetCount.Value = true; RandomizeDuration.Value = true; MinTargetScale.Value = 0.35f; MaxTargetScale.Value = 1.8f; MaxActiveTargetsVariance.Value = 6; RoundDurationVariance.Value = 10f; SmallBias.Value = 0.65f; } private static void ApplyMildPreset() { ForceBossRounds.Value = true; RandomizeScale.Value = true; RandomizeTargetCount.Value = true; RandomizeDuration.Value = true; MinTargetScale.Value = 0.7f; MaxTargetScale.Value = 1.15f; MaxActiveTargetsVariance.Value = 1; RoundDurationVariance.Value = 2f; SmallBias.Value = 0.5f; } private static void HandleTargetSpawned(Target target) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (Enabled.Value && RandomizeScale.Value && !((Object)(object)target == (Object)null)) { Vector3 val = Traverse.Create((object)target).Field("_originalScale").GetValue(); if (val == Vector3.zero) { val = ((Component)target).transform.localScale; } float value = MinTargetScale.Value; float num = Mathf.Max(value, MaxTargetScale.Value); float num2 = (float)Rng.NextDouble(); float num3 = Mathf.Lerp(1f, 2.2f, Mathf.Clamp01(SmallBias.Value)); num2 = Mathf.Pow(num2, num3); float num4 = Mathf.Lerp(value, num, num2); ((Component)target).transform.localScale = val * num4; } } private static void HandleTargetSpawnerStarted(object spawnerObj) { if (Enabled.Value && spawnerObj != null) { Traverse val = Traverse.Create(spawnerObj); int value = val.Field("baseMaxActiveTargets").GetValue(); float value2 = val.Field("roundDurationSeconds").GetValue(); int num = value; float num2 = value2; if (RandomizeTargetCount.Value) { int value3 = MaxActiveTargetsVariance.Value; num = Mathf.Max(1, value + Rng.Next(-value3, value3 + 1)); val.Field("baseMaxActiveTargets").SetValue((object)num); } if (RandomizeDuration.Value) { float value4 = RoundDurationVariance.Value; num2 = Mathf.Max(5f, value2 + (float)(Rng.NextDouble() * 2.0 - 1.0) * value4); val.Field("roundDurationSeconds").SetValue((object)num2); } Log.LogInfo((object)$"[RandomBossRush] Round modifiers: maxActiveTargets {value}->{num}, duration {value2:F1}->{num2:F1}"); } } } }