Decompiled source of funny v1.0.8

BepInEx/plugins/BetterLight.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using VMechLight.MonoBehaviors;

[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("VMechLight")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A manually power flashlight")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VMechLight")]
[assembly: AssemblyTitle("VMechLight")]
[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 VMechLight
{
	[BepInPlugin("versus.dynamolight", "Dynamo Flashlight", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "versus.dynamolight";

		private const string NAME = "Dynamo Flashlight";

		private const string VERSION = "1.0.0";

		public static Plugin instance;

		public static AudioClip pull1;

		public static AudioClip pull2;

		private void Awake()
		{
			instance = this;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "dynamolight");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			pull1 = val.LoadAsset<AudioClip>("Assets/DynamoLight/DynamoLight/pull1.mp3");
			pull2 = val.LoadAsset<AudioClip>("Assets/DynamoLight/DynamoLight/pull2.mp3");
			Item val2 = val.LoadAsset<Item>("Assets/DynamoLight/DynamoLight/DynamoLight.asset");
			DynamoLight dynamoLight = val2.spawnPrefab.AddComponent<DynamoLight>();
			((GrabbableObject)dynamoLight).grabbable = true;
			((GrabbableObject)dynamoLight).grabbableToEnemies = true;
			((GrabbableObject)dynamoLight).itemProperties = val2;
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			Utilities.FixMixerGroups(val2.spawnPrefab);
			Items.RegisterScrap(val2, 5, (LevelTypes)(-1));
			TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
			Items.RegisterShopItem(val2, (TerminalNode)null, (TerminalNode)null, val3, 25);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched Dynamo Flashlight");
		}
	}
}
namespace VMechLight.MonoBehaviors
{
	internal class DynamoLight : GrabbableObject
	{
		public GameObject lightlow;

		public GameObject lightmid;

		public GameObject lighthigh;

		public float battery = 0f;

		public AudioSource source;

		public override void Start()
		{
			((GrabbableObject)this).Start();
			source = ((Component)this).GetComponent<AudioSource>();
			lightlow = ((Component)((Component)this).transform.GetChild(1)).gameObject;
			lightmid = ((Component)((Component)this).transform.GetChild(2)).gameObject;
			lighthigh = ((Component)((Component)this).transform.GetChild(3)).gameObject;
		}

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (buttonDown && base.playerHeldBy.sprintMeter >= 0.1f)
			{
				battery += 10f;
				PlayerControllerB playerHeldBy = base.playerHeldBy;
				playerHeldBy.sprintMeter -= 0.1f;
				pullserver();
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 20f, 3f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
		}

		public override void Update()
		{
			((GrabbableObject)this).Update();
			flashlightserver();
		}

		[ServerRpc]
		public void pullserver()
		{
			pullclient();
		}

		[ClientRpc]
		public void pullclient()
		{
			if (battery <= 10f)
			{
				source.PlayOneShot(Plugin.pull1, 1f);
			}
			else if (battery > 10f)
			{
				source.PlayOneShot(Plugin.pull2, 1f);
			}
		}

		[ServerRpc]
		public void flashlightserver()
		{
			flashlightclient();
		}

		[ClientRpc]
		public void flashlightclient()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (battery > 0f)
			{
				if (battery <= 20f)
				{
					battery -= 0.015f;
				}
				else if (battery > 20f)
				{
					battery -= 0.0075f;
				}
				RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, 10f, 1f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			}
			if (battery > 0f && battery < 10f)
			{
				lightlow.SetActive(true);
				lightmid.SetActive(false);
				lighthigh.SetActive(false);
				base.useCooldown = 0.75f;
			}
			else if (battery > 10f && battery < 20f)
			{
				lightlow.SetActive(false);
				lightmid.SetActive(true);
				lighthigh.SetActive(false);
				base.useCooldown = 2f;
			}
			else if (battery > 20f && battery <= 30f)
			{
				lightlow.SetActive(false);
				lightmid.SetActive(false);
				lighthigh.SetActive(true);
				base.useCooldown = 15f;
			}
			else if (battery <= 0f)
			{
				lightlow.SetActive(false);
				lightmid.SetActive(false);
				lighthigh.SetActive(false);
				base.useCooldown = 0f;
			}
			if (battery > 30f)
			{
				battery = 30f;
			}
		}
	}
}

