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 Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("uk.1a3.tierspawnconfig")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+e1fd31c9a0a1c47021a2b978ac96b5a41bdb7b85")]
[assembly: AssemblyProduct("TierSpawnConfig")]
[assembly: AssemblyTitle("uk.1a3.tierspawnconfig")]
[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 TierSpawnConfig
{
[HarmonyPatch]
public class EnemyPatches
{
private static readonly int reservedViewCount = 100;
private static bool viewCountWarning;
[HarmonyPatch(typeof(EnemyDirector), "FirstSpawnPointAdd")]
[HarmonyPrefix]
private static bool EnemyDirector_FirstSpawnPointAdd_Prefix(EnemyDirector __instance, EnemyParent _enemyParent)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
if (!PluginLoader.closestSpawnPoints.Value)
{
return true;
}
List<LevelPoint> list = SemiFunc.LevelPointsGetAll();
float num = float.MaxValue;
LevelPoint val = null;
foreach (LevelPoint item in list)
{
if (!item.Truck && !__instance.enemyFirstSpawnPoints.Contains(item))
{
float num2 = Vector3.Distance(((Component)item).transform.position, ((Component)LevelGenerator.Instance.LevelPathTruck).transform.position);
if (num2 < num)
{
num = num2;
val = item;
}
}
}
if (Object.op_Implicit((Object)(object)val))
{
_enemyParent.firstSpawnPoint = val;
__instance.enemyFirstSpawnPoints.Add(val);
}
return false;
}
[HarmonyPatch(typeof(EnemyDirector), "FirstSpawnPointAdd")]
[HarmonyPostfix]
private static void EnemyDirector_FirstSpawnPointAdd_Postfix(EnemyDirector __instance)
{
int num = SemiFunc.LevelPointsGetAll().Count((LevelPoint x) => !x.Truck);
if (__instance.enemyFirstSpawnPoints.Count >= num)
{
PluginLoader.StaticLogger.LogDebug((object)$"{__instance.enemyFirstSpawnPoints.Count}/{num} spawn points are used, clearing list");
__instance.enemyFirstSpawnPoints.Clear();
}
}
[HarmonyPatch(typeof(EnemyDirector), "AmountSetup")]
[HarmonyPrefix]
private static bool EnemyDirector_AmountSetup(EnemyDirector __instance)
{
if (PluginLoader.tier1EnemyCount.Value >= 0)
{
__instance.amountCurve1Value = PluginLoader.tier1EnemyCount.Value;
}
else if (SemiFunc.RunGetDifficultyMultiplier2() > 0f)
{
__instance.amountCurve1Value = (int)__instance.amountCurve1_2.Evaluate(SemiFunc.RunGetDifficultyMultiplier2());
}
else
{
__instance.amountCurve1Value = (int)__instance.amountCurve1_1.Evaluate(SemiFunc.RunGetDifficultyMultiplier1());
}
if (PluginLoader.tier2EnemyCount.Value >= 0)
{
__instance.amountCurve2Value = PluginLoader.tier2EnemyCount.Value;
}
else if (SemiFunc.RunGetDifficultyMultiplier2() > 0f)
{
__instance.amountCurve2Value = (int)__instance.amountCurve2_2.Evaluate(SemiFunc.RunGetDifficultyMultiplier2());
}
else
{
__instance.amountCurve2Value = (int)__instance.amountCurve2_1.Evaluate(SemiFunc.RunGetDifficultyMultiplier1());
}
if (PluginLoader.tier3EnemyCount.Value >= 0)
{
__instance.amountCurve3Value = PluginLoader.tier3EnemyCount.Value;
}
else if (SemiFunc.RunGetDifficultyMultiplier2() > 0f)
{
__instance.amountCurve3Value = (int)__instance.amountCurve3_2.Evaluate(SemiFunc.RunGetDifficultyMultiplier2());
}
else
{
__instance.amountCurve3Value = (int)__instance.amountCurve3_1.Evaluate(SemiFunc.RunGetDifficultyMultiplier1());
}
__instance.enemyListCurrent.Clear();
List<string> enemyBlacklist = (from x in PluginLoader.blacklistedEnemies.Value.Split(',')
select x.Trim()).ToList();
PluginLoader.StaticLogger.LogInfo((object)$"Setting enemy counts: Tier 1: {__instance.amountCurve1Value}, Tier 2: {__instance.amountCurve2Value}, Tier 3: {__instance.amountCurve3Value}");
PluginLoader.StaticLogger.LogInfo((object)("Blacklisted Enemies: " + string.Join(", ", enemyBlacklist)));
for (int i = 0; i < __instance.amountCurve3Value; i++)
{
__instance.PickEnemies(__instance.enemiesDifficulty3.Where((EnemySetup x) => !enemyBlacklist.Contains(((Object)x).name) && (PluginLoader.tier3EnemyGroups.Value || !((Object)x).name.StartsWith("Enemy Group - "))).ToList());
}
for (int j = 0; j < __instance.amountCurve2Value; j++)
{
__instance.PickEnemies(__instance.enemiesDifficulty2.Where((EnemySetup x) => !enemyBlacklist.Contains(((Object)x).name)).ToList());
}
for (int k = 0; k < __instance.amountCurve1Value; k++)
{
__instance.PickEnemies(__instance.enemiesDifficulty1.Where((EnemySetup x) => !enemyBlacklist.Contains(((Object)x).name)).ToList());
}
if (SemiFunc.RunGetDifficultyMultiplier3() > 0f)
{
__instance.despawnedTimeMultiplier = __instance.despawnTimeCurve_2.Evaluate(SemiFunc.RunGetDifficultyMultiplier3());
}
else if (SemiFunc.RunGetDifficultyMultiplier2() > 0f)
{
__instance.despawnedTimeMultiplier = __instance.despawnTimeCurve_1.Evaluate(SemiFunc.RunGetDifficultyMultiplier2());
}
else
{
__instance.despawnedTimeMultiplier = 1f;
}
__instance.totalAmount = __instance.amountCurve1Value + __instance.amountCurve2Value + __instance.amountCurve3Value;
return false;
}
internal static void UpdateEnemyTimers(EnemyParent __instance)
{
if ((float)PluginLoader.despawnedTimer.Value >= 0f)
{
__instance.DespawnedTimeMin = PluginLoader.despawnedTimer.Value;
__instance.DespawnedTimeMax = PluginLoader.despawnedTimer.Value;
}
else
{
__instance.DespawnedTimeMin = 240f;
__instance.DespawnedTimeMax = 300f;
}
if (__instance.DespawnedTimer < __instance.DespawnedTimeMin || __instance.DespawnedTimer > __instance.DespawnedTimeMax)
{
__instance.DespawnedTimer = Random.Range(__instance.DespawnedTimeMin, __instance.DespawnedTimeMax);
}
if ((float)PluginLoader.spawnedTimer.Value >= 0f)
{
__instance.SpawnedTimeMin = PluginLoader.spawnedTimer.Value;
__instance.SpawnedTimeMax = PluginLoader.spawnedTimer.Value;
}
else
{
__instance.SpawnedTimeMin = 20f;
__instance.SpawnedTimeMax = 40f;
}
if (__instance.SpawnedTimer < __instance.SpawnedTimeMin || __instance.SpawnedTimer > __instance.SpawnedTimeMax)
{
__instance.SpawnedTimer = Random.Range(__instance.SpawnedTimeMin, __instance.SpawnedTimeMax);
}
}
[HarmonyPatch(typeof(EnemyParent), "Awake")]
[HarmonyPostfix]
private static void EnemyParent_Awake(EnemyParent __instance)
{
UpdateEnemyTimers(__instance);
}
[HarmonyPatch(typeof(EnemyDirector), "Start")]
[HarmonyPostfix]
private static void EnemyDirector_Start(EnemyDirector __instance)
{
__instance.debugNoSpawnedPause = true;
}
[HarmonyPatch(typeof(SemiFunc), "EnemyPhysObjectSphereCheck")]
[HarmonyPrefix]
private static bool SemiFunc_EnemyPhysObjectSphereCheck(Vector3 _position, float _radius, ref bool __result)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (!PluginLoader.skipCollisionCheck.Value)
{
return true;
}
__result = (from x in Physics.OverlapSphere(_position, _radius, LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject()))
where (Object)(object)((Component)x).GetComponent<EnemyParent>() != (Object)null
select x).ToArray().Length != 0;
return false;
}
[HarmonyPatch(typeof(SemiFunc), "EnemyPhysObjectBoundingBoxCheck")]
[HarmonyPrefix]
private static bool SemiFunc_EnemyPhysObjectBoundingBoxCheck(Vector3 _currentPosition, Vector3 _checkPosition, Rigidbody _rigidbody, ref bool __result)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
if (!PluginLoader.skipCollisionCheck.Value)
{
return true;
}
Bounds bounds = default(Bounds);
((Bounds)(ref bounds))..ctor(Vector3.zero, Vector3.zero);
Collider[] componentsInChildren = ((Component)_rigidbody).GetComponentsInChildren<Collider>();
foreach (Collider val in componentsInChildren)
{
if (((Bounds)(ref bounds)).size == Vector3.zero)
{
bounds = val.bounds;
}
else
{
((Bounds)(ref bounds)).Encapsulate(val.bounds);
}
}
Vector3 val2 = _currentPosition - ((Component)_rigidbody).transform.position;
Vector3 val3 = ((Bounds)(ref bounds)).center - ((Component)_rigidbody).transform.position;
((Bounds)(ref bounds)).center = _checkPosition - val2 + val3;
((Bounds)(ref bounds)).size = ((Bounds)(ref bounds)).size * 1.2f;
Collider[] array = Physics.OverlapBox(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).extents, Quaternion.identity, LayerMask.op_Implicit(SemiFunc.LayerMaskGetPhysGrabObject()));
for (int j = 0; j < array.Length; j++)
{
if ((Object)(object)((Component)array[j]).GetComponentInParent<Rigidbody>() != (Object)(object)_rigidbody && (Object)(object)((Component)array[j]).GetComponentInParent<EnemyRigidbody>() == (Object)null)
{
__result = true;
return false;
}
}
__result = false;
return false;
}
[HarmonyPatch(typeof(LevelGenerator), "EnemySpawn")]
[HarmonyPrefix]
private static bool LevelGenerator_EnemySpawn(LevelGenerator __instance, EnemySetup enemySetup)
{
if (PhotonNetwork.ViewCount < PhotonNetwork.MAX_VIEW_IDS - reservedViewCount)
{
viewCountWarning = false;
return true;
}
if (!viewCountWarning)
{
viewCountWarning = true;
PluginLoader.StaticLogger.LogWarning((object)$"Multiplayer photon view limit reached! {__instance.EnemiesSpawnTarget}/{EnemyDirector.instance.totalAmount} enemies were spawned!");
}
return false;
}
}
[BepInPlugin("uk.1a3.tierspawnconfig", "TierSpawnConfig", "1.0.4")]
internal class PluginLoader : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("uk.1a3.tierspawnconfig");
private static bool initialized;
public static ConfigEntry<bool> overlayEnabled;
public static ConfigEntry<int> tier1EnemyCount;
public static ConfigEntry<int> tier2EnemyCount;
public static ConfigEntry<int> tier3EnemyCount;
public static ConfigEntry<bool> tier3EnemyGroups;
public static ConfigEntry<string> blacklistedEnemies;
public static ConfigEntry<bool> closestSpawnPoints;
public static ConfigEntry<bool> skipCollisionCheck;
public static ConfigEntry<int> despawnedTimer;
public static ConfigEntry<int> spawnedTimer;
public static PluginLoader Instance { get; private set; }
internal static ManualLogSource StaticLogger { get; private set; }
internal static ConfigFile StaticConfig { get; private set; }
private void Awake()
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Expected O, but got Unknown
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Expected O, but got Unknown
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Expected O, but got Unknown
if (initialized)
{
return;
}
initialized = true;
Instance = this;
StaticLogger = ((BaseUnityPlugin)this).Logger;
StaticConfig = ((BaseUnityPlugin)this).Config;
StaticLogger.LogInfo((object)"Patches Loaded");
tier1EnemyCount = StaticConfig.Bind<int>("Spawn Count", "Tier 1", 10, new ConfigDescription("How many tier 1 enemies should be spawned? -1 = Vanilla, 0 = None", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 500), Array.Empty<object>()));
tier2EnemyCount = StaticConfig.Bind<int>("Spawn Count", "Tier 2", 10, new ConfigDescription("How many tier 2 enemies should be spawned? -1 = Vanilla, 0 = None", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 500), Array.Empty<object>()));
tier3EnemyCount = StaticConfig.Bind<int>("Spawn Count", "Tier 3", 10, new ConfigDescription("How many tier 3 enemies should be spawned? -1 = Vanilla, 0 = None", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 500), Array.Empty<object>()));
tier3EnemyGroups = StaticConfig.Bind<bool>("Spawn Count", "Tier 3 Groups", false, "Should tier 3 spawn groups be enabled? These are groups of lower tier enemies that sometimes replace the spawn of a tier 3 enemy.");
blacklistedEnemies = StaticConfig.Bind<string>("Spawn Count", "Blacklisted Enemies", "Enemy - Ceiling Eye,Enemy - Hidden,Enemy - Thin Man", "Which enemies should be disabled? This is a comma-separated list of enemy spawn groups. For the full list check the mod's thunderstore page.");
closestSpawnPoints = StaticConfig.Bind<bool>("Spawn Location", "Prioritize Closest Points", true, "Reverse the order that spawn points are picked from. If enabled, the closest spawn points will be used first, otherwise the furthest ones will be used first.");
skipCollisionCheck = StaticConfig.Bind<bool>("Spawn Location", "Bypass Collision Check", true, "Should enemies be able to spawn on top of each other?");
despawnedTimer = StaticConfig.Bind<int>("Spawn Timer", "Respawn Timer", 0, new ConfigDescription("How many seconds should enemies take to respawn? -1 = Vanilla, 0 = Instant", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 600), Array.Empty<object>()));
despawnedTimer.SettingChanged += delegate
{
EnemyParent[] array2 = Object.FindObjectsOfType<EnemyParent>(true);
for (int j = 0; j < array2.Length; j++)
{
EnemyPatches.UpdateEnemyTimers(array2[j]);
}
};
spawnedTimer = StaticConfig.Bind<int>("Spawn Timer", "Despawn Timer", 600, new ConfigDescription("How many seconds should enemies take to despawn if nobody is near? -1 = Vanilla, 0 = Disabled", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 600), Array.Empty<object>()));
spawnedTimer.SettingChanged += delegate
{
EnemyParent[] array = Object.FindObjectsOfType<EnemyParent>(true);
for (int i = 0; i < array.Length; i++)
{
EnemyPatches.UpdateEnemyTimers(array[i]);
}
};
harmony.PatchAll(typeof(EnemyPatches));
overlayEnabled = StaticConfig.Bind<bool>("Overlay", "Enabled", true, "Should the overlay be shown?");
GameObject val = new GameObject("TSCOverlay")
{
hideFlags = (HideFlags)61
};
Object.DontDestroyOnLoad((Object)val);
val.AddComponent<TesterOverlay>();
}
}
public class TesterOverlay : MonoBehaviour
{
private string text;
private float updateTimer;
private void OnGUI()
{
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Expected O, but got Unknown
//IL_0191: Expected O, but got Unknown
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Expected O, but got Unknown
//IL_01ae: Expected O, but got Unknown
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Expected O, but got Unknown
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
if (!PluginLoader.overlayEnabled.Value)
{
text = "";
return;
}
if (SemiFunc.RunIsLevel())
{
updateTimer += Time.deltaTime;
if (updateTimer >= 5f)
{
updateTimer = 0f;
Enemy[] array = Object.FindObjectsOfType<Enemy>(true);
if (array.Length != 0)
{
text = string.Join('\n', from x in (from x in array
group x by x.EnemyParent.enemyName into x
orderby x.Key
select x).ToList()
select $"{x.Key}: {x.Count((Enemy y) => ((Behaviour)y).isActiveAndEnabled)}/{x.Count()}");
text += $"\nTotal: {array.Count((Enemy y) => ((Behaviour)y).isActiveAndEnabled)}/{array.Length}";
}
else
{
text = null;
}
}
}
else
{
text = null;
}
if (!string.IsNullOrEmpty(text))
{
GUIStyle val = new GUIStyle(GUI.skin.label)
{
fontSize = 13,
fontStyle = (FontStyle)1,
alignment = (TextAnchor)8,
wordWrap = false,
normal = new GUIStyleState
{
textColor = Color.white
}
};
GUIStyle val2 = new GUIStyle(val)
{
normal = new GUIStyleState
{
textColor = Color.black
}
};
float num = 400f;
float num2 = (float)Screen.width - num - 4f;
float num3 = val.CalcHeight(new GUIContent(text), num);
float num4 = (float)Screen.height - num3 - 20f;
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(num2, num4, num, num3);
GUI.Label(new Rect(((Rect)(ref val3)).x + 1f, ((Rect)(ref val3)).y + 1f, ((Rect)(ref val3)).width, ((Rect)(ref val3)).height), text, val2);
GUI.Label(val3, text, val);
}
}
}
internal static class MyPluginInfo
{
public const string PLUGIN_GUID = "uk.1a3.tierspawnconfig";
public const string PLUGIN_NAME = "TierSpawnConfig";
public const string PLUGIN_VERSION = "1.0.4";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}