Decompiled source of Chats Revenge REPO v1.1.0

plugins/ChatsRevenge/ChatsRevenge.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Logging;
using ChatsRevenge;
using ChatsRevenge.Patches;
using ChatsRevenge.Utils;
using HarmonyLib;
using Newtonsoft.Json;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("chatsRevenge")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("chatsRevenge")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("75d93849-215e-4a79-a691-6b62346e18e9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public class CoroutineRunner : MonoBehaviour
{
	public string functionName;

	public float delaySeconds;

	public object[] parameters = new object[0];

	private bool isready = false;

	public void Update()
	{
		if (isready)
		{
			isready = false;
			((MonoBehaviour)this).Invoke("callFunction", delaySeconds);
		}
	}

	public void delayedFunction(string _functionName, float _delaySeconds, object[] _parameters)
	{
		parameters = _parameters;
		delaySeconds = _delaySeconds;
		functionName = _functionName;
		isready = true;
	}

	private void callFunction()
	{
		string text = functionName;
		object[] array = parameters;
		functionName = "";
		Plugin.Instance.log("DelayedInvoke");
		MethodInfo method = ((object)Plugin.Instance).GetType().GetMethod(text, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (method != null)
		{
			method.Invoke(Plugin.Instance, array);
			return;
		}
		Plugin.Instance.logError("Function '" + text + "' not found in " + ((object)this).GetType().Name + ".");
	}
}
public class ParticleFollower : MonoBehaviour
{
	public Transform target;

	public Vector3 offset;

	private void Update()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)target != (Object)null)
		{
			((Component)this).transform.position = target.position + offset;
		}
	}
}
namespace ChatsRevenge
{
	[BepInPlugin("ChatsRevenge", "ChatsRevenge", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string PluginName = "ChatsRevenge";

		public const string VersionString = "1.0.0";

		public string version = "1.0.0";

		private static readonly Harmony Harmony = new Harmony("ChatsRevenge");

		public GameDirector currentRound;

		private bool loaded = false;

		public static ManualLogSource Log = new ManualLogSource("ChatsRevenge");

		public PlayerController _localController;

		public PlayerAvatar _localAvatar;

		public IDictionary<string, AudioClip> clips = new Dictionary<string, AudioClip>();

		private string itemName;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			else
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			Instance = this;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: ChatsRevenge, VersionString: 1.0.0 is loading...");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: ChatsRevenge, VersionString: 1.0.0 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.PatchAll(typeof(ModUtils));
			Harmony.PatchAll(typeof(PlayerPatches));
			pythonSocket.Instance.start();
			log("CHATSREVENGE AWKAKE");
			loaded = true;
		}

		public bool pluginLoaded()
		{
			return loaded;
		}

		public void preAction()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			currentRound = GameDirector.instance;
			_localController = API.getLocalPlayerController();
			_localAvatar = _localController.playerAvatarScript;
			if (!clips.ContainsKey("mario"))
			{
				AudioClip audioFromFile = API.GetAudioFromFile("https://audio.jukehost.co.uk/Bp1CR9Ccf7XIBN99pFWWnTLdG73ZpQXL");
				clips["mario"] = audioFromFile;
			}
			if (!clips.ContainsKey("nether portal"))
			{
				AudioClip audioFromFile2 = API.GetAudioFromFile("https://audio.jukehost.co.uk/UrLqB7v8BasXza3Kq1FNKiE2uhVdbUkz");
				clips["nether portal"] = audioFromFile2;
			}
			if (!clips.ContainsKey("gamble"))
			{
				AudioClip audioFromFile3 = API.GetAudioFromFile("https://audio.jukehost.co.uk/Pm6dtuoWyUr16onL9zlIraAWKPZS6Xvj");
				clips["gamble"] = audioFromFile3;
			}
		}

		public void sendNotification(string message)
		{
			sendNotificationRPC(message);
			API.CallRPCOtherClients("sendNotificationRPC", message);
		}

