Decompiled source of Plagues Of Evil v1.0.4

bcs4313_Plagues_Of_Evil.dll

Decompiled 8 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using On;
using On.GameNetcodeStuff;
using PlaguesOfDoom.src.Soul_Devourer;
using PlaguesOfDoom.src.Soul_Devourer.PlaguesOfDoom;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using bcs4313_Plagues_Of_Evil.NetcodePatcher;

[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("bcs4313")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Evil Plagues for Lethal Company.")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d281c8602246f8fa3bf4536ffca3fe971b0d7508")]
[assembly: AssemblyProduct("Plagues")]
[assembly: AssemblyTitle("bcs4313_Plagues_Of_Evil")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 SoulDev
{
	internal class EntityWarp
	{
		public struct entrancePack
		{
			public EntranceTeleport tele;

			public Vector3 navPosition;
		}

		public static EntranceTeleport[] mapEntrances;

		public static entrancePack findNearestEntrance(EnemyAI __instance)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_0057: 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)
			float num = 100000000f;
			EntranceTeleport val = null;
			EntranceTeleport[] array = mapEntrances;
			for (int i = 0; i < array.Length; i++)
			{
				if (__instance.isOutside == array[i].isEntranceToBuilding && Vector3.Distance(((Component)__instance).transform.position, ((Component)array[i]).transform.position) < num)
				{
					num = Vector3.Distance(((Component)__instance).transform.position, ((Component)array[i]).transform.position);
					val = array[i];
				}
			}
			entrancePack result = default(entrancePack);
			NavMeshHit val2 = default(NavMeshHit);
			if ((Object)(object)val != (Object)null && NavMesh.SamplePosition(((Component)val).transform.position, ref val2, 10f, -1))
			{
				result.navPosition = ((NavMeshHit)(ref val2)).position;
			}
			result.tele = val;
			return result;
		}

		public static void SendEnemyInside(EnemyAI __instance)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			__instance.isOutside = false;
			__instance.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
			EntranceTeleport tele = findNearestEntrance(__instance).tele;
			if (!Object.op_Implicit((Object)(object)tele))
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find entrance teleport.");
			}
			Transform entrancePoint = tele.entrancePoint;
			if (!Object.op_Implicit((Object)(object)entrancePoint))
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find best exit position.");
			}
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)entrancePoint).transform.position, ref val, 10f, -1))
			{
				__instance.serverPosition = ((NavMeshHit)(ref val)).position;
				((Component)__instance).transform.position = ((NavMeshHit)(ref val)).position;
				__instance.agent.Warp(__instance.serverPosition);
				__instance.SyncPositionToClients();
			}
			else
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find exit NavmeshHit position");
			}
		}

		public static void SendEnemyOutside(EnemyAI __instance, bool SpawnOnDoor = true)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			__instance.isOutside = true;
			__instance.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			EntranceTeleport tele = findNearestEntrance(__instance).tele;
			if (!Object.op_Implicit((Object)(object)tele))
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find entrance teleport.");
			}
			Transform entrancePoint = tele.entrancePoint;
			if (!Object.op_Implicit((Object)(object)entrancePoint))
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find best exit position.");
			}
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)entrancePoint).transform.position, ref val, 10f, -1))
			{
				__instance.serverPosition = ((NavMeshHit)(ref val)).position;
				((Component)__instance).transform.position = ((NavMeshHit)(ref val)).position;
				__instance.agent.Warp(__instance.serverPosition);
				__instance.SyncPositionToClients();
			}
			else
			{
				Debug.LogError((object)"MOAI EntranceTeleport: Failed to find exit NavmeshHit position");
			}
		}
	}
}
namespace PlaguesOfDoom
{
	[BepInPlugin("bcs4313_Plagues_Of_Evil", "Plagues", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static class Assets
		{
			public static AssetBundle MainAssetBundle;

			public static void PopulateAssets()
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				MainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "bcs_plaguesofdoom"));
				if ((Object)(object)MainAssetBundle == (Object)null)
				{
					Logger.LogError((object)"Failed to load custom assets.");
				}
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_SetPlanetsWeather <>9__5_0;

			public static hook_LoadNewLevel <>9__5_1;

			public static hook_OnHourChanged <>9__5_2;

			public static hook_OnCollideWithPlayer <>9__5_3;

			public static hook_DamagePlayerClientRpc <>9__5_4;

			public static hook_ItemActivate <>9__5_5;

			internal void <Awake>b__5_0(orig_SetPlanetsWeather orig, StartOfRound self, int connectedPlayersOnServer)
			{
				orig.Invoke(self, connectedPlayersOnServer);
				try
				{
					PlagueInfectionHUD.EnsureExists();
					PlagueStatus.Cure();
					PoopPlague[] array = Object.FindObjectsOfType<PoopPlague>();
					foreach (PoopPlague poopPlague in array)
					{
						Object.Destroy((Object)(object)((Component)poopPlague).gameObject);
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("Plagues of Evil Error: " + ex.ToString()));
				}
			}

			internal void <Awake>b__5_1(orig_LoadNewLevel orig, RoundManager self, int randomSeed, SelectableLevel newLevel)
			{
				orig.Invoke(self, randomSeed, newLevel);
				try
				{
					PlagueInfectionHUD.EnsureExists();
					PlagueStatus.Cure();
					PoopPlague[] array = Object.FindObjectsOfType<PoopPlague>();
					foreach (PoopPlague poopPlague in array)
					{
						Object.Destroy((Object)(object)((Component)poopPlague).gameObject);
					}
					if (((NetworkBehaviour)RoundManager.Instance).IsHost && (Object)(object)NetRelay == (Object)null)
					{
						NetRelay = Object.Instantiate<GameObject>(NetRelayPrefab);
						NetRelay.GetComponent<NetworkObject>().Spawn(false);
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("Plagues of Evil Error: " + ex.ToString()));
				}
			}

			internal void <Awake>b__5_2(orig_OnHourChanged orig, TimeOfDay self, int amount)
			{
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self, amount);
				if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
				{
					return;
				}
				try
				{
					if (!((float)Random.Range(0, 100) < infectionChance.Value))
					{
						return;
					}
					<>c__DisplayClass5_0 CS$<>8__locals2 = new <>c__DisplayClass5_0
					{
						plagues = Object.FindObjectsOfType<PoopPlague>()
					};
					EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>().Where(delegate(EnemyAI enemy)
					{
						<>c__DisplayClass5_1 CS$<>8__locals3 = new <>c__DisplayClass5_1
						{
							enemy = enemy
						};
						return !CS$<>8__locals2.plagues.Any((PoopPlague p) => p.IsRiding(CS$<>8__locals3.enemy));
					}).ToArray();
					if (array.Length != 0)
					{
						Vector3 position = ((Component)array[Random.RandomRangeInt(0, array.Length)]).transform.position;
						SpawnPoopPlague(position);
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)ex);
				}
			}

			internal void <Awake>b__5_3(orig_OnCollideWithPlayer orig, EnemyAI self, Collider other)
			{
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass5_2 CS$<>8__locals11 = new <>c__DisplayClass5_2
				{
					self = self
				};
				orig.Invoke(CS$<>8__locals11.self, other);
				try
				{
					if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
					{
						if (!lastRelaySent.TryGetValue(((NetworkBehaviour)CS$<>8__locals11.self).NetworkObjectId, out var value) || !(Time.time - value < relayCooldown))
						{
							lastRelaySent[((NetworkBehaviour)CS$<>8__locals11.self).NetworkObjectId] = Time.time;
							if (!Object.op_Implicit((Object)(object)NetRelay))
							{
								NetRelay = ((Component)Object.FindObjectsOfType<PlagueNetRelay>()[0]).gameObject;
							}
							NetRelay.GetComponent<PlagueNetRelay>().RelayCollisionServerRpc(((NetworkBehaviour)CS$<>8__locals11.self).NetworkObjectId);
						}
						return;
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)("Plagues of Evil: Client Net Relay Error -> " + ex.ToString()));
				}
				CS$<>8__locals11.player = null;
				float num = float.MaxValue;
				PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
				foreach (PlayerControllerB val in allPlayerScripts)
				{
					if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead)
					{
						float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)CS$<>8__locals11.self).transform.position);
						if (num2 < num)
						{
							num = num2;
							CS$<>8__locals11.player = val;
						}
					}
				}
				if (!((Object)(object)CS$<>8__locals11.player == (Object)null))
				{
					List<PoopPlague> plagues = PoopPlague.plagues;
					bool flag = plagues.Any((PoopPlague p) => p.IsRiding(CS$<>8__locals11.self));
					bool flag2 = plagues.Any((PoopPlague p) => p.IsRiding(CS$<>8__locals11.player));
					if (flag && !flag2)
					{
						SpawnPoopPlague(((Component)CS$<>8__locals11.player).transform.position);
					}
				}
			}

			internal void <Awake>b__5_4(orig_DamagePlayerClientRpc orig, PlayerControllerB self, int damageNumber, int newHealthAmount)
			{
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
				<>c__DisplayClass5_3 CS$<>8__locals6 = new <>c__DisplayClass5_3();
				orig.Invoke(self, damageNumber, newHealthAmount);
				if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
				{
					return;
				}
				CS$<>8__locals6.player = null;
				float num = float.MaxValue;
				PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
				foreach (PlayerControllerB val in allPlayerScripts)
				{
					if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !val.isPlayerDead)
					{
						float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)self).transform.position);
						if (num2 < num)
						{
							num = num2;
							CS$<>8__locals6.player = val;
						}
					}
				}
				if ((Object)(object)CS$<>8__locals6.player == (Object)null)
				{
					return;
				}
				List<EnemyAI> list = new List<EnemyAI>();
				EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>();
				foreach (EnemyAI val2 in array)
				{
					if (Vector3.Distance(((Component)val2).transform.position, ((Component)CS$<>8__locals6.player).transform.position) < infectionDistanceThreshold * MeasureMonsterScale(val2))
					{
						list.Add(val2);
					}
				}
				PoopPlague[] source = Object.FindObjectsOfType<PoopPlague>();
				using List<EnemyAI>.Enumerator enumerator = list.GetEnumerator();
				while (enumerator.MoveNext())
				{
					bool flag = source.Any(new <>c__DisplayClass5_4
					{
						monster = enumerator.Current
					}.<Awake>b__10);
					bool flag2 = source.Any((PoopPlague p) => p.IsRiding(CS$<>8__locals6.player));
					if (flag && !flag2)
					{
						SpawnPoopPlague(((Component)CS$<>8__locals6.player).transform.position);
					}
				}
			}

			internal void <Awake>b__5_5(orig_ItemActivate orig, TetraChemicalItem self, bool used, bool buttonDown)
			{
				orig.Invoke(self, used, buttonDown);
				try
				{
					PlayerControllerB localPlayerController = RoundManager.Instance.playersManager.localPlayerController;
					if (!((Object)(object)((GrabbableObject)self).playerHeldBy == (Object)(object)RoundManager.Instance.playersManager.localPlayerController) || !PlagueStatus.VirusName.Equals("Diarrhea Diabolica") || !PlagueStatus.IsLocalPlayerInfected || !(localPlayerController.drunkness > 0.72f))
					{
						return;
					}
					Debug.Log((object)"Plagues of Evil: Diarrhea Diabolica Cure attempted");
					PlagueStatus.Cure();
					PoopPlague[] array = Object.FindObjectsOfType<PoopPlague>();
					foreach (PoopPlague poopPlague in array)
					{
						if ((Object)(object)poopPlague.playerVictim == (Object)(object)localPlayerController)
						{
							if (((NetworkBehaviour)RoundManager.Instance).IsHost)
							{
								Object.Destroy((Object)(object)((Component)poopPlague).gameObject);
							}
							else
							{
								poopPlague.DestroySelfServerRpc();
							}
						}
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("Plagues of Evil: Error with TZP Inhalant: error -> " + ex.ToString()));
				}
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass5_0
		{
			public PoopPlague[] plagues;

			internal bool <Awake>b__6(EnemyAI enemy)
			{
				<>c__DisplayClass5_1 CS$<>8__locals1 = new <>c__DisplayClass5_1
				{
					enemy = enemy
				};
				return !plagues.Any((PoopPlague p) => p.IsRiding(CS$<>8__locals1.enemy));
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass5_1
		{
			public EnemyAI enemy;

			internal bool <Awake>b__7(PoopPlague p)
			{
				return p.IsRiding(enemy);
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass5_2
		{
			public EnemyAI self;

			public PlayerControllerB player;

			internal bool <Awake>b__8(PoopPlague p)
			{
				return p.IsRiding(self);
			}

			internal bool <Awake>b__9(PoopPlague p)
			{
				return p.IsRiding(player);
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass5_3
		{
			public PlayerControllerB player;

			public Func<PoopPlague, bool> <>9__11;

			internal bool <Awake>b__11(PoopPlague p)
			{
				return p.IsRiding(player);
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass5_4
		{
			public EnemyAI monster;

			internal bool <Awake>b__10(PoopPlague p)
			{
				return p.IsRiding(monster);
			}
		}

		public static Harmony _harmony;

		public static ManualLogSource Logger;

		public static GameObject PoopPlagueGO;

		public static GameObject NetRelay;

		public static GameObject NetRelayPrefab;

		public static float relayCooldown = 0.5f;

		public static Dictionary<ulong, float> lastRelaySent = new Dictionary<ulong, float>();

		public static float infectionDistanceThreshold = 1f;

		public static float playerReferenceHeight = 2f;

		public static ConfigEntry<float> infectionChance;

		private void Awake()
		{
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_00bb: 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_00c6: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			//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_00eb: Expected O, but got Unknown
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Expected O, but got Unknown
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Assets.PopulateAssets();
			bindVars();
			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);
					}
				}
			}
			Random.InitState((int)DateTime.Now.Ticks);
			object obj = <>c.<>9__5_0;
			if (obj == null)
			{
				hook_SetPlanetsWeather val = delegate(orig_SetPlanetsWeather orig, StartOfRound self, int connectedPlayersOnServer)
				{
					orig.Invoke(self, connectedPlayersOnServer);
					try
					{
						PlagueInfectionHUD.EnsureExists();
						PlagueStatus.Cure();
						PoopPlague[] array3 = Object.FindObjectsOfType<PoopPlague>();
						foreach (PoopPlague poopPlague in array3)
						{
							Object.Destroy((Object)(object)((Component)poopPlague).gameObject);
						}
					}
					catch (Exception ex2)
					{
						Debug.LogError((object)("Plagues of Evil Error: " + ex2.ToString()));
					}
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			StartOfRound.SetPlanetsWeather += (hook_SetPlanetsWeather)obj;
			object obj2 = <>c.<>9__5_1;
			if (obj2 == null)
			{
				hook_LoadNewLevel val2 = delegate(orig_LoadNewLevel orig, RoundManager self, int randomSeed, SelectableLevel newLevel)
				{
					orig.Invoke(self, randomSeed, newLevel);
					try
					{
						PlagueInfectionHUD.EnsureExists();
						PlagueStatus.Cure();
						PoopPlague[] array3 = Object.FindObjectsOfType<PoopPlague>();
						foreach (PoopPlague poopPlague in array3)
						{
							Object.Destroy((Object)(object)((Component)poopPlague).gameObject);
						}
						if (((NetworkBehaviour)RoundManager.Instance).IsHost && (Object)(object)NetRelay == (Object)null)
						{
							NetRelay = Object.Instantiate<GameObject>(NetRelayPrefab);
							NetRelay.GetComponent<NetworkObject>().Spawn(false);
						}
					}
					catch (Exception ex2)
					{
						Debug.LogError((object)("Plagues of Evil Error: " + ex2.ToString()));
					}
				};
				<>c.<>9__5_1 = val2;
				obj2 = (object)val2;
			}
			RoundManager.LoadNewLevel += (hook_LoadNewLevel)obj2;
			try
			{
				PoopPlagueGO = Assets.MainAssetBundle.LoadAsset<GameObject>("FartPlague");
				NetworkPrefabs.RegisterNetworkPrefab(PoopPlagueGO);
				NetRelayPrefab = Assets.MainAssetBundle.LoadAsset<GameObject>("bcs_PlagueNetRelay");
				NetworkPrefabs.RegisterNetworkPrefab(NetRelayPrefab);
				Debug.Log((object)("Plagues of Evil loaded! -> " + (object)NetRelayPrefab));
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("Error initializing Plagues of Doom: error -> " + ex.ToString()));
			}
			object obj3 = <>c.<>9__5_2;
			if (obj3 == null)
			{
				hook_OnHourChanged val3 = delegate(orig_OnHourChanged orig, TimeOfDay self, int amount)
				{
					//IL_0080: Unknown result type (might be due to invalid IL or missing references)
					//IL_0085: Unknown result type (might be due to invalid IL or missing references)
					//IL_0087: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(self, amount);
					if (((NetworkBehaviour)RoundManager.Instance).IsHost)
					{
						try
						{
							if ((float)Random.Range(0, 100) < infectionChance.Value)
							{
								PoopPlague[] plagues = Object.FindObjectsOfType<PoopPlague>();
								EnemyAI[] array3 = (from enemy in Object.FindObjectsOfType<EnemyAI>()
									where !plagues.Any((PoopPlague p) => p.IsRiding(enemy))
									select enemy).ToArray();
								if (array3.Length != 0)
								{
									Vector3 position = ((Component)array3[Random.RandomRangeInt(0, array3.Length)]).transform.position;
									SpawnPoopPlague(position);
								}
							}
						}
						catch (Exception ex2)
						{
							Debug.LogError((object)ex2);
						}
					}
				};
				<>c.<>9__5_2 = val3;
				obj3 = (object)val3;
			}
			TimeOfDay.OnHourChanged += (hook_OnHourChanged)obj3;
			object obj4 = <>c.<>9__5_3;
			if (obj4 == null)
			{
				hook_OnCollideWithPlayer val4 = delegate(orig_OnCollideWithPlayer orig, EnemyAI self, Collider other)
				{
					//IL_0144: Unknown result type (might be due to invalid IL or missing references)
					//IL_0154: Unknown result type (might be due to invalid IL or missing references)
					//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(self, other);
					try
					{
						if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
						{
							if (!lastRelaySent.TryGetValue(((NetworkBehaviour)self).NetworkObjectId, out var value) || !(Time.time - value < relayCooldown))
							{
								lastRelaySent[((NetworkBehaviour)self).NetworkObjectId] = Time.time;
								if (!Object.op_Implicit((Object)(object)NetRelay))
								{
									NetRelay = ((Component)Object.FindObjectsOfType<PlagueNetRelay>()[0]).gameObject;
								}
								NetRelay.GetComponent<PlagueNetRelay>().RelayCollisionServerRpc(((NetworkBehaviour)self).NetworkObjectId);
							}
							return;
						}
					}
					catch (Exception ex2)
					{
						Debug.Log((object)("Plagues of Evil: Client Net Relay Error -> " + ex2.ToString()));
					}
					PlayerControllerB player = null;
					float num = float.MaxValue;
					PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
					foreach (PlayerControllerB val7 in allPlayerScripts)
					{
						if (!((Object)(object)val7 == (Object)null) && val7.isPlayerControlled && !val7.isPlayerDead)
						{
							float num2 = Vector3.Distance(((Component)val7).transform.position, ((Component)self).transform.position);
							if (num2 < num)
							{
								num = num2;
								player = val7;
							}
						}
					}
					if (!((Object)(object)player == (Object)null))
					{
						List<PoopPlague> plagues = PoopPlague.plagues;
						bool flag = plagues.Any((PoopPlague p) => p.IsRiding(self));
						bool flag2 = plagues.Any((PoopPlague p) => p.IsRiding(player));
						if (flag && !flag2)
						{
							SpawnPoopPlague(((Component)player).transform.position);
						}
					}
				};
				<>c.<>9__5_3 = val4;
				obj4 = (object)val4;
			}
			EnemyAI.OnCollideWithPlayer += (hook_OnCollideWithPlayer)obj4;
			object obj5 = <>c.<>9__5_4;
			if (obj5 == null)
			{
				hook_DamagePlayerClientRpc val5 = delegate(orig_DamagePlayerClientRpc orig, PlayerControllerB self, int damageNumber, int newHealthAmount)
				{
					//IL_0083: Unknown result type (might be due to invalid IL or missing references)
					//IL_008e: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
					//IL_0108: Unknown result type (might be due to invalid IL or missing references)
					//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(self, damageNumber, newHealthAmount);
					if (((NetworkBehaviour)RoundManager.Instance).IsHost)
					{
						PlayerControllerB player = null;
						float num = float.MaxValue;
						PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
						foreach (PlayerControllerB val7 in allPlayerScripts)
						{
							if (!((Object)(object)val7 == (Object)null) && val7.isPlayerControlled && !val7.isPlayerDead)
							{
								float num2 = Vector3.Distance(((Component)val7).transform.position, ((Component)self).transform.position);
								if (num2 < num)
								{
									num = num2;
									player = val7;
								}
							}
						}
						if (!((Object)(object)player == (Object)null))
						{
							List<EnemyAI> list = new List<EnemyAI>();
							EnemyAI[] array3 = Object.FindObjectsOfType<EnemyAI>();
							foreach (EnemyAI val8 in array3)
							{
								if (Vector3.Distance(((Component)val8).transform.position, ((Component)player).transform.position) < infectionDistanceThreshold * MeasureMonsterScale(val8))
								{
									list.Add(val8);
								}
							}
							PoopPlague[] source = Object.FindObjectsOfType<PoopPlague>();
							foreach (EnemyAI monster in list)
							{
								bool flag = source.Any((PoopPlague p) => p.IsRiding(monster));
								bool flag2 = source.Any((PoopPlague p) => p.IsRiding(player));
								if (flag && !flag2)
								{
									SpawnPoopPlague(((Component)player).transform.position);
								}
							}
						}
					}
				};
				<>c.<>9__5_4 = val5;
				obj5 = (object)val5;
			}
			PlayerControllerB.DamagePlayerClientRpc += (hook_DamagePlayerClientRpc)obj5;
			object obj6 = <>c.<>9__5_5;
			if (obj6 == null)
			{
				hook_ItemActivate val6 = delegate(orig_ItemActivate orig, TetraChemicalItem self, bool used, bool buttonDown)
				{
					orig.Invoke(self, used, buttonDown);
					try
					{
						PlayerControllerB localPlayerController = RoundManager.Instance.playersManager.localPlayerController;
						if ((Object)(object)((GrabbableObject)self).playerHeldBy == (Object)(object)RoundManager.Instance.playersManager.localPlayerController && PlagueStatus.VirusName.Equals("Diarrhea Diabolica") && PlagueStatus.IsLocalPlayerInfected && localPlayerController.drunkness > 0.72f)
						{
							Debug.Log((object)"Plagues of Evil: Diarrhea Diabolica Cure attempted");
							PlagueStatus.Cure();
							PoopPlague[] array3 = Object.FindObjectsOfType<PoopPlague>();
							foreach (PoopPlague poopPlague in array3)
							{
								if ((Object)(object)poopPlague.playerVictim == (Object)(object)localPlayerController)
								{
									if (((NetworkBehaviour)RoundManager.Instance).IsHost)
									{
										Object.Destroy((Object)(object)((Component)poopPlague).gameObject);
									}
									else
									{
										poopPlague.DestroySelfServerRpc();
									}
								}
							}
						}
					}
					catch (Exception ex2)
					{
						Debug.LogError((object)("Plagues of Evil: Error with TZP Inhalant: error -> " + ex2.ToString()));
					}
				};
				<>c.<>9__5_5 = val6;
				obj6 = (object)val6;
			}
			TetraChemicalItem.ItemActivate += (hook_ItemActivate)obj6;
			PlagueSpawnerConfig.Init(((BaseUnityPlugin)this).Config);
		}

		public static void SpawnPoopPlague(Vector3 pos)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(PoopPlagueGO, pos, Quaternion.identity);
			val.GetComponent<NetworkObject>().Spawn(false);
		}

		public static float MeasureMonsterScale(EnemyAI mob)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0070: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mob == (Object)null)
			{
				return 1f;
			}
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			Collider[] componentsInChildren = ((Component)mob).GetComponentsInChildren<Collider>();
			foreach (Collider val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null))
				{
					Bounds bounds = val.bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					num3 = Mathf.Max(num3, size.y);
					num4 = Mathf.Max(num4, Mathf.Max(size.x, size.z));
					if (!val.isTrigger)
					{
						num = Mathf.Max(num, size.y);
						num2 = Mathf.Max(num2, Mathf.Max(size.x, size.z));
					}
				}
			}
			if (num <= 0.01f)
			{
				num = num3;
				num2 = num4;
			}
			if (num <= 0.01f)
			{
				return 1f;
			}
			float num5 = num / playerReferenceHeight;
			float num6 = num2 / playerReferenceHeight;
			return Mathf.Clamp(Mathf.Sqrt(num5 * num6), 0.5f, 6f);
		}

		public void bindVars()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0042: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0054: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			infectionChance = ((BaseUnityPlugin)this).Config.Bind<float>("Diarrhea Diabolica", "Enemy Infection Chance", 3.1f, "% Chance for an enemy to be randomly infected every lethal company hour. The illness can spread to players if the enemy contacts you OR when you take dmg while they are very close.");
			ConfigEntry<float> obj = infectionChance;
			FloatInputFieldOptions val = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val).Min = 0f;
			((BaseRangeOptions<float>)val).Max = 100f;
			FloatInputFieldConfigItem val2 = new FloatInputFieldConfigItem(obj, val);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
		}
	}
	internal class CarPlague : EnemyAI
	{
		public enum State
		{
			SearchingForPlayer
		}

		public float infectionSeverity = 0f;

		public float secondsToFart = 0f;

		public float secondsToFartChain = 0f;

		public float secondsToPoop = 0f;

		public float secondsToMegaPoop = 0f;

		[Header("AI Debug")]
		public bool debugThoughts = true;

		public override void Start()
		{
			((EnemyAI)this).Start();
			secondsToFart = Random.Range(0, 12);
			secondsToFartChain = Random.Range(0, 30);
			secondsToPoop = Random.Range(4, 120);
			secondsToMegaPoop = Random.Range(8, 240);
		}

		public override void DoAIInterval()
		{
			((EnemyAI)this).DoAIInterval();
		}

		public override void Update()
		{
			((EnemyAI)this).Update();
			secondsToFart -= Time.deltaTime;
			secondsToFartChain -= Time.deltaTime;
			secondsToPoop -= Time.deltaTime;
			secondsToMegaPoop -= Time.deltaTime;
			infectionSeverity += Time.deltaTime;
		}

		private void Think(string msg)
		{
			if (debugThoughts)
			{
				Debug.Log((object)$"[PoopPlague@{Time.time:F1}] {msg}");
			}
		}

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

		protected override void __initializeRpcs()
		{
			((EnemyAI)this).__initializeRpcs();
		}

		protected internal override string __getTypeName()
		{
			return "CarPlague";
		}
	}
	public static class PlagueSpawnerConfig
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static GenericButtonHandler <0>__OnSpawnClicked;

			public static GenericButtonHandler <1>__OnPrintCoordsClicked;
		}

		private const string Section = "Plague Spawner";

		private static ConfigEntry<float> _spawnX;

		private static ConfigEntry<float> _spawnY;

		private static ConfigEntry<float> _spawnZ;

		public static void Init(ConfigFile config)
		{
			//IL_0063: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_008d: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00bd: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00c3: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_00ed: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			_spawnX = config.Bind<float>("Plague Spawner", "Spawn X", 0f, "World X coordinate to spawn the plague at.");
			_spawnY = config.Bind<float>("Plague Spawner", "Spawn Y", 0f, "World Y coordinate to spawn the plague at.");
			_spawnZ = config.Bind<float>("Plague Spawner", "Spawn Z", 0f, "World Z coordinate to spawn the plague at.");
			ConfigEntry<float> spawnX = _spawnX;
			FloatInputFieldOptions val = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val).Min = -10000f;
			((BaseRangeOptions<float>)val).Max = 10000f;
			FloatInputFieldConfigItem val2 = new FloatInputFieldConfigItem(spawnX, val);
			ConfigEntry<float> spawnY = _spawnY;
			FloatInputFieldOptions val3 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val3).Min = -10000f;
			((BaseRangeOptions<float>)val3).Max = 10000f;
			FloatInputFieldConfigItem val4 = new FloatInputFieldConfigItem(spawnY, val3);
			ConfigEntry<float> spawnZ = _spawnZ;
			FloatInputFieldOptions val5 = new FloatInputFieldOptions
			{
				RequiresRestart = false
			};
			((BaseRangeOptions<float>)val5).Min = -10000f;
			((BaseRangeOptions<float>)val5).Max = 10000f;
			FloatInputFieldConfigItem val6 = new FloatInputFieldConfigItem(spawnZ, val5);
			object obj = <>O.<0>__OnSpawnClicked;
			if (obj == null)
			{
				GenericButtonHandler val7 = OnSpawnClicked;
				<>O.<0>__OnSpawnClicked = val7;
				obj = (object)val7;
			}
			GenericButtonConfigItem val8 = new GenericButtonConfigItem("Plague Spawner", "Spawn Plague", "Spawns a plague at the X/Y/Z above. It attaches to the nearest monster or player. Host only.", "Spawn", (GenericButtonHandler)obj);
			object obj2 = <>O.<1>__OnPrintCoordsClicked;
			if (obj2 == null)
			{
				GenericButtonHandler val9 = OnPrintCoordsClicked;
				<>O.<1>__OnPrintCoordsClicked = val9;
				obj2 = (object)val9;
			}
			GenericButtonConfigItem val10 = new GenericButtonConfigItem("Plague Spawner", "My Coordinates", "Fills X/Y/Z with your active camera position and copies it to the clipboard. Useful for filling in the fields above.", "Print/Inject Current Coords", (GenericButtonHandler)obj2);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val4);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val8);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val10);
		}

		private static void OnSpawnClicked()
		{
			//IL_006c: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)RoundManager.Instance == (Object)null || !((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				HUDManager instance = HUDManager.Instance;
				if (instance != null)
				{
					instance.DisplayTip("Plague Spawner", "Host only, and only in a game.", true, false, "LC_Tip1");
				}
				return;
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(_spawnX.Value, _spawnY.Value, _spawnZ.Value);
			Plugin.SpawnPoopPlague(val);
			HUDManager instance2 = HUDManager.Instance;
			if (instance2 != null)
			{
				instance2.DisplayTip("Plague Spawner", $"Spawned at X: {val.x:F1}  Y: {val.y:F1}  Z: {val.z:F1}", false, false, "LC_Tip1");
			}
		}

		private static void OnPrintCoordsClicked()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			Camera activeDisplayCamera = GetActiveDisplayCamera();
			if ((Object)(object)activeDisplayCamera == (Object)null)
			{
				Debug.Log((object)"Plague Spawner: Failed to Get Camera.");
				HUDManager instance = HUDManager.Instance;
				if (instance != null)
				{
					instance.DisplayTip("Plague Spawner", "Not in a game.", true, false, "LC_Tip1");
				}
				return;
			}
			Vector3 position = ((Component)activeDisplayCamera).transform.position;
			_spawnX.Value = position.x;
			_spawnY.Value = position.y;
			_spawnZ.Value = position.z;
			GUIUtility.systemCopyBuffer = $"{position.x:F2}, {position.y:F2}, {position.z:F2}";
			Debug.Log((object)$"Coords injected/copied X: {position.x:F1}  Y: {position.y:F1}  Z: {position.z:F1}");
			HUDManager instance2 = HUDManager.Instance;
			if (instance2 != null)
			{
				instance2.DisplayTip("Coords injected/copied", $"X: {position.x:F1}  Y: {position.y:F1}  Z: {position.z:F1}", false, false, "LC_Tip1");
			}
		}

		public static Camera GetActiveDisplayCamera()
		{
			//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)
			GameObject[] array = GameObject.FindGameObjectsWithTag("MainCamera");
			if (array == null || array.Length == 0)
			{
				return null;
			}
			Camera result = null;
			float num = float.NegativeInfinity;
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Camera component = val.GetComponent<Camera>();
				if (!((Object)(object)component == (Object)null) && val.activeInHierarchy && ((Behaviour)component).enabled && ((Behaviour)component).isActiveAndEnabled)
				{
					float num2 = 0f;
					AudioListener component2 = val.GetComponent<AudioListener>();
					if ((Object)(object)component2 != (Object)null && ((Behaviour)component2).enabled)
					{
						num2 += 1000f;
					}
					if ((Object)(object)component.targetTexture != (Object)null)
					{
						num2 -= 1000f;
					}
					num2 = ((component.targetDisplay != 0) ? (num2 - 500f) : (num2 + 100f));
					num2 += component.depth * 10f;
					Rect rect = component.rect;
					float num3 = Mathf.Abs(((Rect)(ref rect)).width * ((Rect)(ref rect)).height);
					num2 += num3 * 50f;
					if (component.cullingMask == 0)
					{
						num2 -= 200f;
					}
					if (num2 > num)
					{
						num = num2;
						result = component;
					}
				}
			}
			return result;
		}
	}
	public static class PlagueStatus
	{
		public const string DefaultVirusName = "Diarrhea Diabolica";

		public const string DefaultVirusStrain = "STRAIN RN-7";

		public static string VirusName = "Diarrhea Diabolica";

		public static string VirusStrain = "STRAIN RN-7";

		public static string CureHint = "CURE: TZP";

		public const float SeverityAtFullProgress = 400f;

		public static readonly float[] StageThresholds = new float[5] { 0f, 0.14f, 0.32f, 0.58f, 0.82f };

		public static readonly string[] StageNames = new string[5] { "STAGE 1 - INCUBATING VIRUS", "STAGE 2 - GUT INFLAMMATION/COLONIZATION", "STAGE 3 - MICROBIOME COLONIZED", "STAGE 4 - CELLULAR DESTRUCTION", "STAGE 5 - TERMINAL" };

		public static bool IsLocalPlayerInfected { get; private set; }

		public static float Severity { get; private set; }

		public static int StageIndex { get; private set; }

		public static float LastSyncTime { get; private set; }

		public static float NormalizedSeverity => Mathf.Clamp01(Severity / 400f);

		public static string CurrentStageName
		{
			get
			{
				if (StageNames == null || StageNames.Length == 0)
				{
					return string.Empty;
				}
				return StageNames[Mathf.Clamp(StageIndex, 0, StageNames.Length - 1)];
			}
		}

		public static event Action OnInfected;

		public static event Action OnCleared;

		public static event Action<int> OnStageChanged;

		public static void ReportInfection(float severity)
		{
			bool isLocalPlayerInfected = IsLocalPlayerInfected;
			int stageIndex = StageIndex;
			Severity = Mathf.Max(0f, severity);
			LastSyncTime = Time.time;
			StageIndex = StageFor(Severity);
			IsLocalPlayerInfected = true;
			if (!isLocalPlayerInfected)
			{
				if (PlagueStatus.OnInfected != null)
				{
					PlagueStatus.OnInfected();
				}
				if (PlagueStatus.OnStageChanged != null)
				{
					PlagueStatus.OnStageChanged(StageIndex);
				}
			}
			else if (StageIndex != stageIndex && PlagueStatus.OnStageChanged != null)
			{
				PlagueStatus.OnStageChanged(StageIndex);
			}
		}

		public static void ReportClear()
		{
			if (IsLocalPlayerInfected)
			{
				IsLocalPlayerInfected = false;
				Severity = 0f;
				StageIndex = 0;
				if (PlagueStatus.OnCleared != null)
				{
					PlagueStatus.OnCleared();
				}
			}
		}

		public static void Cure()
		{
			ReportClear();
		}

		public static void ResetState()
		{
			IsLocalPlayerInfected = false;
			Severity = 0f;
			StageIndex = 0;
			LastSyncTime = 0f;
		}

		public static int StageFor(float severity)
		{
			float num = Mathf.Clamp01(severity / 400f);
			int result = 0;
			for (int i = 0; i < StageThresholds.Length; i++)
			{
				if (num >= StageThresholds[i])
				{
					result = i;
				}
			}
			return result;
		}
	}
	internal class PoopPlague : NetworkBehaviour
	{
		public enum State
		{
			SearchingForPlayer
		}

		[HideInInspector]
		public EnemyAI enemyVictim = null;

		[HideInInspector]
		public PlayerControllerB playerVictim = null;

		public static List<PoopPlague> plagues = new List<PoopPlague>();

		public ParticleSystem plagueParticles;

		public GameObject poopBurstParticles;

		public GameObject poopPile;

		public float pileLifetime = 120f;

		public AudioSource[] fartnoises;

		public AudioSource fartLaunchNoise;

		public AudioSource poopNoise;

		public float infectionSeverity = 0f;

		public static Action<Vector3> SpawnRequested;

		[HideInInspector]
		public float secondsToFart = 0f;

		[HideInInspector]
		public float secondsToFartChain = 0f;

		[HideInInspector]
		public float secondsToPoop = 0f;

		public static float fartMinTime = 0f;

		public static float fartMaxTime = 14f;

		public static float fartChainMinTime = 3f;

		public static float fartChainMaxTime = 120f;

		public static float poopMinTime = 4f;

		public static float poopMaxTime = 240f;

		public float severitySyncInterval = 0.25f;

		[HideInInspector]
		public float severitySyncTimer = 0f;

		private float progressionSpeed = 0.004f;

		public static float modelPlaceOffsetY = 0.12f;

		public static float playerReferenceHeight = 2f;

		private bool chainActive = false;

		public float fartPlaceOffsetY = 0.1f;

		public static float lateralForceMult = 0.15f;

		public static float upwardForceMult = 0.015f;

		[Header("AI Debug")]
		public bool debugThoughts = true;

		public bool IsRiding(EnemyAI mob)
		{
			return (Object)(object)enemyVictim != (Object)null && (Object)(object)enemyVictim == (Object)(object)mob && !enemyVictim.isEnemyDead;
		}

		public bool IsRiding(PlayerControllerB ply)
		{
			return (Object)(object)playerVictim != (Object)null && (Object)(object)playerVictim == (Object)(object)ply;
		}

		public void Start()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			PlagueInfectionHUD.EnsureExists();
			secondsToFart = Random.Range(fartMinTime, fartMaxTime);
			secondsToFartChain = Random.Range(fartChainMinTime, fartChainMaxTime);
			secondsToPoop = Random.Range(poopMinTime, poopMaxTime);
			float num = 99999f;
			PlayerControllerB val = null;
			EnemyAI val2 = null;
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val3 in array)
			{
				if (!((Object)(object)val3 == (Object)null) && !val3.isPlayerDead)
				{
					float num2 = Vector3.Distance(((Component)val3).transform.position, ((Component)this).transform.position);
					if (num2 < num)
					{
						val = val3;
						val2 = null;
						num = num2;
					}
				}
			}
			List<EnemyAI> spawnedEnemies = RoundManager.Instance.SpawnedEnemies;
			if (spawnedEnemies != null)
			{
				foreach (EnemyAI item in spawnedEnemies)
				{
					if (!((Object)(object)item == (Object)null) && !item.isEnemyDead)
					{
						float num3 = Vector3.Distance(((Component)item).transform.position, ((Component)this).transform.position);
						if (num3 < num)
						{
							val2 = item;
							val = null;
							num = num3;
						}
					}
				}
			}
			if ((Object)(object)val2 != (Object)null)
			{
				enemyVictim = val2;
				Think("attached to monster -> " + EnemyLabel(enemyVictim) + " at " + num.ToString("F1") + "m");
			}
			else if ((Object)(object)val != (Object)null)
			{
				playerVictim = val;
				Think("attached to player -> " + playerVictim.playerUsername + " at " + num.ToString("F1") + "m");
			}
			else
			{
				Debug.LogError((object)"Attachment Failure Error, the plague will not function properly.");
			}
			poopBurstParticles.SetActive(false);
			plagues.Add(this);
		}

		public override void OnDestroy()
		{
			((NetworkBehaviour)this).OnDestroy();
			plagues.Remove(this);
		}

		public void Update()
		{
			//IL_0022: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)playerVictim))
			{
				((Component)this).transform.position = ((Component)playerVictim).transform.position;
				((Component)this).transform.rotation = ((Component)playerVictim).transform.rotation;
			}
			if (Object.op_Implicit((Object)(object)enemyVictim))
			{
				((Component)this).transform.position = ((Component)enemyVictim).transform.position;
				((Component)this).transform.rotation = ((Component)enemyVictim).transform.rotation;
			}
			if (!((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				return;
			}
			infectionSeverity += Time.deltaTime;
			if (Object.op_Implicit((Object)(object)playerVictim))
			{
				if (playerVictim.isPlayerDead)
				{
					InfectionClearedClientRpc(((NetworkBehaviour)playerVictim).NetworkObjectId);
					Object.Destroy((Object)(object)((Component)this).gameObject);
					return;
				}
				severitySyncTimer -= Time.deltaTime;
				if (severitySyncTimer <= 0f)
				{
					severitySyncTimer = severitySyncInterval;
					InfectionSyncClientRpc(((NetworkBehaviour)playerVictim).NetworkObjectId, infectionSeverity);
				}
				RunSymptoms();
			}
			else if (Object.op_Implicit((Object)(object)enemyVictim))
			{
				if (enemyVictim.isEnemyDead)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
					return;
				}
				RunSymptoms();
			}
			secondsToFart -= Time.deltaTime;
			secondsToFartChain -= Time.deltaTime;
			secondsToPoop -= Time.deltaTime;
		}

		private void RunSymptoms()
		{
			float severityDivisor = getSeverityDivisor();
			if (secondsToFart <= 0f)
			{
				SendFart();
				secondsToFart = Random.Range(fartMinTime, fartMaxTime) / severityDivisor;
			}
			if (secondsToFartChain <= 0f && !chainActive)
			{
				StartFartChainClientRpc();
				((MonoBehaviour)this).StartCoroutine(FartChainCoroutine(Random.Range(0.1f, 2.2f) / severityDivisor, Random.RandomRangeInt(3, 18)));
				secondsToFartChain = Random.Range(fartChainMinTime, fartChainMaxTime) / severityDivisor;
			}
			if (secondsToPoop <= 0f)
			{
				SendPoop();
				float num = 1f;
				if (infectionSeverity > 128f)
				{
					num += 0.5f;
				}
				secondsToPoop = Random.Range(poopMinTime, poopMaxTime / num) / (severityDivisor + infectionSeverity / 60f);
			}
		}

		private void SendFart()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			int soundIndex = Random.RandomRangeInt(0, fartnoises.Length);
			if ((Object)(object)playerVictim != (Object)null)
			{
				FartPlayerClientRpc(((NetworkBehaviour)playerVictim).NetworkObjectId, GetRandomLateralPosition(((Component)playerVictim).transform), soundIndex, infectionSeverity > 56f && !playerVictim.isClimbingLadder);
			}
			else if ((Object)(object)enemyVictim != (Object)null)
			{
				Vector3 position = ((Component)enemyVictim).transform.position;
				position.y -= fartPlaceOffsetY;
				FartMonsterClientRpc(GetRandomLateralPosition(((Component)enemyVictim).transform), position, soundIndex);
			}
		}

		private void SendPoop()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)playerVictim != (Object)null)
			{
				PoopClientRpc(((NetworkBehaviour)playerVictim).NetworkObjectId);
			}
			else if ((Object)(object)enemyVictim != (Object)null)
			{
				Vector3 position = ((Component)enemyVictim).transform.position;
				position.y -= modelPlaceOffsetY;
				PoopMonsterClientRpc(position, ((Component)enemyVictim).transform.rotation);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void DestroySelfServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val2 = default(ServerRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1962921830u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val, 1962921830u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		[ClientRpc]
		public void InfectionSyncClientRpc(ulong pid, float severity)
		{
			//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)
			//IL_00e9: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2651633768u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, pid);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref severity, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2651633768u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB localPlayerController = RoundManager.Instance.playersManager.localPlayerController;
				if (!((Object)(object)localPlayerController == (Object)null) && ((NetworkBehaviour)localPlayerController).NetworkObjectId == pid)
				{
					PlagueStatus.ReportInfection(severity);
				}
			}
		}

		[ClientRpc]
		public void InfectionClearedClientRpc(ulong pid)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3451390639u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, pid);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3451390639u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB localPlayerController = RoundManager.Instance.playersManager.localPlayerController;
				if (!((Object)(object)localPlayerController == (Object)null) && ((NetworkBehaviour)localPlayerController).NetworkObjectId == pid)
				{
					PlagueStatus.ReportClear();
				}
			}
		}

		public float getSeverityDivisor()
		{
			return Math.Min(1f + infectionSeverity * progressionSpeed, 4f);
		}

		[ClientRpc]
		public void PoopClientRpc(ulong pid)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3280028637u, val2, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val, pid);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3280028637u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					PlayerControllerB player = GetPlayer(pid);
					Vector3 position = ((Component)player).transform.position;
					position.y -= modelPlaceOffsetY;
					GameObject val3 = Object.Instantiate<GameObject>(poopPile, position, ((Component)player).transform.rotation);
					poopNoise.PlayOneShot(poopNoise.clip);
					Object.Destroy((Object)(object)val3, pileLifetime);
				}
			}
		}

		[ClientRpc]
		public void PoopMonsterClientRpc(Vector3 position, Quaternion rotation)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_0096: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3614122076u, val2, (RpcDelivery)0);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref position);
					((FastBufferWriter)(ref val)).WriteValueSafe(ref rotation);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 3614122076u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					GameObject val3 = Object.Instantiate<GameObject>(poopPile, position, rotation);
					Transform transform = val3.transform;
					transform.localScale *= MeasureMonsterScale(enemyVictim);
					poopNoise.PlayOneShot(poopNoise.clip);
					Object.Destroy((Object)(object)val3, pileLifetime);
				}
			}
		}

		public static float MeasureMonsterScale(EnemyAI mob)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0070: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mob == (Object)null)
			{
				return 1f;
			}
			float num = 0f;
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			Collider[] componentsInChildren = ((Component)mob).GetComponentsInChildren<Collider>();
			foreach (Collider val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null))
				{
					Bounds bounds = val.bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					num3 = Mathf.Max(num3, size.y);
					num4 = Mathf.Max(num4, Mathf.Max(size.x, size.z));
					if (!val.isTrigger)
					{
						num = Mathf.Max(num, size.y);
						num2 = Mathf.Max(num2, Mathf.Max(size.x, size.z));
					}
				}
			}
			if (num <= 0.01f)
			{
				num = num3;
				num2 = num4;
			}
			if (num <= 0.01f)
			{
				return 1f;
			}
			float num5 = num / playerReferenceHeight;
			float num6 = num2 / playerReferenceHeight;
			return Mathf.Clamp(Mathf.Sqrt(num5 * num6), 0.5f, 6f);
		}

		public Vector3 GetRandomLateralPosition(Transform target)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_003d: 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)
			Vector3 position = target.position;
			position.x += Random.Range(-0.5f, 0.5f);
			position.z += Random.Range(-0.5f, 0.5f);
			return position;
		}

		public IEnumerator FartChainCoroutine(float baseDelay, int quantity)
		{
			chainActive = true;
			for (int i = 0; i < quantity; i++)
			{
				SendFart();
				if (infectionSeverity > 128f)
				{
					SendPoop();
				}
				yield return (object)new WaitForSeconds(Mathf.Max(0.15f, baseDelay * Random.Range(0.4f, 1f)));
			}
			if (((NetworkBehaviour)RoundManager.Instance).IsHost)
			{
				StopFartChainClientRpc();
			}
			chainActive = false;
		}

		[ClientRpc]
		public void StartFartChainClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(976496214u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 976496214u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					fartLaunchNoise.PlayOneShot(fartLaunchNoise.clip);
					poopBurstParticles.SetActive(true);
					Transform transform = poopBurstParticles.transform;
					transform.localScale *= MeasureMonsterScale(enemyVictim);
				}
			}
		}

		[ClientRpc]
		public void StopFartChainClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val2 = default(ClientRpcParams);
					FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2807728605u, val2, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val, 2807728605u, val2, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.__rpc_exec_stage = (__RpcExecStage)0;
					poopBurstParticles.SetActive(false);
				}
			}
		}

		[ClientRpc]
		public void FartPlayerClientRpc(ulong pid, Vector3 lateralForcePosition, int soundIndex, bool pastlatent)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_008b: 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)
			//IL_00aa: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(361897538u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, pid);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref lateralForcePosition);
				BytePacker.WriteValueBitPacked(val, soundIndex);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref pastlatent, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 361897538u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB player = GetPlayer(pid);
				PlayerControllerB localPlayerController = RoundManager.Instance.playersManager.localPlayerController;
				if (((NetworkBehaviour)localPlayerController).NetworkObjectId == ((NetworkBehaviour)player).NetworkObjectId)
				{
					localPlayerController.drunkness += 0.14f;
				}
				if (pastlatent)
				{
					Vector3 position = ((Component)player).transform.position;
					position.y -= fartPlaceOffsetY;
					Landmine.SpawnExplosion(lateralForcePosition, false, 0f, 0f, 0, 17f * lateralForceMult, (GameObject)null, false);
					Landmine.SpawnExplosion(position, false, 0f, 0f, 0, 15f * upwardForceMult, (GameObject)null, false);
				}
				fartnoises[soundIndex].PlayOneShot(fartnoises[soundIndex].clip);
			}
		}

		[ClientRpc]
		public void FartMonsterClientRpc(Vector3 lateralForcePosition, Vector3 upwardForcePosition, int soundIndex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: 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 != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2110591788u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref lateralForcePosition);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref upwardForcePosition);
				BytePacker.WriteValueBitPacked(val, soundIndex);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2110591788u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (infectionSeverity > 56f)
				{
					Landmine.SpawnExplosion(lateralForcePosition, false, 0f, 0f, 0, 17f * lateralForceMult, (GameObject)null, false);
					Landmine.SpawnExplosion(upwardForcePosition, false, 0f, 0f, 0, 15f * upwardForceMult, (GameObject)null, false);
				}
				fartnoises[soundIndex].PlayOneShot(fartnoises[soundIndex].clip);
			}
		}

		public PlayerControllerB GetPlayer(ulong pid)
		{
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				if (((NetworkBehaviour)val).NetworkObjectId == pid)
				{
					return val;
				}
			}
			return null;
		}

		private string EnemyLabel(EnemyAI mob)
		{
			if ((Object)(object)mob == (Object)null)
			{
				return "null";
			}
			if ((Object)(object)mob.enemyType == (Object)null)
			{
				return ((Object)mob).name;
			}
			return mob.enemyType.enemyName;
		}

		private void Think(string msg)
		{
			if (debugThoughts)
			{
				Debug.Log((object)$"[PoopPlague@{Time.time:F1}] {msg}");
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1962921830u, new RpcReceiveHandler(__rpc_handler_1962921830), "DestroySelfServerRpc");
			((NetworkBehaviour)this).__registerRpc(2651633768u, new RpcReceiveHandler(__rpc_handler_2651633768), "InfectionSyncClientRpc");
			((NetworkBehaviour)this).__registerRpc(3451390639u, new RpcReceiveHandler(__rpc_handler_3451390639), "InfectionClearedClientRpc");
			((NetworkBehaviour)this).__registerRpc(3280028637u, new RpcReceiveHandler(__rpc_handler_3280028637), "PoopClientRpc");
			((NetworkBehaviour)this).__registerRpc(3614122076u, new RpcReceiveHandler(__rpc_handler_3614122076), "PoopMonsterClientRpc");
			((NetworkBehaviour)this).__registerRpc(976496214u, new RpcReceiveHandler(__rpc_handler_976496214), "StartFartChainClientRpc");
			((NetworkBehaviour)this).__registerRpc(2807728605u, new RpcReceiveHandler(__rpc_handler_2807728605), "StopFartChainClientRpc");
			((NetworkBehaviour)this).__registerRpc(361897538u, new RpcReceiveHandler(__rpc_handler_361897538), "FartPlayerClientRpc");
			((NetworkBehaviour)this).__registerRpc(2110591788u, new RpcReceiveHandler(__rpc_handler_2110591788), "FartMonsterClientRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1962921830(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PoopPlague)(object)target).DestroySelfServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2651633768(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_006f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong pid = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref pid);
				float severity = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref severity, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PoopPlague)(object)target).InfectionSyncClientRpc(pid, severity);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3451390639(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong pid = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref pid);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PoopPlague)(object)target).InfectionClearedClientRpc(pid);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3280028637(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong pid = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref pid);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PoopPlague)(object)target).PoopClientRpc(pid);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3614122076(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				Quaternion rotation = default(Quaternion);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref rotation);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PoopPlague)(object)target).PoopMonsterClientRpc(position, rotation);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_976496214(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PoopPlague)(object)target).StartFartChainClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2807728605(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PoopPlague)(object)target).StopFartChainClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_361897538(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong pid = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref pid);
				Vector3 lateralForcePosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref lateralForcePosition);
				int soundIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref soundIndex);
				bool pastlatent = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref pastlatent, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PoopPlague)(object)target).FartPlayerClientRpc(pid, lateralForcePosition, soundIndex, pastlatent);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2110591788(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 lateralForcePosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref lateralForcePosition);
				Vector3 upwardForcePosition = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref upwardForcePosition);
				int soundIndex = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref soundIndex);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PoopPlague)(object)target).FartMonsterClientRpc(lateralForcePosition, upwardForcePosition, soundIndex);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "PoopPlague";
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "bcs4313_Plagues_Of_Evil";

		public const string PLUGIN_NAME = "Plagues";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace PlaguesOfDoom.src.Soul_Devourer
{
	public class PlagueNetRelay : NetworkBehaviour
	{
		public void Start()
		{
			Debug.Log((object)"Plagues of Evil: Plague Net Relay Instantated!");
		}

		[ServerRpc(RequireOwnership = false)]
		public void RelayCollisionServerRpc(ulong enemyAIUID)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: 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)
			//IL_01e1: 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 != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3863007501u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, enemyAIUID);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 3863007501u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			base.__rpc_exec_stage = (__RpcExecStage)0;
			EnemyAI self = GetEnemy(enemyAIUID);
			PlayerControllerB player = null;
			float num = float.MaxValue;
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val3 in allPlayerScripts)
			{
				if (!((Object)(object)val3 == (Object)null) && val3.isPlayerControlled && !val3.isPlayerDead)
				{
					float num2 = Vector3.Distance(((Component)val3).transform.position, ((Component)self).transform.position);
					if (num2 < num)
					{
						num = num2;
						player = val3;
					}
				}
			}
			if (!((Object)(object)player == (Object)null))
			{
				PoopPlague[] source = Object.FindObjectsOfType<PoopPlague>();
				bool flag = source.Any((PoopPlague p) => p.IsRiding(self));
				bool flag2 = source.Any((PoopPlague p) => p.IsRiding(player));
				if (flag && !flag2)
				{
					Plugin.SpawnPoopPlague(((Component)player).transform.position);
				}
			}
		}

		public EnemyAI GetEnemy(ulong uid)
		{
			EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>();
			EnemyAI[] array2 = array;
			foreach (EnemyAI val in array2)
			{
				if (((NetworkBehaviour)val).NetworkObjectId == uid)
				{
					return val;
				}
			}
			return null;
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3863007501u, new RpcReceiveHandler(__rpc_handler_3863007501), "RelayCollisionServerRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_3863007501(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ulong enemyAIUID = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref enemyAIUID);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((PlagueNetRelay)(object)target).RelayCollisionServerRpc(enemyAIUID);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "PlagueNetRelay";
		}
	}
}
namespace PlaguesOfDoom.src.Soul_Devourer.PlaguesOfDoom
{
	public class PlagueInfectionHUD : MonoBehaviour
	{
		[Header("Badge (persistent, while infected)")]
		public CanvasGroup badgeGroup;

