Decompiled source of MonstersPlus v2.0.0

MonstersPlus2.0.0.dll

Decompiled a year ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
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 Unity.Netcode;
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("LethalCompanyTemplate")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalCompanyTemplate")]
[assembly: AssemblyTitle("LethalCompanyTemplate")]
[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 LethalCompanyTemplate
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LethalCompanyTemplate";

		public const string PLUGIN_NAME = "LethalCompanyTemplate";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LethalCompanyTemplate.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("LethalCompanyTemplate.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace Zero
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Zero.MonstersPlus";

		public const string PLUGIN_NAME = "MonstersPlus";

		public const string PLUGIN_VERSION = "2.0.0";
	}
	[BepInPlugin("Zero.MonstersPlus", "MonstersPlus", "2.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private static ConfigEntry<int> BaseSpawnChance;

		private static int baseSpawnChance;

		private static int spawnChance;

		private static ConfigEntry<int> EnemyMax;

		private static ConfigEntry<int> StartSpawnTime;

		private static ConfigEntry<int> MinSpawnInterval;

		private static ConfigEntry<int> MaxSpawnInterval;

		private static int minSpawnInterval;

		private static int maxSpawnInterval;

		private static int startSpawnTime;

		private static int enemyMax;

		private static int enemyCount;

		private static int spawnInterval;

		private static float spawnTime;

		private static int lootbug;

		private static int lizard;

		private static int flea;

		private static int spider;

		private static int slime;

		private static int thumper;

		private static int coil;

		private static int girl;

		private static int bracken;

		private static int jester;

		public static ManualLogSource log;

		private Harmony harmony = new Harmony("Zero.MonstersPlus");

		internal static bool isHost;

		private static RoundManager roundManager;

		private void Awake()
		{
			log = Logger.CreateLogSource("Zero.MonstersPlus");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[Z] Plugin: Zero.MonstersPlus");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[Z] Name: MonstersPlus");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[Z] Version: 2.0.0");
			harmony.PatchAll(typeof(Plugin));
			SetBindings();
		}

		private void SetBindings()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			BaseSpawnChance = ((BaseUnityPlugin)this).Config.Bind<int>("Base Spawn Chance", "<1-100> Chance to Spawn", 30, new ConfigDescription("Base chance for an enemy to spawn.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			EnemyMax = ((BaseUnityPlugin)this).Config.Bind<int>("Enemy Limit", "Max <n> of enemies", 8, new ConfigDescription("Max number of enemies that can spawn", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 16), Array.Empty<object>()));
			StartSpawnTime = ((BaseUnityPlugin)this).Config.Bind<int>("Spawn Delay", "Start spawning enemies after <n> seconds", 60, new ConfigDescription("Number of seconds to wait before spawning in enemies every <n> seconds interval.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(60, 360), Array.Empty<object>()));
			MinSpawnInterval = ((BaseUnityPlugin)this).Config.Bind<int>("Min Spawn Interval", "Spawn enemy within <min> seconds", 30, new ConfigDescription("Minimum seconds before a new enemy can spawn.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(30, 360), Array.Empty<object>()));
			MaxSpawnInterval = ((BaseUnityPlugin)this).Config.Bind<int>("Max Spawn Interval", "Spawn enemy within <max> seconds", 60, new ConfigDescription("Maximum seconds before a new enemy can spawn.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(30, 360), Array.Empty<object>()));
			baseSpawnChance = BaseSpawnChance.Value;
			startSpawnTime = StartSpawnTime.Value;
			minSpawnInterval = MinSpawnInterval.Value;
			maxSpawnInterval = MaxSpawnInterval.Value;
			enemyMax = EnemyMax.Value;
		}

		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		public static void StartPatch()
		{
			if (minSpawnInterval > maxSpawnInterval)
			{
				minSpawnInterval = maxSpawnInterval;
			}
			roundManager = RoundManager.Instance;
			isHost = ((NetworkBehaviour)RoundManager.Instance).NetworkManager.IsHost;
		}

		[HarmonyPatch(typeof(RoundManager), "LoadNewLevel")]
		[HarmonyPostfix]
		private static void NewLevel(ref SelectableLevel newLevel)
		{
			List<SpawnableEnemyWithRarity> enemies = newLevel.Enemies;
			lootbug = (lizard = (flea = (slime = (thumper = (coil = (girl = (bracken = (jester = -1))))))));
			for (int i = 0; i < newLevel.Enemies.Count; i++)
			{
				if (enemies[i].enemyType.enemyName.ToLower().Contains("hoarding"))
				{
					lootbug = i;
				}
				else if (enemies[i].enemyType.enemyName.ToLower().Contains("puffer"))
				{
					lizard = i;
				}
				else if (enemies[i].enemyType.enemyName.ToLower().Contains("centipede"))
				{
					flea = i;
				}
				else if (enemies[i].enemyType.enemyName.ToLower().Contains("spider"))
				{
					spider = i;
				}
				else if (enemies[i].enemyType.enemyName.ToLower().Contains("blob"))
				{
					slime = i;
				}
				else if (enemies[i].enemyType.enemyName.ToLower().Contains("crawler"))
				{
					thumper = i;
				}
				else if (enemies[i].enemyType.enemyName.ToLower().Contains("coil"))
				{
					coil = i;
				}
				else if (enemies[i].enemyType.enemyName.ToLower().Contains("girl"))
				{
					girl = i;
				}
				else if (enemies[i].enemyType.enemyName.ToLower().Contains("flowerman"))
				{
					bracken = i;
				}
				else if (enemies[i].enemyType.enemyName.ToLower().Contains("jester"))
				{
					jester = i;
				}
			}
			spawnTime = roundManager.timeScript.currentDayTime + (float)startSpawnTime;
			spawnInterval = Random.Range(minSpawnInterval, maxSpawnInterval + 1);
			spawnChance = baseSpawnChance;
			enemyCount = 0;
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnInsideEnemiesFromVentsIfReady")]
		[HarmonyPostfix]
		public static void SpawnInsideEnemiesFromVentsIfReadyPatch()
		{
			//IL_0086: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			if (!isHost)
			{
				return;
			}
			roundManager.currentLevel.maxEnemyPowerCount = 250;
			if (enemyCount >= enemyMax || !(roundManager.timeScript.currentDayTime > spawnTime) || roundManager.allEnemyVents.Length == 0)
			{
				return;
			}
			int num = Random.Range(0, roundManager.allEnemyVents.Length);
			Vector3 position = roundManager.allEnemyVents[num].floorNode.position;
			float y = roundManager.allEnemyVents[num].floorNode.eulerAngles.y;
			int num2 = Random.Range(1, 101);
			int num3 = 0;
			int num4 = Random.Range(0, 100);
			int num5 = Mathf.FloorToInt(roundManager.timeScript.currentDayTime / 60f);
			if (num5 >= 1 && num5 <= 4)
			{
				spawnChance = baseSpawnChance + num5 * 5;
			}
			else if (num5 >= 5)
			{
				spawnChance = baseSpawnChance + 20 + (num5 - 4) * 10;
			}
			if (spawnChance > 100)
			{
				spawnChance = 100;
			}
			if (num4 >= 1 && num4 <= spawnChance)
			{
				if (num2 >= 1 && num2 <= 10)
				{
					if (lootbug != -1)
					{
						num3 = lootbug;
					}
				}
				else if (num2 >= 11 && num2 <= 15)
				{
					if (lizard != -1)
					{
						num3 = lizard;
					}
				}
				else if (num2 >= 16 && num2 <= 35)
				{
					if (flea != -1)
					{
						num3 = flea;
					}
				}
				else if (num2 >= 36 && num2 <= 50)
				{
					if (spider != -1)
					{
						num3 = spider;
					}
				}
				else if (num2 >= 51 && num2 <= 65)
				{
					if (slime != -1)
					{
						num3 = slime;
					}
				}
				else if (num2 >= 66 && num2 <= 80)
				{
					if (thumper != -1)
					{
						num3 = thumper;
					}
				}
				else if (num2 >= 81 && num2 <= 85)
				{
					if (coil != -1)
					{
						num3 = coil;
					}
				}
				else if (num2 >= 86 && num2 <= 90)
				{
					if (girl != -1)
					{
						num3 = girl;
					}
				}
				else if (num2 >= 91 && num2 <= 95)
				{
					if (bracken != -1)
					{
						num3 = bracken;
					}
				}
				else if (num2 >= 96 && num2 <= 100 && jester != -1)
				{
					num3 = jester;
				}
				roundManager.SpawnEnemyOnServer(position, y, num3);
				enemyCount++;
			}
			spawnInterval = Random.Range(minSpawnInterval, maxSpawnInterval + 1);
			spawnTime = roundManager.timeScript.currentDayTime + (float)spawnInterval;
			log.LogInfo((object)("[Z] Spawned: <" + num3 + "> : " + roundManager.currentLevel.Enemies[num3].enemyType.enemyName));
			log.LogInfo((object)($"[Z] Time: {roundManager.timeScript.currentDayTime} | Spawning @ " + spawnTime));
			log.LogInfo((object)("[Z] Enemy Count: " + enemyCount));
		}
	}
}