		public void sendNotificationRPC(string message)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			SemiFunc.UIBigMessage(message, "{!}", 25f, Color.white, Color.white);
			API.SetFieldOrProperty(BigMessageUI.instance, "bigMessageTimer", 3f);
		}

		public void log(string message)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)message);
		}

		public void logError(string message)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)message);
		}

		public void giveImmunityRPC(string data)
		{
			giveImmunity(int.Parse(data));
		}

		public void giveImmunity(int duration)
		{
			if (duration < 0)
			{
				duration = 1;
			}
			PlayerPatches.immune = true;
			PlayerPatches.immuneEndTime = Time.realtimeSinceStartup + (float)duration;
			string targetedPlayer = API.getTargetedPlayer();
			immunityEffectRPC(targetedPlayer);
			API.CallRPCOtherClients("immunityEffectRPC", targetedPlayer);
		}

		public void immunityEffectRPC(string steamid)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar playerAvatar = API.getPlayerAvatar(steamid);
			GameObject val = Resources.Load<GameObject>("Enemies/Enemy - Ceiling Eye");
			if ((Object)(object)val != (Object)null)
			{
				EnemyCeilingEye componentInChildren = val.GetComponentInChildren<EnemyCeilingEye>();
				if ((Object)(object)componentInChildren == (Object)null)
				{
					logError("enemyscript not found");
					return;
				}
				ParticleSystem val2 = Object.Instantiate<ParticleSystem>(componentInChildren.eyeBeamParticles, ((Component)playerAvatar).transform);
				ParticleFollower particleFollower = ((Component)val2).gameObject.AddComponent<ParticleFollower>();
				particleFollower.target = ((Component)playerAvatar).transform;
				particleFollower.offset = new Vector3(0f, 1f, 0f);
				val2.Play();
				API.delayedFunctiom(this, "stopParticles", PlayerPatches.teleportDuration, val2);
			}
			PlaySoundPlayerLocationLocal("mario", steamid, 5.5f, 0.3f);
		}

		public void teleportPlayer()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			if (!API.isDead(_localAvatar))
			{
				List<LevelPoint> list = SemiFunc.LevelPointsGetAll();
				Random random = new Random();
				int index = random.Next(0, list.Count());
				LevelPoint val = list[index];
				Vector3 position = ((Component)val).transform.position;
				for (float num = Math.Abs(position.x - ((Component)_localAvatar).transform.position.x) + Math.Abs(position.z - ((Component)_localAvatar).transform.position.z); num < 30f; num = Math.Abs(position.x - ((Component)_localAvatar).transform.position.x) + Math.Abs(position.z - ((Component)_localAvatar).transform.position.z))
				{
					random = new Random();
					index = random.Next(0, list.Count());
					val = list[index];
					position = ((Component)val).transform.position;
				}
				API.delayedFunctiom(this, "setPlayerLocation", PlayerPatches.teleportDuration, position);
				string targetedPlayer = API.getTargetedPlayer();
				teleportEffect(targetedPlayer);
				API.CallRPCOtherClients("teleportEffect", targetedPlayer ?? "");
			}
		}

		public void setPlayerLocation(Vector3 location)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!API.isDead(_localAvatar))
			{
				((Component)_localController).transform.position = location;
			}
		}

		public void teleportEffect(string steamid)
		{
			//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_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar playerAvatar = API.getPlayerAvatar(steamid);
			GameObject val = Resources.Load<GameObject>("Valuables/03 Medium/valuable wizard time glass");
			if ((Object)(object)val != (Object)null)
			{
				log("WizardGlass != null");
				ParticleSystem particleSystemSwirl = val.GetComponent<ValuableWizardTimeGlass>().particleSystemSwirl;
				if ((Object)(object)particleSystemSwirl != (Object)null)
				{
					ParticleSystem val2 = Object.Instantiate<ParticleSystem>(particleSystemSwirl, ((Component)playerAvatar).transform);
					ParticleFollower particleFollower = ((Component)val2).gameObject.AddComponent<ParticleFollower>();
					particleFollower.target = ((Component)playerAvatar).transform;
					particleFollower.offset = new Vector3(0f, 1f, 0f);
					val2.Play();
					API.delayedFunctiom(this, "stopParticles", PlayerPatches.teleportDuration, val2);
				}
				ParticleSystem particleSystemGlitter = val.GetComponent<ValuableWizardTimeGlass>().particleSystemGlitter;
				if ((Object)(object)particleSystemGlitter != (Object)null)
				{
					ParticleSystem val3 = Object.Instantiate<ParticleSystem>(particleSystemGlitter, ((Component)playerAvatar).transform);
					ParticleFollower particleFollower2 = ((Component)val3).gameObject.AddComponent<ParticleFollower>();
					particleFollower2.target = ((Component)playerAvatar).transform;
					particleFollower2.offset = new Vector3(0f, 1f, 0f);
					val3.Play();
					API.delayedFunctiom(this, "stopParticles", PlayerPatches.teleportDuration, val3);
				}
			}
			PlaySoundPlayerLocationLocal("nether portal", steamid, PlayerPatches.teleportDuration, 0.1f);
		}

		public void stopParticles(ParticleSystem particle)
		{
			particle.Stop();
			Object.Destroy((Object)(object)particle);
		}

		public void spawnMine()
		{
			PlayerAvatar targetedPlayerAvatar = API.getTargetedPlayerAvatar();
			string text = SemiFunc.PlayerGetSteamID(targetedPlayerAvatar);
			if (API.isHost())
			{
				spawnMineRPC(text);
			}
			else
			{
				API.CallRPC("spawnMineRPC", text);
			}
		}

		public void spawnMineRPC(string steamid)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			preAction();
			PlayerAvatar playerAvatar = API.getPlayerAvatar(steamid);
			Vector3 position = ((Component)playerAvatar).transform.position;
			Quaternion rotation = ((Component)playerAvatar).transform.rotation;
			float num = (float)((double)((Quaternion)(ref rotation)).eulerAngles.y * 3.14 / 180.0);
			position.x += 3f * Mathf.Sin(num);
			position.z += 3f * Mathf.Cos(num);
			position.y += 2f;
			string itemPath = API.getItemPath("Mine Stun");
			GameObject val = API.NetworkInstantiate(itemPath, position, Quaternion.identity, 0);
			ItemMine component = val.GetComponent<ItemMine>();
			API.delayedFunctiom(this, "armMine", 0.1f, component);
		}

		private void armMine(ItemMine mine)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ItemToggle val = (ItemToggle)API.GetFieldOrProperty(mine, "itemToggle");
			val.ToggleItem(true, SemiFunc.PhotonViewIDPlayerAvatarLocal());
			MethodInfo method = ((object)mine).GetType().GetMethod("StateSet", BindingFlags.Instance | BindingFlags.NonPublic);
			method.Invoke(mine, new object[1] { (object)(States)2 });
		}

		public void spawnGrenade()
		{
			PlayerAvatar targetedPlayerAvatar = API.getTargetedPlayerAvatar();
			string text = SemiFunc.PlayerGetSteamID(targetedPlayerAvatar);
			if (API.isHost())
			{
				spawnGrenadeRPC(text);
			}
			else
			{
				API.CallRPC("spawnGrenadeRPC", text);
			}
		}

		public void spawnGrenadeRPC(string steamid)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			preAction();
			PlayerAvatar playerAvatar = API.getPlayerAvatar(steamid);
			Vector3 position = ((Component)playerAvatar).transform.position;
			position.y += 2f;
			string itemPath = API.getItemPath("Grenade Explosive");
			GameObject val = API.NetworkInstantiate(itemPath, position, Quaternion.identity, 0);
			ItemGrenade component = val.GetComponent<ItemGrenade>();
			API.delayedFunctiom(this, "armGrenade", 0.1f, component);
		}

		private void armGrenade(ItemGrenade mine)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ItemToggle val = (ItemToggle)API.GetFieldOrProperty(mine, "itemToggle");
			val.ToggleItem(true, SemiFunc.PhotonViewIDPlayerAvatarLocal());
		}

		public void revive()
		{
			if (API.isDead(_localAvatar))
			{
				string steamID = API.getSteamID(_localAvatar);
				if (API.isHost())
				{
					reviveRPC(steamID);
				}
				else
				{
					API.CallRPC("reviveRPC", steamID);
				}
				return;
			}
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (API.isDead(player))
				{
					player.Revive(false);
					break;
				}
			}
		}

		public void reviveAll()
		{
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (API.isDead(player))
				{
					API.CallRPC("reviveRPC", API.getSteamID(player));
					break;
				}
			}
		}

		public void reviveRPC(string steamid)
		{
			API.getPlayerAvatar(steamid).Revive(false);
		}

		public void PlaySoundPlayerLocation(string clipName, string steamid, float stopTime = 9999f, float volume = 10f)
		{
			API.CallRPCOtherClients("PlaySoundPlayerLocationRPC", $"{clipName}#{steamid}#{stopTime}#{volume}");
			PlaySoundPlayerLocationLocal(clipName, steamid, stopTime, volume);
		}

		public void PlaySoundPlayerLocationRPC(string data)
		{
			string[] array = data.Split(new char[1] { '#' });
			string clipName = array[0];
			string steamid = array[1];
			float stopTime = float.Parse(array[2]);
			float num = float.Parse(array[3]);
			PlaySoundPlayerLocationLocal(clipName, steamid, stopTime);
		}

		public void PlaySoundPlayerLocationLocal(string clipName, string steamid, float stopTime = 9999f, float volume = 10f)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar playerAvatar = API.getPlayerAvatar(steamid);
			try
			{
				AudioClip val = clips[clipName];
				AudioSource val2 = (AudioSource)((Component)playerAvatar).gameObject.AddComponent(typeof(AudioSource));
				val2.clip = val;
				val2.spatialBlend = 1f;
				val2.volume = volume;
				((Component)val2).transform.position = ((Component)playerAvatar).transform.position;
				val2.Play();
				float num = val.length * ((Time.timeScale < 0.01f) ? 0.01f : Time.timeScale);
				if (num > stopTime)
				{
					num = stopTime;
				}
				API.delayedFunctiom(this, "stopAudio", num, val2);
			}
			catch
			{
			}
		}

		public void stopAudio(AudioSource audioSource)
		{
			audioSource.Stop();
			Object.Destroy((Object)(object)audioSource);
		}

		public void destroyMostValuedFountItem()
		{
			//IL_00eb: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			List<GameObject> valuableItmes = API.GetValuableItmes();
			if (valuableItmes.Count == 0)
			{
				return;
			}
			float num = 0f;
			GameObject val = valuableItmes[0];
			foreach (GameObject item in valuableItmes)
			{
				ValuableObject component = item.GetComponent<ValuableObject>();
				bool flag = (bool)API.GetInternalField<ValuableObject>(component, "discovered");
				if (component.dollarValueCurrent > num && flag)
				{
					num = component.dollarValueCurrent;
					val = item;
				}
			}
			ValuableObject component2 = val.GetComponent<ValuableObject>();
			PhysGrabObjectImpactDetector component3 = val.GetComponent<PhysGrabObjectImpactDetector>();
			log($"breaking {((Object)val).name} worth {num}");
			string data = $"{((Object)val).name}#{component2.dollarValueOriginal}#{val.transform.position.x}#{val.transform.position.y}#{val.transform.position.z}";
			destroyItemRPC(data);
			API.CallRPC("destroyItemRPC", data);
		}

		public void destroyClosest()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			List<GameObject> valuableItmes = API.GetValuableItmes();
			if (valuableItmes.Count == 0)
			{
				return;
			}
			PlayerAvatar targetedPlayerAvatar = API.getTargetedPlayerAvatar();
			GameObject val = valuableItmes[0];
			Vector3 val2 = val.transform.position - ((Component)targetedPlayerAvatar).transform.position;
			float num = ((Vector3)(ref val2)).magnitude;
			foreach (GameObject item in valuableItmes)
			{
				val2 = item.transform.position - ((Component)targetedPlayerAvatar).transform.position;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				ValuableObject component = item.GetComponent<ValuableObject>();
				if (num > magnitude)
				{
					num = magnitude;
					val = item;
				}
			}
			ValuableObject component2 = val.GetComponent<ValuableObject>();
			PhysGrabObjectImpactDetector component3 = val.GetComponent<PhysGrabObjectImpactDetector>();
			log("breaking " + ((Object)val).name);
			string data = $"{((Object)val).name}#{component2.dollarValueOriginal}#{val.transform.position.x}#{val.transform.position.y}#{val.transform.position.z}";
			destroyItemRPC(data);
			API.CallRPC("destroyItemRPC", data);
		}

		public void destroyItemRPC(string data)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0105: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			preAction();
			string[] array = data.Split(new char[1] { '#' });
			string text = array[0];
			float num = float.Parse(array[1]);
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(float.Parse(array[2]), float.Parse(array[3]), float.Parse(array[4]));
			List<GameObject> valuableItmes = API.GetValuableItmes();
			foreach (GameObject item in valuableItmes)
			{
				if (((Object)item).name != text || Math.Abs(item.GetComponent<ValuableObject>().dollarValueOriginal - num) > 5f)
				{
					continue;
				}
				Vector3 val2 = item.transform.position - val;
				if (((Vector3)(ref val2)).magnitude > 5f)
				{
					continue;
				}
				PhysGrabObjectImpactDetector component = item.GetComponent<PhysGrabObjectImpactDetector>();
				PhysAudio val3 = (PhysAudio)API.GetFieldOrProperty(component, "impactAudio");
				Sound val4 = new Sound();
				val4 = val3.breakMedium;
				val4.Play(item.transform.position, 1f, 1f, 1f, 1f);
				GameObject val5 = Resources.Load<GameObject>("Enemies/Enemy - Beamer");
				if ((Object)(object)val5 != (Object)null)
				{
					EnemyBeamer componentInChildren = val5.GetComponentInChildren<EnemyBeamer>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						ParticleSystem val6 = Object.Instantiate<ParticleSystem>(componentInChildren.particleDeathBody, item.transform.position, Quaternion.identity);
						ParticleSystem val7 = Object.Instantiate<ParticleSystem>(componentInChildren.particleDeathSmoke, item.transform.position, Quaternion.identity);
						val6.Play();
						val7.Play();
						API.delayedFunctiom(this, "stopParticles", 1f, val6);
						API.delayedFunctiom(this, "stopParticles", 1f, val7);
					}
				}
				if (API.isHost())
				{
					API.delayedFunctiom(this, "destroyItemServer", 0.1f, item);
				}
				break;
			}
		}

		public void destroyItemServer(GameObject item)
		{
			if (API.isHost())
			{
				PhotonNetwork.Destroy(item);
			}
		}

		public void antiGravity(float time)
		{
			_localController.AntiGravity(time);
		}

		public void antiGravityRPC(string time)
		{
			_localController.AntiGravity(float.Parse(time));
		}

		public void healPlayer()
		{
			healRPC();
		}

		public void healRPC(string data = "")
		{
			int num = (int)API.GetFieldOrProperty(_localAvatar.playerHealth, "maxHealth");
			((Component)_localAvatar).GetComponent<PlayerHealth>().Heal(num, true);
		}

		public void discountRPC(string data)
		{
			List<ItemAttributes> list = (List<ItemAttributes>)API.GetFieldOrProperty(ShopManager.instance, "shoppingList");
			foreach (ItemAttributes item in list)
			{
				float num = (float)API.GetFieldOrProperty(item, "itemValueMin");
				float num2 = (float)API.GetFieldOrProperty(item, "itemValueMax");
				API.SetFieldOrProperty(item, "itemValueMin", num / 2f);
				API.SetFieldOrProperty(item, "itemValueMax", num2 / 2f);
				item.GetValue();
			}
		}

		public void lootbox()
		{
			string targetedPlayer = API.getTargetedPlayer();
			lootboxRPC(targetedPlayer);
			API.CallRPCOtherClients("lootboxRPC", targetedPlayer);
		}

		public void lootboxRPC(string steamid)
		{
			PlaySoundPlayerLocation("gamble", steamid, 9999f, 0.1f);
			API.delayedFunctiom(this, "spawnMyteryItem", 4f, steamid);
		}

		public void spawnMyteryItem(string steamid)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar playerAvatar = API.getPlayerAvatar(steamid);
			Vector3 position = ((Component)playerAvatar).transform.position;
			Quaternion rotation = ((Component)playerAvatar).transform.rotation;
			float num = (float)((double)((Quaternion)(ref rotation)).eulerAngles.y * 3.14 / 180.0);
			position.x += 3f * Mathf.Sin(num);
			position.z += 3f * Mathf.Cos(num);
			position.y += 0.5f;
			GameObject val = Resources.Load<GameObject>("Enemies/Enemy - Beamer");
			if ((Object)(object)val != (Object)null)
			{
				EnemyBeamer componentInChildren = val.GetComponentInChildren<EnemyBeamer>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					ParticleSystem val2 = Object.Instantiate<ParticleSystem>(componentInChildren.particleDeathSmoke, position, Quaternion.identity);
					val2.Play();
					API.delayedFunctiom(this, "stopParticles", 1f, val2);
				}
			}
			if (!API.isHost())
			{
				return;
			}
			List<Item> list = new List<Item>(StatsManager.instance.itemDictionary.Values);
			List<GameObject> list2 = new List<GameObject>();
			foreach (Item item in list)
			{
				list2.Add(item.prefab);
			}
			List<GameObject> collection = (List<GameObject>)API.GetFieldOrProperty(ValuableDirector.instance, "tinyValuables");
			List<GameObject> collection2 = (List<GameObject>)API.GetFieldOrProperty(ValuableDirector.instance, "smallValuables");
			List<GameObject> collection3 = (List<GameObject>)API.GetFieldOrProperty(ValuableDirector.instance, "mediumValuables");
			List<GameObject> collection4 = (List<GameObject>)API.GetFieldOrProperty(ValuableDirector.instance, "bigValuables");
			List<GameObject> collection5 = (List<GameObject>)API.GetFieldOrProperty(ValuableDirector.instance, "wideValuables");
			List<GameObject> list3 = new List<GameObject>();
			list3.AddRange(list2);
			list3.AddRange(collection);
			list3.AddRange(collection2);
			list3.AddRange(collection3);
			list3.AddRange(collection4);
			list3.AddRange(collection5);
			int index = Random.Range(0, list3.Count);
			GameObject val3 = list3[index];
			string itemPath = API.getItemPath(((Object)val3).name);
			API.NetworkInstantiate(itemPath, position, Quaternion.identity, 0);
		}

		public void lightsOff(int duration)
		{
			if (duration < 0)
			{
				duration = 1;
			}
			API.CallRPCOtherClients("lightsOffRPC", $"{duration}");
			lightsOffRPC($"{duration}");
		}

		public void lightsOffRPC(string data)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				((Behaviour)player.flashlightController.spotlight).enabled = false;
				player.flashlightController.halo.enabled = false;
				player.flashlightController.LightActive = false;
				API.SetFieldOrProperty(player.flashlightController, "stateTimer", float.Parse(data) * Time.deltaTime);
				API.InvokeMethod<FlashlightController>(player.flashlightController, "Outro", Array.Empty<object>());
				player.flashlightController.lightOffAudio.Play(((Component)player.flashlightController).transform.position, 1f, 1f, 1f, 1f);
				PlayerPatches.lightsoff = true;
				PlayerPatches.lightsEndTime = Time.realtimeSinceStartup + float.Parse(data);
			}
		}

		public void gnomeInfestation()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar avatar = API.getTargetedPlayerAvatar();
			List<LevelPoint> list = SemiFunc.LevelPointsGetAll();
			log($"spawn pint count {list.Count}");
			list = list.OrderBy((LevelPoint point) => Vector3.Distance(((Component)point).transform.position, ((Component)avatar).transform.position)).ToList();
			int val = 3;
			int num = 4;
			val = Math.Min(val, list.Count);
			for (int i = 0; i < num; i++)
			{
				Random random = new Random();
				int index = random.Next(0, val);
				Vector3 position = ((Component)list[index]).transform.position;
				position.x += 1.5f * (float)random.Next(0, 100) / 100f;
				position.z += 1.5f * (float)random.Next(0, 100) / 100f;
				position.y += 0.5f;
				spawnEnemy("Enemy - Gnome", position);
				EnemyGnomeDirector.instance.gnomes.Clear();
				API.InvokeMethod<EnemyGnomeDirector>(EnemyGnomeDirector.instance, "Setup", Array.Empty<object>());
			}
		}

		public void spawnEnemy(string name, Vector3 location)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (API.isHost())
			{
				spawnEnemyServer(name, location);
				return;
			}
			string data = $"{name}#{location.x}#{location.y}#{location.z}";
			API.CallRPC("spawnEnemyRPC", data);
		}

		public void spawnEnemyRPC(string data)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			string[] array = data.Split(new char[1] { '#' });
			string enemyType = array[0];
			Vector3 location = default(Vector3);
			((Vector3)(ref location))..ctor(float.Parse(array[1]), float.Parse(array[2]), float.Parse(array[3]));
			spawnEnemyServer(enemyType, location);
		}

		public void spawnEnemyServer(string enemyType, Vector3 location)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			foreach (EnemySetup item in EnemyDirector.instance.enemiesDifficulty1)
			{
				bool flag = false;
				foreach (GameObject spawnObject in item.spawnObjects)
				{
					if (((Object)spawnObject).name == enemyType)
					{
						log(((Object)spawnObject).name);
						flag = true;
						break;
					}
				}
				if (flag)
				{
					RunManager.instance.EnemiesSpawnedRemoveStart();
					API.InvokeMethod<LevelGenerator>(LevelGenerator.Instance, "EnemySpawn", new object[2] { item, location });
					EnemyDirector.instance.DebugResult();
					RunManager.instance.EnemiesSpawnedRemoveEnd();
					break;
				}
			}
		}

		public void selfDestruct()
		{
			int num = (int)API.GetFieldOrProperty(_localAvatar.playerHealth, "maxHealth");
			_localAvatar.playerHealth.Hurt(num, false, -1);
		}
	}
}
namespace ChatsRevenge.Utils
{
	internal class API
	{
		public static PlayerController _localController { get; set; }