		public TextMeshProUGUI virusNameLabel;

		public TextMeshProUGUI stageLabel;

		public TextMeshProUGUI percentLabel;

		public Image severityBar;

		public Image stageIndicatorImage;

		public TextMeshProUGUI cureHintLabel;

		[Header("Banner (one-shot, on infection)")]
		public CanvasGroup bannerGroup;

		public TextMeshProUGUI bannerTitle;

		public TextMeshProUGUI bannerSubtitle;

		public TextMeshProUGUI bannerHint;

		public float bannerHoldTime = 3f;

		[Header("Feel")]
		public float fadeSpeed = 3f;

		public float syncTimeout = 3f;

		public float pulseSpeed = 4f;

		[Range(0f, 1f)]
		public float pulseAmount = 0.45f;

		public Color[] stageColors = (Color[])(object)new Color[5]
		{
			new Color(0.35f, 0.9f, 0.35f),
			new Color(0.95f, 0.85f, 0.25f),
			new Color(0.98f, 0.55f, 0.15f),
			new Color(0.9f, 0.15f, 0.12f),
			new Color(0.78f, 0.1f, 0.48f)
		};

		[Header("Audio (optional)")]
		public AudioClip onsetClip;

		public AudioClip stageClip;

		[Range(0f, 1f)]
		public float audioVolume = 0.7f;

