Decompiled source of MoreBees v1.2.0

MoreBees.dll

Decompiled 8 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MoreBees")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreBees")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3f0c9dae-feda-4a22-8a72-6fd44834ed41")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MoreBees
{
	public static class PluginInfo
	{
		public const string modName = "MoreBees";

		public const string modVersion = "1.2.0";

		public const string modGUID = "the3venthoriz0n.MoreBees";
	}
	[BepInPlugin("the3venthoriz0n.MoreBees", "MoreBees", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource StaticLogger;

		public void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("the3venthoriz0n.MoreBees");
			try
			{
				val.PatchAll();
				StaticLogger.LogInfo((object)"MoreBees 1.2.0 is loaded.");
			}
			catch (Exception ex)
			{
				StaticLogger.LogError((object)("Failed to patch: " + ex));
			}
		}
	}
}
namespace MoreBees.Patches
{
	[HarmonyPatch]
	public class MoreBees
	{
		private static FieldInfo currentLevelField;

		static MoreBees()
		{
			currentLevelField = AccessTools.Field(typeof(RoundManager), "currentLevel");
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnDaytimeEnemiesOutside")]
		[HarmonyPrefix]
		private static void ChooseDaytimeEnemies(RoundManager __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if (currentLevelField != null)
			{
				SelectableLevel val = (SelectableLevel)currentLevelField.GetValue(__instance);
				if ((Object)(object)val != (Object)null)
				{
					val.maxDaytimeEnemyPowerCount = 70;
					List<SpawnableEnemyWithRarity> daytimeEnemies = val.DaytimeEnemies;
					Debug.LogWarning((object)$"--------------------Number of DaytimeEnemies: {daytimeEnemies.Count}");
					{
						foreach (SpawnableEnemyWithRarity item in daytimeEnemies)
						{
							if (((Object)item.enemyType).name == "RedLocustBees")
							{
								item.rarity = 100;
							}
							else
							{
								item.rarity = 0;
							}
						}
						return;
					}
				}
				Debug.LogError((object)"currentLevel is NULL");
			}
			else
			{
				Debug.LogError((object)"CurrentLevelField is NULL");
			}
		}

		[HarmonyPatch(typeof(RoundManager), "SpawnDaytimeEnemiesOutside")]
		[HarmonyPostfix]
		private static void MoreDaytimeEnemies(RoundManager __instance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			float num = 100f;
			GameObject[] array = GameObject.FindGameObjectsWithTag("OutsideAINode");
			if (!(currentLevelField != null))
			{
				return;
			}
			SelectableLevel val = (SelectableLevel)currentLevelField.GetValue(__instance);
			foreach (SpawnableEnemyWithRarity daytimeEnemy in __instance.currentLevel.DaytimeEnemies)
			{
				int num2 = (daytimeEnemy.enemyType.MaxCount = val.maxDaytimeEnemyPowerCount);
				MethodInfo methodInfo = AccessTools.Method(typeof(RoundManager), "SpawnRandomDaytimeEnemy", new Type[2]
				{
					typeof(GameObject[]),
					typeof(float)
				}, (Type[])null);
				if (!(methodInfo != null))
				{
					continue;
				}
				for (int i = 0; i < num2; i++)
				{
					object? obj = methodInfo.Invoke(__instance, new object[2] { array, num });
					GameObject val2 = (GameObject)((obj is GameObject) ? obj : null);
					if ((Object)(object)val2 != (Object)null)
					{
						Debug.LogWarning((object)"BUZZ");
						__instance.SpawnedEnemies.Add(val2.GetComponent<EnemyAI>());
						EnemyType enemyType = val2.GetComponent<EnemyAI>().enemyType;
						enemyType.numberSpawned++;
						continue;
					}
					break;
				}
			}
		}
	}
	[HarmonyPatch]
	public class MoreSprint
	{
		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		private static void MoreSprintPatch(ref float ___sprintMeter, PlayerControllerB __instance)
		{
			if ((Object)(object)__instance.currentlyHeldObjectServer != (Object)null)
			{
				string name = ((Object)__instance.currentlyHeldObjectServer).name;
				if (name == "RedLocustHive(Clone)")
				{
					___sprintMeter = 1f;
				}
			}
		}
	}
	[HarmonyPatch]
	public class MoreTentacles
	{
		[HarmonyPatch(typeof(DepositItemsDesk), "SetCompanyMood")]
		[HarmonyPostfix]
		private static void MoreTentaclesPatch(ref CompanyMood ___currentMood, ref float ___noiseBehindWallVolume)
		{
			___currentMood.desiresSilence = true;
			___currentMood.sensitivity = 10f;
			___currentMood.irritability = 10f;
			___currentMood.judgementSpeed = 10f;
			___currentMood.timeToWaitBeforeGrabbingItem = 1f;
			___currentMood.startingPatience = 0f;
			___noiseBehindWallVolume = 10f;
		}
	}
}