BepInEx/plugins/ChangeAI.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FairAI.Component;
using FairAI.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using LethalThings;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FairAI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FairAI")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("42deea12-f73e-4d63-81e9-5359e98c8d53")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace FairAI
{
	internal class FAIR_AI : NetworkBehaviour
	{
		public EnemyAI targetWithRotation;

		[ClientRpc]
		public void SwitchedTargetedEnemyClientRpc(Turret turret, EnemyAI enemy, bool setModeToCharging = false)
		{
			targetWithRotation = enemy;
			if (setModeToCharging)
			{
				Type typeFromHandle = typeof(Turret);
				MethodInfo method = typeFromHandle.GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
				method.Invoke(turret, new object[1] { 1 });
			}
		}

		[ClientRpc]
		public void RemoveTargetedEnemyClientRpc()
		{
			targetWithRotation = null;
		}
	}
	[BepInPlugin("GoldenKitten.FairAI", "Fair AI", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "GoldenKitten.FairAI";

		private const string modName = "Fair AI";

		private const string modVersion = "1.0.0";

		private Harmony harmony = new Harmony("GoldenKitten.FairAI");

		public static Plugin Instance;

		public static ManualLogSource logger;

		public static List<EnemyType> enemies;

		public static List<Item> items;

		public static bool playersEnteredInside = false;

		public static int wallsAndEnemyLayerMask = 524288;

		public static int enemyMask = 524288;

		public static int allHittablesMask;

		private static float onMeshThreshold = 3f;

		private void Awake()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony = new Harmony("GoldenKitten.FairAI");
			logger = Logger.CreateLogSource("GoldenKitten.FairAI");
			harmony.PatchAll(typeof(Plugin));
			logger.LogInfo((object)"Fair AI initiated!");
			CreateHarmonyPatch(harmony, typeof(RoundManager), "Start", null, typeof(RoundManagerPatch), "PatchStart", isPrefix: false);
			CreateHarmonyPatch(harmony, typeof(StartOfRound), "Start", null, typeof(StartOfRoundPatch), "PatchStart", isPrefix: false);
			CreateHarmonyPatch(harmony, typeof(StartOfRound), "Update", null, typeof(StartOfRoundPatch), "PatchUpdate", isPrefix: false);
			CreateHarmonyPatch(harmony, typeof(Turret), "Start", null, typeof(TurretAIPatch), "PatchStart", isPrefix: false);
			CreateHarmonyPatch(harmony, typeof(Turret), "Update", null, typeof(TurretAIPatch), "PatchUpdate", isPrefix: true);
			CreateHarmonyPatch(harmony, typeof(Turret), "SetTargetToPlayerBody", null, typeof(TurretAIPatch), "PatchSetTargetToPlayerBody", isPrefix: true);
			CreateHarmonyPatch(harmony, typeof(Turret), "TurnTowardsTargetIfHasLOS", null, typeof(TurretAIPatch), "PatchTurnTowardsTargetIfHasLOS", isPrefix: true);
			CreateHarmonyPatch(harmony, typeof(Landmine), "SpawnExplosion", new Type[4]
			{
				typeof(Vector3),
				typeof(bool),
				typeof(float),
				typeof(float)
			}, typeof(MineAIPatch), "PatchSpawnExplosion", isPrefix: false);
			CreateHarmonyPatch(harmony, typeof(Landmine), "OnTriggerEnter", null, typeof(MineAIPatch), "PatchOnTriggerEnter", isPrefix: false);
			CreateHarmonyPatch(harmony, typeof(Landmine), "OnTriggerExit", null, typeof(MineAIPatch), "PatchOnTriggerExit", isPrefix: false);
			CreateHarmonyPatch(harmony, typeof(Landmine), "Detonate", null, typeof(MineAIPatch), "DetonatePatch", isPrefix: false);
			if (FindType("LethalThings.RoombaAI") != null)
			{
				CreateHarmonyPatch(harmony, FindType("LethalThings.RoombaAI"), "Start", null, typeof(BoombaPatch), "PatchStart", isPrefix: false);
				CreateHarmonyPatch(harmony, FindType("LethalThings.RoombaAI"), "DoAIInterval", null, typeof(BoombaPatch), "PatchDoAIInterval", isPrefix: false);
			}
		}

		public static List<PlayerControllerB> GetActivePlayers()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				if ((Object)val != (Object)null && !val.isPlayerDead && ((Behaviour)val).isActiveAndEnabled && val.isPlayerControlled)
				{
					list.Add(val);
				}
			}
			return list;
		}

		public static bool AllowFairness(Vector3 position)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)StartOfRound.Instance != (Object)null && Can("CheckForPlayersInside"))
			{
				if (IsAPlayersOutside())
				{
					if (!(position.y > -80f))
					{
						Bounds bounds = StartOfRound.Instance.shipInnerRoomBounds.bounds;
						if (!((Bounds)(ref bounds)).Contains(position))
						{
							goto IL_005c;
						}
					}
					return true;
				}
				goto IL_005c;
			}
			return true;
			IL_005c:
			return playersEnteredInside;
		}

		public static bool IsAPlayersOutside()
		{
			List<PlayerControllerB> activePlayers = GetActivePlayers();
			for (int i = 0; i < activePlayers.Count; i++)
			{
				PlayerControllerB val = activePlayers[i];
				if (!val.isInsideFactory)
				{
					return true;
				}
			}
			return false;
		}

		public static bool IsAPlayerInsideShip()
		{
			List<PlayerControllerB> activePlayers = GetActivePlayers();
			for (int i = 0; i < activePlayers.Count; i++)
			{
				PlayerControllerB val = activePlayers[i];
				if (val.isInHangarShipRoom)
				{
					return true;
				}
			}
			return false;
		}

		public static bool IsAPlayerInsideDungeon()
		{
			List<PlayerControllerB> activePlayers = GetActivePlayers();
			for (int i = 0; i < activePlayers.Count; i++)
			{
				PlayerControllerB val = activePlayers[i];
				if (val.isInsideFactory)
				{
					return true;
				}
			}
			return false;
		}

		public static bool CanMob(string parentIdentifier, string identifier, string mobName)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			string text = RemoveInvalidCharacters(mobName).ToUpper();
			if (((BaseUnityPlugin)Instance).Config[new ConfigDefinition("Mobs", parentIdentifier)].BoxedValue.ToString().ToUpper().Equals("TRUE"))
			{
				foreach (ConfigDefinition key in ((BaseUnityPlugin)Instance).Config.Keys)
				{
					if (RemoveInvalidCharacters(key.Key.ToUpper()).Equals(RemoveInvalidCharacters(text + identifier.ToUpper())))
					{
						return ((BaseUnityPlugin)Instance).Config[key].BoxedValue.ToString().ToUpper().Equals("TRUE");
					}
				}
				return false;
			}
			return false;
		}

		public static bool Can(string identifier)
		{
			foreach (ConfigDefinition key in ((BaseUnityPlugin)Instance).Config.Keys)
			{
				if (RemoveInvalidCharacters(key.Key.ToUpper()).Equals(RemoveInvalidCharacters(identifier.ToUpper())))
				{
					return ((BaseUnityPlugin)Instance).Config[key].BoxedValue.ToString().ToUpper().Equals("TRUE");
				}
			}
			return false;
		}

		public static string RemoveWhitespaces(string source)
		{
			return string.Join("", source.Split((string[]?)null, StringSplitOptions.RemoveEmptyEntries));
		}

		public static string RemoveSpecialCharacters(string source)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (char c in source)
			{
				if ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
				{
					stringBuilder.Append(c);
				}
			}
			return stringBuilder.ToString();
		}

		public static string RemoveInvalidCharacters(string source)
		{
			return RemoveWhitespaces(RemoveSpecialCharacters(source));
		}

		public static Type FindType(string fullName)
		{
			try
			{
				if ((from a in AppDomain.CurrentDomain.GetAssemblies()
					where !a.IsDynamic
					select a).SelectMany((Assembly a) => a.GetTypes()).FirstOrDefault((Type t) => t.FullName.Equals(fullName)) != null)
				{
					return (from a in AppDomain.CurrentDomain.GetAssemblies()
						where !a.IsDynamic
						select a).SelectMany((Assembly a) => a.GetTypes()).FirstOrDefault((Type t) => t.FullName.Equals(fullName));
				}
			}
			catch
			{
				return null;
			}
			return null;
		}

		public static void CreateHarmonyPatch(Harmony harmony, Type typeToPatch, string methodToPatch, Type[] parameters, Type patchType, string patchMethod, bool isPrefix)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			if (typeToPatch == null || patchType == null)
			{
				logger.LogInfo((object)"Type is either incorrect or does not exist!");
				return;
			}
			MethodInfo methodInfo = AccessTools.Method(typeToPatch, methodToPatch, parameters, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(patchType, patchMethod, (Type[])null, (Type[])null);
			if (isPrefix)
			{
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			else
			{
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		public static bool IsAgentOnNavMesh(GameObject agentObject)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = agentObject.transform.position;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(position, ref val, onMeshThreshold, -1) && Mathf.Approximately(position.x, ((NavMeshHit)(ref val)).position.x) && Mathf.Approximately(position.z, ((NavMeshHit)(ref val)).position.z))
			{
				return position.y >= ((NavMeshHit)(ref val)).position.y;
			}
			return false;
		}

		public static bool AttackTargets(Vector3 aimPoint, Vector3 forward, float range)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			return HitTargets(GetTargets(aimPoint, forward, range), forward);
		}

		public static List<GameObject> GetTargets(Vector3 aimPoint, Vector3 forward, float range)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			List<GameObject> list = new List<GameObject>();
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(aimPoint, forward);
			RaycastHit[] array = Physics.RaycastAll(val, range, allHittablesMask, (QueryTriggerInteraction)2);
			Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
			Vector3 val2 = aimPoint + forward * range;
			IHittable val3 = default(IHittable);
			EnemyAI val6 = default(EnemyAI);
			for (int i = 0; i < array.Length; i++)
			{
				GameObject gameObject = ((Component)((RaycastHit)(ref array[i])).transform).gameObject;
				if (gameObject.TryGetComponent<IHittable>(ref val3))
				{
					EnemyAI val4 = null;
					EnemyAICollisionDetect val5 = (EnemyAICollisionDetect)(object)((val3 is EnemyAICollisionDetect) ? val3 : null);
					if (val5 != null)
					{
						val4 = val5.mainScript;
					}
					if ((Object)(object)val4 != (Object)null && (val4.isEnemyDead || val4.enemyHP <= 0 || !val4.enemyType.canDie))
					{
						continue;
					}
					if (val3 is PlayerControllerB)
					{
						list.Add(gameObject);
					}
					else
					{
						if (!((Object)(object)val4 != (Object)null))
						{
							continue;
						}
						list.Add(gameObject);
					}
					val2 = ((RaycastHit)(ref array[i])).point;
					break;
				}
				if (((Component)((RaycastHit)(ref array[i])).collider).TryGetComponent<EnemyAI>(ref val6))
				{
					if (val6.isEnemyDead || val6.enemyHP <= 0 || !val6.enemyType.canDie)
					{
						continue;
					}
					list.Add(((Component)val6).gameObject);
					val2 = ((RaycastHit)(ref array[i])).point;
					break;
				}
				val2 = ((RaycastHit)(ref array[i])).point;
				break;
			}
			return list;
		}

		public static bool HitTargets(List<GameObject> targets, Vector3 forward)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			bool hits = false;
			if (!targets.Any())
			{
				return hits;
			}
			targets.ForEach(delegate(GameObject t)
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0239: Unknown result type (might be due to invalid IL or missing references)
				//IL_0240: Expected O, but got Unknown
				//IL_0346: Unknown result type (might be due to invalid IL or missing references)
				//IL_0317: Unknown result type (might be due to invalid IL or missing references)
				//IL_031e: Expected O, but got Unknown
				//IL_0333: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_029d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)t != (Object)null)
				{
					if ((Object)(object)t.GetComponent<PlayerControllerB>() != (Object)null)
					{
						PlayerControllerB component = t.GetComponent<PlayerControllerB>();
						int num = 20;
						hits = true;
						component.DamagePlayer(num, true, true, (CauseOfDeath)7, 0, false, forward);
					}
					else if ((Object)(object)t.GetComponent<EnemyAICollisionDetect>() != (Object)null)
					{
						EnemyAICollisionDetect component2 = t.GetComponent<EnemyAICollisionDetect>();
						int num2 = 1;
						if (!component2.mainScript.isEnemyDead && ((NetworkBehaviour)component2.mainScript).IsOwner && CanMob("TurretDamageAllMobs", ".Turret Damage", component2.mainScript.enemyType.enemyName))
						{
							if (component2.mainScript is NutcrackerEnemyAI)
							{
								if (((EnemyAI)(NutcrackerEnemyAI)component2.mainScript).currentBehaviourStateIndex > 0)
								{
									component2.mainScript.HitEnemyOnLocalClient(num2, default(Vector3), (PlayerControllerB)null, false);
									hits = true;
								}
							}
							else
							{
								component2.mainScript.HitEnemyOnLocalClient(num2, default(Vector3), (PlayerControllerB)null, false);
								hits = true;
							}
						}
					}
					else if ((Object)(object)t.GetComponent<EnemyAI>() != (Object)null)
					{
						EnemyAI component3 = t.GetComponent<EnemyAI>();
						if (((NetworkBehaviour)component3).IsOwner)
						{
							int num3 = 1;
							if (CanMob("TurretDamageAllMobs", ".Turret Damage", component3.enemyType.enemyName))
							{
								if (component3 is NutcrackerEnemyAI)
								{
									if (((EnemyAI)(NutcrackerEnemyAI)component3).currentBehaviourStateIndex > 0)
									{
										component3.HitEnemyOnLocalClient(num3, default(Vector3), (PlayerControllerB)null, false);
										hits = true;
									}
								}
								else
								{
									component3.HitEnemyOnLocalClient(num3, default(Vector3), (PlayerControllerB)null, false);
									hits = true;
								}
							}
						}
					}
					else if (t.GetComponent<IHittable>() != null)
					{
						IHittable component4 = t.GetComponent<IHittable>();
						if (component4 is EnemyAICollisionDetect)
						{
							EnemyAICollisionDetect val = (EnemyAICollisionDetect)component4;
							int num4 = 1;
							if (((NetworkBehaviour)val.mainScript).IsOwner && CanMob("TurretDamageAllMobs", ".Turret Damage", val.mainScript.enemyType.enemyName))
							{
								if (val.mainScript is NutcrackerEnemyAI)
								{
									if (((EnemyAI)(NutcrackerEnemyAI)val.mainScript).currentBehaviourStateIndex > 0)
									{
										val.mainScript.HitEnemyOnLocalClient(num4, default(Vector3), (PlayerControllerB)null, false);
										hits = true;
									}
								}
								else
								{
									val.mainScript.HitEnemyOnLocalClient(num4, default(Vector3), (PlayerControllerB)null, false);
									hits = true;
								}
							}
						}
						else if (component4 is PlayerControllerB)
						{
							PlayerControllerB val2 = (PlayerControllerB)component4;
							int num5 = 33;
							hits = true;
							val2.DamagePlayer(num5, true, true, (CauseOfDeath)7, 0, false, forward);
						}
						else
						{
							component4.Hit(1, forward, (PlayerControllerB)null, true);
							hits = true;
						}
					}
				}
			});
			return hits;
		}
	}
}
namespace FairAI.Patches
{
	internal class BoombaPatch
	{
		public static void PatchStart(ref RoombaAI __instance)
		{
			((Component)__instance).gameObject.AddComponent<BoombaTimer>();
		}