		public static PlayerAvatar _localAvatar { get; set; }

		public static AudioClip GetAudioFromFile(string audiopath)
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(audiopath, (AudioType)13);
			audioClip.SendWebRequest();
			while (!audioClip.isDone)
			{
			}
			return DownloadHandlerAudioClip.GetContent(audioClip);
		}

		public static void ProcessInput(string input)
		{
			string[] array = input.Split(new char[1] { ';' });
			int num = int.Parse(array[0]);
			string text = array[1];
			string text2 = array[2];
			string text3 = array[3];
			string text4 = array[4];
			int num2 = int.Parse(array[5]);
			bool flag = true;
			Plugin.Instance.log(input);
			if (text == "REPO_immunity")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " gave a player immunity");
				if (flag)
				{
					PlayerAvatar targetedPlayerAvatar = getTargetedPlayerAvatar();
					if ((Object)(object)targetedPlayerAvatar != (Object)(object)_localAvatar)
					{
						CallRPC("giveImmunityRPC", num2.ToString());
					}
					else
					{
						Plugin.Instance.giveImmunity(num2);
					}
				}
			}
			if (text == "REPO_spawnMine")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " spawned a mine");
				if (flag)
				{
					Plugin.Instance.spawnMine();
				}
			}
			if (text == "REPO_spawnGrenade")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " spawned a grenade");
				if (flag)
				{
					Plugin.Instance.spawnGrenade();
				}
			}
			if (text == "REPO_revive")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " revived a player");
				if (flag)
				{
					Plugin.Instance.revive();
				}
			}
			if (text == "REPO_reviveAll")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " revived everyone");
				Plugin.Instance.reviveAll();
			}
			if (text == "REPO_teleport")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " teleported a player");
				if (!isDead(_localAvatar))
				{
					Plugin.Instance.teleportPlayer();
				}
				else
				{
					PlayerAvatar targetedPlayerAvatar2 = getTargetedPlayerAvatar();
					CallRPCClient(targetedPlayerAvatar2.photonView.Owner, "teleportPlayer", "");
				}
			}
			if (text == "REPO_destroyexpensive")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " destroyed the best loot");
				Plugin.Instance.destroyMostValuedFountItem();
			}
			if (text == "REPO_destroyClosest")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " destroyed the closest loot");
				Plugin.Instance.destroyClosest();
			}
			if (text == "REPO_antiGravity")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " removed gravity");
				if (!isDead(_localAvatar))
				{
					Plugin.Instance.antiGravity(num2);
				}
				else
				{
					PlayerAvatar targetedPlayerAvatar3 = getTargetedPlayerAvatar();
					CallRPCClient(targetedPlayerAvatar3.photonView.Owner, "antiGravityRPC", num2.ToString());
				}
			}
			if (text == "REPO_heal")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " healed a player");
				Plugin.Instance.healPlayer();
			}
			if (text == "REPO_healAll")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " healed everyone");
				Plugin.Instance.healPlayer();
				CallRPCOtherClients("healRPC", "");
			}
			if (text == "REPO_discount")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " spawned a mine");
				if (isHost())
				{
					Plugin.Instance.discountRPC("");
				}
				else
				{
					CallRPC("discountRPC", "");
				}
			}
			if (text == "REPO_lootbox")
			{
				Plugin.Instance.sendNotification("<b>ChatsRevenge > </b>" + text2 + " spawned an item");
				Plugin.Instance.lootbox();
			}
			if (text == "REPO_lightsOff")
			{
				Plugin.Instance.sendNotification($"<b>ChatsRevenge > </b>{text2} turned the light off for {num2}s");
				Plugin.Instance.lightsOff(num2);
			}
			if (text == "REPO_gnomeInfestation")
			{
				Plugin.Instance.gnomeInfestation();
			}
			if (text == "REPO_selfDestruct")
			{
				if (isHost())
				{
					Plugin.Instance.selfDestruct();
					return;
				}
				PlayerAvatar targetedPlayerAvatar4 = getTargetedPlayerAvatar();
				CallRPCClient(targetedPlayerAvatar4.photonView.Owner, "ProcessInput", input);
			}
		}

		public static bool inGame()
		{
			try
			{
				if (!Plugin.Instance.pluginLoaded())
				{
					Plugin.Instance.log("Plugin not initialized yet, waiting...");
					return false;
				}
			}
			catch (Exception)
			{
				Debug.Log((object)"Plugin not initialized yet, waiting...");
				return false;
			}
			if (!Plugin.Instance.pluginLoaded())
			{
				Debug.Log((object)"Plugin not initialized yet, waiting...");
				return false;
			}
			if (SemiFunc.RunIsLobbyMenu() || SemiFunc.RunIsLobby() || SemiFunc.RunIsRecording())
			{
				return false;
			}
			return true;
		}

		public static void CallRPC(string functionName, string data)
		{
			if (PhotonNetwork.IsConnected && !PhotonNetwork.IsMasterClient)
			{
				_localAvatar.photonView.RPC("AddToStatsManagerRPC", (RpcTarget)2, new object[2] { functionName, data });
			}
		}

		public static void CallRPCOtherClients(string functionName, string data)
		{
			if (PhotonNetwork.IsConnected)
			{
				_localAvatar.photonView.RPC("AddToStatsManagerRPC", (RpcTarget)1, new object[2] { functionName, data });
			}
		}

		public static void CallRPCClient(Player target, string functionName, string data)
		{
			if (PhotonNetwork.IsConnected && target != _localAvatar.photonView.Owner)
			{
				_localAvatar.photonView.RPC("AddToStatsManagerRPC", target, new object[2] { functionName, data });
			}
		}

		public static bool HandleRPC(string functionName, string data)
		{
			if (functionName == "ProcessInput")
			{
				ProcessInput(data);
				return false;
			}
			MethodInfo method = GetMethod(typeof(Plugin), functionName);
			if (method != null)
			{
				method.Invoke(Plugin.Instance, new object[1] { data });
				return false;
			}
			return true;
		}

		public static void delayedFunctiom<T>(T instance, string functionName, float delaySeconds, params object[] parameters)
		{
			Plugin.Instance.log("StartDelayedFunction");
			((MonoBehaviour)_localController).StartCoroutine(DelayedInvoke(instance, functionName, delaySeconds, parameters));
		}

		private static IEnumerator DelayedInvoke<T>(T instance, string functionName, float delaySeconds, object[] parameters)
		{
			Plugin.Instance.log("DelayedInvoke");
			yield return (object)new WaitForSeconds(delaySeconds);
			MethodInfo method = instance.GetType().GetMethod(functionName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method != null)
			{
				method.Invoke(instance, parameters);
				yield break;
			}
			Plugin.Instance.logError("Function '" + functionName + "' not found in " + instance.GetType().Name + ".");
		}

		public static object GetInternalField<T>(T instance, string fieldName)
		{
			FieldInfo field = typeof(T).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null)
			{
				return field.GetValue(instance);
			}
			Debug.LogWarning((object)("Field '" + fieldName + "' not found in " + typeof(T).Name));
			return null;
		}

		public static GameObject NetworkInstantiate(string prefabName, Vector3 position, Quaternion rotation, byte group = 0, object[] data = null)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			if (PhotonNetwork.CurrentRoom == null)
			{
				Debug.LogError((object)"Can not Instantiate before the client joined/created a room.");
				return null;
			}
			try
			{
				return (GameObject)GetMethod(typeof(PhotonNetwork), "NetworkInstantiate", typeof(InstantiateParameters)).Invoke(null, new object[3]
				{
					(object)new InstantiateParameters(prefabName, position, rotation, group, data, (byte)0, (int[])null, PhotonNetwork.LocalPlayer, PhotonNetwork.ServerTimestamp),
					true,
					false
				});
			}
			catch (Exception ex)
			{
				Debug.LogError((object)ex);
				return null;
			}
		}

		public static MethodInfo GetMethod(Type type, string name, Type uniqueParamType)
		{
			return (from x in type.GetRuntimeMethods()
				where x.Name.Equals(name)
				select x into r
				let p = r.GetParameters()
				where p.Any((ParameterInfo o) => uniqueParamType.IsAssignableFrom(o.ParameterType))
				select r).ToList()[0];
		}

		public static MethodInfo GetMethod(Type type, string functionName)
		{
			return type.GetMethod(functionName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}

		public static void InvokeMethod<T>(T instance, string functionName, params object[] parameters)
		{
			MethodInfo method = typeof(T).GetMethod(functionName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (method != null)
			{
				method.Invoke(instance, parameters);
			}
			else
			{
				Debug.LogError((object)("Function " + functionName + " not found!"));
			}
		}

		public static void SetFieldOrProperty(object target, string name, object value)
		{
			if (target == null)
			{
				throw new ArgumentNullException("target");
			}
			if (string.IsNullOrEmpty(name))
			{
				throw new ArgumentNullException("name");
			}
			Type type = target.GetType();
			FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				field.SetValue(target, value);
				return;
			}
			PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null && property.CanWrite)
			{
				property.SetValue(target, value);
				return;
			}
			throw new ArgumentException("Field or property '" + name + "' not found on type " + type.FullName);
		}

		public static object GetFieldOrProperty(object target, string name)
		{
			if (target == null)
			{
				throw new ArgumentNullException("target");
			}
			if (string.IsNullOrEmpty(name))
			{
				throw new ArgumentNullException("name");
			}
			Type type = target.GetType();
			FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				return field.GetValue(target);
			}
			PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null && property.CanRead)
			{
				return property.GetValue(target);
			}
			throw new ArgumentException("Field or property '" + name + "' not found on type " + type.FullName);
		}

		public static bool ItemMatches(Item item, string name)
		{
			return string.Equals(item.itemAssetName, name, StringComparison.OrdinalIgnoreCase) || string.Equals(item.itemName, name, StringComparison.OrdinalIgnoreCase);
		}

		public static string getSteamID(PlayerAvatar avatar)
		{
			try
			{
				return SemiFunc.PlayerGetSteamID(avatar);
			}
			catch
			{
				return "";
			}
		}

		public static string getSteamID(PlayerController controller)
		{
			return getSteamID(controller.playerAvatarScript);
		}

		public static string getSteamID(PlayerHealth __instance)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			FieldInfo field = typeof(PlayerHealth).GetField("playerAvatar", BindingFlags.Instance | BindingFlags.NonPublic);
			string result = "";
			if (field != null)
			{
				PlayerAvatar avatar = (PlayerAvatar)field.GetValue(__instance);
				result = getSteamID(avatar);
			}
			return result;
		}

		public static PlayerController getLocalPlayerController()
		{
			try
			{
				_localController = PlayerController.instance;
				_localAvatar = _localController.playerAvatarScript;
				PlayerPatches.clientID = getSteamID(_localAvatar);
				return _localController;
			}
			catch
			{
				return null;
			}
		}

		public static bool isDead(PlayerAvatar avatar)
		{
			return (bool)GetInternalField<PlayerAvatar>(avatar, "deadSet");
		}

		public static string getTargetedPlayer()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			if ((Object)(object)_localController == (Object)null)
			{
				getLocalPlayerController();
			}
			PlayerAvatar val = _localAvatar;
			if (isDead(_localAvatar) && Object.op_Implicit((Object)(object)SpectateCamera.instance))
			{
				val = (PlayerAvatar)GetInternalField<SpectateCamera>(SpectateCamera.instance, "player");
				if ((Object)(object)val == (Object)null)
				{
					val = _localAvatar;
				}
			}
			string text = (string)GetInternalField<PlayerAvatar>(val, "playerName");
			string steamID = getSteamID(val);
			Plugin.Instance.log("Spectating " + text + " " + steamID);
			return steamID;
		}

		public static PlayerAvatar getTargetedPlayerAvatar()
		{
			string targetedPlayer = getTargetedPlayer();
			return getPlayerAvatar(targetedPlayer);
		}

		public static PlayerAvatar getPlayerAvatar(string steamid)
		{
			Plugin.Instance.log($"Player count {GameDirector.instance.PlayerList.Count}");
			return SemiFunc.PlayerGetFromSteamID(steamid);
		}

		public static bool isHost()
		{
			return SemiFunc.IsMasterClientOrSingleplayer();
		}

		public static List<GameObject> GetValuableItmes()
		{
			GameObject[] array = GameObject.FindGameObjectsWithTag("Phys Grab Object");
			List<GameObject> list = new List<GameObject>();
			if (array == null || array.Length == 0)
			{
				Plugin.Instance.log("Unable to locate items");
			}
			else
			{
				GameObject[] array2 = array;
				foreach (GameObject val in array2)
				{
					if ((Object)(object)val.GetComponent<ValuableObject>() != (Object)null)
					{
						list.Add(val);
					}
					else if ((Object)(object)val.GetComponentInChildren<ValuableObject>() != (Object)null)
					{
						list.Add(val);
					}
				}
			}
			return list;
		}

		public static string getItemPath(string searchName)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			string[] array = new string[11]
			{
				"Items/", "Items/Items/", "Items/Removed Items/", "Valuables/", "Valuables/01 Tiny/", "Valuables/02 Small/", "Valuables/03 Medium/", "Valuables/04 Big/", "Valuables/05 Wide/", "Valuables/06 Tall/",
				"Valuables/07 Very Tall/"
			};
			string[] array2 = new string[4] { "", "Item ", "Valuable ", "Enemy Valuable - " };
			string[] array3 = array;
			foreach (string text in array3)
			{
				string[] array4 = array2;
				foreach (string text2 in array4)
				{
					string text3 = text + text2 + searchName;
					GameObject val = Resources.Load<GameObject>(text3);
					if ((Object)val != (Object)null)
					{
						return text3;
					}
				}
			}
			return "";
		}
	}
	public class CustomPrefabPool : MonoBehaviour, IPunPrefabPool
	{
		public static Dictionary<string, GameObject> prefabDict = new Dictionary<string, GameObject>();

		public static void RegisterPrefab(string itemName, GameObject prefab)
		{
			if (!prefabDict.ContainsKey(itemName))
			{
				prefabDict[itemName] = prefab;
			}
		}

		public GameObject Instantiate(string prefabId, Vector3 position, Quaternion rotation)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (prefabDict.TryGetValue(prefabId, out var value))
			{
				return Object.Instantiate<GameObject>(value, position, rotation);
			}
			Debug.LogError((object)("Prefab '" + prefabId + "' not found in CustomPrefabPool!"));
			return null;
		}

		public void Destroy(GameObject gameObject)
		{
			Object.Destroy((Object)(object)gameObject);
		}
	}
	internal static class ModUtils
	{
	}
	[JsonObject]
	internal class broadcastData
	{
		[JsonProperty]
		public string command { get; set; }

		[JsonProperty]
		public string text { get; set; }

		[JsonProperty]
		public bool BOOL { get; set; }

		public int INT { get; set; }

		[JsonProperty]
		public float x { get; set; }

		[JsonProperty]
		public float y { get; set; }

		[JsonProperty]
		public float z { get; set; }

		[JsonProperty]
		public float eulerY { get; set; }

		[JsonProperty]
		public ulong clientId { get; set; }
	}
	public class pythonSocket
	{
		private static pythonSocket _instance;

		[SerializeField]
		private string IP = "127.0.0.1";

		[SerializeField]
		private int rxPort = 7885;

		[SerializeField]
		private int txPort = 7886;

		private int indx = -1;

		private UdpClient client;

		private IPEndPoint pythonHost;

		private Thread readDataThread;

		public static pythonSocket Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new pythonSocket();
				}
				return _instance;
			}
		}

		public static Plugin plugin { get; set; }

		public static string currentCMD { get; set; } = "";


		private pythonSocket()
		{
		}

		public void SendData(string message)
		{
			try
			{
				byte[] bytes = Encoding.UTF8.GetBytes(message);
				client.Send(bytes, bytes.Length, pythonHost);
			}
			catch (Exception ex)
			{
				Plugin.Instance.log(ex.ToString());
			}
		}

		public void start()
		{
			pythonHost = new IPEndPoint(IPAddress.Parse(IP), txPort);
			client = new UdpClient(rxPort);
			readDataThread = new Thread(readData);
			readDataThread.IsBackground = true;
			readDataThread.Start();
		}

		public void OnDestroy()
		{
			client.Close();
		}

		private void readData()
		{
			while (true)
			{
				try
				{
					IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 0);
					byte[] bytes = client.Receive(ref remoteEP);
					string @string = Encoding.UTF8.GetString(bytes);
					string[] array = @string.Split(new char[1] { ';' });
					int num = int.Parse(array[0]);
					string text = array[1];
					string text2 = array[2];
					string text3 = array[3];
					if (text.Contains("REPO"))
					{
						if (indx == -1 || (indx != num && num == 0))
						{
							indx = num;
							SendData("REPO " + Plugin.Instance.version);
						}
						else if (num != indx)
						{
							Plugin.Instance.log("received");
							indx = num;
							currentCMD = @string;
							API.ProcessInput(@string);
						}
					}
				}
				catch (Exception ex)
				{
					Plugin.Instance.log(ex.ToString());
				}
			}
		}
	}
}
namespace ChatsRevenge.Patches
{
	[HarmonyPatch(typeof(PlayerController))]
	internal class PlayerPatches
	{
		public static bool immune { get; set; } = false;


