using System;
using System.Collections.Generic;
using System.Diagnostics;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 MonsterCount
{
[ContentWarningPlugin("ElfDevelop.MonsterCount", "1.0.0", false)]
[BepInPlugin("ElfDevelop.MonsterCount", "MonsterCount", "1.0.0")]
public class MonsterCountPlugin : BaseUnityPlugin
{
internal static ConfigEntry<float> Multiplier;
internal static ConfigEntry<float> PerExtraPlayer;
internal static ConfigEntry<float> MaxMultiplier;
internal static ConfigEntry<string> DisabledMonsters;
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: 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
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Multiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Monsters", "Multiplier", 0.6f, new ConfigDescription("Monster budget multiplier for both waves. 1 = vanilla, 0.5 = about half as many monsters, 2 = about twice as many.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
PerExtraPlayer = ((BaseUnityPlugin)this).Config.Bind<float>("Monsters", "PerPlayerAbove4", 0.1f, new ConfigDescription("Added to the multiplier for every player above 4 (big lobbies with Virality). 0.1 = +0.1 per extra player.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
MaxMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Monsters", "MaxMultiplier", 3f, new ConfigDescription("Upper limit for the final multiplier.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 20f), Array.Empty<object>()));
DisabledMonsters = ((BaseUnityPlugin)this).Config.Bind<string>("Monsters", "DisabledMonsters", "Mouthe", "Comma-separated monster names that never spawn (a part of the name is enough, case doesn't matter), e.g. \"Reaper, Teapot\". The host's log lists every monster in the spawn pool each day.");
new Harmony("ElfDevelop.MonsterCount").PatchAll();
Logger.LogInfo((object)$"MonsterCount 1.0.0 has loaded! Multiplier {Multiplier.Value}, disabled: \"{DisabledMonsters.Value}\"");
}
internal static float CurrentMultiplier()
{
int num = (((Object)(object)PlayerHandler.instance != (Object)null) ? PlayerHandler.instance.players.Count : 0);
float num2 = (float)Mathf.Max(0, num - 4) * PerExtraPlayer.Value;
return Mathf.Clamp(Multiplier.Value + num2, 0f, MaxMultiplier.Value);
}
internal static List<string> DisabledNames()
{
return (from s in DisabledMonsters.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
select s.Trim() into s
where s.Length > 0
select s).ToList();
}
}
[HarmonyPatch(typeof(BigNumbers))]
internal static class BudgetPatches
{
[HarmonyPatch("GetMonsterBudgetForDayFirstWave")]
[HarmonyPostfix]
private static void FirstWave(int day, ref int __result)
{
__result = Scale(__result, day, "1st");
}
[HarmonyPatch("GetMonsterBudgetForSecondWave")]
[HarmonyPostfix]
private static void SecondWave(int day, ref int __result)
{
__result = Scale(__result, day, "2nd");
}
private static int Scale(int budget, int day, string wave)
{
float num = MonsterCountPlugin.CurrentMultiplier();
int num2 = Mathf.RoundToInt((float)budget * num);
MonsterCountPlugin.Logger.LogInfo((object)$"Day {day} {wave} wave budget {budget} x{num:0.##} = {num2}");
return num2;
}
}
[HarmonyPatch(typeof(RoundSpawner), "Start")]
internal static class SpawnPoolPatch
{
[HarmonyPrefix]
[HarmonyPriority(0)]
private static void FilterPool(RoundSpawner __instance)
{
GameObject[] source = __instance.possibleSpawns ?? Array.Empty<GameObject>();
MonsterCountPlugin.Logger.LogInfo((object)("Spawn pool: " + string.Join(", ", from p in source
where (Object)(object)p != (Object)null
select ((Object)p).name)));
List<string> disabled = MonsterCountPlugin.DisabledNames();
if (disabled.Count == 0)
{
return;
}
List<GameObject> removed = source.Where((GameObject p) => (Object)(object)p != (Object)null && disabled.Any((string d) => ((Object)p).name.IndexOf(d, StringComparison.OrdinalIgnoreCase) >= 0)).ToList();
if (removed.Count != 0)
{
if (removed.Any((GameObject p) => ((Object)p).name.IndexOf("Weeping", StringComparison.OrdinalIgnoreCase) >= 0))
{
__instance.m_hasWeeping = false;
}
__instance.possibleSpawns = source.Where((GameObject p) => !removed.Contains(p)).ToArray();
MonsterCountPlugin.Logger.LogInfo((object)("Removed from spawn pool: " + string.Join(", ", removed.Select((GameObject p) => ((Object)p).name))));
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}