Decompiled source of LC Host Tools v1.0.1

BepInEx/plugins/ToxicOmega_Tools-fixed.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LC_API.GameInterfaceAPI.Features;
using LC_API.Networking;
using ToxicOmega_Tools.Patches;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ToxicOmega_Tools")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ToxicOmega_Tools")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f25f0ba7-4a38-4ce6-8d98-4ee185b333d6")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace ToxicOmega_Tools
{
	[BepInPlugin("com.toxicomega.toxicomega_tools", "ToxicOmega Tools", "2.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "com.toxicomega.toxicomega_tools";

		private const string modName = "ToxicOmega Tools";

		private const string modVersion = "2.0.0";

		private readonly Harmony harmony = new Harmony("com.toxicomega.toxicomega_tools");

		internal static Plugin Instance;

		internal static ManualLogSource mls;

		internal List<Waypoint> waypoints = new List<Waypoint>();

		internal Random shipTeleporterSeed;

		internal bool enableGod = false;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("com.toxicomega.toxicomega_tools");
			mls.LogInfo((object)"ToxicOmega Tools mod has awoken.");
			mls.LogMessage((object)" _______ __                __      ___ ___                  __             ");
			mls.LogMessage((object)"|    ___|__.--.--.-----.--|  |    |   |   .-----.----.-----|__.-----.-----.");
			mls.LogMessage((object)"|    ___|  |_   _|  -__|  _  |    |   |   |  -__|   _|__ --|  |  _  |     |");
			mls.LogMessage((object)"|___|   |__|__.__|_____|_____|     \\_____/|_____|__| |_____|__|_____|__|__|");
			harmony.PatchAll();
			Network.RegisterAll();
		}

		public static bool CheckPlayerIsHost(PlayerControllerB player)
		{
			return Player.HostPlayer.ClientId == player.playerClientId;
		}

		public static PlayerControllerB GetPlayerFromString(string searchString)
		{
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			if (searchString.StartsWith("#") && searchString.Length > 1)
			{
				string text = searchString.Substring(1);
				if (ulong.TryParse(text, out var clientId))
				{
					PlayerControllerB val = ((IEnumerable<PlayerControllerB>)allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(clientId)));
					if ((Object)(object)val != (Object)null)
					{
						return val;
					}
					LogMessage($"No Player with ID {clientId}!", isError: true);
					return null;
				}
				LogMessage("Player ID # " + text + " is invalid!", isError: true);
				return null;
			}
			PlayerControllerB val2 = ((IEnumerable<PlayerControllerB>)allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerUsername.ToLower().StartsWith(searchString.ToLower())));
			if ((Object)(object)val2 != (Object)null)
			{
				return val2;
			}
			LogMessage("Player " + searchString + " not found!", isError: true);
			return null;
		}

		public static Vector3 GetPositionFromCommand(string input, int positionType, PlayerControllerB playerToTP = null)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_095a: Unknown result type (might be due to invalid IL or missing references)
			//IL_095b: Unknown result type (might be due to invalid IL or missing references)
			//IL_095f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_077a: Unknown result type (might be due to invalid IL or missing references)
			//IL_077e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0787: Unknown result type (might be due to invalid IL or missing references)
			//IL_078d: Unknown result type (might be due to invalid IL or missing references)
			//IL_078f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0794: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0901: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0872: Unknown result type (might be due to invalid IL or missing references)
			//IL_0877: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0845: Unknown result type (might be due to invalid IL or missing references)
			//IL_084a: Unknown result type (might be due to invalid IL or missing references)
			//IL_081e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0823: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			bool flag2 = false;
			Vector3 result = Vector3.zero;
			Terminal val = Object.FindObjectOfType<Terminal>();
			RoundManager instance = RoundManager.Instance;
			RandomScrapSpawn[] array = Object.FindObjectsOfType<RandomScrapSpawn>();
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			switch (positionType)
			{
			case 0:
				if (input == "$")
				{
					if (array.Length == 0)
					{
						LogMessage("No RandomScrapSpawn in this area!", isError: true);
						return Vector3.zero;
					}
					result = ((Component)array[Random.Range(0, array.Length)]).transform.position;
				}
				else if (input.StartsWith("@") && input.Length > 1)
				{
					if (!int.TryParse(input.Substring(1), out var result5))
					{
						LogMessage("Waypoint @" + input.Substring(1) + " is invalid!", isError: true);
						return Vector3.zero;
					}
					if (result5 >= Instance.waypoints.Count)
					{
						LogMessage("Waypoint @" + input.Substring(1) + " does not exist!", isError: true);
						return Vector3.zero;
					}
					Waypoint waypoint4 = Instance.waypoints[result5];
					HUDManager_Patch.sendPlayerInside = waypoint4.isInside;
					result = waypoint4.position;
				}
				else if (input == "")
				{
					result = ((Component)localPlayerController).transform.position;
				}
				else
				{
					flag = true;
				}
				break;
			case 1:
				if (input == "" || input == "$")
				{
					if (instance.outsideAINodes.Length == 0 || !((Object)(object)instance.outsideAINodes[0] != (Object)null))
					{
						LogMessage("No outsideAINodes in this area!", isError: true);
						return Vector3.zero;
					}
					result = instance.outsideAINodes[Random.Range(0, instance.outsideAINodes.Length)].transform.position;
				}
				else if (input.StartsWith("@") && input.Length > 1)
				{
					if (!int.TryParse(input.Substring(1), out var result6))
					{
						LogMessage("Waypoint @" + input.Substring(1) + " is invalid!", isError: true);
						return Vector3.zero;
					}
					if (result6 >= Instance.waypoints.Count)
					{
						LogMessage("Waypoint @" + input.Substring(1) + " does not exist!", isError: true);
						return Vector3.zero;
					}
					Waypoint waypoint5 = Instance.waypoints[result6];
					result = waypoint5.position;
				}
				else
				{
					flag = true;
				}
				break;
			case 2:
				if (input == "" || input == "$")
				{
					if (instance.allEnemyVents.Length == 0 || !((Object)(object)instance.allEnemyVents[0] != (Object)null))
					{
						LogMessage("No allEnemyVents in this area!", isError: true);
						return Vector3.zero;
					}
					result = instance.allEnemyVents[Random.Range(0, instance.allEnemyVents.Length)].floorNode.position;
				}
				else if (input.StartsWith("@") && input.Length > 1)
				{
					if (!int.TryParse(input.Substring(1), out var result3))
					{
						LogMessage("Waypoint @" + input.Substring(1) + " is invalid!", isError: true);
						return Vector3.zero;
					}
					if (result3 >= Instance.waypoints.Count)
					{
						LogMessage("Waypoint @" + input.Substring(1) + " does not exist!", isError: true);
						return Vector3.zero;
					}
					Waypoint waypoint2 = Instance.waypoints[result3];
					result = waypoint2.position;
				}
				else
				{
					flag = true;
				}
				break;
			case 3:
				if (input == "$")
				{
					if (instance.insideAINodes.Length == 0 || !((Object)(object)instance.insideAINodes[0] != (Object)null))
					{
						LogMessage("No insideAINodes in this area!", isError: true);
						return Vector3.zero;
					}
					HUDManager_Patch.sendPlayerInside = true;
					if (Instance.shipTeleporterSeed == null)
					{
						mls.LogInfo((object)"Teleport Seed: Random");
						Vector3 position2 = instance.insideAINodes[Random.Range(0, instance.insideAINodes.Length)].transform.position;
						result = instance.GetRandomNavMeshPositionInRadius(position2, 10f, default(NavMeshHit));
					}
					else
					{
						mls.LogInfo((object)"Teleport Seed: Inverse-Teleporter");
						Vector3 position3 = instance.insideAINodes[Instance.shipTeleporterSeed.Next(0, instance.insideAINodes.Length)].transform.position;
						Random random = Instance.shipTeleporterSeed;
						result = instance.GetRandomNavMeshPositionInBoxPredictable(position3, 10f, default(NavMeshHit), random, -1);
					}
					LogMessage("Teleported " + playerToTP.playerUsername + " to random location within factory.");
				}
				else if (input == "!")
				{
					if (!((Object)(object)val != (Object)null))
					{
						LogMessage("Terminal not found!", isError: true);
						return Vector3.zero;
					}
					HUDManager_Patch.sendPlayerInside = false;
					result = ((Component)val).transform.position;
					LogMessage("Teleported " + playerToTP.playerUsername + " to terminal.");
				}
				else if (input.StartsWith("@") && input.Length > 1)
				{
					if (!int.TryParse(input.Substring(1), out var result4))
					{
						LogMessage("Waypoint @" + input.Substring(1) + " is invalid!", isError: true);
						return Vector3.zero;
					}
					if (result4 >= Instance.waypoints.Count)
					{
						LogMessage("Waypoint @" + input.Substring(1) + " does not exist!", isError: true);
						return Vector3.zero;
					}
					Waypoint waypoint3 = Instance.waypoints[result4];
					HUDManager_Patch.sendPlayerInside = waypoint3.isInside;
					result = waypoint3.position;
					LogMessage($"Teleported {playerToTP.playerUsername} to Waypoint @{result4}.");
				}
				else
				{
					flag2 = true;
					flag = true;
				}
				break;
			case 4:
				if (input == "" || input == "$")
				{
					if (instance.insideAINodes.Length == 0 || !((Object)(object)instance.insideAINodes[0] != (Object)null))
					{
						LogMessage("No insideAINodes in this area!", isError: true);
						return Vector3.zero;
					}
					Vector3 position = instance.insideAINodes[Random.Range(0, instance.insideAINodes.Length)].transform.position;
					result = instance.GetRandomNavMeshPositionInRadius(position, 10f, default(NavMeshHit));
				}
				else if (input.StartsWith("@") && input.Length > 1)
				{
					if (!int.TryParse(input.Substring(1), out var result2))
					{
						LogMessage("Waypoint @" + input.Substring(1) + " is invalid!", isError: true);
						return Vector3.zero;
					}
					if (result2 >= Instance.waypoints.Count)
					{
						LogMessage("Waypoint @" + input.Substring(1) + " does not exist!", isError: true);
						return Vector3.zero;
					}
					Waypoint waypoint = Instance.waypoints[result2];
					result = waypoint.position;
				}
				else
				{
					flag = true;
				}
				break;
			}
			if (flag)
			{
				PlayerControllerB playerFromString = GetPlayerFromString(input);
				if ((Object)(object)playerFromString == (Object)null || !playerFromString.isPlayerControlled)
				{
					return Vector3.zero;
				}
				if (playerFromString.isPlayerDead)
				{
					LogMessage("Could not target " + playerFromString.playerUsername + "!\nPlayer is dead!", isError: true);
					return Vector3.zero;
				}
				result = ((Component)playerFromString).transform.position;
				if (flag2)
				{
					HUDManager_Patch.sendPlayerInside = Player.Get(playerFromString).IsInFactory;
					LogMessage("Teleported " + playerToTP.playerUsername + " to " + playerFromString.playerUsername + ".");
				}
			}
			return result;
		}

		public static void LogMessage(string message, bool isError = false)
		{
			string empty = string.Empty;
			if (isError)
			{
				empty = "Error!";
				mls.LogError((object)message);
			}
			else
			{
				empty = "Success!";
				mls.LogInfo((object)message);
			}
			HUDManager.Instance.DisplayTip(empty, message, isError, false, "LC_Tip1");
		}

		public static void PlayerTeleportEffects(ulong playerClientID, bool isInside)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(playerClientID)));
			if ((Object)(object)val.redirectToEnemy != (Object)null)
			{
				val.redirectToEnemy.ShipTeleportEnemy();
			}
			SavePlayer(val);
			if (Object.op_Implicit((Object)(object)Object.FindObjectOfType<AudioReverbPresets>()))
			{
				Object.FindObjectOfType<AudioReverbPresets>().audioPresets[isInside ? 2 : 3].ChangeAudioReverbForPlayer(val);
			}
			val.isInElevator = !isInside;
			val.isInHangarShipRoom = !isInside;
			val.isInsideFactory = isInside;
			val.averageVelocity = 0f;
			val.velocityLastFrame = Vector3.zero;
			val.beamUpParticle.Play();
			val.beamOutBuildupParticle.Play();
		}

		public static void RevivePlayer(ulong playerClientID)
		{
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
			PlayerControllerB val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(playerClientID)));
			StartOfRound instance = StartOfRound.Instance;
			Terminal val2 = Object.FindObjectOfType<Terminal>();
			Debug.Log((object)"Reviving players A");
			val.ResetPlayerBloodObjects(val.isPlayerDead);
			if (val.isPlayerDead || val.isPlayerControlled)
			{
				val.isClimbingLadder = false;
				val.ResetZAndXRotation();
				val.health = 100;
				val.disableLookInput = false;
				Debug.Log((object)"Reviving players B");
				if (val.isPlayerDead)
				{
					val.isPlayerDead = false;
					val.isPlayerControlled = true;
					val.isInElevator = true;
					val.isInHangarShipRoom = true;
					val.isInsideFactory = false;
					val.wasInElevatorLastFrame = false;
					instance.SetPlayerObjectExtrapolate(false);
					val.TeleportPlayer(((Component)val2).transform.position, false, 0f, false, true);
					val.setPositionOfDeadPlayer = false;
					val.DisablePlayerModel(instance.allPlayerObjects[playerClientID], true, true);
					((Behaviour)val.helmetLight).enabled = false;
					Debug.Log((object)"Reviving players C");
					val.Crouch(false);
					val.criticallyInjured = false;
					if ((Object)(object)val.playerBodyAnimator != (Object)null)
					{
						val.playerBodyAnimator.SetBool("Limp", false);
					}
					val.bleedingHeavily = false;
					val.activatingItem = false;
					val.twoHanded = false;
					val.inSpecialInteractAnimation = false;
					val.disableSyncInAnimation = false;
					val.inAnimationWithEnemy = null;
					val.holdingWalkieTalkie = false;
					val.speakingToWalkieTalkie = false;
					Debug.Log((object)"Reviving players D");
					val.isSinking = false;
					val.isUnderwater = false;
					val.sinkingValue = 0f;
					val.statusEffectAudio.Stop();
					val.DisableJetpackControlsLocally();
					val.health = 100;
					Debug.Log((object)"Reviving players E");
					val.mapRadarDotAnimator.SetBool("dead", false);
					if (((NetworkBehaviour)val).IsOwner)
					{
						HUDManager.Instance.gasHelmetAnimator.SetBool("gasEmitting", false);
						val.hasBegunSpectating = false;
						HUDManager.Instance.RemoveSpectateUI();
						HUDManager.Instance.gameOverAnimator.SetTrigger("revive");
						val.hinderedMultiplier = 1f;
						val.isMovementHindered = 0;
						val.sourcesCausingSinking = 0;
						Debug.Log((object)"Reviving players E2");
						val.reverbPreset = instance.shipReverb;
					}
				}
				Debug.Log((object)"Reviving players F");
				SoundManager.Instance.earsRingingTimer = 0f;
				val.voiceMuffledByEnemy = false;
				SoundManager.Instance.playerVoicePitchTargets[playerClientID] = 1f;
				SoundManager.Instance.SetPlayerPitch(1f, (int)playerClientID);
				if ((Object)(object)val.currentVoiceChatIngameSettings == (Object)null)
				{
					instance.RefreshPlayerVoicePlaybackObjects();
				}
				if ((Object)(object)val.currentVoiceChatIngameSettings != (Object)null)
				{
					if ((Object)(object)val.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
					{
						val.currentVoiceChatIngameSettings.InitializeComponents();
					}
					if ((Object)(object)val.currentVoiceChatIngameSettings.voiceAudio == (Object)null)
					{
						return;
					}
					((Component)val.currentVoiceChatIngameSettings.voiceAudio).GetComponent<OccludeAudio>().overridingLowPass = false;
				}
				Debug.Log((object)"Reviving players G");
			}
			val.bleedingHeavily = false;
			val.criticallyInjured = false;
			val.playerBodyAnimator.SetBool("Limp", false);
			val.health = 100;
			HUDManager.Instance.UpdateHealthUI(100, false);
			val.spectatedPlayerScript = null;
			((Behaviour)HUDManager.Instance.audioListenerLowPass).enabled = false;
			Debug.Log((object)"Reviving players H");
			instance.SetSpectateCameraToGameOverMode(false, val);
			instance.livingPlayers++;
			instance.allPlayersDead = false;
			instance.UpdatePlayerVoiceEffects();
			if (localPlayerController.playerClientId == val.playerClientId)
			{
				HUDManager.Instance.HideHUD(false);
			}
		}

		public static void SavePlayer(PlayerControllerB player)
		{
			CentipedeAI[] array = Object.FindObjectsByType<CentipedeAI>((FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				if ((Object)(object)array[i].clingingToPlayer == (Object)(object)player)
				{
					((EnemyAI)array[i]).HitEnemy(0, player, true);
				}
			}
			ForestGiantAI[] array2 = Object.FindObjectsByType<ForestGiantAI>((FindObjectsSortMode)0);
			for (int j = 0; j < array2.Length; j++)
			{
				if ((Object)(object)((EnemyAI)array2[j]).inSpecialAnimationWithPlayer == (Object)(object)player)
				{
					((Component)array2[j]).GetComponentInChildren<EnemyAI>().SetEnemyStunned(true, 7.5f, player);
				}
			}
			MaskedPlayerEnemy[] array3 = Object.FindObjectsByType<MaskedPlayerEnemy>((FindObjectsSortMode)0);
			for (int k = 0; k < array3.Length; k++)
			{
				if ((Object)(object)((EnemyAI)array3[k]).inSpecialAnimationWithPlayer == (Object)(object)player)
				{
					((EnemyAI)array3[k]).CancelSpecialAnimationWithPlayer();
					((EnemyAI)array3[k]).HitEnemy(0, player, true);
					((Component)array3[k]).GetComponentInChildren<EnemyAI>().SetEnemyStunned(true, 7.5f, player);
				}
			}
			if (StartOfRound.Instance.localPlayerController.playerClientId == player.playerClientId)
			{
				HUDManager.Instance.HUDAnimator.SetBool("biohazardDamage", false);
			}
		}

		public static void SpawnEnemy(int enemyID, int amount, string targetString)
		{
		}

		public static void SpawnItem(int itemID, int amount, int value, string targetString)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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)
			List<Item> itemsList = StartOfRound.Instance.allItemsList.itemsList;
			if (GetPositionFromCommand(targetString, 0) == Vector3.zero)
			{
				return;
			}
			string text = ((value >= 0) ? $"{value}" : "Random");
			string text2 = ((targetString == "$") ? "Random" : ((!targetString.StartsWith("@")) ? GetPlayerFromString(targetString).playerUsername : ("WP @" + targetString.Substring(1))));
			LogMessage($"Spawned Item\nName: {((Object)itemsList[itemID]).name}, ID: {itemID}, Amount: {amount}, Value: {text}, Location: {text2}.");
			for (int i = 0; i < amount; i++)
			{
				try
				{
					if (itemsList[itemID].minValue > itemsList[itemID].maxValue)
					{
						int minValue = itemsList[itemID].minValue;
						itemsList[itemID].minValue = itemsList[itemID].maxValue;
						itemsList[itemID].maxValue = minValue;
					}
					Item val = Item.CreateAndSpawnItem(itemsList[itemID].itemName, true, GetPositionFromCommand(targetString, 0), default(Quaternion));
					if (itemID == 59)
					{
						mls.LogInfo((object)"RPC SENDING: \"TOT_SYNC_AMMO\".");
						Network.Broadcast<TOT_ITEM_Broadcast>("TOT_SYNC_AMMO", new TOT_ITEM_Broadcast
						{
							networkObjectID = ((NetworkBehaviour)val).NetworkObjectId
						});
						mls.LogInfo((object)"RPC END: \"TOT_SYNC_AMMO\".");
					}
					if ((Object)(object)val != (Object)null && value != -1)
					{
						val.ScrapValue = value;
					}
				}
				catch (Exception ex)
				{
					LogMessage($"Unable to Spawn Item ID: {itemID}", isError: true);
					mls.LogError((object)ex);
				}
			}
		}

		public static void SpawnTrap(int trapID, int amount, string targetString)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			RoundManager instance = RoundManager.Instance;
			if (GetPositionFromCommand(targetString, 4) == Vector3.zero)
			{
				return;
			}
			LogMessage(string.Format(arg2: (targetString == "$") ? "Random" : ((!targetString.StartsWith("@")) ? GetPlayerFromString(targetString).playerUsername : ("WP @" + targetString.Substring(1))), format: "Spawned Trap\nName: {0}, Amount: {1}, Location: {2}.", arg0: (trapID == 1) ? "Turret" : "Mine", arg1: amount));
			switch (trapID)
			{
			case 0:
			{
				SpawnableMapObject[] spawnableMapObjects2 = instance.currentLevel.spawnableMapObjects;
				foreach (SpawnableMapObject val3 in spawnableMapObjects2)
				{
					try
					{
						if ((Object)(object)val3.prefabToSpawn.GetComponentInChildren<Landmine>() != (Object)null)
						{
							for (int l = 0; l < amount; l++)
							{
								Vector3 randomNavMeshPositionInRadius = instance.GetRandomNavMeshPositionInRadius(val3.prefabToSpawn.transform.position, 10f, default(NavMeshHit));
								GameObject val4 = Object.Instantiate<GameObject>(val3.prefabToSpawn, GetPositionFromCommand(targetString, 4), Quaternion.identity);
								val4.GetComponent<NetworkObject>().Spawn(true);
							}
							break;
						}
					}
					catch (Exception ex2)
					{
						LogMessage("Unable to Spawn Trap: " + ((trapID == 1) ? "Turret" : "Mine") + "!", isError: true);
						mls.LogError((object)ex2);
					}
				}
				break;
			}
			case 1:
			{
				SpawnableMapObject[] spawnableMapObjects = instance.currentLevel.spawnableMapObjects;
				foreach (SpawnableMapObject val in spawnableMapObjects)
				{
					try
					{
						if ((Object)(object)val.prefabToSpawn.GetComponentInChildren<Turret>() != (Object)null)
						{
							for (int j = 0; j < amount; j++)
							{
								Vector3 positionFromCommand = GetPositionFromCommand(targetString, 4);
								GameObject val2 = Object.Instantiate<GameObject>(val.prefabToSpawn, positionFromCommand, Quaternion.identity);
								val2.transform.eulerAngles = new Vector3(0f, instance.YRotationThatFacesTheFarthestFromPosition(positionFromCommand + Vector3.up * 0.2f, 25f, 6), 0f);
								val2.GetComponent<NetworkObject>().Spawn(true);
							}
							break;
						}
					}
					catch (Exception ex)
					{
						LogMessage("Unable to Spawn Trap: " + ((trapID == 1) ? "Turret" : "Mine") + "!", isError: true);
						mls.LogError((object)ex);
					}
				}
				break;
			}
			}
		}
	}
	public class Waypoint
	{
		public bool isInside { get; set; }

		public Vector3 position { get; set; }
	}
}
namespace ToxicOmega_Tools.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManager_Patch
	{
		public static bool sendPlayerInside = true;

		private static int itemListPage;

		private static int enemyListPage;

		private static int itemID;

		private static int itemCount;

		private static int itemValue;

		private static int enemyID;

		private static int spawnCount;

		private static int trapID;

		private static string playerString = "";

		private static PlayerControllerB playerTarget = null;

		public static List<SpawnableEnemyWithRarity> allEnemiesList;

		[HarmonyPatch("EnableChat_performed")]
		[HarmonyPrefix]
		private static bool EnableChatAction(HUDManager __instance)
		{
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (localPlayerController.isPlayerDead && Plugin.CheckPlayerIsHost(localPlayerController))
			{
				ShipBuildModeManager.Instance.CancelBuildMode(true);
				__instance.localPlayer.isTypingChat = true;
				((Selectable)__instance.chatTextField).Select();
				__instance.PingHUDElement(__instance.Chat, 0.1f, 1f, 1f);
				((Behaviour)__instance.typingIndicator).enabled = true;
				return false;
			}
			return true;
		}

		[HarmonyPatch("SubmitChat_performed")]
		[HarmonyPrefix]
		private static bool RegisterChatCommand(HUDManager __instance)
		{
			//IL_0ac9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ace: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cde: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dcb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fdb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e84: Unknown result type (might be due to invalid IL or missing references)
			//IL_1592: Unknown result type (might be due to invalid IL or missing references)
			//IL_15a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c39: Unknown result type (might be due to invalid IL or missing references)
			RoundManager instance = RoundManager.Instance;
			Terminal val = Object.FindObjectOfType<Terminal>();
			List<Item> itemsList = StartOfRound.Instance.allItemsList.itemsList;
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			__instance.tipsPanelCoroutine = null;
			bool flag = true;
			string text = __instance.chatTextField.text;
			if (text == null || text == "")
			{
				return true;
			}
			string[] array = (from s in text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
				select s.TrimEnd(Array.Empty<char>()).ToLowerInvariant()).ToArray();
			if (!Plugin.CheckPlayerIsHost(localPlayerController))
			{
				return true;
			}
			switch (array[0].Replace("/", "").ToLower())
			{
			case "help":
			{
				List<string> list4 = new List<string>
				{
					"Item: Lists spawnable items", "Give: Spawns items", "Trap: Spawns traps", "List: Lists current Players/Items/Enemies", "TP: Teleport players", "WP: Creates/lists waypoints", "Heal: Heals/revives a player", "GodMode: Disables death", "Code: Lists/toggles blast doors and traps", "Breaker: Toggles breaker box",
					"Credit: Lists/adjusts spendable credits", "Charge: Charges a player's held item"
				};
				int result3 = 1;
				if (array.Length > 1)
				{
					int.TryParse(array[1], out result3);
				}
				result3 = Math.Max(result3, 1);
				FindPage(list4, result3, 4, "Command");
				break;
			}
			case "item":
			case "it":
			case "items":
				if (array.Length > 1)
				{
					int.TryParse(array[1], out itemListPage);
				}
				itemListPage = Math.Max(itemListPage, 1);
				FindPage(itemsList, itemListPage, 10, "Item");
				break;
			case "give":
			case "gi":
				playerString = "";
				itemID = 0;
				itemCount = 1;
				itemValue = -1;
				if (array.Length < 2)
				{
					FindPage(itemsList, 1, 10, "Item");
					break;
				}
				if (!int.TryParse(array[1], out itemID) || itemID >= itemsList.Count)
				{
					Plugin.LogMessage("Item ID \"" + array[1] + "\" not found!", isError: true);
					break;
				}
				if (array.Length > 2)
				{
					int.TryParse(array[2], out itemCount);
				}
				itemCount = Math.Max(itemCount, 1);
				if (array.Length > 3)
				{
					if (array[3] == "$")
					{
						itemValue = -1;
					}
					else
					{
						int.TryParse(array[3], out itemValue);
						if (itemValue < 0)
						{
							itemValue = 0;
						}
					}
				}
				if (array.Length > 4)
				{
					playerString = string.Join(" ", array.Skip(4)).ToLower();
				}
				Plugin.SpawnItem(itemID, itemCount, itemValue, playerString);
				break;
			case "en":
			case "enemy":
			case "enemies":
				Plugin.LogMessage("Removed!", isError: true);
				break;
			case "sp":
			case "spawn":
				Plugin.LogMessage("Removed!", isError: true);
				break;
			case "trap":
			case "tr":
				spawnCount = 1;
				playerString = "";
				if (array.Length < 2)
				{
					HUDManager.Instance.DisplayTip("Trap List", "ID #0: Mine\nID #1: Turret", false, false, "LC_Tip1");
					break;
				}
				if ("landmine".StartsWith(array[1]) || "mine".StartsWith(array[1]) || array[1] == "0")
				{
					trapID = 0;
				}
				else
				{
					if (!"turret".StartsWith(array[1]) && !(array[1] == "1"))
					{
						Plugin.LogMessage("Unable to find a trap with name " + array[1] + "!", isError: true);
						break;
					}
					trapID = 1;
				}
				if (array.Length > 2)
				{
					int.TryParse(array[2], out spawnCount);
					spawnCount = Math.Max(spawnCount, 1);
				}
				if (array.Length > 3)
				{
					playerString = string.Join(" ", array.Skip(3)).ToLower();
				}
				Plugin.SpawnTrap(trapID, spawnCount, playerString);
				break;
			case "list":
			case "li":
			{
				string text4 = "";
				int result = 1;
				if (array.Length > 2)
				{
					int.TryParse(array[2], out result);
				}
				result = Math.Max(result, 1);
				if (array.Length < 2 || "players".StartsWith(array[1]))
				{
					List<PlayerControllerB> list = StartOfRound.Instance.allPlayerScripts.ToList();
					text4 = "Player";
					FindPage(list, result, 10, text4);
				}
				else if ("items".StartsWith(array[1]))
				{
					List<GrabbableObject> list2 = Object.FindObjectsOfType<GrabbableObject>().ToList();
					text4 = "Active Item";
					FindPage(list2, result, 10, text4);
				}
				else if ("enemy".StartsWith(array[1]) || "enemies".StartsWith(array[1]))
				{
					List<EnemyAI> list3 = Object.FindObjectsOfType<EnemyAI>().ToList();
					text4 = "Active Enemy";
					FindPage(list3, result, 10, text4);
				}
				else
				{
					Plugin.LogMessage("Unable to find list by name " + array[1] + "!", isError: true);
				}
				break;
			}
			case "tele":
			case "tp":
			case "teleport":
				switch (array.Length)
				{
				case 1:
					if (Plugin.GetPositionFromCommand("!", 3, localPlayerController) != Vector3.zero)
					{
						if (!localPlayerController.isPlayerDead)
						{
							Plugin.mls.LogInfo((object)"RPC SENDING: \"TOT_TP_PLAYER\".");
							Network.Broadcast<TOT_TP_PLAYER_Broadcast>("TOT_TP_PLAYER", new TOT_TP_PLAYER_Broadcast
							{
								isInside = false,
								playerClientId = localPlayerController.playerClientId
							});
							Plugin.mls.LogInfo((object)"RPC END: \"TOT_TP_PLAYER\".");
							Player.Get(localPlayerController).Position = Plugin.GetPositionFromCommand("!", 3, localPlayerController);
						}
						else
						{
							Plugin.LogMessage("Could not teleport " + localPlayerController.playerUsername + "!\nPlayer is dead!", isError: true);
						}
					}
					break;
				case 2:
				case 3:
				{
					PlayerControllerB val4 = ((array.Length > 2) ? Plugin.GetPlayerFromString(array[1]) : localPlayerController);
					if ((Object)(object)val4 != (Object)null && !val4.isPlayerDead)
					{
						if (Plugin.GetPositionFromCommand((array.Length > 2) ? array[2] : array[1], 3, val4) != Vector3.zero)
						{
							Plugin.mls.LogInfo((object)"RPC SENDING: \"TOT_TP_PLAYER\".");
							Network.Broadcast<TOT_TP_PLAYER_Broadcast>("TOT_TP_PLAYER", new TOT_TP_PLAYER_Broadcast
							{
								isInside = sendPlayerInside,
								playerClientId = val4.playerClientId
							});
							Plugin.mls.LogInfo((object)"RPC END: \"TOT_TP_PLAYER\".");
							Player.Get(val4).Position = Plugin.GetPositionFromCommand((array.Length > 2) ? array[2] : array[1], 3, val4);
						}
					}
					else if ((Object)(object)val4 != (Object)null && val4.isPlayerDead)
					{
						Plugin.LogMessage("Could not teleport " + val4.playerUsername + "!\nPlayer is dead!", isError: true);
					}
					break;
				}
				}
				break;
			case "wp":
			case "waypoint":
			case "waypoints":
				if (array.Length == 1)
				{
					if (Plugin.Instance.waypoints.Count > 0)
					{
						string text2 = "";
						for (int i = 0; i < Plugin.Instance.waypoints.Count; i++)
						{
							text2 += $"@{i}{Plugin.Instance.waypoints[i].position}, ";
						}
						text2 = text2.TrimEnd(',', ' ') + ".";
						HUDManager.Instance.DisplayTip("Waypoint List", text2, false, false, "LC_Tip1");
					}
					else
					{
						Plugin.LogMessage("Waypoint List is empty!", isError: true);
					}
				}
				else if ("add".StartsWith(array[1]))
				{
					if ((Object)(object)localPlayerController != (Object)null && !localPlayerController.isPlayerDead)
					{
						bool isInFactory = Player.Get(localPlayerController).IsInFactory;
						Vector3 position = ((Component)localPlayerController).transform.position;
						Plugin.Instance.waypoints.Add(new Waypoint
						{
							isInside = isInFactory,
							position = position
						});
						Plugin.LogMessage($"Waypoint @{Plugin.Instance.waypoints.Count - 1} created at {position}.");
					}
				}
				else if ("clear".StartsWith(array[1]))
				{
					Plugin.Instance.waypoints.Clear();
					Plugin.LogMessage("Waypoints cleared.");
				}
				else if ("door".StartsWith(array[1]) || "entrance".StartsWith(array[1]))
				{
					Plugin.Instance.waypoints.Add(new Waypoint
					{
						isInside = true,
						position = RoundManager.FindMainEntrancePosition(true, false)
					});
					Plugin.LogMessage($"Waypoint @{Plugin.Instance.waypoints.Count - 1} created at Main Entrance.");
				}
				break;
			case "heal":
			case "save":
			case "he":
				if (array.Length < 2)
				{
					playerTarget = localPlayerController;
				}
				else
				{
					string searchString2 = string.Join(" ", array.Skip(1)).ToLower();
					playerTarget = Plugin.GetPlayerFromString(searchString2);
				}
				if ((Object)(object)playerTarget != (Object)null)
				{
					if (playerTarget.isPlayerDead)
					{
						Plugin.LogMessage("Attempting to revive " + playerTarget.playerUsername + ".");
					}
					else
					{
						Plugin.LogMessage("Healing " + playerTarget.playerUsername + ".");
					}
					Plugin.mls.LogInfo((object)"RPC SENDING: \"TOT_HEAL_PLAYER\".");
					Network.Broadcast<TOT_PLAYER_Broadcast>("TOT_HEAL_PLAYER", new TOT_PLAYER_Broadcast
					{
						playerClientId = playerTarget.playerClientId
					});
					Plugin.mls.LogInfo((object)"RPC END: \"TOT_HEAL_PLAYER\".");
					Player.Get(playerTarget).SprintMeter = 100f;
					Player.Get(playerTarget).Health = 100;
					Player.Get(playerTarget).Hurt(-1, (CauseOfDeath)0, default(Vector3), false, 0, false, true);
				}
				break;
			case "gm":
			case "godmode":
			case "god":
				Plugin.Instance.enableGod = !Plugin.Instance.enableGod;
				Plugin.LogMessage("GodMode toggled " + (Plugin.Instance.enableGod ? "on!" : "off."));
				break;
			case "code":
			case "co":
			case "codes":
			{
				TerminalAccessibleObject[] array2 = Object.FindObjectsOfType<TerminalAccessibleObject>();
				if (array2.Length != 0)
				{
					if (array.Length < 2)
					{
						string text3 = "";
						TerminalAccessibleObject[] array3 = array2;
						foreach (TerminalAccessibleObject val5 in array3)
						{
							if (val5.objectCode != null)
							{
								text3 += val5.objectCode;
								if (val5.isBigDoor)
								{
									text3 += "(Door), ";
								}
								else if (Object.op_Implicit((Object)(object)((Component)val5).GetComponentInChildren<Turret>()))
								{
									text3 += "(Turret), ";
								}
								else if (Object.op_Implicit((Object)(object)((Component)val5).GetComponentInChildren<Landmine>()))
								{
									text3 += "(Landmine), ";
								}
							}
						}
						text3 = text3.TrimEnd(',', ' ') + ".";
						HUDManager.Instance.DisplayTip("Code List", text3, false, false, "LC_Tip1");
						break;
					}
					TerminalAccessibleObject[] array4 = array2;
					foreach (TerminalAccessibleObject val6 in array4)
					{
						if ((Object)(object)val6 != (Object)null && val6.objectCode == array[1])
						{
							val6.CallFunctionFromTerminal();
							if (Object.op_Implicit((Object)(object)((Component)val6).GetComponentInChildren<Turret>()))
							{
								((Component)val6).GetComponentInChildren<Turret>().ToggleTurretEnabled(false);
							}
							else if (Object.op_Implicit((Object)(object)((Component)val6).GetComponentInChildren<Landmine>()))
							{
								((Component)val6).GetComponentInChildren<Landmine>().ToggleMine(false);
							}
						}
					}
					Plugin.LogMessage("Attempted to toggle all TerminalAccessibleObject of code " + array[1] + ".");
				}
				else
				{
					Plugin.LogMessage("No TerminalAccessibleObject in this area!", isError: true);
				}
				break;
			}
			case "br":
			case "breaker":
			{
				BreakerBox val3 = Object.FindObjectOfType<BreakerBox>();
				if ((Object)(object)val3 != (Object)null)
				{
					val3.SwitchBreaker(!val3.isPowerOn);
					Plugin.LogMessage("Turned breaker " + (val3.isPowerOn ? "on" : "off") + ".");
				}
				else
				{
					Plugin.LogMessage("BreakerBox not found!", isError: true);
				}
				break;
			}
			case "cr":
			case "money":
			case "credits":
			case "credit":
				if ((Object)(object)val != (Object)null)
				{
					if (array.Length < 2)
					{
						Plugin.LogMessage($"Group Credits: {val.groupCredits}");
						break;
					}
					int.TryParse(array[1], out var result2);
					Plugin.mls.LogInfo((object)"RPC SENDING: \"TOT_TERMINAL_CREDITS\".");
					Network.Broadcast<TOT_INT_Broadcast>("TOT_TERMINAL_CREDITS", new TOT_INT_Broadcast
					{
						dataInt = result2
					});
					Plugin.mls.LogInfo((object)"RPC END: \"TOT_TERMINAL_CREDITS\".");
					Plugin.LogMessage($"Adjusted Credits by {result2}.\nNew Total: {val.groupCredits}.");
				}
				else
				{
					Plugin.LogMessage("Terminal not found!", isError: true);
				}
				break;
			case "ch":
			case "charge":
				if (array.Length < 2)
				{
					playerTarget = localPlayerController;
				}
				else
				{
					string searchString = string.Join(" ", array.Skip(1)).ToLower();
					playerTarget = Plugin.GetPlayerFromString(searchString);
				}
				if ((Object)(object)playerTarget != (Object)null && !playerTarget.isPlayerDead)
				{
					GrabbableObject val2 = playerTarget.ItemSlots[playerTarget.currentItemSlot];
					if ((Object)(object)val2 != (Object)null)
					{
						if (val2.itemProperties.requiresBattery)
						{
							Plugin.mls.LogInfo((object)"RPC SENDING: \"TOT_CHARGE_PLAYER\".");
							Network.Broadcast<TOT_PLAYER_Broadcast>("TOT_CHARGE_PLAYER", new TOT_PLAYER_Broadcast
							{
								playerClientId = playerTarget.playerClientId
							});
							Plugin.mls.LogInfo((object)"RPC END: \"TOT_CHARGE_PLAYER\".");
							Plugin.LogMessage("Charging " + playerTarget.playerUsername + "'s item \"" + val2.itemProperties.itemName + "\".");
						}
						else
						{
							Plugin.LogMessage(playerTarget.playerUsername + "'s item \"" + val2.itemProperties.itemName + "\" does not use a battery!", isError: true);
						}
					}
					else
					{
						Plugin.LogMessage(playerTarget.playerUsername + " is not holding an item!", isError: true);
					}
				}
				else if (playerTarget.isPlayerDead)
				{
					Plugin.LogMessage("Could not charge " + playerTarget.playerUsername + "'s item!\nPlayer is dead!", isError: true);
				}
				break;
			default:
				flag = false;
				break;
			}
			if (flag)
			{
				__instance.chatTextField.text = string.Empty;
			}
			if (localPlayerController.isPlayerDead && Plugin.CheckPlayerIsHost(localPlayerController))
			{
				if (!string.IsNullOrEmpty(__instance.chatTextField.text) && __instance.chatTextField.text.Length < 50)
				{
					__instance.AddTextToChatOnServer(__instance.chatTextField.text, (int)__instance.localPlayer.playerClientId);
				}
				for (int l = 0; l < StartOfRound.Instance.allPlayerScripts.Length; l++)
				{
					if (StartOfRound.Instance.allPlayerScripts[l].isPlayerControlled && (double)Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[l]).transform.position) > 24.399999618530273 && (!GameNetworkManager.Instance.localPlayerController.holdingWalkieTalkie || !StartOfRound.Instance.allPlayerScripts[l].holdingWalkieTalkie))
					{
						__instance.playerCouldRecieveTextChatAnimator.SetTrigger("ping");
						break;
					}
				}
				localPlayerController.isTypingChat = false;
				__instance.chatTextField.text = "";
				EventSystem.current.SetSelectedGameObject((GameObject)null);
				__instance.PingHUDElement(__instance.Chat, 2f, 1f, 0.2f);
				((Behaviour)__instance.typingIndicator).enabled = false;
				return false;
			}
			return true;
		}

		private static void FindPage<T>(List<T> list, int page, int itemsPerPage, string listName)
		{
			List<Item> itemsList = StartOfRound.Instance.allItemsList.itemsList;
			List<PlayerControllerB> list2 = StartOfRound.Instance.allPlayerScripts.ToList();
			List<GrabbableObject> list3 = Object.FindObjectsOfType<GrabbableObject>().ToList();
			List<EnemyAI> list4 = Object.FindObjectsOfType<EnemyAI>().ToList();
			bool flag = true;
			int count = list.Count;
			int num = (int)Math.Ceiling((double)count / (double)itemsPerPage);
			page = Math.Min(page, num);
			int num2 = (page - 1) * itemsPerPage;
			int val = num2 + itemsPerPage - 1;
			val = Math.Min(val, count - 1);
			if (num2 < 0 || num2 >= count || num2 > val)
			{
				if (num2 >= count || list.Count == 0)
				{
					Plugin.LogMessage(listName + " list is empty!", isError: true);
				}
				else
				{
					Plugin.LogMessage("Invalid page number! Please enter a valid page number.", isError: true);
				}
				return;
			}
			string text = "";
			for (int i = num2; i <= val; i++)
			{
				switch (listName)
				{
				case "Item":
					text += $"{itemsList[i].itemName}({i}), ";
					continue;
				case "Command":
					text += $"{list[i]}\n";
					continue;
				case "Player":
					if (list2[i].isPlayerControlled)
					{
						text += $"Player #{list2[i].playerClientId}: {list2[i].playerUsername}\n";
						continue;
					}
					break;
				}
				if (listName == "Active Item")
				{
					text = text + list3[i].itemProperties.itemName + ", ";
					flag = false;
				}
				else if (listName == "Active Enemy")
				{
					text = text + list4[i].enemyType.enemyName + ", ";
					flag = false;
				}
			}
			text = text.TrimEnd(',', ' ', '\n') + ((listName == "Player") ? "" : ".");
			string text2 = string.Format("{0}{1} (Page {2} of {3})", listName, flag ? " List" : "", page, num);
			HUDManager.Instance.DisplayTip(text2, text, false, false, "LC_Tip1");
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerB_Patch
	{
		[HarmonyPatch("KillPlayer")]
		[HarmonyPostfix]
		private static void DeadPlayerEnableHUD(PlayerControllerB __instance)
		{
			if (Player.HostPlayer.ClientId == __instance.playerClientId)
			{
				HUDManager instance = HUDManager.Instance;
				instance.HideHUD(false);
				instance.ToggleHUD(true);
			}
		}

		[HarmonyPatch("AllowPlayerDeath")]
		[HarmonyPrefix]
		private static bool OverrideDeath(PlayerControllerB __instance)
		{
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (!Plugin.CheckPlayerIsHost(localPlayerController))
			{
				return true;
			}
			return !Plugin.Instance.enableGod;
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("LoadNewLevel")]
		[HarmonyPrefix]
		private static void ModifyLevel(ref SelectableLevel newLevel)
		{
		}

		private static bool ListHasEnemy(List<SpawnableEnemyWithRarity> list, string enemyName)
		{
			return list.Any((SpawnableEnemyWithRarity e) => e.enemyType.enemyName == enemyName);
		}

		private static List<SpawnableEnemyWithRarity> FixInsideEnemySpawns()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Expected O, but got Unknown
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Expected O, but got Unknown
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Expected O, but got Unknown
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Expected O, but got Unknown
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Expected O, but got Unknown
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Expected O, but got Unknown
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Expected O, but got Unknown
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Expected O, but got Unknown
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Expected O, but got Unknown
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Expected O, but got Unknown
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Expected O, but got Unknown
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Expected O, but got Unknown
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Expected O, but got Unknown
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Expected O, but got Unknown
			List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
			BlobAI val = null;
			CentipedeAI val2 = null;
			CrawlerAI val3 = null;
			DressGirlAI val4 = null;
			FlowermanAI val5 = null;
			HoarderBugAI val6 = null;
			JesterAI val7 = null;
			LassoManAI val8 = null;
			MaskedPlayerEnemy val9 = null;
			NutcrackerEnemyAI val10 = null;
			PufferAI val11 = null;
			SandSpiderAI val12 = null;
			SpringManAI val13 = null;
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(BlobAI));
			foreach (Object val14 in array)
			{
				val = (BlobAI)val14;
			}
			SpawnableEnemyWithRarity val15 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val != (Object)null)
			{
				val15.enemyType = ((EnemyAI)val).enemyType;
			}
			list.Add(val15);
			Object[] array2 = Resources.FindObjectsOfTypeAll(typeof(CentipedeAI));
			foreach (Object val16 in array2)
			{
				val2 = (CentipedeAI)val16;
			}
			SpawnableEnemyWithRarity val17 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val2 != (Object)null)
			{
				val17.enemyType = ((EnemyAI)val2).enemyType;
			}
			list.Add(val17);
			Object[] array3 = Resources.FindObjectsOfTypeAll(typeof(CrawlerAI));
			foreach (Object val18 in array3)
			{
				val3 = (CrawlerAI)val18;
			}
			SpawnableEnemyWithRarity val19 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val3 != (Object)null)
			{
				val19.enemyType = ((EnemyAI)val3).enemyType;
			}
			list.Add(val19);
			Object[] array4 = Resources.FindObjectsOfTypeAll(typeof(DressGirlAI));
			foreach (Object val20 in array4)
			{
				val4 = (DressGirlAI)val20;
			}
			SpawnableEnemyWithRarity val21 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val4 != (Object)null)
			{
				val21.enemyType = ((EnemyAI)val4).enemyType;
			}
			list.Add(val21);
			Object[] array5 = Resources.FindObjectsOfTypeAll(typeof(FlowermanAI));
			foreach (Object val22 in array5)
			{
				val5 = (FlowermanAI)val22;
			}
			SpawnableEnemyWithRarity val23 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val5 != (Object)null)
			{
				val23.enemyType = ((EnemyAI)val5).enemyType;
			}
			list.Add(val23);
			Object[] array6 = Resources.FindObjectsOfTypeAll(typeof(HoarderBugAI));
			foreach (Object val24 in array6)
			{
				val6 = (HoarderBugAI)val24;
			}
			SpawnableEnemyWithRarity val25 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val6 != (Object)null)
			{
				val25.enemyType = ((EnemyAI)val6).enemyType;
			}
			list.Add(val25);
			Object[] array7 = Resources.FindObjectsOfTypeAll(typeof(JesterAI));
			foreach (Object val26 in array7)
			{
				val7 = (JesterAI)val26;
			}
			SpawnableEnemyWithRarity val27 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val7 != (Object)null)
			{
				val27.enemyType = ((EnemyAI)val7).enemyType;
			}
			list.Add(val27);
			Object[] array8 = Resources.FindObjectsOfTypeAll(typeof(LassoManAI));
			foreach (Object val28 in array8)
			{
				val8 = (LassoManAI)val28;
			}
			SpawnableEnemyWithRarity val29 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val8 != (Object)null)
			{
				val29.enemyType = ((EnemyAI)val8).enemyType;
			}
			list.Add(val29);
			Object[] array9 = Resources.FindObjectsOfTypeAll(typeof(MaskedPlayerEnemy));
			foreach (Object val30 in array9)
			{
				val9 = (MaskedPlayerEnemy)val30;
			}
			SpawnableEnemyWithRarity val31 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val9 != (Object)null)
			{
				val31.enemyType = ((EnemyAI)val9).enemyType;
			}
			list.Add(val31);
			Object[] array10 = Resources.FindObjectsOfTypeAll(typeof(NutcrackerEnemyAI));
			foreach (Object val32 in array10)
			{
				val10 = (NutcrackerEnemyAI)val32;
			}
			SpawnableEnemyWithRarity val33 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val10 != (Object)null)
			{
				val33.enemyType = ((EnemyAI)val10).enemyType;
			}
			list.Add(val33);
			Object[] array11 = Resources.FindObjectsOfTypeAll(typeof(PufferAI));
			foreach (Object val34 in array11)
			{
				val11 = (PufferAI)val34;
			}
			SpawnableEnemyWithRarity val35 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val11 != (Object)null)
			{
				val35.enemyType = ((EnemyAI)val11).enemyType;
			}
			list.Add(val35);
			Object[] array12 = Resources.FindObjectsOfTypeAll(typeof(SandSpiderAI));
			foreach (Object val36 in array12)
			{
				val12 = (SandSpiderAI)val36;
			}
			SpawnableEnemyWithRarity val37 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val12 != (Object)null)
			{
				val37.enemyType = ((EnemyAI)val12).enemyType;
			}
			list.Add(val37);
			Object[] array13 = Resources.FindObjectsOfTypeAll(typeof(SpringManAI));
			foreach (Object val38 in array13)
			{
				val13 = (SpringManAI)val38;
			}
			SpawnableEnemyWithRarity val39 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val13 != (Object)null)
			{
				val39.enemyType = ((EnemyAI)val13).enemyType;
			}
			list.Add(val39);
			return list;
		}

		private static List<SpawnableEnemyWithRarity> FixOutsideEnemySpawns()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Expected O, but got Unknown
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Expected O, but got Unknown
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Expected O, but got Unknown
			List<SpawnableEnemyWithRarity> list = new List<SpawnableEnemyWithRarity>();
			BaboonBirdAI val = null;
			DocileLocustBeesAI val2 = null;
			DoublewingAI val3 = null;
			ForestGiantAI val4 = null;
			MouthDogAI val5 = null;
			RedLocustBees val6 = null;
			SandWormAI val7 = null;
			Object[] array = Resources.FindObjectsOfTypeAll(typeof(BaboonBirdAI));
			foreach (Object val8 in array)
			{
				val = (BaboonBirdAI)val8;
			}
			SpawnableEnemyWithRarity val9 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val != (Object)null)
			{
				val9.enemyType = ((EnemyAI)val).enemyType;
			}
			list.Add(val9);
			Object[] array2 = Resources.FindObjectsOfTypeAll(typeof(DocileLocustBeesAI));
			foreach (Object val10 in array2)
			{
				val2 = (DocileLocustBeesAI)val10;
			}
			SpawnableEnemyWithRarity val11 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val2 != (Object)null)
			{
				val11.enemyType = ((EnemyAI)val2).enemyType;
			}
			list.Add(val11);
			Object[] array3 = Resources.FindObjectsOfTypeAll(typeof(DoublewingAI));
			foreach (Object val12 in array3)
			{
				val3 = (DoublewingAI)val12;
			}
			SpawnableEnemyWithRarity val13 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val3 != (Object)null)
			{
				val13.enemyType = ((EnemyAI)val3).enemyType;
			}
			list.Add(val13);
			Object[] array4 = Resources.FindObjectsOfTypeAll(typeof(ForestGiantAI));
			foreach (Object val14 in array4)
			{
				val4 = (ForestGiantAI)val14;
			}
			SpawnableEnemyWithRarity val15 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val4 != (Object)null)
			{
				val15.enemyType = ((EnemyAI)val4).enemyType;
			}
			list.Add(val15);
			Object[] array5 = Resources.FindObjectsOfTypeAll(typeof(MouthDogAI));
			foreach (Object val16 in array5)
			{
				val5 = (MouthDogAI)val16;
			}
			SpawnableEnemyWithRarity val17 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val5 != (Object)null)
			{
				val17.enemyType = ((EnemyAI)val5).enemyType;
			}
			list.Add(val17);
			Object[] array6 = Resources.FindObjectsOfTypeAll(typeof(RedLocustBees));
			foreach (Object val18 in array6)
			{
				val6 = (RedLocustBees)val18;
			}
			SpawnableEnemyWithRarity val19 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val6 != (Object)null)
			{
				val19.enemyType = ((EnemyAI)val6).enemyType;
			}
			list.Add(val19);
			Object[] array7 = Resources.FindObjectsOfTypeAll(typeof(SandWormAI));
			foreach (Object val20 in array7)
			{
				val7 = (SandWormAI)val20;
			}
			SpawnableEnemyWithRarity val21 = new SpawnableEnemyWithRarity();
			if ((Object)(object)val7 != (Object)null)
			{
				val21.enemyType = ((EnemyAI)val7).enemyType;
			}
			list.Add(val21);
			return list;
		}
	}
	[HarmonyPatch(typeof(ShipTeleporter))]
	internal class ShipTeleporter_Patch
	{
		[HarmonyPatch("SetRandomSeed")]
		[HarmonyPostfix]
		private static void grabTeleporterSeed(ref Random ___shipTeleporterSeed)
		{
			Plugin.Instance.shipTeleporterSeed = ___shipTeleporterSeed;
		}

		[HarmonyPatch("OnDisable")]
		[HarmonyPostfix]
		private static void resetTeleporterSeed()
		{
			Plugin.Instance.shipTeleporterSeed = null;
		}
	}
	[HarmonyPatch(typeof(StartMatchLever))]
	internal class StartMatchLever_Patch
	{
		[HarmonyPatch("StartGame")]
		[HarmonyPostfix]
		private static void resetWaypoints()
		{
			Plugin.Instance.waypoints.Clear();
		}
	}
	internal class TOTNetworking
	{
		private static string hostVerifiedMessage = "RPC SENDER VERIFIED AS HOST, PROCEEDING WITH HANDLER METHOD.";

		private static string nonHostSenderMessage = "RPC SENDER IS NOT THE HOST, HANDLER METHOD CANCELLED.";

		[NetworkMessage("TOT_CHARGE_PLAYER", true)]
		public static void TOT_CHARGE_PLAYER_HANDLER(ulong sender, TOT_PLAYER_Broadcast message)
		{
			Plugin.mls.LogInfo((object)"RPC RECEIVED: \"TOT_CHARGE_PLAYER\".");
			PlayerControllerB player2 = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(sender)));
			if (Plugin.CheckPlayerIsHost(player2))
			{
				Plugin.mls.LogInfo((object)hostVerifiedMessage);
				PlayerControllerB val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(message.playerClientId)));
				GrabbableObject val2 = val.ItemSlots[val.currentItemSlot];
				if ((Object)(object)val2 != (Object)null && val2.itemProperties.requiresBattery)
				{
					val2.insertedBattery.charge = 1f;
				}
			}
			else
			{
				Plugin.mls.LogInfo((object)nonHostSenderMessage);
			}
		}

		[NetworkMessage("TOT_HEAL_PLAYER", true)]
		public static void TOT_HEAL_PLAYER_HANDLER(ulong sender, TOT_PLAYER_Broadcast message)
		{
			Plugin.mls.LogInfo((object)"RPC RECEIVED: \"TOT_HEAL_PLAYER\".");
			PlayerControllerB player2 = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(sender)));
			if (Plugin.CheckPlayerIsHost(player2))
			{
				Plugin.mls.LogInfo((object)hostVerifiedMessage);
				PlayerControllerB val = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(message.playerClientId)));
				if ((Object)(object)val != (Object)null && val.isPlayerDead)
				{
					Plugin.RevivePlayer(val.playerClientId);
				}
				if ((Object)(object)val != (Object)null)
				{
					Plugin.SavePlayer(val);
					val.isExhausted = false;
					val.bleedingHeavily = false;
				}
			}
			else
			{
				Plugin.mls.LogInfo((object)nonHostSenderMessage);
			}
		}

		[NetworkMessage("TOT_TERMINAL_CREDITS", true)]
		public static void TOT_TERMINAL_CREDITS_HANDLER(ulong sender, TOT_INT_Broadcast message)
		{
			Plugin.mls.LogInfo((object)"RPC RECEIVED: \"TOT_TERMINAL_CREDITS\".");
			PlayerControllerB player2 = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(sender)));
			if (Plugin.CheckPlayerIsHost(player2))
			{
				Plugin.mls.LogInfo((object)hostVerifiedMessage);
				Terminal val = Object.FindObjectOfType<Terminal>();
				if ((Object)(object)val != (Object)null)
				{
					val.groupCredits += message.dataInt;
				}
			}
			else
			{
				Plugin.mls.LogInfo((object)nonHostSenderMessage);
			}
		}

		[NetworkMessage("TOT_TP_PLAYER", true)]
		public static void TOT_TP_PLAYER_HANDLER(ulong sender, TOT_TP_PLAYER_Broadcast message)
		{
			Plugin.mls.LogInfo((object)"RPC RECEIVED: \"TOT_TP_PLAYER\".");
			PlayerControllerB player2 = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(sender)));
			if (Plugin.CheckPlayerIsHost(player2))
			{
				Plugin.mls.LogInfo((object)hostVerifiedMessage);
				Plugin.mls.LogInfo((object)$"Found: {((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(sender))).playerUsername}, Sending Inside: {message.isInside}");
				Plugin.PlayerTeleportEffects(message.playerClientId, message.isInside);
			}
			else
			{
				Plugin.mls.LogInfo((object)nonHostSenderMessage);
			}
		}

		[NetworkMessage("TOT_SYNC_AMMO", true)]
		public static void TOT_SYNC_AMMO_HANDLER(ulong sender, TOT_ITEM_Broadcast message)
		{
			Plugin.mls.LogInfo((object)"RPC RECEIVED: \"TOT_SYNC_AMMO\".");
			PlayerControllerB player2 = ((IEnumerable<PlayerControllerB>)StartOfRound.Instance.allPlayerScripts).FirstOrDefault((Func<PlayerControllerB, bool>)((PlayerControllerB player) => player.playerClientId.Equals(sender)));
			if (Plugin.CheckPlayerIsHost(player2))
			{
				Plugin.mls.LogInfo((object)hostVerifiedMessage);
				((Component)((IEnumerable<Item>)Item.List).FirstOrDefault((Func<Item, bool>)((Item item) => ((NetworkBehaviour)item).NetworkObjectId.Equals(message.networkObjectID)))).GetComponentInChildren<ShotgunItem>().shellsLoaded = 2;
			}
			else
			{
				Plugin.mls.LogInfo((object)nonHostSenderMessage);
			}
		}
	}
	internal class TOT_INT_Broadcast
	{
		public int dataInt { get; set; }
	}
	internal class TOT_ITEM_Broadcast
	{
		public ulong networkObjectID { get; set; }
	}
	internal class TOT_PLAYER_Broadcast
	{
		public ulong playerClientId { get; set; }
	}
	internal class TOT_TP_PLAYER_Broadcast
	{
		public bool isInside { get; set; }

		public ulong playerClientId { get; set; }
	}
}