		public static void PatchDoAIInterval(ref RoombaAI __instance)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.AllowFairness(((Component)__instance).transform.position) || !Plugin.IsAgentOnNavMesh(((Component)__instance).gameObject) || (((EnemyAI)__instance).currentSearch == null && !((EnemyAI)__instance).movingTowardsTargetPlayer) || (!__instance.mineAudio.isPlaying && !__instance.mineFarAudio.isPlaying) || !((Component)__instance).GetComponent<BoombaTimer>().IsActiveBomb())
			{
				return;
			}
			Vector3 val = ((Component)__instance).transform.position + Vector3.up;
			Collider[] array = Physics.OverlapSphere(val, 6f, 2621448, (QueryTriggerInteraction)2);
			for (int i = 0; i < array.Length; i++)
			{
				float num = Vector3.Distance(val, ((Component)array[i]).transform.position);
				if ((num > 4f && Physics.Linecast(val, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1)) || !((Object)(object)((Component)array[i]).gameObject.GetComponent<EnemyAICollisionDetect>() != (Object)null))
				{
					continue;
				}
				EnemyAICollisionDetect component = ((Component)array[i]).gameObject.GetComponent<EnemyAICollisionDetect>();
				if (!((Object)(object)((Component)component.mainScript).gameObject != (Object)(object)((Component)__instance).gameObject) || !Plugin.CanMob("BoombaAllMobs", ".Boomba", component.mainScript.enemyType.enemyName))
				{
					continue;
				}
				if ((Object)(object)component != (Object)null && ((NetworkBehaviour)component.mainScript).IsOwner && !component.mainScript.isEnemyDead)
				{
					Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, val, Quaternion.Euler(-90f, 0f, 0f), RoundManager.Instance.mapPropsContainer.transform).SetActive(true);
					if (num < 3f)
					{
						component.mainScript.KillEnemyOnOwnerClient(true);
					}
					else if (num < 6f)
					{
						component.mainScript.HitEnemyOnLocalClient(2, default(Vector3), (PlayerControllerB)null, false);
					}
				}
				if (((NetworkBehaviour)__instance).IsServer)
				{
					((EnemyAI)__instance).KillEnemy(true);
				}
				else
				{
					((EnemyAI)__instance).KillEnemyServerRpc(true);
				}
			}
		}
	}
	internal class EnemyAIPatch
	{
		public static void DoAIIntervalPatch(ref EnemyAI __instance)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (!(__instance is ForestGiantAI))
			{
				return;
			}
			ForestGiantAI val = (ForestGiantAI)__instance;
			if (StartOfRound.Instance.livingPlayers != 0 && !((EnemyAI)val).isEnemyDead)
			{
				int currentBehaviourStateIndex = ((EnemyAI)val).currentBehaviourStateIndex;
				int num = currentBehaviourStateIndex;
				if (num == 1)
				{
					val.investigating = false;
				}
			}
		}

		public static bool OnCollideWithEnemyPatch(ref EnemyAI __instance, Collider other)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			if (__instance is ForestGiantAI)
			{
				Type typeFromHandle = typeof(ForestGiantAI);
				ForestGiantAI val = (ForestGiantAI)__instance;
				FieldInfo field = typeFromHandle.GetField("inEatingPlayerAnimation", BindingFlags.Instance | BindingFlags.NonPublic);
				bool flag = (bool)field.GetValue(val);
				if ((Object)(object)((EnemyAI)val).inSpecialAnimationWithPlayer != (Object)null || flag || ((EnemyAI)val).stunNormalizedTimer >= 0f)
				{
					return false;
				}
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if (!((Object)(object)component != (Object)null) || !((Object)(object)component == (Object)(object)GameNetworkManager.Instance.localPlayerController))
				{
					return false;
				}
				Vector3 val2 = Vector3.Normalize((val.centerPosition.position - (((Component)GameNetworkManager.Instance.localPlayerController).transform.position + Vector3.up * 1.5f)) * 1000f);
				if (!Physics.Linecast(val.centerPosition.position + val2 * 1.7f, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position + Vector3.up * 1.5f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && ((!StartOfRound.Instance.shipIsLeaving && StartOfRound.Instance.shipHasLanded) || !GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom) && !((Object)(object)component.inAnimationWithEnemy != (Object)null))
				{
					if (component.inSpecialInteractAnimation && (Object)(object)component.currentTriggerInAnimationWith != (Object)null)
					{
						component.currentTriggerInAnimationWith.CancelAnimationExternally();
					}
					FieldInfo field2 = typeFromHandle.GetField("triggerChaseByTouchingDebounce", BindingFlags.Instance | BindingFlags.NonPublic);
					bool flag2 = (bool)field2.GetValue(val);
					if (((EnemyAI)val).currentBehaviourStateIndex == 0 && !flag2)
					{
						field2.SetValue(val, true);
						MethodInfo method = typeFromHandle.GetMethod("BeginChasingNewPlayerServerRpc", BindingFlags.Instance | BindingFlags.NonPublic);
						method.Invoke(__instance, new object[1] { (int)component.playerClientId });
					}
					else
					{
						val.GrabPlayerServerRpc((int)component.playerClientId);
					}
				}
				return false;
			}
			return true;
		}
	}
	internal class MineAIPatch
	{
		public static void PatchOnTriggerEnter(ref Landmine __instance, Collider other, ref float ___pressMineDebounceTimer)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.AllowFairness(((Component)__instance).transform.position))
			{
				EnemyAICollisionDetect component = ((Component)other).gameObject.GetComponent<EnemyAICollisionDetect>();
				if ((Object)(object)component != (Object)null && !component.mainScript.isEnemyDead && Plugin.CanMob("ExplodeAllMobs", ".Mine", component.mainScript.enemyType.enemyName.ToUpper()))
				{
					___pressMineDebounceTimer = 0.5f;
					__instance.PressMineServerRpc();
				}
			}
		}

		public static void PatchOnTriggerExit(ref Landmine __instance, Collider other, ref bool ___sendingExplosionRPC)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.AllowFairness(((Component)__instance).transform.position))
			{
				EnemyAICollisionDetect component = ((Component)other).gameObject.GetComponent<EnemyAICollisionDetect>();
				if ((Object)(object)component != (Object)null && !component.mainScript.isEnemyDead && Plugin.CanMob("ExplodeAllMobs", ".Mine", component.mainScript.enemyType.enemyName.ToUpper()) && !__instance.hasExploded)
				{
					__instance.SetOffMineAnimation();
					___sendingExplosionRPC = true;
					__instance.ExplodeMineServerRpc();
				}
			}
		}

		public static void DetonatePatch(ref Landmine __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				((MonoBehaviour)__instance).StartCoroutine(WaitForUpdate(1.5f, __instance));
			}
		}

		public static IEnumerator WaitForUpdate(float waitTime, Landmine mine)
		{
			yield return (object)new WaitForSeconds(waitTime);
			if (!((Object)(object)mine == (Object)null))
			{
				if ((Object)(object)((Component)mine).GetComponent<NetworkObject>() != (Object)null)
				{
					((Component)mine).GetComponent<NetworkObject>().Despawn(true);
				}
				else
				{
					Object.Destroy((Object)(object)((Component)mine).gameObject);
				}
			}
		}

		public static void PatchSpawnExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(explosionPosition, 6f, 2621448, (QueryTriggerInteraction)2);
			for (int i = 0; i < array.Length; i++)
			{
				float num = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
				if ((num > 4f && Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, 256, (QueryTriggerInteraction)1)) || !((Object)(object)((Component)array[i]).gameObject.GetComponent<EnemyAICollisionDetect>() != (Object)null))
				{
					continue;
				}
				EnemyAICollisionDetect component = ((Component)array[i]).gameObject.GetComponent<EnemyAICollisionDetect>();
				if ((Object)(object)component != (Object)null && ((NetworkBehaviour)component.mainScript).IsOwner && !component.mainScript.isEnemyDead)
				{
					if (num < killRange)
					{
						component.mainScript.HitEnemyOnLocalClient(component.mainScript.enemyHP, default(Vector3), (PlayerControllerB)null, false);
					}
					else if (num < damageRange)
					{
						component.mainScript.HitEnemyOnLocalClient(Mathf.RoundToInt((float)(component.mainScript.enemyHP / 2)), default(Vector3), (PlayerControllerB)null, false);
					}
				}
			}
		}
	}
	internal class RoundManagerPatch
	{
		public static void PatchStart(ref RoundManager __instance)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Expected O, but got Unknown
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Expected O, but got Unknown
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Expected O, but got Unknown
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Expected O, but got Unknown
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Expected O, but got Unknown
			Plugin.enemies = (from EnemyType e in Resources.FindObjectsOfTypeAll(typeof(EnemyType))
				where (Object)(object)e != (Object)null
				select e).ToList();
			Plugin.items = (from Item i in Resources.FindObjectsOfTypeAll(typeof(Item))
				where (Object)(object)i != (Object)null
				select i).ToList();
			Plugin.allHittablesMask = StartOfRound.Instance.collidersRoomMaskDefaultAndPlayers | 0x280008 | Plugin.enemyMask;
			if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "ExplodeAllMobs")))
			{
				ConfigEntry<bool> val = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", "ExplodeAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Set Off Mines.");
			}
			if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "BoombaAllMobs")))
			{
				ConfigEntry<bool> val2 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", "BoombaAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Set Off Boombas.");
			}
			if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "TurretTargetAllMobs")))
			{
				ConfigEntry<bool> val3 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", "TurretTargetAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Be Targeted By Turrets.");
			}
			if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "TurretDamageAllMobs")))
			{
				ConfigEntry<bool> val4 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", "TurretDamageAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Be Killed By Turrets.");
			}
			if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "CheckForPlayersInside")))
			{
				ConfigEntry<bool> val5 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", "CheckForPlayersInside", false, "Whether to check for players inside the dungeon before anything else occurs.");
			}
			foreach (EnemyType enemy in Plugin.enemies)
			{
				string text = Plugin.RemoveInvalidCharacters(enemy.enemyName);
				if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Mine")))
				{
					ConfigEntry<bool> val6 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", text + ".Mine", true, "Does it set off the landmine or not?");
				}
				if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Boomba")))
				{
					ConfigEntry<bool> val7 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", text + ".Boomba", true, "Does it set off the boomba or not?");
				}
				if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Turret Target")))
				{
					ConfigEntry<bool> val8 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", text + ".Turret Target", true, "Is it targetable by turrets?");
				}
				if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Turret Damage")))
				{
					ConfigEntry<bool> val9 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", text + ".Turret Damage", true, "Is it damageable by turrets?");
				}
			}
		}
	}
	internal class StartOfRoundPatch
	{
		public static void PatchStart(ref StartOfRound __instance)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Expected O, but got Unknown
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Expected O, but got Unknown
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Expected O, but got Unknown
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Expected O, but got Unknown
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Expected O, but got Unknown
			Plugin.enemies = (from EnemyType e in Resources.FindObjectsOfTypeAll(typeof(EnemyType))
				where (Object)(object)e != (Object)null
				select e).ToList();
			Plugin.items = (from Item i in Resources.FindObjectsOfTypeAll(typeof(Item))
				where (Object)(object)i != (Object)null
				select i).ToList();
			Plugin.allHittablesMask = StartOfRound.Instance.collidersRoomMaskDefaultAndPlayers | 0x280008 | Plugin.enemyMask;
			if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "ExplodeAllMobs")))
			{
				ConfigEntry<bool> val = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", "ExplodeAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Set Off Mines.");
			}
			if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "BoombaAllMobs")))
			{
				ConfigEntry<bool> val2 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", "BoombaAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Set Off Boombas.");
			}
			if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "TurretTargetAllMobs")))
			{
				ConfigEntry<bool> val3 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", "TurretTargetAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Be Targeted By Turrets.");
			}
			if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "TurretDamageAllMobs")))
			{
				ConfigEntry<bool> val4 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", "TurretDamageAllMobs", true, "Leave On To Customise Mobs Below Or Turn Off To Make All Mobs Unable To Be Killed By Turrets.");
			}
			if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", "CheckForPlayersInside")))
			{
				ConfigEntry<bool> val5 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", "CheckForPlayersInside", false, "Whether to check for players inside the dungeon before anything else occurs.");
			}
			foreach (EnemyType enemy in Plugin.enemies)
			{
				string text = Plugin.RemoveInvalidCharacters(enemy.enemyName);
				if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Mine")))
				{
					ConfigEntry<bool> val6 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", text + ".Mine", true, "Does it set off the landmine or not?");
				}
				if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Boomba")))
				{
					ConfigEntry<bool> val7 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", text + ".Boomba", true, "Does it set off the boomba or not?");
				}
				if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Turret Target")))
				{
					ConfigEntry<bool> val8 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", text + ".Turret Target", true, "Is it targetable by turrets?");
				}
				if (!((BaseUnityPlugin)Plugin.Instance).Config.ContainsKey(new ConfigDefinition("Mobs", text + ".Turret Damage")))
				{
					ConfigEntry<bool> val9 = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Mobs", text + ".Turret Damage", true, "Is it damageable by turrets?");
				}
			}
		}

		public static void PatchUpdate(ref StartOfRound __instance)
		{
			if (Plugin.Can("CheckForPlayersInside"))
			{
				if (__instance.shipIsLeaving)
				{
					Plugin.playersEnteredInside = false;
				}
				else
				{
					Plugin.playersEnteredInside = Plugin.IsAPlayerInsideDungeon();
				}
			}
		}
	}
	internal class TurretAIPatch
	{
		public static float viewRadius = 10f;

		public static float viewAngle = 90f;

		public static void PatchStart(ref Turret __instance)
		{
			FAIR_AI component = ((Component)__instance).gameObject.GetComponent<FAIR_AI>();
			if ((Object)(object)component == (Object)null)
			{
				component = ((Component)__instance).gameObject.AddComponent<FAIR_AI>();
			}
		}

		public static bool PatchUpdate(ref Turret __instance)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected I4, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Invalid comparison between Unknown and I4
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Invalid comparison between Unknown and I4
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Invalid comparison between Unknown and I4
			//IL_078f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0795: Invalid comparison between Unknown and I4
			//IL_09d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09db: Invalid comparison between Unknown and I4
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Invalid comparison between Unknown and O
			//IL_082b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0831: Invalid comparison between Unknown and O
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Expected O, but got Unknown
			//IL_08d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0908: Unknown result type (might be due to invalid IL or missing references)
			//IL_090d: Unknown result type (might be due to invalid IL or missing references)
			//IL_091f: Unknown result type (might be due to invalid IL or missing references)
			//IL_083e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0848: Expected O, but got Unknown
			//IL_0ddc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e10: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_0955: Unknown result type (might be due to invalid IL or missing references)
			//IL_095a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0977: Unknown result type (might be due to invalid IL or missing references)
			//IL_097c: Unknown result type (might be due to invalid IL or missing references)
			//IL_098b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c52: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bad: Invalid comparison between Unknown and O
			//IL_0ea5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ec3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ccc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cdc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ceb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc4: Expected O, but got Unknown
			if (Plugin.AllowFairness(((Component)__instance).transform.position))
			{
				FAIR_AI component = ((Component)__instance).gameObject.GetComponent<FAIR_AI>();
				Type typeFromHandle = typeof(Turret);
				if (!__instance.turretActive)
				{
					FieldInfo field = typeFromHandle.GetField("wasTargetingPlayerLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);
					field.SetValue(__instance, false);
					__instance.turretMode = (TurretMode)0;
					__instance.targetPlayerWithRotation = null;
					component.targetWithRotation = null;
					return false;
				}
				FieldInfo field2 = typeFromHandle.GetField("wasTargetingPlayerLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);
				object value = field2.GetValue(__instance);
				if ((Object)(object)__instance.targetPlayerWithRotation != (Object)null || (Object)(object)component.targetWithRotation != (Object)null)
				{
					if (!(bool)value)
					{
						field2.SetValue(__instance, true);
						if ((int)__instance.turretMode == 0)
						{
							__instance.turretMode = (TurretMode)1;
						}
					}
					MethodInfo method = typeFromHandle.GetMethod("SetTargetToPlayerBody", BindingFlags.Instance | BindingFlags.NonPublic);
					method.Invoke(__instance, null);
					MethodInfo method2 = typeFromHandle.GetMethod("TurnTowardsTargetIfHasLOS", BindingFlags.Instance | BindingFlags.NonPublic);
					method2.Invoke(__instance, null);
				}
				else if ((bool)value)
				{
					field2.SetValue(__instance, false);
					__instance.turretMode = (TurretMode)0;
				}
				FieldInfo field3 = typeFromHandle.GetField("turretModeLastFrame", BindingFlags.Instance | BindingFlags.NonPublic);
				object value2 = field3.GetValue(__instance);
				FieldInfo field4 = typeFromHandle.GetField("rotatingClockwise", BindingFlags.Instance | BindingFlags.NonPublic);
				object value3 = field4.GetValue(__instance);
				FieldInfo field5 = typeFromHandle.GetField("fadeBulletAudioCoroutine", BindingFlags.Instance | BindingFlags.NonPublic);
				object value4 = field5.GetValue(__instance);
				FieldInfo field6 = typeFromHandle.GetField("turretInterval", BindingFlags.Instance | BindingFlags.NonPublic);
				object value5 = field6.GetValue(__instance);
				FieldInfo field7 = typeFromHandle.GetField("rotatingSmoothly", BindingFlags.Instance | BindingFlags.NonPublic);
				object value6 = field7.GetValue(__instance);
				FieldInfo field8 = typeFromHandle.GetField("switchRotationTimer", BindingFlags.Instance | BindingFlags.NonPublic);
				object value7 = field8.GetValue(__instance);
				FieldInfo field9 = typeFromHandle.GetField("rotatingRight", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field10 = typeFromHandle.GetField("hasLineOfSight", BindingFlags.Instance | BindingFlags.NonPublic);
				object value8 = field10.GetValue(__instance);
				FieldInfo field11 = typeFromHandle.GetField("lostLOSTimer", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field12 = typeFromHandle.GetField("shootRay", BindingFlags.Instance | BindingFlags.NonPublic);
				object value9 = field12.GetValue(__instance);
				FieldInfo field13 = typeFromHandle.GetField("hit", BindingFlags.Instance | BindingFlags.NonPublic);
				object value10 = field13.GetValue(__instance);
				FieldInfo field14 = typeFromHandle.GetField("berserkTimer", BindingFlags.Instance | BindingFlags.NonPublic);
				object value11 = field14.GetValue(__instance);
				FieldInfo field15 = typeFromHandle.GetField("enteringBerserkMode", BindingFlags.Instance | BindingFlags.NonPublic);
				object value12 = field15.GetValue(__instance);
				TurretMode turretMode = __instance.turretMode;
				TurretMode val = turretMode;
				RaycastHit val4;
				switch ((int)val)
				{
				case 0:
					value2 = field3.GetValue(__instance);
					if ((int)(TurretMode)value2 > 0)
					{
						field3.SetValue(__instance, (object)(TurretMode)0);
						field4.SetValue(__instance, false);
						__instance.mainAudio.Stop();
						__instance.farAudio.Stop();
						__instance.berserkAudio.Stop();
						value4 = field5.GetValue(__instance);
						if ((object)(Coroutine)value4 != null)
						{
							((MonoBehaviour)__instance).StopCoroutine((Coroutine)value4);
						}
						MethodInfo method4 = typeFromHandle.GetMethod("FadeBulletAudio", BindingFlags.Instance | BindingFlags.NonPublic);
						IEnumerator enumerator = (IEnumerator)method4.Invoke(__instance, null);
						field5.SetValue(__instance, ((MonoBehaviour)__instance).StartCoroutine(enumerator));
						__instance.bulletParticles.Stop(true, (ParticleSystemStopBehavior)1);
						__instance.rotationSpeed = 28f;
						field7.SetValue(__instance, true);
						__instance.turretAnimator.SetInteger("TurretMode", 0);
						field6.SetValue(__instance, Random.Range(0f, 0.15f));
					}
					if (!((NetworkBehaviour)__instance).IsServer)
					{
						break;
					}
					if ((float)value7 >= 7f)
					{
						field8.SetValue(__instance, 0f);
						value7 = field8.GetValue(__instance);
						bool flag = !(bool)field9.GetValue(__instance);
						__instance.SwitchRotationClientRpc(flag);
						__instance.SwitchRotationOnInterval(flag);
					}
					else
					{
						field8.SetValue(__instance, (float)value7 + Time.deltaTime);
					}
					value5 = field6.GetValue(__instance);
					if ((float)value5 >= 0.25f)
					{
						field6.SetValue(__instance, 0f);
						PlayerControllerB val5 = __instance.CheckForPlayersInLineOfSight(1.35f, true);
						List<EnemyAI> actualTargets = GetActualTargets(__instance, GetTargets(__instance));
						if ((Object)(object)val5 != (Object)null && !val5.isPlayerDead)
						{
							__instance.targetPlayerWithRotation = val5;
							MethodInfo method5 = typeFromHandle.GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
							method5.Invoke(__instance, new object[1] { 1 });
							__instance.SwitchTargetedPlayerClientRpc((int)val5.playerClientId, true);
						}
						else if (actualTargets.Any())
						{
							__instance.targetPlayerWithRotation = null;
							component.targetWithRotation = actualTargets[0];
							MethodInfo method6 = typeFromHandle.GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
							method6.Invoke(__instance, new object[1] { 1 });
							component.SwitchedTargetedEnemyClientRpc(__instance, actualTargets[0], setModeToCharging: true);
						}
					}
					else
					{
						value5 = field6.GetValue(__instance);
						field6.SetValue(__instance, (float)value5 + Time.deltaTime);
					}
					break;
				case 1:
					value2 = field3.GetValue(__instance);
					if ((int)(TurretMode)value2 != 1)
					{
						field3.SetValue(__instance, (object)(TurretMode)1);
						field4.SetValue(__instance, false);
						__instance.mainAudio.PlayOneShot(__instance.detectPlayerSFX);
						__instance.berserkAudio.Stop();
						WalkieTalkie.TransmitOneShotAudio(__instance.mainAudio, __instance.detectPlayerSFX, 1f);
						__instance.rotationSpeed = 95f;
						field7.SetValue(__instance, false);
						field11.SetValue(__instance, 0f);
						__instance.turretAnimator.SetInteger("TurretMode", 1);
					}
					if (!((NetworkBehaviour)__instance).IsServer)
					{
						break;
					}
					value5 = field6.GetValue(__instance);
					if ((float)value5 >= 1.5f)
					{
						field6.SetValue(__instance, 0f);
						Debug.Log((object)"Charging timer is up, setting to firing mode");
						if (!(bool)value8)
						{
							Debug.Log((object)"hasLineOfSight is false");
							__instance.targetPlayerWithRotation = null;
							component.targetWithRotation = null;
							__instance.RemoveTargetedPlayerClientRpc();
							component.RemoveTargetedEnemyClientRpc();
						}
						else
						{
							MethodInfo method7 = typeFromHandle.GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
							method7.Invoke(__instance, new object[1] { 2 });
							__instance.SetToModeClientRpc(2);
						}
					}
					else
					{
						value5 = field6.GetValue(__instance);
						field6.SetValue(__instance, (float)value5 + Time.deltaTime);
					}
					break;
				case 2:
					value2 = field3.GetValue(__instance);
					if ((int)(TurretMode)value2 != 2)
					{
						field3.SetValue(__instance, (object)(TurretMode)2);
						__instance.berserkAudio.Stop();
						__instance.mainAudio.clip = __instance.firingSFX;
						__instance.mainAudio.Play();
						__instance.farAudio.clip = __instance.firingFarSFX;
						__instance.farAudio.Play();
						__instance.bulletParticles.Play(true);
						__instance.bulletCollisionAudio.Play();
						value4 = field5.GetValue(__instance);
						if ((object)(Coroutine)value4 != null)
						{
							((MonoBehaviour)__instance).StopCoroutine((Coroutine)value4);
						}
						__instance.bulletCollisionAudio.volume = 1f;
						field7.SetValue(__instance, false);
						field11.SetValue(__instance, 0f);
						__instance.turretAnimator.SetInteger("TurretMode", 2);
					}
					value5 = field6.GetValue(__instance);
					if ((float)value5 >= 0.21f)
					{
						field6.SetValue(__instance, 0f);
						Plugin.AttackTargets(__instance.aimPoint.position, __instance.aimPoint.forward, 30f);
						field12.SetValue(__instance, (object)new Ray(__instance.aimPoint.position, __instance.aimPoint.forward));
						RaycastHit val6 = default(RaycastHit);
						if (Physics.Raycast((Ray)value9, ref val6, 30f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
						{
							field13.SetValue(__instance, val6);
							Ray val7 = (Ray)value9;
							value10 = field13.GetValue(__instance);
							Transform transform2 = ((Component)__instance.bulletCollisionAudio).transform;
							val4 = (RaycastHit)value10;
							transform2.position = ((Ray)(ref val7)).GetPoint(((RaycastHit)(ref val4)).distance - 0.5f);
						}
					}
					else
					{
						value5 = field6.GetValue(__instance);
						field6.SetValue(__instance, (float)value5 + Time.deltaTime);
					}
					break;
				case 3:
					value2 = field3.GetValue(__instance);
					if ((int)(TurretMode)value2 != 3)
					{
						field3.SetValue(__instance, (object)(TurretMode)3);
						__instance.turretAnimator.SetInteger("TurretMode", 1);
						field14.SetValue(__instance, 1.3f);
						__instance.berserkAudio.Play();
						__instance.rotationSpeed = 77f;
						field15.SetValue(__instance, true);
						field7.SetValue(__instance, true);
						field11.SetValue(__instance, 0f);
						field2.SetValue(__instance, false);
						__instance.targetPlayerWithRotation = null;
						component.targetWithRotation = null;
					}
					value12 = field15.GetValue(__instance);
					if ((bool)value12)
					{
						value11 = field14.GetValue(__instance);
						field14.SetValue(__instance, (float)value11 - Time.deltaTime);
						value11 = field14.GetValue(__instance);
						if ((float)value11 <= 0f)
						{
							field15.SetValue(__instance, false);
							field4.SetValue(__instance, true);
							field14.SetValue(__instance, 9f);
							__instance.turretAnimator.SetInteger("TurretMode", 2);
							__instance.mainAudio.clip = __instance.firingSFX;
							__instance.mainAudio.Play();
							__instance.farAudio.clip = __instance.firingFarSFX;
							__instance.farAudio.Play();
							__instance.bulletParticles.Play(true);
							__instance.bulletCollisionAudio.Play();
							value4 = field5.GetValue(__instance);
							if ((object)(Coroutine)value4 != null)
							{
								((MonoBehaviour)__instance).StopCoroutine((Coroutine)value4);
							}
							__instance.bulletCollisionAudio.volume = 1f;
						}
						break;
					}
					value5 = field6.GetValue(__instance);
					if ((float)value5 >= 0.21f)
					{
						field6.SetValue(__instance, 0f);
						Plugin.AttackTargets(__instance.aimPoint.position, __instance.aimPoint.forward, 30f);
						field12.SetValue(__instance, (object)new Ray(__instance.aimPoint.position, __instance.aimPoint.forward));
						value9 = field12.GetValue(__instance);
						RaycastHit val2 = default(RaycastHit);
						if (Physics.Raycast((Ray)value9, ref val2, 30f, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
						{
							value9 = field12.GetValue(__instance);
							field13.SetValue(__instance, val2);
							value10 = field12.GetValue(__instance);
							Transform transform = ((Component)__instance.bulletCollisionAudio).transform;
							Ray val3 = (Ray)value9;
							val4 = (RaycastHit)value10;
							transform.position = ((Ray)(ref val3)).GetPoint(((RaycastHit)(ref val4)).distance - 0.5f);
						}
					}
					else
					{
						value5 = field6.GetValue(__instance);
						field6.SetValue(__instance, (float)value5 - Time.deltaTime);
					}
					if (((NetworkBehaviour)__instance).IsServer)
					{
						value11 = field14.GetValue(__instance);
						field14.SetValue(__instance, (float)value11 - Time.deltaTime);
						value11 = field14.GetValue(__instance);
						if ((float)value11 <= 0f)
						{
							MethodInfo method3 = typeFromHandle.GetMethod("SwitchTurretMode", BindingFlags.Instance | BindingFlags.NonPublic);
							method3.Invoke(__instance, new object[1] { 0 });
							__instance.SetToModeClientRpc(0);
						}
					}
					break;
				}
				value3 = field4.GetValue(__instance);
				if ((bool)value3)
				{
					__instance.turnTowardsObjectCompass.localEulerAngles = new Vector3(-180f, __instance.turretRod.localEulerAngles.y - Time.deltaTime * 20f, 180f);
					__instance.turretRod.rotation = Quaternion.RotateTowards(__instance.turretRod.rotation, __instance.turnTowardsObjectCompass.rotation, __instance.rotationSpeed * Time.deltaTime);
					return false;
				}
				value6 = field7.GetValue(__instance);
				if ((bool)value6)
				{
					__instance.turnTowardsObjectCompass.localEulerAngles = new Vector3(-180f, Mathf.Clamp(__instance.targetRotation, 0f - __instance.rotationRange, __instance.rotationRange), 180f);
				}
				__instance.turretRod.rotation = Quaternion.RotateTowards(__instance.turretRod.rotation, __instance.turnTowardsObjectCompass.rotation, __instance.rotationSpeed * Time.deltaTime);
			}
			return false;
		}

		public static bool PatchSetTargetToPlayerBody(ref Turret __instance)
		{
			Type typeFromHandle = typeof(Turret);
			FieldInfo field = typeFromHandle.GetField("targetingDeadPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
			object value = field.GetValue(__instance);
			if ((Object)(object)__instance.targetPlayerWithRotation != (Object)null)
			{
				if (__instance.targetPlayerWithRotation.isPlayerDead)
				{
					value = field.GetValue(__instance);
					if (!(bool)value)
					{
						field.SetValue(__instance, true);
					}
					if ((Object)(object)__instance.targetPlayerWithRotation.deadBody != (Object)null)
					{
						__instance.targetTransform = ((Component)__instance.targetPlayerWithRotation.deadBody.bodyParts[5]).transform;
					}
					FAIR_AI component = ((Component)__instance).gameObject.GetComponent<FAIR_AI>();
					if ((Object)(object)component.targetWithRotation != (Object)null)
					{
						value = field.GetValue(__instance);
						if (!(bool)value)
						{
							field.SetValue(__instance, true);
						}
						value = field.GetValue(__instance);
						if (!((Component)component.targetWithRotation).GetComponent<EnemyAI>().isEnemyDead)
						{
							field.SetValue(__instance, false);
							__instance.targetTransform = ((Component)component.targetWithRotation).transform;
						}
					}
				}
				else
				{
					field.SetValue(__instance, false);
					__instance.targetTransform = ((Component)__instance.targetPlayerWithRotation.gameplayCamera).transform;
				}
			}
			else
			{
				FAIR_AI component2 = ((Component)__instance).gameObject.GetComponent<FAIR_AI>();
				if ((Object)(object)component2.targetWithRotation != (Object)null)
				{
					value = field.GetValue(__instance);
					if (!(bool)value)
					{
						field.SetValue(__instance, true);
					}
					value = field.GetValue(__instance);
					if (!((Component)component2.targetWithRotation).GetComponent<EnemyAI>().isEnemyDead)
					{
						field.SetValue(__instance, false);
						__instance.targetTransform = ((Component)component2.targetWithRotation).transform;
					}
				}
			}
			return false;
		}

		public static bool PatchTurnTowardsTargetIfHasLOS(ref Turret __instance)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			if (TurnTowardsTargetEnemyIfHasLOS(__instance))
			{
				return false;
			}
			bool flag = true;
			Type typeFromHandle = typeof(Turret);
			FieldInfo field = typeFromHandle.GetField("targetingDeadPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
			object value = field.GetValue(__instance);
			FieldInfo field2 = typeFromHandle.GetField("hasLineOfSight", BindingFlags.Instance | BindingFlags.NonPublic);
			object value2 = field.GetValue(__instance);
			FieldInfo field3 = typeFromHandle.GetField("lostLOSTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			object value3 = field.GetValue(__instance);
			if ((bool)value || Vector3.Angle(__instance.targetTransform.position - __instance.centerPoint.position, __instance.forwardFacingPos.forward) > __instance.rotationRange)
			{
				flag = false;
			}
			if (Physics.Linecast(__instance.aimPoint.position, __instance.targetTransform.position, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
			{
				flag = false;
			}
			if (flag)
			{
				field2.SetValue(__instance, true);
				field3.SetValue(__instance, 0f);
				__instance.tempTransform.position = __instance.targetTransform.position;
				Transform tempTransform = __instance.tempTransform;
				tempTransform.position -= Vector3.up * 0.15f;
				__instance.turnTowardsObjectCompass.LookAt(__instance.tempTransform);
				return false;
			}
			value2 = field2.GetValue(__instance);
			if ((bool)value2)
			{
				field2.SetValue(__instance, false);
				field3.SetValue(__instance, 0f);
			}
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return false;
			}
			value3 = field3.GetValue(__instance);
			field3.SetValue(__instance, (float)value3 + Time.deltaTime);
			value3 = field3.GetValue(__instance);
			if ((float)value3 >= 2f)
			{
				field3.SetValue(__instance, 0f);
				Debug.Log((object)"Turret: LOS timer ended on server. checking for new player target");
				PlayerControllerB val = __instance.CheckForPlayersInLineOfSight(2f, false);
				List<EnemyAI> actualTargets = GetActualTargets(__instance, GetTargets(__instance));
				if ((Object)(object)val != (Object)null)
				{
					__instance.targetPlayerWithRotation = val;
					__instance.SwitchTargetedPlayerClientRpc((int)val.playerClientId, false);
					Debug.Log((object)"Turret: Got new player target");
				}
				else
				{
					Debug.Log((object)"Turret: No new player to target; returning to detection mode.");
					__instance.targetPlayerWithRotation = null;
					__instance.RemoveTargetedPlayerClientRpc();
				}
			}
			return false;
		}

		public static bool TurnTowardsTargetEnemyIfHasLOS(Turret turret)
		{
			//IL_0050: 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)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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_0185: Unknown result type (might be due to invalid IL or missing references)
			bool flag = true;
			Type typeFromHandle = typeof(Turret);
			FieldInfo field = typeFromHandle.GetField("targetingDeadPlayer", BindingFlags.Instance | BindingFlags.NonPublic);
			object value = field.GetValue(turret);
			FieldInfo field2 = typeFromHandle.GetField("hasLineOfSight", BindingFlags.Instance | BindingFlags.NonPublic);
			FieldInfo field3 = typeFromHandle.GetField("lostLOSTimer", BindingFlags.Instance | BindingFlags.NonPublic);
			if ((bool)value || Vector3.Angle(turret.targetTransform.position - turret.centerPoint.position, turret.forwardFacingPos.forward) > turret.rotationRange)
			{
				flag = false;
			}
			if (Physics.Linecast(turret.aimPoint.position, turret.targetTransform.position, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
			{
				flag = false;
			}
			List<EnemyAI> actualTargets = GetActualTargets(turret, GetTargets(turret));
			if (flag && actualTargets != null && actualTargets.Any())
			{
				field2.SetValue(turret, true);
				field3.SetValue(turret, 0f);
				if ((Object)(object)((Component)turret).GetComponent<FAIR_AI>() != (Object)null)
				{
					FAIR_AI component = ((Component)turret).GetComponent<FAIR_AI>();
					if ((Object)(object)component.targetWithRotation == (Object)null)
					{
						component.targetWithRotation = actualTargets[0];
					}
					turret.tempTransform.position = ((Component)component.targetWithRotation).transform.position;
					Transform tempTransform = turret.tempTransform;
					tempTransform.position -= Vector3.up * 0.15f;
					turret.turnTowardsObjectCompass.LookAt(turret.tempTransform);
				}
				return flag;
			}
			object value2 = field2.GetValue(turret);
			if ((bool)value2)
			{
				field2.SetValue(turret, false);
				field3.SetValue(turret, 0f);
			}
			if (!((NetworkBehaviour)turret).IsServer)
			{
				return false;
			}
			FAIR_AI component2 = ((Component)turret).gameObject.GetComponent<FAIR_AI>();
			List<EnemyAI> actualTargets2 = GetActualTargets(turret, GetTargets(turret));
			if (actualTargets2.Any())
			{
				component2.targetWithRotation = actualTargets2[0];
				component2.SwitchedTargetedEnemyClientRpc(turret, actualTargets2[0]);
				return true;
			}
			component2.targetWithRotation = null;
			component2.RemoveTargetedEnemyClientRpc();
			return false;
		}

		public static List<EnemyAI> GetActualTargets(Turret turret, List<EnemyAI> targets)
		{
			List<EnemyAI> list = new List<EnemyAI>();
			if (targets != null)
			{
				targets.RemoveAll((EnemyAI t) => (Object)(object)t == (Object)null);
				if (targets.Any())
				{
					foreach (EnemyAI target in targets)
					{
						if ((Object)(object)target != (Object)null && !target.isEnemyDead && Plugin.CanMob("TurretTargetAllMobs", ".Turret Target", target.enemyType.enemyName))
						{
							list.Add(target);
						}
					}
				}
			}
			return list;
		}

		private static List<EnemyAI> GetTargets(Turret turret, float radius = 2f, bool angleRangeCheck = false)
		{
			List<Transform> list = FindVisibleTargets(turret);
			List<EnemyAI> en = new List<EnemyAI>();
			if (list.Any())
			{
				list.ForEach(delegate(Transform e)
				{
					EnemyAICollisionDetect component = ((Component)e).GetComponent<EnemyAICollisionDetect>();
					EnemyAI val = ((Component)component).GetComponent<EnemyAI>();
					if ((Object)(object)component != (Object)null)
					{
						val = component.mainScript;
					}
					if ((Object)(object)val != (Object)null && Plugin.CanMob("TurretTargetAllMobs", ".Turret Target", val.enemyType.enemyName))
					{
						en.Add(val);
					}
				});
			}
			return en;
		}

		public static Vector3 DirectionFromAngle(Turret turret, float angleInDegrees, bool angleIsGlobal)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!angleIsGlobal)
			{
				angleInDegrees += ((Component)turret).transform.eulerAngles.y;
			}
			return new Vector3(Mathf.Sin(angleInDegrees * ((float)Math.PI / 180f)), 0f, Mathf.Cos(angleInDegrees * ((float)Math.PI / 180f)));
		}

		public static List<Transform> FindVisibleTargets(Turret turret)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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)
			Collider[] array = Physics.OverlapSphere(turret.aimPoint.position, viewRadius, Plugin.enemyMask);
			List<Transform> list = new List<Transform>();
			for (int i = 0; i < array.Length; i++)
			{
				Transform transform = ((Component)array[i]).transform;
				Vector3 val = transform.position - turret.aimPoint.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				if (!(Vector3.Angle(turret.aimPoint.forward, normalized) < viewAngle / 2f))
				{
					continue;
				}
				float num = Vector3.Distance(turret.aimPoint.position, transform.position);
				if (!Physics.Raycast(turret.aimPoint.position, normalized, num, ~Plugin.enemyMask))
				{
					if ((Object)(object)((Component)transform).GetComponent<EnemyAICollisionDetect>() != (Object)null && Plugin.CanMob("TurretTargetAllMobs", ".Turret Target", ((Component)transform).GetComponent<EnemyAICollisionDetect>().mainScript.enemyType.enemyName))
					{
						list.Add(transform);
					}
					if ((Object)(object)((Component)transform).GetComponent<EnemyAI>() != (Object)null && Plugin.CanMob("TurretTargetAllMobs", ".Turret Target", ((Component)transform).GetComponent<EnemyAI>().enemyType.enemyName))
					{
						list.Add(transform);
					}
				}
			}
			return list;
		}
	}
}
namespace FairAI.Component
{
	internal class BoombaTimer : MonoBehaviour
	{
		private bool isActiveBomb = false;

		private void Start()
		{
			((MonoBehaviour)this).StartCoroutine(StartBombTimer());
			Plugin.logger.LogInfo((object)"Boomba has been set active.");
		}

		public IEnumerator StartBombTimer()
		{
			SetActiveBomb(isActive: false);
			yield return (object)new WaitForSeconds(3f);
			SetActiveBomb(isActive: true);
		}

		public void SetActiveBomb(bool isActive)
		{
			isActiveBomb = isActive;
		}

		public bool IsActiveBomb()
		{
			return isActiveBomb;
		}
	}
}

BepInEx/plugins/Bodies.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using CleaningCompany.Misc;
using CleaningCompany.Monos;
using HarmonyLib;
using LethalLib.Modules;
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("SellBodies")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SellBodies")]
[assembly: AssemblyTitle("SellBodies")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class <Module>
{
	static <Module>()
	{
	}
}
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;
		}
	}
}
namespace CleaningCompany
{
	[BepInPlugin("malco.sell_bodies", "Sell Bodies", "1.0.0")]
	[BepInDependency("evaisa.lethallib", "0.10.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("malco.sell_bodies");

		private const string GUID = "malco.sell_bodies";

		private const string NAME = "Sell Bodies";

		private const string VERSION = "1.0.0";

		private static string root = "Assets/CleaningAssets/";

		private Dictionary<string, int> minBodyValues;

		private Dictionary<string, bool> BodiesToDrop;

		private Dictionary<string, int> maxBodyValues;

		private Dictionary<string, float> bodyWeights;

		private Dictionary<string, string> pathToName = new Dictionary<string, string>
		{
			{
				root + "HoarderItem.asset",
				"Hoarding bug"
			},
			{
				root + "SpiderItem.asset",
				"Bunker Spider"
			},
			{
				root + "ThumperItem.asset",
				"Crawler"
			},
			{
				root + "CentipedeItem.asset",
				"Centipede"
			},
			{
				root + "NutcrackerItem.asset",
				"Nutcracker"
			},
			{
				root + "BrackenBodyItem.asset",
				"Flowerman"
			},
			{
				root + "BaboonItem.asset",
				"Baboon hawk"
			},
			{
				root + "MouthDogItem.asset",
				"MouthDog"
			}
		};

		public Dictionary<string, Item> BodySpawns = new Dictionary<string, Item>();

		public List<GameObject> tools = new List<GameObject>();

		private AssetBundle bundle;

		public static Plugin instance;

		public static PluginConfig cfg { get; private set; }

		private void Awake()
		{
			cfg = new PluginConfig(((BaseUnityPlugin)this).Config);
			cfg.InitBindings();
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sellbodies");
			bundle = AssetBundle.LoadFromFile(text);
			instance = this;
			ApplyConfig();
			SetupScrap();
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Sell Bodies is patched!");
		}

		private void ApplyConfig()
		{
			bodyWeights = new Dictionary<string, float>
			{
				{
					root + "HoarderItem.asset",
					cfg.HOARDER_WEIGHT
				},
				{
					root + "SpiderItem.asset",
					cfg.SPIDER_WEIGHT
				},
				{
					root + "ThumperItem.asset",
					cfg.THUMPER_WEIGHT
				},
				{
					root + "NutcrackerItem.asset",
					cfg.NUTCRACKER_WEIGHT
				},
				{
					root + "CentipedeItem.asset",
					cfg.CENTIPEDE_WEIGHT
				},
				{
					root + "BrackenBodyItem.asset",
					cfg.BRACKEN_WEIGHT
				},
				{
					root + "BaboonItem.asset",
					cfg.BABOON_WEIGHT
				},
				{
					root + "MouthDogItem.asset",
					cfg.MOUTHDOG_WEIGHT
				}
			};
			maxBodyValues = new Dictionary<string, int>
			{
				{
					root + "HoarderItem.asset",
					cfg.HOARDER_MAX
				},
				{
					root + "SpiderItem.asset",
					cfg.SPIDER_MAX
				},
				{
					root + "ThumperItem.asset",
					cfg.THUMPER_MAX
				},
				{
					root + "NutcrackerItem.asset",
					cfg.NUTCRACKER_MAX
				},
				{
					root + "CentipedeItem.asset",
					cfg.CENTIPEDE_MAX
				},
				{
					root + "BrackenBodyItem.asset",
					cfg.BRACKEN_MAX
				},
				{
					root + "BaboonItem.asset",
					cfg.BABOON_MAX
				},
				{
					root + "MouthDogItem.asset",
					cfg.MOUTHDOG_MAX
				}
			};
			minBodyValues = new Dictionary<string, int>
			{
				{
					root + "HoarderItem.asset",
					cfg.HOARDER_MIN
				},
				{
					root + "SpiderItem.asset",
					cfg.SPIDER_MIN
				},
				{
					root + "ThumperItem.asset",
					cfg.THUMPER_MIN
				},
				{
					root + "NutcrackerItem.asset",
					cfg.NUTCRACKER_MIN
				},
				{
					root + "CentipedeItem.asset",
					cfg.CENTIPEDE_MIN
				},
				{
					root + "BrackenBodyItem.asset",
					cfg.BRACKEN_MIN
				},
				{
					root + "BaboonItem.asset",
					cfg.BABOON_MIN
				},
				{
					root + "MouthDogItem.asset",
					cfg.MOUTHDOG_MIN
				}
			};
			BodiesToDrop = new Dictionary<string, bool>
			{
				{
					root + "HoarderItem.asset",
					cfg.HOARDER
				},
				{
					root + "SpiderItem.asset",
					cfg.SPIDER
				},
				{
					root + "ThumperItem.asset",
					cfg.THUMPER
				},
				{
					root + "NutcrackerItem.asset",
					cfg.NUTCRACKER
				},
				{
					root + "CentipedeItem.asset",
					cfg.CENTIPEDE
				},
				{
					root + "BrackenBodyItem.asset",
					cfg.BRACKEN
				},
				{
					root + "BaboonItem.asset",
					cfg.BABOON
				},
				{
					root + "MouthDogItem.asset",
					cfg.MOUTHDOG
				}
			};
		}

		private void SetupScrap()
		{
			foreach (KeyValuePair<string, string> item in pathToName)
			{
				Item val = bundle.LoadAsset<Item>(item.Key);
				Utilities.FixMixerGroups(val.spawnPrefab);
				val.twoHanded = true;
				val.spawnPrefab.AddComponent<BodySyncer>();
				val.maxValue = maxBodyValues[item.Key];
				val.minValue = minBodyValues[item.Key];
				val.weight = bodyWeights[item.Key];
				NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
				Items.RegisterItem(val);
				if (BodiesToDrop[item.Key])
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Set " + item.Value + " to drop " + val.itemName));
					BodySpawns.Add(item.Value, val);
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Disregarding " + val.itemName + " - disabled in config"));
				}
			}
		}
	}
}
namespace CleaningCompany.Patches
{
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatcher
	{
		private static ulong currentEnemy = 9999999uL;

		[HarmonyPostfix]
		[HarmonyPatch("KillEnemyServerRpc")]
		private static void SpawnScrapBody(EnemyAI __instance)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (currentEnemy != ((NetworkBehaviour)__instance).NetworkObject.NetworkObjectId && ((NetworkBehaviour)__instance).IsHost)
			{
				currentEnemy = ((NetworkBehaviour)__instance).NetworkObject.NetworkObjectId;
				string enemyName = __instance.enemyType.enemyName;
				if (Plugin.instance.BodySpawns.ContainsKey(enemyName))
				{
					GameObject val = Object.Instantiate<GameObject>(Plugin.instance.BodySpawns[enemyName].spawnPrefab, ((Component)__instance).transform.position + Vector3.up, Quaternion.identity);
					val.GetComponent<NetworkObject>().Spawn(false);
					((Component)__instance).GetComponent<NetworkObject>().Despawn(true);
				}
			}
		}
	}
}
namespace CleaningCompany.Monos
{
	internal class BodySyncer : NetworkBehaviour
	{
		public override void OnNetworkSpawn()
		{
			if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer)
			{
				((MonoBehaviour)this).StartCoroutine(WaitToSync());
			}
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		private IEnumerator WaitToSync()
		{
			yield return (object)new WaitForSeconds(1f);
			PhysicsProp prop = ((Component)this).GetComponent<PhysicsProp>();
			int price = Random.Range(((GrabbableObject)prop).itemProperties.minValue, ((GrabbableObject)prop).itemProperties.maxValue);
			SyncDetailsClientRpc(price, new NetworkBehaviourReference((NetworkBehaviour)(object)prop));
		}

		[ClientRpc]
		private void SyncDetailsClientRpc(int price, NetworkBehaviourReference netRef)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1512427331u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, price);
				((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref netRef, default(ForNetworkSerializable));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1512427331u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				PhysicsProp val3 = default(PhysicsProp);
				((NetworkBehaviourReference)(ref netRef)).TryGet<PhysicsProp>(ref val3, (NetworkManager)null);
				if ((Object)(object)val3 != (Object)null)
				{
					((GrabbableObject)val3).scrapValue = price;
					((GrabbableObject)val3).itemProperties.creditsWorth = price;
					((Component)val3).GetComponentInChildren<ScanNodeProperties>().subText = $"Value: ${price}";
					Debug.Log((object)"Successfully synced body values");
				}
				else
				{
					Debug.LogError((object)"Failed to resolve network reference!");
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_BodySyncer()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1512427331u, new RpcReceiveHandler(__rpc_handler_1512427331));
		}

		private static void __rpc_handler_1512427331(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int price = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref price);
				NetworkBehaviourReference netRef = default(NetworkBehaviourReference);
				((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref netRef, default(ForNetworkSerializable));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((BodySyncer)(object)target).SyncDetailsClientRpc(price, netRef);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "BodySyncer";
		}
	}
}
namespace CleaningCompany.Misc
{
	public class PluginConfig
	{
		private readonly ConfigFile configFile;

		public bool SPIDER { get; set; }

		public bool THUMPER { get; set; }

		public bool NUTCRACKER { get; set; }

		public bool CENTIPEDE { get; set; }

		public bool HOARDER { get; set; }

		public bool BRACKEN { get; set; }

		public bool MOUTHDOG { get; set; }

		public bool BABOON { get; set; }

		public int SPIDER_MIN { get; set; }

		public int THUMPER_MIN { get; set; }

		public int NUTCRACKER_MIN { get; set; }

		public int CENTIPEDE_MIN { get; set; }

		public int HOARDER_MIN { get; set; }

		public int BRACKEN_MIN { get; set; }

		public int MOUTHDOG_MIN { get; set; }

		public int BABOON_MIN { get; set; }

		public int NUTCRACKER_MAX { get; set; }

		public int SPIDER_MAX { get; set; }

		public int THUMPER_MAX { get; set; }

		public int CENTIPEDE_MAX { get; set; }

		public int HOARDER_MAX { get; set; }

		public int BRACKEN_MAX { get; set; }

		public int MOUTHDOG_MAX { get; set; }

		public int BABOON_MAX { get; set; }

		public float NUTCRACKER_WEIGHT { get; set; }

		public float SPIDER_WEIGHT { get; set; }

		public float THUMPER_WEIGHT { get; set; }

		public float CENTIPEDE_WEIGHT { get; set; }

		public float HOARDER_WEIGHT { get; set; }

		public float BRACKEN_WEIGHT { get; set; }

		public float MOUTHDOG_WEIGHT { get; set; }

		public float BABOON_WEIGHT { get; set; }

		public PluginConfig(ConfigFile cfg)
		{
			configFile = cfg;
		}

		private T ConfigEntry<T>(string section, string key, T defaultVal, string description)
		{
			return configFile.Bind<T>(section, key, defaultVal, description).Value;
		}

		public void InitBindings()
		{
			CENTIPEDE_MIN = ConfigEntry("Body Values", "Min price of Centipede Bodies", 45, "");
			CENTIPEDE_MAX = ConfigEntry("Body Values", "Max price of Centipede Bodies", 70, "");
			HOARDER_MIN = ConfigEntry("Body Values", "Min price of Hoarding Bug Bodies", 55, "");
			HOARDER_MAX = ConfigEntry("Body Values", "Max price of Hoarding Bug Bodies", 88, "");
			SPIDER_MIN = ConfigEntry("Body Values", "Min price of Spider Bodies", 70, "");
			SPIDER_MAX = ConfigEntry("Body Values", "Max price of Spider Bodies", 110, "");
			THUMPER_MIN = ConfigEntry("Body Values", "Min price of Thumper Bodies", 120, "");
			THUMPER_MAX = ConfigEntry("Body Values", "Max price of Thumper Bodies", 160, "");
			NUTCRACKER_MIN = ConfigEntry("Body Values", "Min price of Nutcracker Bodies", 125, "");
			NUTCRACKER_MAX = ConfigEntry("Body Values", "Max price of Nutcracker Bodies", 150, "");
			BRACKEN_MAX = ConfigEntry("Body Values", "Max price of Bracken Bodies", 140, "");
			BRACKEN_MIN = ConfigEntry("Body Values", "Min price of Bracken Bodies", 100, "");
			BRACKEN_MAX = ConfigEntry("Body Values", "Max price of Baboon Hawk Bodies", 155, "");
			BABOON_MIN = ConfigEntry("Body Values", "Min price of Baboon Hawk Bodies", 105, "");
			MOUTHDOG_MAX = ConfigEntry("Body Values", "Max price of Eyeless Dog Bodies", 200, "");
			MOUTHDOG_MIN = ConfigEntry("Body Values", "Min price of Eyeless Dog Bodies", 175, "");
			CENTIPEDE = ConfigEntry("Body Weights", "Enable selling of centipede bodies", defaultVal: true, "");
			HOARDER = ConfigEntry("Body Weights", "Enable selling of hoarder bodies", defaultVal: true, "");
			SPIDER = ConfigEntry("Body Weights", "Enable selling of spider bodies", defaultVal: true, "");
			THUMPER = ConfigEntry("Body Weights", "Enable selling of crawler / half / thumper bodies", defaultVal: true, "");
			NUTCRACKER = ConfigEntry("Body Weights", "Enable selling of nutcracker bodies", defaultVal: true, "");
			MOUTHDOG = ConfigEntry("Body Weights", "Enable selling of eyeless dog bodies", defaultVal: true, "");
			BABOON = ConfigEntry("Body Weights", "Enable selling of baboon hawk bodies", defaultVal: true, "");
			BRACKEN = ConfigEntry("Body Weights", "Enable selling of bracken bodies", defaultVal: true, "");
			CENTIPEDE_WEIGHT = ConfigEntry("Body Weights", "Weight of Centipede Bodies", 1.65f, "");
			HOARDER_WEIGHT = ConfigEntry("Body Weights", "Weight of Hoarding Bug Bodies", 1.6f, "");
			SPIDER_WEIGHT = ConfigEntry("Body Weights", "Weight of Spider Bodies", 2.3f, "");
			THUMPER_WEIGHT = ConfigEntry("Body Weights", "Weight of Thumper Bodies", 2.9f, "");
			NUTCRACKER_WEIGHT = ConfigEntry("Body Weights", "Weight of Nutcracker Bodies", 2.9f, "");
			MOUTHDOG_WEIGHT = ConfigEntry("Body Weights", "Weight of Eyeless Dog Bodies", 3f, "");
			BABOON_WEIGHT = ConfigEntry("Body Weights", "Weight of Baboon Hawk Bodies", 2.5f, "");
			BRACKEN_WEIGHT = ConfigEntry("Body Weights", "Weight of Bracken Bodies", 1.9f, "");
		}
	}
}