Decompiled source of MonsterFilter v1.0.0

Monster Filter/aelghar.monsterFilter.dll

Decompiled 3 months ago
using System;
using System.Collections;
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 CurvedUI;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour.HookGen;
using On;
using UnityEngine;
using monsterFilter.Patches;

[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("aelghar.monsterFilter")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("monsterFilter")]
[assembly: AssemblyTitle("aelghar.monsterFilter")]
[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.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]
	[Microsoft.CodeAnalysis.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]
	[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 monsterFilter
{
	[ContentWarningPlugin("aelghar.monsterFilter", "1.0.0", false)]
	[BepInPlugin("aelghar.monsterFilter", "monsterFilter", "1.0.0")]
	public class monsterFilter : BaseUnityPlugin
	{
		public static ConfigEntry<string> configMonster;

		public static ConfigEntry<int> configNbMonsterStart;

		public static ConfigEntry<int> configNbMonsterDelayed;

		public static ConfigEntry<float> configDayMultiplier;

		public static string selectedMonster;

		public static monsterFilter Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			HookAll();
			Logger.LogInfo((object)"aelghar.monsterFilter v1.0.0 has loaded!");
			configMonster = ((BaseUnityPlugin)this).Config.Bind<string>("General", "MonsterToSpawn", "Zombe", "Choose a monster to spawn, available monsters are (Captital letters are important) :\r\n\"BigSlap\", \"Ear\", \"Flicker\", \"Jello\", \"Knifo\", \"Mouthe\", \"Slurper\", \"Toolkit_Wisk\", \"Snatcho\", \"Weeping\", \"Zombe\", \"BarnacleBall\", \"KnifoGroup 2\", \"KnifoGroup 5\", \"SlurperGroup 5\", \"SnatchoGroup 5\", \"Toolkit_WiskGroup 3\", \"WeepingGroup2\", \"ZombieGroup3\", \"ZombieGroup5\", \"Mouthe5\", \"Larva\", \"Bombs\", \"Spider\", \"Dog\", \"EyeGuy\", \"CamCreep\", \"Harpooner\", \"Streamer\", \"InfiltratorSpawner\", \"Worm\", \"UltraKnifoGroup\", \"SnailSpawner\", \"Fire\", \"Puffo\", \"BlackHoleBot\", \"Mime\", \"Arms\"\r\n\nMonsters were not all tested, but they \"should\" work. Worms is very buggy in base game so prepare for a lot of lag/spam in console if you try it.");
			configNbMonsterStart = ((BaseUnityPlugin)this).Config.Bind<int>("General", "AmountOfInitialMonster", 10, "The amount of monsters to have present on the map once it's started.");
			configNbMonsterDelayed = ((BaseUnityPlugin)this).Config.Bind<int>("General", "AmountOfDelayedMonster", 10, "How much monster should be added over the next ~300-350 seconds");
			configDayMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "dailyMult", 0.2f, "How much monster should be added as you progress. .2 means 20% more monster per day. Gets rounded down. (so 10.2 monster gives 10 monsters.)");
		}

		internal static void HookAll()
		{
			Logger.LogDebug((object)"Hooking...");
			filterMonsters.Init();
			Logger.LogDebug((object)"Finished Hooking!");
		}

		internal static void UnhookAll()
		{
			Logger.LogDebug((object)"Unhooking...");
			HookEndpointManager.RemoveAllOwnedBy((object)Assembly.GetExecutingAssembly());
			Logger.LogDebug((object)"Finished Unhooking!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "aelghar.monsterFilter";

		public const string PLUGIN_NAME = "monsterFilter";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace monsterFilter.Patches
{
	public class filterMonsters
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__RoundSpawner_Start;

			public static hook_SpawnRound <1>__RoundSpawner_SpawnRound;

			public static hook_SpawnSecondRun <2>__RoundSpawner_SpawnSecondRun;
		}

		public static int getMonsterVal(string monster)
		{
			Dictionary<string, int> dictionary = new Dictionary<string, int>
			{
				{ "BigSlap", 15 },
				{ "Ear", 4 },
				{ "Flicker", 1 },
				{ "Jello", 5 },
				{ "Knifo", 6 },
				{ "Mouthe", 1 },
				{ "Slurper", 1 },
				{ "Toolkit_Wisk", 4 },
				{ "Snatcho", 3 },
				{ "Weeping", 5 },
				{ "Zombe", 1 },
				{ "BarnacleBall", 10 },
				{ "KnifoGroup 2", 12 },
				{ "KnifoGroup 5", 30 },
				{ "SlurperGroup 5", 5 },
				{ "SnatchoGroup 5", 15 },
				{ "Toolkit_WiskGroup 3", 12 },
				{ "WeepingGroup2", 10 },
				{ "ZombieGroup3", 3 },
				{ "ZombieGroup5", 5 },
				{ "Mouthe5", 5 },
				{ "Larva", 6 },
				{ "Bombs", 6 },
				{ "Spider", 4 },
				{ "Dog", 6 },
				{ "EyeGuy", 6 },
				{ "CamCreep", 1 },
				{ "Harpooner", 8 },
				{ "Streamer", 15 },
				{ "InfiltratorSpawner", 1 },
				{ "Worm", 1 },
				{ "UltraKnifoGroup", 28 },
				{ "SnailSpawner", 10 },
				{ "Fire", 6 },
				{ "Puffo", 2 },
				{ "BlackHoleBot", 2 },
				{ "Mime", 8 },
				{ "Arms", 6 }
			};
			return dictionary[monster];
		}

		internal static void Init()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//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_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			object obj = <>O.<0>__RoundSpawner_Start;
			if (obj == null)
			{
				hook_Start val = RoundSpawner_Start;
				<>O.<0>__RoundSpawner_Start = val;
				obj = (object)val;
			}
			RoundSpawner.Start += (hook_Start)obj;
			object obj2 = <>O.<1>__RoundSpawner_SpawnRound;
			if (obj2 == null)
			{
				hook_SpawnRound val2 = RoundSpawner_SpawnRound;
				<>O.<1>__RoundSpawner_SpawnRound = val2;
				obj2 = (object)val2;
			}
			RoundSpawner.SpawnRound += (hook_SpawnRound)obj2;
			object obj3 = <>O.<2>__RoundSpawner_SpawnSecondRun;
			if (obj3 == null)
			{
				hook_SpawnSecondRun val3 = RoundSpawner_SpawnSecondRun;
				<>O.<2>__RoundSpawner_SpawnSecondRun = val3;
				obj3 = (object)val3;
			}
			RoundSpawner.SpawnSecondRun += (hook_SpawnSecondRun)obj3;
		}

		private static void RoundSpawner_SpawnSecondRun(orig_SpawnSecondRun orig, RoundSpawner self, float waitTime, int budgetForSpawn, int biggestPurchase)
		{
			int monsterVal = getMonsterVal(monsterFilter.configMonster.Value);
			float num = 1f + (float)SurfaceNetworkHandler.RoomStats.CurrentDay * monsterFilter.configDayMultiplier.Value - monsterFilter.configDayMultiplier.Value;
			int num2 = CurvedUIExtensionMethods.ToInt((float)monsterFilter.configNbMonsterDelayed.Value * num);
			int monsterVal2 = getMonsterVal(monsterFilter.configMonster.Value);
			monsterFilter.Logger.LogInfo((object)" ---- Overriding budget with new value ---- ");
			monsterFilter.Logger.LogInfo((object)("Old budget: " + budgetForSpawn + "; Old biggestPurchase: " + biggestPurchase));
			monsterFilter.Logger.LogInfo((object)("New Budget: " + monsterVal * num2 + "; New biggestPurchase: " + monsterVal2));
			monsterFilter.Logger.LogInfo((object)" ---- Override complete ---- ");
			orig.Invoke(self, waitTime, monsterVal * num2, monsterVal2);
		}

		private static void RoundSpawner_SpawnRound(orig_SpawnRound orig, RoundSpawner self, int budget, int biggestPurchase, bool isFirstRound)
		{
			int monsterVal = getMonsterVal(monsterFilter.configMonster.Value);
			float num = 1f + (float)SurfaceNetworkHandler.RoomStats.CurrentDay * monsterFilter.configDayMultiplier.Value - monsterFilter.configDayMultiplier.Value;
			int num2 = CurvedUIExtensionMethods.ToInt((float)monsterFilter.configNbMonsterStart.Value * num);
			int monsterVal2 = getMonsterVal(monsterFilter.configMonster.Value);
			monsterFilter.Logger.LogInfo((object)" ---- Overriding budget with new value ---- ");
			monsterFilter.Logger.LogInfo((object)("Old budget: " + budget + "; Old biggestPurchase: " + biggestPurchase));
			monsterFilter.Logger.LogInfo((object)("New Budget: " + monsterVal * num2 + "; New biggestPurchase: " + monsterVal2));
			monsterFilter.Logger.LogInfo((object)" ---- Override complete ---- ");
			orig.Invoke(self, monsterVal * num2, monsterVal2, isFirstRound);
		}

		private static IEnumerator RoundSpawner_Start(orig_Start orig, RoundSpawner self)
		{
			GameObject[] array = (GameObject[])(object)new GameObject[1];
			string value = monsterFilter.configMonster.Value;
			monsterFilter.Logger.LogInfo((object)("Chosen monster is: " + value));
			for (int i = 0; i < self.possibleSpawns.Length; i++)
			{
				if (((Object)self.possibleSpawns[i]).name.Contains(value))
				{
					monsterFilter.Logger.LogInfo((object)("Found " + value + "! replacing monster list to only have " + value + "."));
					array[0] = self.possibleSpawns[i];
					break;
				}
			}
			self.possibleSpawns = array;
			monsterFilter.Logger.LogInfo((object)"New array of availlable monsters looks like this : ");
			for (int j = 0; j < self.possibleSpawns.Length; j++)
			{
				monsterFilter.Logger.LogInfo((object)((Object)self.possibleSpawns[j]).name);
			}
			return orig.Invoke(self);
		}
	}
}