Decompiled source of EvenMoreCommands v1.3.1

plugins/EvenMoreCommands.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using EvenMoreCommands.Patches;
using EvenMoreCommands.Utils;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Extensions;
using REPOLib.Modules;
using UnityEngine;
using WebSocketSharp;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Koxek101")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EvenMoreCommands")]
[assembly: AssemblyTitle("EvenMoreCommands")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EvenMoreCommands
{
	[BepInPlugin("Koxek101.EvenMoreCommands", "EvenMoreCommands", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public bool AllowCommandsAsHost;

		public bool AboutToSpawn;

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll(typeof(Plugin));
			Harmony.PatchAll(typeof(Commands));
			Harmony.PatchAll(typeof(MessageSystem));
			Harmony.PatchAll(typeof(Stamina));
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}
namespace EvenMoreCommands.Utils
{
	public class Result<T>
	{
		public bool IsOk { get; set; }

		public T Value { get; set; }

		public string ErrorMessage { get; set; }

		public Result(T value)
		{
			IsOk = true;
			Value = value;
		}

		public Result(string errorMessage)
		{
			IsOk = false;
			ErrorMessage = errorMessage;
		}

		public static Result<T> Ok(T value)
		{
			return new Result<T>(value);
		}

		public static Result<T> Err(string errorMessage)
		{
			return new Result<T>(errorMessage);
		}

		public void Match(Action<Result<T>> Ok, Action<Result<T>> Err)
		{
			if (IsOk)
			{
				Ok(this);
			}
			else
			{
				Err(this);
			}
		}
	}
}
namespace EvenMoreCommands.Patches
{
	[HarmonyPatch(typeof(SemiFunc))]
	[HarmonyPatch("Command")]
	public class Commands : MonoBehaviour
	{
		[HarmonyPostfix]
		public static void Additional_Command(string _command)
		{
			string[] array = _command.Trim().Split(" ");
			string text = array[0].ToLower();
			string[] array2 = ((array.Length >= 2) ? new Span<string>(array, 1, array.Length - 1).ToArray() : Array.Empty<string>());
			Result<string> result2 = Result<string>.Err("Internal error! check logs");
			try
			{
				if (1 == 0)
				{
				}
				Result<string> result3 = text switch
				{
					"/enemy" => SpawnEnemy(array2), 
					"/listenemies" => ListEnemies(), 
					"/kill" => Kill(array2), 
					"/damageplr" => DamagePlayer(array2), 
					"/sethp" => SetHealth(array2), 
					"/respawn" => Respawn(array2), 
					"/damageenemy" => DamageEnemy(array2), 
					"/fixextract" => TryUnsoftlock(), 
					"/extractcheat" => CompleteExtract(array2), 
					"/camshake" => ShakeCam(array2), 
					"/selfdestruct" => SelfDestuctOutsideTruck(array2), 
					"/say" => SendChatMessage(array2), 
					"/damageitem" => DamageItems(array2), 
					"/extractadd" => AddItemsToExtractionInRange(array2), 
					"/extractremove" => RemoveItemsFromExtractionInRange(array2), 
					"/kick" => KickPlayer(array2), 
					"/staminacheat" => ToggleStaminaCheat(), 
					_ => Result<string>.Err("NO_COMMAND_CALLED"), 
				};
				if (1 == 0)
				{
				}
				result2 = result3;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)ex.Message);
				Plugin.Logger.LogError((object)ex.StackTrace);
			}
			try
			{
				result2.Match(delegate(Result<string> result)
				{
					MessageSystem.Instance.SendMessage(result.Value);
				}, delegate(Result<string> err)
				{
					if (!err.ErrorMessage.Equals("NO_COMMAND_CALLED"))
					{
						MessageSystem.Instance.SendMessage(err.ErrorMessage);
					}
				});
			}
			catch (Exception ex2)
			{
				Debug.LogError((object)ex2);
			}
		}

		public static Result<string> ToggleStaminaCheat()
		{
			Stamina.cheat = !Stamina.cheat;
			return Result<string>.Ok("Toggled!");
		}

		public static Result<string> Kill(string[] args)
		{
			string text = "";
			if (args.Length != 0)
			{
				text = args.Aggregate((string x, string y) => x + " " + y);
			}
			if (string.IsNullOrEmpty(text))
			{
				string text2 = "No playername provided.";
				Plugin.Logger.LogError((object)text2);
				return Result<string>.Err(text2);
			}
			text = text.Trim();
			return DamagePlayer(new string[2] { text, "10000" });
		}

		public static Result<string> DamagePlayer(string[] args)
		{
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			int result = 0;
			string text = "";
			if (args.Length != 0)
			{
				if (int.TryParse(args[^1], out result))
				{
					text = args[..^1].Aggregate((string x, string y) => x + " " + y);
				}
				else
				{
					text = args.Aggregate((string x, string y) => x + " " + y);
					result = 1;
				}
			}
			if (string.IsNullOrEmpty(text))
			{
				string text2 = "No playername provided.";
				Plugin.Logger.LogError((object)text2);
				return Result<string>.Err(text2);
			}
			text = text.Trim();
			PlayerAvatar val = null;
			foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
			{
				if (item.playerName.StartsWith(text, StringComparison.OrdinalIgnoreCase))
				{
					val = item;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)("could not find player that name starts with " + text));
				return Result<string>.Err("nu uh");
			}
			PlayerHealth playerHealth = val.playerHealth;
			if ((Object)(object)playerHealth == (Object)null)
			{
				Plugin.Logger.LogError((object)"Target player health is null");
				return Result<string>.Err("nu uh");
			}
			if (SemiFunc.IsMultiplayer())
			{
				playerHealth.HurtOther(result, ((Component)val).transform.position, false, -1);
			}
			else
			{
				playerHealth.Hurt(result, false, -1);
			}
			return Result<string>.Ok("Pew!");
		}

		public static Result<string> ListEnemies()
		{
			string text = "";
			foreach (EnemySetup enemy in EnemyDirectorExtensions.GetEnemies(EnemyDirector.instance))
			{
				text = text + ((Object)enemy.spawnObjects[0]).name + "\n";
			}
			Plugin.Logger.LogMessage((object)text);
			return Result<string>.Ok("Check logs");
		}

		public static Result<string> SpawnEnemy(string[] args)
		{
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			int result = 1;
			string text = "";
			if (args.Length != 0)
			{
				if (int.TryParse(args[^1], out result))
				{
					text = args[..^1].Aggregate((string x, string y) => x + " " + y);
				}
				else
				{
					text = args.Aggregate((string x, string y) => x + " " + y);
					result = 1;
				}
			}
			if (string.IsNullOrEmpty(text))
			{
				string text2 = "No enemy provided.";
				Plugin.Logger.LogError((object)text2);
				return Result<string>.Err(text2);
			}
			text = text.Trim();
			EnemySetup val = default(EnemySetup);
			if (!EnemyDirectorExtensions.TryGetEnemyThatContainsName(EnemyDirector.instance, text, ref val))
			{
				Debug.LogWarning((object)(text + " is not an asset object"));
				return Result<string>.Err("nope!");
			}
			GameObject item = val.spawnObjects[0];
			EnemySetup val2 = ScriptableObject.CreateInstance<EnemySetup>();
			val2.spawnObjects = new List<GameObject>();
			for (int i = 1; i <= result; i++)
			{
				val2.spawnObjects.Add(item);
			}
			Transform transform = ((Component)Camera.main).transform;
			Vector3 position = transform.position + transform.forward * 2f;
			bool flag = true;
			SpawnEnemy(val2, position, Quaternion.identity, spawnDespawned: false);
			return Result<string>.Ok("i should run!");
		}

		public static Result<string> SetHealth(string[] args)
		{
			int result = 0;
			string text = "";
			if (args.Length != 0)
			{
				if (!int.TryParse(args[^1], out result))
				{
					return Result<string>.Err("health value is invalid");
				}
				try
				{
					text = args[..^1].Aggregate((string x, string y) => x + " " + y);
				}
				catch (Exception)
				{
					text = PlayerAvatar.instance.playerName;
				}
			}
			if (string.IsNullOrEmpty(text))
			{
				string text2 = "No playername provided.";
				Plugin.Logger.LogError((object)text2);
				return Result<string>.Err(text2);
			}
			text = text.Trim();
			PlayerAvatar val = null;
			foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
			{
				if (item.playerName.StartsWith(text, StringComparison.OrdinalIgnoreCase))
				{
					val = item;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Logger.LogError((object)("could not find player that name starts with " + text));
				return Result<string>.Err("nu uh");
			}
			PlayerHealth playerHealth = val.playerHealth;
			if ((Object)(object)playerHealth != (Object)null)
			{
				playerHealth.photonView.RPC("UpdateHealthRPC", (RpcTarget)0, new object[3] { result, result, false });
				return Result<string>.Ok("set");
			}
			return Result<string>.Err("Internal error!");
		}

		public static Result<string> Respawn(string[] args)
		{
			int result = 0;
			string text = "";
			if (args.Length != 0)
			{
				if (int.TryParse(args[^1], out result))
				{
					text = args[..^1].Aggregate((string x, string y) => x + " " + y);
				}
				else
				{
					text = args.Aggregate((string x, string y) => x + " " + y);
					result = 0;
				}
			}
			PlayerAvatar val = null;
			if (Ext.IsNullOrEmpty(text))
			{
				val = PlayerAvatar.instance;
			}
			else
			{
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if (player.playerName.StartsWith(text, StringComparison.OrdinalIgnoreCase))
					{
						val = player;
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return Result<string>.Err("thats a nobody");
			}
			if (result == 1)
			{
				val.Revive(false);
			}
			else if (val.deadSet)
			{
				val.Revive(false);
			}
			LevelGenerator instance = LevelGenerator.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.PlayerSpawn();
			}
			return Result<string>.Ok("Boom");
		}

		public static Result<string> DamageEnemy(string[] args)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!int.TryParse(args[0], out var range) || !int.TryParse(args[1], out var damage))
			{
				return Result<string>.Err("invalid params");
			}
			PlayerAvatar plr = PlayerAvatar.instance;
			if ((Object)(object)plr == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"Player avatar is null cannot procced");
				return Result<string>.Err("nope");
			}
			Vector3 location = ((Component)Camera.main).transform.position;
			EnemyDirector.instance.enemiesSpawned.ForEach(delegate(EnemyParent e)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: 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)
				Vector3 val = ((Component)e).transform.position - location;
				if (((Vector3)(ref val)).magnitude <= (float)range)
				{
					Enemy enemy = e.Enemy;
					FieldRef<Enemy, EnemyHealth> val2 = AccessTools.FieldRefAccess<Enemy, EnemyHealth>("Health");
					EnemyHealth val3 = val2.Invoke(enemy);
					val3.Hurt(damage, ((Component)plr).transform.position);
					Plugin.Logger.LogDebug((object)(((Object)enemy).name + " hurt for " + damage + " damage"));
				}
			});
			return Result<string>.Ok("Die!");
		}

		public static Result<string> TryUnsoftlock()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			RoundDirector instance = RoundDirector.instance;
			ExtractionPoint extractionPointCurrent = instance.extractionPointCurrent;
			Plugin.Logger.LogInfo((object)"Softlock detials: ");
			try
			{
				Plugin.Logger.LogInfo((object)extractionPointCurrent.currentState);
				Plugin.Logger.LogInfo((object)extractionPointCurrent.haulCurrent);
				Plugin.Logger.LogInfo((object)extractionPointCurrent.haulSurplus);
				Plugin.Logger.LogInfo((object)RoundDirector.instance.extractionHaulGoal);
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)(ex.Message + "\n" + ex.StackTrace));
			}
			extractionPointCurrent.photonView.RPC("StateSetRPC", (RpcTarget)0, new object[1] { (object)(State)7 });
			instance.photonView.RPC("ExtractionPointUnlockRPC", (RpcTarget)0, Array.Empty<object>());
			return Result<string>.Ok("That should've fixed it");
		}

		public static Result<string> CompleteExtract(string[] args)
		{
			int result = 0;
			if (args.Length != 0)
			{
				bool flag = int.TryParse(args[0], out result);
			}
			RoundDirector instance = RoundDirector.instance;
			if ((Object)(object)instance != (Object)null)
			{
				ExtractionPoint val = instance.extractionPointCurrent;
				if ((Object)(object)val == (Object)null)
				{
					foreach (GameObject extractionPoint in instance.extractionPointList)
					{
						ExtractionPoint component = extractionPoint.GetComponent<ExtractionPoint>();
						if (!component.StateIs((State)7))
						{
							val = component;
							break;
						}
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					if (!instance.extractionPointActive)
					{
						instance.photonView.RPC("ExtractionPointActivateRPC", (RpcTarget)0, new object[1] { val.photonView.ViewID });
					}
					val.photonView.RPC("ExtractionPointSurplusRPC", (RpcTarget)0, new object[1] { result });
					return Result<string>.Ok("yippe");
				}
			}
			return Result<string>.Err("");
		}

		public static Result<string> ShakeCam(string[] args)
		{
			string text = "";
			if (args.Length != 0)
			{
				text = args.Aggregate((string x, string y) => x + " " + y);
			}
			PlayerAvatar val = null;
			if (Ext.IsNullOrEmpty(text))
			{
				val = PlayerAvatar.instance;
			}
			else
			{
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if (player.playerName.StartsWith(text, StringComparison.OrdinalIgnoreCase))
					{
						val = player;
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return Result<string>.Err("thats a nobody");
			}
			Player owner = val.photonView.Owner;
			RoundDirector instance = RoundDirector.instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.photonView.RPC("ExtractionCompletedAllRPC", owner, Array.Empty<object>());
				return Result<string>.Ok("shake");
			}
			return Result<string>.Err("");
		}

		public static Result<string> SelfDestuctOutsideTruck(string[] args)
		{
			string text = "";
			if (args.Length != 0)
			{
				text = args.Aggregate((string x, string y) => x + " " + y);
			}
			PlayerAvatar val = null;
			if (Ext.IsNullOrEmpty(text))
			{
				return Result<string>.Err("thats a nobody");
			}
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (player.playerName.StartsWith(text, StringComparison.OrdinalIgnoreCase))
				{
					val = player;
					break;
				}
			}
			if ((Object)(object)val == (Object)null && !text.Equals("all", StringComparison.OrdinalIgnoreCase))
			{
				return Result<string>.Err("thats a nobody");
			}
			if ((Object)(object)val != (Object)null)
			{
				Player owner = val.photonView.Owner;
				TruckScreenText.instance.photonView.RPC("SelfDestructPlayersOutsideTruckRPC", owner, Array.Empty<object>());
				return Result<string>.Ok("hehe");
			}
			TruckScreenText.instance.photonView.RPC("SelfDestructPlayersOutsideTruckRPC", (RpcTarget)1, Array.Empty<object>());
			return Result<string>.Ok("hehe");
		}

		public static Result<string> SendChatMessage(string[] args)
		{
			string text = "";
			string text2 = "";
			if (args.Length != 0)
			{
				text = args[0];
				args[0] = "";
				text2 = args.Aggregate((string x, string y) => x + " " + y);
			}
			PlayerAvatar val = null;
			if (Ext.IsNullOrEmpty(text))
			{
				val = PlayerAvatar.instance;
			}
			else
			{
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if (player.playerName.StartsWith(text, StringComparison.OrdinalIgnoreCase))
					{
						val = player;
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return Result<string>.Err("thats a nobody");
			}
			Plugin.Logger.LogMessage((object)"trying to say something");
			val.ChatMessageSend(text2, false);
			Plugin.Logger.LogMessage((object)"is it working?");
			return Result<string>.Ok("sayit");
		}

		public static Result<string> DamageItems(string[] args)
		{
			if (!int.TryParse(args[0], out var result) || !int.TryParse(args[1], out var result2))
			{
				return Result<string>.Err("invalid params");
			}
			DamageItemsAsync(result, result2);
			return Result<string>.Ok("Damaged items!");
		}

		public static Result<string> AddItemsToExtractionInRange(string[] args)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!int.TryParse(args[0], out var result))
			{
				return Result<string>.Err("invalid params");
			}
			Vector3 position = ((Component)Camera.current).transform.position;
			int num = 0;
			foreach (PhysGrabObject physGrabObject in RoundDirector.instance.physGrabObjects)
			{
				if (physGrabObject.isValuable)
				{
					ValuableObject component = ((Component)physGrabObject).GetComponent<ValuableObject>();
					Vector3 position2 = ((Component)component).transform.position;
					Vector3 val = position2 - position;
					if (!(((Vector3)(ref val)).magnitude > (float)result))
					{
						component.AddToDollarHaulList();
						num++;
					}
				}
			}
			return Result<string>.Ok("Added " + num + " to Haul list");
		}

		public static Result<string> RemoveItemsFromExtractionInRange(string[] args)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if (!int.TryParse(args[0], out var result))
			{
				return Result<string>.Err("invalid params");
			}
			Vector3 position = ((Component)Camera.current).transform.position;
			int num = 0;
			foreach (PhysGrabObject physGrabObject in RoundDirector.instance.physGrabObjects)
			{
				if (physGrabObject.isValuable)
				{
					ValuableObject component = ((Component)physGrabObject).GetComponent<ValuableObject>();
					Vector3 position2 = ((Component)component).transform.position;
					Vector3 val = position2 - position;
					if (!(((Vector3)(ref val)).magnitude > (float)result))
					{
						component.RemoveFromDollarHaulList();
						num++;
					}
				}
			}
			return Result<string>.Ok("Removed " + num + " from Haul list");
		}

		public static Result<string> KickPlayer(string[] args)
		{
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				string text = "Hi you just tried to use the kick commands as host\r\nWhile probably its possible it would work it shouldn't\r\nFirst of all its toxic to kick players when not the host and if you have a need to do so maybe find a diffrent group to play with";
				Plugin.Logger.LogWarning((object)text);
				return Result<string>.Err("Check Logs!");
			}
			string value = "";
			if (args.Length != 0)
			{
				value = args.Aggregate((string x, string y) => x + " " + y);
			}
			if (string.IsNullOrEmpty(value))
			{
				return Result<string>.Err("thats a nobody");
			}
			PlayerAvatar val = null;
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (player.playerName.StartsWith(value, StringComparison.OrdinalIgnoreCase))
				{
					val = player;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return Result<string>.Err("thats a nobody");
			}
			Player owner = val.photonView.Owner;
			RaiseEventOptions val2 = new RaiseEventOptions();
			val2.TargetActors = new int[1] { owner.ActorNumber };
			RaiseEventOptions val3 = val2;
			if (PhotonNetwork.NetworkingClient.OpRaiseEvent((byte)203, (object)null, val3, SendOptions.SendReliable))
			{
				return Result<string>.Ok("kicked");
			}
			Plugin.Logger.LogError((object)("something went wrong when trying to kick " + val.playerName));
			return Result<string>.Err("Error");
		}

		public static async void DamageItemsAsync(int range, int damage)
		{
			Vector3 pos = ((Component)Camera.main).transform.position;
			int damaged = 0;
			RoundDirector rd = RoundDirector.instance;
			foreach (PhysGrabObject grab in rd.physGrabObjects)
			{
				Vector3 valuablePos = ((Component)grab).transform.position;
				Vector3 val = valuablePos - pos;
				if (!(((Vector3)(ref val)).magnitude > (float)damage))
				{
					damaged++;
					PhysGrabObjectImpactDetector detector = grab.impactDetector;
					detector.Break((float)damage, valuablePos, Random.RandomRangeInt(1, 3));
					await Task.Delay(50);
				}
			}
		}

		internal static List<EnemyParent>? SpawnEnemy(EnemySetup enemySetup, Vector3 position, Quaternion rotation, bool spawnDespawned = true)
		{
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: 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)
			if ((Object)(object)enemySetup == (Object)null)
			{
				Plugin.Logger.LogError((object)"Failed to spawn enemy. EnemySetup is null.");
				return null;
			}
			EnemyParent val = default(EnemyParent);
			if (!EnemySetupExtensions.TryGetEnemyParent(enemySetup, ref val))
			{
				Plugin.Logger.LogError((object)"Failed to spawn enemy. EnemyParent is null.");
				return null;
			}
			if ((Object)(object)LevelGenerator.Instance == (Object)null)
			{
				Plugin.Logger.LogError((object)("Failed to spawn enemy \"" + val.enemyName + "\". EnemySetup instance is null."));
				return null;
			}
			if ((Object)(object)RunManager.instance == (Object)null)
			{
				Plugin.Logger.LogError((object)("Failed to spawn enemy \"" + val.enemyName + "\". RunManager instance is null."));
				return null;
			}
			if ((Object)(object)EnemyDirector.instance == (Object)null)
			{
				Plugin.Logger.LogError((object)("Failed to spawn enemy \"" + val.enemyName + "\". EnemyDirector instance is null."));
				return null;
			}
			List<EnemyParent> list = new List<EnemyParent>();
			EnemyParent val3 = default(EnemyParent);
			foreach (GameObject sortedSpawnObject in EnemySetupExtensions.GetSortedSpawnObjects(enemySetup))
			{
				if ((Object)(object)sortedSpawnObject == (Object)null)
				{
					Plugin.Logger.LogError((object)("Failed to spawn enemy \"" + val.enemyName + "\" spawn object. GameObject is null."));
					continue;
				}
				string enemyPrefabPath = ResourcesHelper.GetEnemyPrefabPath(sortedSpawnObject);
				GameObject val2 = SpawnNetworkPrefab(enemyPrefabPath, position, rotation, 0);
				if ((Object)(object)val2 == (Object)null)
				{
					Plugin.Logger.LogError((object)("Failed to spawn enemy \"" + val.enemyName + "\" spawn object \"" + ((Object)sortedSpawnObject).name + "\""));
				}
				else if (val2.TryGetComponent<EnemyParent>(ref val3))
				{
					list.Add(val3);
					val3.SetupDone = true;
					Enemy componentInChildren = val2.GetComponentInChildren<Enemy>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.EnemyTeleported(position);
					}
					else
					{
						Plugin.Logger.LogError((object)("Enemy \"" + val.enemyName + "\" spawn object \"" + ((Object)sortedSpawnObject).name + "\" does not have an enemy component."));
					}
					LevelGenerator instance = LevelGenerator.Instance;
					instance.EnemiesSpawnTarget++;
					EnemyDirector.instance.FirstSpawnPointAdd(val3);
				}
			}
			if (list.Count == 0)
			{
				Plugin.Logger.LogInfo((object)("Failed to spawn enemy \"" + val.enemyName + "\". No spawn objects where spawned."));
				return list;
			}
			Plugin.Logger.LogInfo((object)$"Spawned enemy \"{val.enemyName}\" at position {position}");
			RunManager.instance.EnemiesSpawnedRemoveEnd();
			return list;
		}

		internal static GameObject? SpawnNetworkPrefab(string prefabId, Vector3 position, Quaternion rotation, byte group = 0, object[]? data = null)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(prefabId))
			{
				Plugin.Logger.LogError((object)"Failed to spawn network prefab. PrefabId is null.");
				return null;
			}
			if (SemiFunc.IsMultiplayer())
			{
				return PhotonNetwork.InstantiateRoomObject(prefabId, position, rotation, group, data);
			}
			GameObject val = Resources.Load<GameObject>(prefabId);
			return Object.Instantiate<GameObject>(val, position, rotation);
		}
	}
	[HarmonyPatch(typeof(SemiFunc))]
	internal class SemiFuncPatch
	{
		[HarmonyPatch("EnemySpawn")]
		[HarmonyPrefix]
		private static bool SemiFunc_Prefix(ref bool __result)
		{
			if (Plugin.Instance.AboutToSpawn)
			{
				__result = true;
				Plugin.Instance.AboutToSpawn = false;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar))]
	[HarmonyPatch("Awake")]
	internal class MessageSystem : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <SendMessageCoroutine>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string message;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <SendMessageCoroutine>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					PlayerAvatar.instance.ChatMessageSend(message, false);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static MessageSystem Instance;

		[HarmonyPostfix]
		public static void Postfix()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = new GameObject("MessageSystem").AddComponent<MessageSystem>();
			}
			else
			{
				Object.Destroy((Object)(object)((Component)Instance).gameObject);
			}
		}

		public void SendMessage(string message)
		{
			((MonoBehaviour)this).StartCoroutine(SendMessageCoroutine(message));
		}

		[IteratorStateMachine(typeof(<SendMessageCoroutine>d__3))]
		public static IEnumerator SendMessageCoroutine(string message)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SendMessageCoroutine>d__3(0)
			{
				message = message
			};
		}
	}
	[HarmonyPatch(typeof(PlayerController))]
	internal class Stamina
	{
		public static bool cheat;

		[HarmonyPatch("Update")]
		[HarmonyPatch("FixedUpdate")]
		[HarmonyPostfix]
		private static void InfiniteStaminaPatch(PlayerController __instance)
		{
			if (cheat)
			{
				if (__instance.sprinting)
				{
					__instance.EnergyCurrent = __instance.EnergyStart;
				}
				else if (__instance.Sliding)
				{
					__instance.EnergyCurrent = __instance.EnergyStart;
				}
			}
		}
	}
}