		[Header("Runtime UI build")]
		public bool autoBuildUI = true;

		public TMP_FontAsset fontOverride;

		public Vector2 referenceResolution = new Vector2(1920f, 1080f);

		private AudioSource _audio;

		private Coroutine _bannerRoutine;

		private RectTransform _badgeRT;

		private float _punch;

		private int _lastStage = -1;

		private int _lastPercent = -1;

		private static Sprite _whiteSprite;

		public static PlagueInfectionHUD Instance { get; private set; }

		private static Sprite WhiteSprite
		{
			get
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				//IL_001e: 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_0054: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_whiteSprite == (Object)null)
				{
					Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
					val.SetPixel(0, 0, Color.white);
					val.Apply();
					_whiteSprite = Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f), 100f);
					((Object)_whiteSprite).name = "PlagueWhite1x1";
				}
				return _whiteSprite;
			}
		}

		public static PlagueInfectionHUD EnsureExists()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			if ((Object)(object)Instance != (Object)null)
			{
				return Instance;
			}
			GameObject val = new GameObject("PlagueInfectionHUD");
			Object.DontDestroyOnLoad((Object)(object)val);
			return val.AddComponent<PlagueInfectionHUD>();
		}

		private void Awake()
		{
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			if (autoBuildUI && (Object)(object)badgeGroup == (Object)null)
			{
				BuildRuntimeUI();
			}
			if ((Object)(object)badgeGroup != (Object)null)
			{
				ref RectTransform badgeRT = ref _badgeRT;
				Transform transform = ((Component)badgeGroup).transform;
				badgeRT = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				badgeGroup.alpha = 0f;
				badgeGroup.blocksRaycasts = false;
				badgeGroup.interactable = false;
			}
			if ((Object)(object)bannerGroup != (Object)null)
			{
				bannerGroup.alpha = 0f;
				bannerGroup.blocksRaycasts = false;
				bannerGroup.interactable = false;
			}
			if ((Object)(object)stageIndicatorImage != (Object)null)
			{
				((Graphic)stageIndicatorImage).color = StageColor(0);
			}
			_audio = ((Component)this).gameObject.GetComponent<AudioSource>();
			if ((Object)(object)_audio == (Object)null)
			{
				_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
			}
			_audio.playOnAwake = false;
			_audio.spatialBlend = 0f;
			_audio.volume = 1f;
			PlagueStatus.ResetState();
			SceneManager.sceneLoaded += HandleSceneLoaded;
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= HandleSceneLoaded;
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		private void OnEnable()
		{
			PlagueStatus.OnInfected += HandleInfected;
			PlagueStatus.OnCleared += HandleCleared;
			PlagueStatus.OnStageChanged += HandleStageChanged;
		}

		private void OnDisable()
		{
			PlagueStatus.OnInfected -= HandleInfected;
			PlagueStatus.OnCleared -= HandleCleared;
			PlagueStatus.OnStageChanged -= HandleStageChanged;
		}

		private void HandleSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			PlagueStatus.ReportClear();
		}

		private void Update()
		{
			if (PlagueStatus.IsLocalPlayerInfected && Time.time - PlagueStatus.LastSyncTime > syncTimeout)
			{
				PlagueStatus.ReportClear();
			}
			DriveBadge();
			DrivePunch();
		}

		private void DriveBadge()
		{
			if ((Object)(object)badgeGroup == (Object)null)
			{
				return;
			}
			float num = (PlagueStatus.IsLocalPlayerInfected ? 1f : 0f);
			badgeGroup.alpha = Mathf.MoveTowards(badgeGroup.alpha, num, Time.deltaTime * fadeSpeed);
			if (badgeGroup.alpha <= 0.001f || !PlagueStatus.IsLocalPlayerInfected)
			{
				return;
			}
			int stageIndex = PlagueStatus.StageIndex;
			float normalizedSeverity = PlagueStatus.NormalizedSeverity;
			if (_lastStage != stageIndex)
			{
				_lastStage = stageIndex;
				ApplyStageVisuals(stageIndex);
			}
			int num2 = Mathf.RoundToInt(normalizedSeverity * 100f);
			if (_lastPercent != num2)
			{
				_lastPercent = num2;
				if ((Object)(object)percentLabel != (Object)null)
				{
					((TMP_Text)percentLabel).text = num2 + "%";
				}
			}
			if ((Object)(object)severityBar != (Object)null)
			{
				severityBar.fillAmount = normalizedSeverity;
			}
			if ((Object)(object)virusNameLabel != (Object)null)
			{
				if (stageIndex >= PlagueStatus.StageNames.Length - 1)
				{
					float num3 = 0.5f + 0.5f * Mathf.Sin(Time.time * pulseSpeed);
					((TMP_Text)virusNameLabel).alpha = Mathf.Lerp(1f - pulseAmount, 1f, num3);
				}
				else if (!Mathf.Approximately(((TMP_Text)virusNameLabel).alpha, 1f))
				{
					((TMP_Text)virusNameLabel).alpha = 1f;
				}
			}
		}

		private void DrivePunch()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (!(_punch <= 0f))
			{
				_punch = Mathf.MoveTowards(_punch, 0f, Time.deltaTime * 2.5f);
				if ((Object)(object)_badgeRT != (Object)null)
				{
					((Transform)_badgeRT).localScale = Vector3.one * (1f + 0.09f * _punch);
				}
			}
		}

		private void ApplyStageVisuals(int stage)
		{
			//IL_0003: 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)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown resul