		public static string clientID { get; set; } = "";


		public static float immuneDuration { get; set; } = 5.5f;


		public static float immuneEndTime { get; set; }

		public static float teleportDuration { get; set; } = 5f;


		public static float overrideEnergy { get; set; } = 0f;


		public static bool lightsoff { get; set; } = false;


		public static float lightsEndTime { get; set; }

		[HarmonyPatch(typeof(PlayerAvatar), "AddToStatsManagerRPC")]
		[HarmonyPrefix]
		public static bool RPCTrigger(ref string _playerName, ref string _steamID)
		{
			Plugin.Instance.log("AddToStatsManagerRPC " + _playerName + " " + _steamID);
			return API.HandleRPC(_playerName, _steamID);
		}

		[HarmonyPatch(typeof(GameDirector), "gameStateStart")]
		[HarmonyPostfix]
		public static void gameStarted()
		{
			Plugin.Instance.preAction();
		}

		[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeath")]
		[HarmonyPrefix]
		private static bool PlayerDeath_Prefix(PlayerAvatar __instance)
		{
			string steamID = API.getSteamID(__instance);
			if (steamID == clientID && immune)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayerHealth), "Hurt")]
		[HarmonyPrefix]
		public static void Hurt_Prefix(PlayerHealth __instance, ref int damage)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				string steamID = API.getSteamID(__instance);
				if (steamID == clientID && immune)
				{
					damage = 0;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerController), "Update")]
		[HarmonyPrefix]
		private static void Update_prefix(PlayerController __instance)
		{
			if (API.inGame() && !((Object)(object)__instance == (Object)null))
			{
				string steamID = API.getSteamID(__instance);
				if (steamID == clientID)
				{
					overrideEnergy = __instance.EnergyCurrent;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerController), "Update")]
		[HarmonyPostfix]
		private static void Update_postfix(PlayerController __instance)
		{
			if (!API.inGame() || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			string steamID = API.getSteamID(__instance);
			if (steamID == clientID)
			{
				float realtimeSinceStartup = Time.realtimeSinceStartup;
				if (realtimeSinceStartup > immuneEndTime)
				{
					immune = false;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerController), "FixedUpdate")]
		[HarmonyPostfix]
		private static void FixedUpdate_postfix(PlayerController __instance)
		{
			if (API.inGame() && !((Object)(object)__instance == (Object)null))
			{
				string steamID = API.getSteamID(__instance);
				if (steamID == clientID && immune && overrideEnergy > __instance.EnergyCurrent)
				{
					__instance.EnergyCurrent = overrideEnergy;
				}
			}
		}

		[HarmonyPatch(typeof(FlashlightController), "Update")]
		[HarmonyPrefix]
		private static bool flashlight_update(FlashlightController __instance)
		{
			if (!lightsoff)
			{
				return true;
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (realtimeSinceStartup > lightsEndTime)
			{
				lightsoff = false;
				return true;
			}
			API.InvokeMethod<FlashlightController>(__instance, "Outro", Array.Empty<object>());
			return false;
		}

		[HarmonyPatch(typeof(EnemyGnome), "StateSpawn")]
		[HarmonyPostfix]
		private static void StateSpawn_gnome_postfix(EnemyGnome __instance)
		{
			List<Vector3> list = (List<Vector3>)API.GetFieldOrProperty(EnemyGnomeDirector.instance, "destinations");
			int num = (int)API.GetFieldOrProperty(__instance, "directorIndex");
			if (list.Count < num)
			{
				EnemyGnomeDirector.instance.gnomes.Clear();
				API.InvokeMethod<EnemyGnomeDirector>(EnemyGnomeDirector.instance, "Setup", Array.Empty<object>());
			}
		}

		[HarmonyPatch(typeof(EnemyGnome), "StateIdle")]
		[HarmonyPrefix]
		private static void StateIdle_gnome_prefix(EnemyGnome __instance)
		{
			List<Vector3> list = (List<Vector3>)API.GetFieldOrProperty(EnemyGnomeDirector.instance, "destinations");
			int num = (int)API.GetFieldOrProperty(__instance, "directorIndex");
			if (list.Count < num)
			{
				EnemyGnomeDirector.instance.gnomes.Clear();
				API.InvokeMethod<EnemyGnomeDirector>(EnemyGnomeDirector.instance, "Setup", Array.Empty<object>());
			}
		}

		[HarmonyPatch(typeof(EnemyGnome), "StateMove")]
		[HarmonyPrefix]
		private static void StateMove_gnome_prefix(EnemyGnome __instance)
		{
			List<Vector3> list = (List<Vector3>)API.GetFieldOrProperty(EnemyGnomeDirector.instance, "destinations");
			int num = (int)API.GetFieldOrProperty(__instance, "directorIndex");
			if (list.Count < num)
			{
				EnemyGnomeDirector.instance.gnomes.Clear();
				API.InvokeMethod<EnemyGnomeDirector>(EnemyGnomeDirector.instance, "Setup", Array.Empty<object>());
			}
		}

		[HarmonyPatch(typeof(EnemyGnome), "Update")]
		[HarmonyPrefix]
		private static void Update_gnome_prefix(EnemyGnome __instance)
		{
			List<Vector3> list = (List<Vector3>)API.GetFieldOrProperty(EnemyGnomeDirector.instance, "destinations");
			int num = (int)API.GetFieldOrProperty(__instance, "directorIndex");
			if (list.Count < num)
			{
				EnemyGnomeDirector.instance.gnomes.Clear();
				API.InvokeMethod<EnemyGnomeDirector>(EnemyGnomeDirector.instance, "Setup", Array.Empty<object>());
			}
		}
	}
}