Decompiled source of Dont Touch Me v1.2.6

BepInEx/plugins/DontTouchMe.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DontTouchMe.NetcodePatcher;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Kittenji")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DontTouchMe")]
[assembly: AssemblyTitle("DontTouchMe")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DontTouchMe
{
	public class Assets
	{
		public static AssetBundle MainAssetBundle;

		public static EnemyType EnemyType;

		public static TerminalNode EnemyNode;

		public static TerminalKeyword EnemyKeyword;

		public static AudioClip AudioMasked1;

		public static AudioClip AudioMasked2;

		internal static Stream GetEmbededResource(string name)
		{
			return Assembly.GetExecutingAssembly().GetManifestResourceStream("DontTouchMe." + name);
		}

		public static void Init()
		{
			MainAssetBundle = AssetBundle.LoadFromStream(GetEmbededResource("dtm.bundle"));
			EnemyType = MainAssetBundle.LoadAsset<EnemyType>("Assets/Mods/DontTouchMe/Resources/DTMEnemy.asset");
			EnemyNode = MainAssetBundle.LoadAsset<TerminalNode>("Assets/Mods/DontTouchMe/Resources/DTMNode.asset");
			EnemyKeyword = MainAssetBundle.LoadAsset<TerminalKeyword>("Assets/Mods/DontTouchMe/Resources/DTMKeyword.asset");
			AudioMasked1 = MainAssetBundle.LoadAsset<AudioClip>("Assets/Mods/DontTouchMe/Resources/dtm_masked_laugh1.wav");
			AudioMasked2 = MainAssetBundle.LoadAsset<AudioClip>("Assets/Mods/DontTouchMe/Resources/dtm_masked_laugh2.wav");
		}
	}
	public class DTMEntityAI : EnemyAI
	{
		[CompilerGenerated]
		private sealed class <>c__DisplayClass29_0
		{
			public float startTime;

			public PlayerControllerB killedPlayer;

			internal bool <ExplodePlayerEffect>b__0()
			{
				if (!(Time.realtimeSinceStartup - startTime > 1f))
				{
					return (Object)(object)killedPlayer.deadBody != (Object)null;
				}
				return true;
			}
		}

		[CompilerGenerated]
		private sealed class <ExplodePlayerEffect>d__29 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public int clientId;

			private <>c__DisplayClass29_0 <>8__1;

			public DTMEntityAI <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				DTMEntityAI dTMEntityAI = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>8__1 = new <>c__DisplayClass29_0();
					<>8__1.killedPlayer = StartOfRound.Instance.allPlayerScripts[clientId];
					<>8__1.startTime = Time.realtimeSinceStartup;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => Time.realtimeSinceStartup - <>8__1.startTime > 1f || (Object)(object)<>8__1.killedPlayer.deadBody != (Object)null));
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					Transform transform = ((Component)<>8__1.killedPlayer).transform;
					if ((Object)(object)<>8__1.killedPlayer.deadBody != (Object)null)
					{
						transform = ((Component)<>8__1.killedPlayer.deadBody).transform;
					}
					Object.Instantiate<GameObject>(StartOfRound.Instance.explosionPrefab, transform.position + Vector3.up * 0.5f, Quaternion.Euler(-90f, 0f, 0f), RoundManager.Instance.mapPropsContainer.transform).SetActive(true);
					((EnemyAI)dTMEntityAI).inSpecialAnimation = 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 List<DTMEntityAI> Instances = new List<DTMEntityAI>();

		[Header("DTM Specific")]
		public InteractTrigger[] Triggers;

		public GameObject Music;

		public AudioSource VoiceA;

		public AudioSource VoiceB;

		private float AttackTime;

		private bool IsAttacking;

		private bool HasAttacked;

		private bool AttemptedMurder;

		public MaskedPlayerEnemy MaskedEnemy;

		[Header("Disguise")]
		public GameObject MainModel;

		public GameObject Disguise;

		private int DisguiseID;

		private float ScreenShakeTime;

		private const float KillWindowMin = 2.3f;

		private const float KillWindowMax = 3.5f;

		private float KillWindowStart = 2.8f;

		private const string ButtonTouchParam = "Touched";

		private const string ButtonPressParam = "Press";

		private Coroutine ExplodePlayerCoroutine;

		public static int Count => Instances.Count;

		public static DTMEntityAI GetClosest(Vector3 pos)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			DTMEntityAI dTMEntityAI = null;
			if (Instances.Count == 0)
			{
				return dTMEntityAI;
			}
			if (Instances.Count == 1)
			{
				return Instances[0];
			}
			float num = float.MaxValue;
			foreach (DTMEntityAI instance in Instances)
			{
				if ((Object)(object)instance == (Object)null)
				{
					Instances.RemoveAll((DTMEntityAI v) => (Object)(object)v == (Object)null);
					dTMEntityAI = GetClosest(pos);
					break;
				}
				float num2 = Vector3.Distance(((Component)instance).transform.position, pos);
				if ((Object)(object)dTMEntityAI == (Object)null || num2 < num)
				{
					dTMEntityAI = instance;
					num = num2;
				}
			}
			return dTMEntityAI;
		}

		public void SetTrigger(bool interactable)
		{
			InteractTrigger[] triggers = Triggers;
			for (int i = 0; i < triggers.Length; i++)
			{
				triggers[i].interactable = interactable;
			}
		}

		public bool CanBeShocked()
		{
			if (!IsAttacking)
			{
				return !HasAttacked;
			}
			return false;
		}

		public override void OnDestroy()
		{
			((EnemyAI)this).OnDestroy();
			Instances.Remove(this);
		}

		public override void Start()
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			Instances.Add(this);
			base.skinnedMeshRenderers = ((Component)this).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			base.meshRenderers = ((Component)this).gameObject.GetComponentsInChildren<MeshRenderer>(true);
			base.thisNetworkObject = ((Component)this).gameObject.GetComponentInChildren<NetworkObject>(true);
			base.thisEnemyIndex = RoundManager.Instance.numberOfEnemiesInScene;
			RoundManager instance = RoundManager.Instance;
			instance.numberOfEnemiesInScene++;
			base.isOutside = Plugin.SpawnOutsideChance > 0 && Random.Range(0, 100) < Plugin.SpawnOutsideChance;
			if (base.isOutside)
			{
				base.allAINodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
				if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
				{
					((EnemyAI)this).EnableEnemyMesh(!StartOfRound.Instance.hangarDoorsClosed || !GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom, false);
				}
			}
			else
			{
				base.allAINodes = GameObject.FindGameObjectsWithTag("AINode");
			}
			base.serverPosition = ((Component)this).transform.position;
			base.updatePositionThreshold = 0f;
			base.path1 = new NavMeshPath();
			base.openDoorSpeedMultiplier = base.enemyType.doorSpeedMultiplier;
			ResetInteraction(changeLocation: true);
			Debug.Log((object)"DON'T TOUCH ME | DON'T TOUCH ME | DON'T TOUCH ME | DON'T TOUCH ME | DON'T TOUCH ME | DON'T TOUCH ME");
			Debug.Log((object)("Spawned Outside: " + base.isOutside));
		}

		private void ResetInteraction(bool changeLocation)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			MaskedEnemy = null;
			base.targetPlayer = null;
			IsAttacking = false;
			HasAttacked = false;
			AttemptedMurder = false;
			SetTrigger(interactable: true);
			((Component)VoiceA).gameObject.SetActive(false);
			base.creatureAnimator.ResetTrigger("Touched");
			base.creatureAnimator.ResetTrigger("Press");
			if (changeLocation)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					Vector3 position = base.allAINodes[Random.Range(0, base.allAINodes.Length)].transform.position;
					position = RoundManager.Instance.GetNavMeshPosition(position, RoundManager.Instance.navHit, 1f, -1);
					((Component)this).transform.position = position;
					((Component)this).transform.rotation = Quaternion.Euler(0f, Random.Range(-180f, 180f), 0f);
					DisguiseID = ((Random.Range(0, 100) < Plugin.DisguiseAsItemChance) ? Random.Range(1, Disguise.transform.childCount) : (-1));
					Debug.Log((object)"[DTM] Trying to sync position with other players.");
					SyncSpawnOnServer();
				}
				else
				{
					base.isClientCalculatingAI = false;
				}
			}
		}

		public override void Update()
		{
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAttacking)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)MaskedEnemy))
			{
				MaskedEnemy = null;
				base.targetPlayer = null;
			}
			float num = Time.time - AttackTime;
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			bool flag = ((EnemyAI)this).PlayerIsTargetable(localPlayerController, false, false) || (localPlayerController.hasBegunSpectating && Object.op_Implicit((Object)(object)localPlayerController.spectatedPlayerScript) && ((EnemyAI)this).PlayerIsTargetable(localPlayerController.spectatedPlayerScript, false, false));
			if (flag && ScreenShakeTime < Time.time)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)3);
				ScreenShakeTime = Time.time + 0.1f;
			}
			AudioSource voiceA = VoiceA;
			bool flag3 = (VoiceB.mute = flag);
			voiceA.mute = !flag3;
			if (num > KillWindowStart && num < 4.4f)
			{
				if (localPlayerController.isPlayerControlled && !localPlayerController.isPlayerDead && flag)
				{
					Vector3 val = ((Component)localPlayerController).transform.position - ((Component)this).transform.position;
					Vector3 val2 = ((Vector3)(ref val)).normalized * Random.Range(15f, 30f);
					val2.y = Random.Range(10f, 15f);
					Vector3 val3 = val2;
					val = default(Vector3);
					localPlayerController.KillPlayer(val3, true, (CauseOfDeath)3, 0, val);
					ExplodePlayerServerRpc((int)localPlayerController.playerClientId);
				}
				if (Plugin.IncludeMonstersOnKill && ((NetworkBehaviour)this).IsServer && !AttemptedMurder)
				{
					foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
					{
						if (Object.op_Implicit((Object)(object)spawnedEnemy) && spawnedEnemy.isOutside == base.isOutside && (Object)(object)((Component)spawnedEnemy).gameObject != (Object)(object)((Component)this).gameObject && spawnedEnemy.thisNetworkObject.IsSpawned && (Plugin.IncludeUnkillableMonsters || spawnedEnemy.enemyType.canDie))
						{
							Debug.Log((object)("[DTM] Killing " + ((Object)spawnedEnemy).name));
							spawnedEnemy.thisNetworkObject.Despawn(true);
						}
					}
					AttemptedMurder = true;
				}
			}
			if (num >= 5f)
			{
				if (Plugin.DestroyEntityAfterTouch)
				{
					IsAttacking = false;
					HasAttacked = true;
					((EnemyAI)this).KillEnemy(true);
				}
				else
				{
					ResetInteraction(Plugin.ChangeLocationAfterTouch);
				}
			}
		}

		[IteratorStateMachine(typeof(<ExplodePlayerEffect>d__29))]
		private IEnumerator ExplodePlayerEffect(int clientId)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ExplodePlayerEffect>d__29(0)
			{
				<>4__this = this,
				clientId = clientId
			};
		}

		[ClientRpc]
		private void ExplodePlayerClientRpc(int clientId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3906254083u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, clientId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3906254083u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (ExplodePlayerCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(ExplodePlayerCoroutine);
				}
				ExplodePlayerCoroutine = ((MonoBehaviour)this).StartCoroutine(ExplodePlayerEffect(clientId));
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void ExplodePlayerServerRpc(int clientId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(877622320u, val, (RpcDelivery)0);
					BytePacker.WriteValueBitPacked(val2, clientId);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 877622320u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					ExplodePlayerClientRpc(clientId);
				}
			}
		}

		private void UpdateDisguise()
		{
			MainModel.SetActive(DisguiseID < 1);
			Disguise.SetActive(!MainModel.activeSelf);
			if (Disguise.activeSelf)
			{
				Transform transform = Disguise.transform;
				for (int i = 1; i < transform.childCount; i++)
				{
					((Component)transform.GetChild(i)).gameObject.SetActive(i == DisguiseID);
				}
			}
		}

		private void SyncSpawnOnServer()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			base.serverPosition = ((Component)this).transform.position;
			Debug.Log((object)("[DTM] Sync Spawn On Server: " + DisguiseID));
			if (((NetworkBehaviour)this).IsOwner)
			{
				SpawnClientRpc(base.serverPosition, ((Component)this).transform.eulerAngles.y, DisguiseID);
			}
			else
			{
				SpawnServerRpc(base.serverPosition, ((Component)this).transform.eulerAngles.y, DisguiseID);
			}
		}

		[ClientRpc]
		public void SpawnClientRpc(Vector3 newPos, float yRot, int disguise)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3860255087u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref newPos);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref yRot, default(ForPrimitives));
					BytePacker.WriteValueBitPacked(val2, disguise);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3860255087u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Debug.Log((object)("[DTM] Received new spawn: " + DisguiseID));
					DisguiseID = disguise;
					((Component)this).transform.position = newPos;
					((Component)this).transform.rotation = Quaternion.Euler(0f, yRot, 0f);
					Music.SetActive(Plugin.PlayMusic && DisguiseID < 1);
					UpdateDisguise();
				}
			}
		}

		[ServerRpc]
		public void SpawnServerRpc(Vector3 newPos, float yRot, int disguise)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Invalid comparison between Unknown and I4
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
				{
					if ((int)networkManager.LogLevel <= 1)
					{
						Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
					}
					return;
				}
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2003288437u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe(ref newPos);
				((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref yRot, default(ForPrimitives));
				BytePacker.WriteValueBitPacked(val2, disguise);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2003288437u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				SpawnClientRpc(newPos, yRot, disguise);
			}
		}

		public void OnTouched(PlayerControllerB player)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAttacking && !((Object)(object)player == (Object)null))
			{
				int num = ((DisguiseID > 0) ? 80 : 20);
				if (Random.Range(0, 100) > num)
				{
					StartAttack(!player.isInsideFactory);
				}
				else if (Random.Range(0, 100) < 10)
				{
					player.JumpToFearLevel(1f, true);
				}
				else
				{
					player.DamagePlayer(999, true, true, (CauseOfDeath)0, Random.Range(1, 3), false, default(Vector3));
				}
			}
		}

		public void StartAttack(bool outside)
		{
			Debug.Log((object)"[DTM] Starting attack");
			if (((NetworkBehaviour)this).IsOwner)
			{
				AttackClientRpc(outside);
			}
			else
			{
				AttackServerRpc(outside);
			}
		}

		[ClientRpc]
		public void AttackClientRpc(bool outside)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3888608358u, val, (RpcDelivery)0);
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref outside, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3888608358u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				Debug.Log((object)"[DTM] Attempting attack on client");
				if (!IsAttacking && !HasAttacked)
				{
					AttackTime = Time.time;
					ScreenShakeTime = 0f;
					KillWindowStart = Random.Range(2.3f, 3.5f);
					DisguiseID = -1;
					Disguise.SetActive(false);
					MainModel.SetActive(true);
					Music.SetActive(false);
					((Component)VoiceA).gameObject.SetActive(true);
					base.isOutside = outside;
					SetTrigger(interactable: false);
					IsAttacking = true;
					base.creatureAnimator.SetTrigger("Touched");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void AttackServerRpc(bool outside)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2283008872u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref outside, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2283008872u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
					Debug.Log((object)"[DTM] Attempting attack from server");
					AttackClientRpc(outside);
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			Debug.Log((object)("[DTM] Hit by enemy: " + (object)playerWhoHit));
			OnTouched(playerWhoHit);
		}

		public override void SetEnemyStunned(bool setToStunned, float setToStunTime = 1f, PlayerControllerB setStunnedByPlayer = null)
		{
			if (setToStunned)
			{
				OnTouched(setStunnedByPlayer);
			}
		}

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

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(3906254083u, new RpcReceiveHandler(__rpc_handler_3906254083), "ExplodePlayerClientRpc");
			((NetworkBehaviour)this).__registerRpc(877622320u, new RpcReceiveHandler(__rpc_handler_877622320), "ExplodePlayerServerRpc");
			((NetworkBehaviour)this).__registerRpc(3860255087u, new RpcReceiveHandler(__rpc_handler_3860255087), "SpawnClientRpc");
			((NetworkBehaviour)this).__registerRpc(2003288437u, new RpcReceiveHandler(__rpc_handler_2003288437), "SpawnServerRpc");
			((NetworkBehaviour)this).__registerRpc(3888608358u, new RpcReceiveHandler(__rpc_handler_3888608358), "AttackClientRpc");
			((NetworkBehaviour)this).__registerRpc(2283008872u, new RpcReceiveHandler(__rpc_handler_2283008872), "AttackServerRpc");
			((EnemyAI)this).__initializeRpcs();
		}

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

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

		private static void __rpc_handler_3860255087(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 newPos = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref newPos);
				float yRot = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref yRot, default(ForPrimitives));
				int disguise = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref disguise);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DTMEntityAI)(object)target).SpawnClientRpc(newPos, yRot, disguise);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2003288437(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			Vector3 newPos = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref newPos);
			float yRot = default(float);
			((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref yRot, default(ForPrimitives));
			int disguise = default(int);
			ByteUnpacker.ReadValueBitPacked(reader, ref disguise);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((DTMEntityAI)(object)target).SpawnServerRpc(newPos, yRot, disguise);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}

		private static void __rpc_handler_3888608358(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool outside = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref outside, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DTMEntityAI)(object)target).AttackClientRpc(outside);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2283008872(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool outside = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref outside, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((DTMEntityAI)(object)target).AttackServerRpc(outside);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "DTMEntityAI";
		}
	}
	public class DTMHitBox : MonoBehaviour, IHittable, IShockableWithGun
	{
		public DTMEntityAI mainScript;

		bool IHittable.Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX, int hitID = -1)
		{
			((EnemyAI)mainScript).SetEnemyStunned(true, 1f, playerWhoHit);
			return true;
		}

		bool IShockableWithGun.CanBeShocked()
		{
			return mainScript.CanBeShocked();
		}

		Vector3 IShockableWithGun.GetShockablePosition()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)((EnemyAI)mainScript).eye != (Object)null)
			{
				return ((EnemyAI)mainScript).eye.position;
			}
			return ((Component)this).transform.position + Vector3.up * 1f;
		}

		float IShockableWithGun.GetDifficultyMultiplier()
		{
			return ((EnemyAI)mainScript).enemyType.stunGameDifficultyMultiplier;
		}

		void IShockableWithGun.ShockWithGun(PlayerControllerB shockedByPlayer)
		{
			((EnemyAI)mainScript).SetEnemyStunned(true, 0.25f, shockedByPlayer);
			DTMEntityAI dTMEntityAI = mainScript;
			((EnemyAI)dTMEntityAI).stunnedIndefinitely = ((EnemyAI)dTMEntityAI).stunnedIndefinitely + 1;
		}

		Transform IShockableWithGun.GetShockableTransform()
		{
			return ((Component)this).transform;
		}

		NetworkObject IShockableWithGun.GetNetworkObject()
		{
			return ((NetworkBehaviour)mainScript).NetworkObject;
		}

		void IShockableWithGun.StopShockingWithGun()
		{
		}
	}
	[BepInPlugin("Kittenji.DontTouchMe", "Don't Touch Me", "1.2.6")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GameNetworkManager))]
		internal class GameNetworkManagerPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void StartPatch()
			{
				((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().AddNetworkPrefab(Assets.EnemyType.enemyPrefab);
				Debug.Log((object)"[DTM] Added network prefab");
			}
		}

		[HarmonyPatch(typeof(Terminal))]
		internal class TerminalPatch
		{
			[CompilerGenerated]
			private sealed class <SpecialEvent>d__6 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public Terminal __instance;

				public int index;

				private PlayerControllerB <localPlayer>5__2;

				private InteractTrigger <trigger>5__3;

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

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

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

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<localPlayer>5__2 = null;
					<trigger>5__3 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_0078: Unknown result type (might be due to invalid IL or missing references)
					//IL_0082: Expected O, but got Unknown
					//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
					//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
					//IL_03db: Unknown result type (might be due to invalid IL or missing references)
					//IL_0369: Unknown result type (might be due to invalid IL or missing references)
					//IL_036f: Unknown result type (might be due to invalid IL or missing references)
					//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
					//IL_0211: Unknown result type (might be due to invalid IL or missing references)
					//IL_021b: Expected O, but got Unknown
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						HandlingSpecialEvent = true;
						<localPlayer>5__2 = GameNetworkManager.Instance.localPlayerController;
						<trigger>5__3 = GetTrigger(__instance);
						if (!Object.op_Implicit((Object)(object)<trigger>5__3))
						{
							HandlingSpecialEvent = false;
							return false;
						}
						<>2__current = (object)new WaitForSeconds(0.35f);
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						switch (index)
						{
						case 1:
							break;
						case 2:
							goto IL_012c;
						case 3:
							goto IL_019f;
						case 4:
							goto IL_023e;
						case 5:
							goto IL_02f8;
						case 6:
							goto IL_0382;
						default:
							goto end_IL_0008;
						}
						__instance.QuitTerminal(true);
						if (Random.Range(0, 100) < 34)
						{
							goto IL_00ef;
						}
						Debug.LogWarning((object)"GET OUT!");
						break;
					case 2:
						<>1__state = -1;
						goto IL_00ef;
					case 3:
						<>1__state = -1;
						goto IL_0151;
					case 4:
						<>1__state = -1;
						goto IL_01c4;
					case 5:
						<>1__state = -1;
						goto IL_0263;
					case 6:
						<>1__state = -1;
						goto IL_031d;
					case 7:
						{
							<>1__state = -1;
							goto IL_03a7;
						}
						IL_0382:
						__instance.QuitTerminal(true);
						goto IL_03a7;
						IL_03a7:
						if (<trigger>5__3.currentCooldownValue > 0f)
						{
							<>2__current = null;
							<>1__state = 7;
							return true;
						}
						if (!StartOfRound.Instance.inShipPhase)
						{
							<localPlayer>5__2.KillPlayer(Vector3.up, true, (CauseOfDeath)0, 0, default(Vector3));
							Debug.LogError((object)"Curiosity killed the cat, in this case... you");
						}
						break;
						IL_0151:
						if (<trigger>5__3.currentCooldownValue > 0f)
						{
							<>2__current = null;
							<>1__state = 3;
							return true;
						}
						if (!StartOfRound.Instance.inShipPhase)
						{
							index = RoundManager.Instance.GetRandomWeightedIndex(Terminal_Weights_TP, (Random)null);
							PerformRandomTPOnPlayer(<localPlayer>5__2, index);
						}
						break;
						IL_02f8:
						__instance.QuitTerminal(true);
						goto IL_031d;
						IL_031d:
						if (<trigger>5__3.currentCooldownValue > 0f)
						{
							<>2__current = null;
							<>1__state = 6;
							return true;
						}
						if (!StartOfRound.Instance.inShipPhase && <localPlayer>5__2.health > 5)
						{
							<localPlayer>5__2.DamagePlayer(<localPlayer>5__2.health - 5, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
							Debug.LogError((object)"Ouch, that must hurt.");
						}
						break;
						IL_012c:
						__instance.QuitTerminal(true);
						goto IL_0151;
						IL_019f:
						__instance.QuitTerminal(true);
						goto IL_01c4;
						IL_01c4:
						if (<trigger>5__3.currentCooldownValue > 0f)
						{
							<>2__current = null;
							<>1__state = 4;
							return true;
						}
						for (int i = 0; i < <localPlayer>5__2.ItemSlots.Length; i++)
						{
							GrabbableObject val = <localPlayer>5__2.ItemSlots[i];
							if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.itemProperties) && val.itemProperties.requiresBattery)
							{
								val.insertedBattery = new Battery(true, 0f);
							}
						}
						Debug.LogError((object)"This mod is not sponsored by DURACELL");
						break;
						IL_00ef:
						if (<trigger>5__3.currentCooldownValue > 0f)
						{
							<>2__current = null;
							<>1__state = 2;
							return true;
						}
						<localPlayer>5__2.DropAllHeldItems(true, false);
						Debug.LogError((object)"Haha, butter fingers!");
						break;
						IL_023e:
						__instance.QuitTerminal(true);
						goto IL_0263;
						IL_0263:
						if (<trigger>5__3.currentCooldownValue > 0f)
						{
							<>2__current = null;
							<>1__state = 5;
							return true;
						}
						if (!StartOfRound.Instance.inShipPhase && RoundManager.Instance.outsideAINodes.Length != 0)
						{
							int num = Random.Range(1, 5);
							for (int j = 0; j < num; j++)
							{
								RoundManager.Instance.SpawnEnemyOnServer(Vector3.zero, Random.Range(-180f, 180f), -3);
							}
							Debug.LogError((object)("OOPS! Have fun with " + ((num > 1) ? "those" : "that") + "..."));
						}
						break;
						end_IL_0008:
						break;
					}
					HandlingSpecialEvent = 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();
				}
			}

			private static Random TerminalRandom = new Random();

			private static FieldInfo InteractTriggerField = AccessTools.Field(typeof(Terminal), "terminalTrigger");

			private static InteractTrigger m_Trigger;

			private static bool HandlingSpecialEvent;

			private static InteractTrigger GetTrigger(Terminal __instance)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				if ((Object)(object)m_Trigger == (Object)null)
				{
					m_Trigger = (InteractTrigger)InteractTriggerField.GetValue(__instance);
				}
				return m_Trigger;
			}

			private static void PerformRandomTPOnPlayer(PlayerControllerB localPlayer, int index, bool redirected = false)
			{
				//IL_0213: Unknown result type (might be due to invalid IL or missing references)
				//IL_0218: Unknown result type (might be due to invalid IL or missing references)
				//IL_0222: Unknown result type (might be due to invalid IL or missing references)
				//IL_0227: Unknown result type (might be due to invalid IL or missing references)
				//IL_022c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0200: Unknown result type (might be due to invalid IL or missing references)
				//IL_026a: Unknown result type (might be due to invalid IL or missing references)
				//IL_026f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0275: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: Unknown result type (might be due to invalid IL or missing references)
				//IL_0158: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_016c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_017a: Unknown result type (might be due to invalid IL or missing references)
				//IL_017c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				if (localPlayer.isPlayerDead)
				{
					return;
				}
				bool flag;
				Vector3 val;
				switch (index)
				{
				default:
					return;
				case 0:
				case 1:
				{
					flag = index == 0;
					GameObject[] array = (flag ? RoundManager.Instance.insideAINodes : RoundManager.Instance.outsideAINodes);
					if (array.Length != 0)
					{
						val = array[Random.Range(0, array.Length)].transform.position;
						val = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(val, 10f, default(NavMeshHit));
						Debug.LogWarning((object)"Where am I anyway?");
						break;
					}
					return;
				}
				case 2:
				{
					Turret[] array2 = Object.FindObjectsOfType<Turret>(false);
					if (array2 == null || array2.Length == 0)
					{
						PerformRandomTPOnPlayer(localPlayer, redirected ? Random.Range(0, 2) : 3, redirected: true);
						return;
					}
					Turret val2 = array2[Random.Range(0, array2.Length)];
					if ((Object)(object)val2 == (Object)null)
					{
						return;
					}
					val = ((Component)val2).transform.position;
					flag = val.y < -80f;
					val = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(val, 2f, default(NavMeshHit));
					Debug.LogError((object)"Run Forest, RUN!!!");
					break;
				}
				case 3:
				{
					Landmine[] array3 = Object.FindObjectsOfType<Landmine>(false);
					if (array3 == null || array3.Length == 0)
					{
						PerformRandomTPOnPlayer(localPlayer, redirected ? Random.Range(0, 2) : 2, redirected: true);
						return;
					}
					Landmine val3 = array3[Random.Range(0, array3.Length)];
					if ((Object)(object)val3 == (Object)null)
					{
						return;
					}
					val = ((Component)val3).transform.position;
					flag = val.y < -80f;
					val = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(val, 2f, default(NavMeshHit));
					Debug.LogError((object)"WAIT, DON'T MOVE!!!... Or do... I'm a programmer, not a land mine inspector.");
					break;
				}
				case 4:
				{
					List<EnemyAI> spawnedEnemies = RoundManager.Instance.SpawnedEnemies;
					if (spawnedEnemies == null || spawnedEnemies.Count == 0)
					{
						PerformRandomTPOnPlayer(localPlayer, Random.Range(0, 2), redirected: true);
						return;
					}
					val = ((Component)spawnedEnemies[Random.Range(0, spawnedEnemies.Count)]).transform.position;
					flag = val.y < -80f;
					val = RoundManager.Instance.GetRandomNavMeshPositionInRadiusSpherical(val, 8f, default(NavMeshHit));
					Debug.LogError((object)"OH NO!, that is horrible!!!............ anyway..");
					break;
				}
				case 5:
					val = ((Component)localPlayer).transform.position + Vector3.up * 100f;
					flag = false;
					Debug.LogError((object)"Fly like a bird... wait, why are you falling?");
					break;
				}
				if (!localPlayer.isPlayerDead)
				{
					localPlayer.DropAllHeldItems(true, false);
					localPlayer.isInElevator = false;
					localPlayer.isInHangarShipRoom = false;
					localPlayer.isInsideFactory = flag;
					localPlayer.averageVelocity = 0f;
					localPlayer.velocityLastFrame = Vector3.zero;
					localPlayer.TeleportPlayer(val, false, 0f, false, true);
					HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
				}
			}

			[IteratorStateMachine(typeof(<SpecialEvent>d__6))]
			private static IEnumerator SpecialEvent(Terminal __instance, int index)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <SpecialEvent>d__6(0)
				{
					__instance = __instance,
					index = index
				};
			}

			[HarmonyPatch("RunTerminalEvents")]
			[HarmonyPostfix]
			private static void RunTerminalEventsPatch(ref Terminal __instance, TerminalNode node)
			{
				if (node.terminalEvent == "dontReadMe")
				{
					Debug.Log((object)"Don't read me, please.");
					int randomWeightedIndex = RoundManager.Instance.GetRandomWeightedIndex(Terminal_Weights, TerminalRandom);
					if (!HandlingSpecialEvent)
					{
						((MonoBehaviour)__instance).StartCoroutine(SpecialEvent(__instance, randomWeightedIndex));
					}
				}
			}

			[HarmonyPatch("Start")]
			[HarmonyPrefix]
			private static void StartPatch(ref Terminal __instance)
			{
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Expected O, but got Unknown
				Debug.Log((object)"[DTM] Adding terminal entries");
				TerminalNode terminalNode = Assets.EnemyNode;
				TerminalKeyword val = __instance.terminalNodes.allKeywords.First((TerminalKeyword k) => k.word == "info");
				if (!__instance.enemyFiles.Any((TerminalNode x) => x.creatureName == terminalNode.creatureName))
				{
					TerminalKeyword keyword = Assets.EnemyKeyword;
					keyword.defaultVerb = val;
					List<TerminalKeyword> list = __instance.terminalNodes.allKeywords.ToList();
					if (!list.Any((TerminalKeyword x) => x.word == keyword.word))
					{
						list.Add(keyword);
						__instance.terminalNodes.allKeywords = list.ToArray();
					}
					List<CompatibleNoun> list2 = val.compatibleNouns.ToList();
					if (!list2.Any((CompatibleNoun x) => x.noun.word == keyword.word))
					{
						list2.Add(new CompatibleNoun
						{
							noun = keyword,
							result = terminalNode
						});
					}
					val.compatibleNouns = list2.ToArray();
					terminalNode.creatureFileID = __instance.enemyFiles.Count;
					__instance.enemyFiles.Add(terminalNode);
					Assets.EnemyType.enemyPrefab.GetComponentInChildren<ScanNodeProperties>().creatureScanID = terminalNode.creatureFileID;
					Debug.Log((object)"[DTM] Done adding entries.");
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound))]
		internal class StartOfRoundPatch
		{
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			private static void AwakePatch(ref StartOfRound __instance)
			{
				//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_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Expected O, but got Unknown
				EnemyType enemyDef = Assets.EnemyType;
				SelectableLevel[] levels = __instance.levels;
				foreach (SelectableLevel val in levels)
				{
					if (val.Enemies.Count >= 2 && !val.Enemies.Any((SpawnableEnemyWithRarity e) => (Object)(object)e.enemyType == (Object)(object)enemyDef))
					{
						Debug.Log((object)("[DTM] Adding entity to level: " + val.PlanetName));
						val.Enemies.Add(new SpawnableEnemyWithRarity
						{
							enemyType = enemyDef,
							rarity = SpawnRarity
						});
					}
				}
			}
		}

		private const string modGUID = "Kittenji.DontTouchMe";

		private readonly Harmony harmony = new Harmony("Kittenji.DontTouchMe");

		public static bool PlayMusic = true;

		public static bool IncludeMonstersOnKill = true;

		public static bool IncludeUnkillableMonsters = true;

		public static bool DestroyMonstersOnKill = true;

		public static int SpawnRarity = 24;

		public static int SpawnOutsideChance = 2;

		public static bool ChangeLocationAfterTouch = true;

		public static bool DestroyEntityAfterTouch = true;

		public static int DisguiseAsItemChance = 40;

		private const int Terminal_Weight_None = 0;

		private const int Terminal_Weight_Quit = 0;

		private const int Terminal_Weight_TP = 15;

		private const int Terminal_Weight_Battery = 14;

		private const int Terminal_Weight_Punish = 14;

		private const int Terminal_Weight_Break = 3;

		private const int Terminal_Weight_Kill = 1;

		private const int Terminal_Weight_TP_Inside = 36;

		private const int Terminal_Weight_TP_Outside = 36;

		private const int Terminal_Weight_TP_Turret = 18;

		private const int Terminal_Weight_TP_Landmine = 6;

		private const int Terminal_Weight_TP_Monster = 3;

		private const int Terminal_Weight_TP_Sky = 1;

		private const int Terminal_Punish_Min = 1;

		private const int Terminal_Punish_Max = 5;

		private static readonly int[] Terminal_Weights = new int[7] { 0, 0, 15, 14, 14, 3, 1 };

		private static readonly int[] Terminal_Weights_TP = new int[6] { 36, 36, 18, 6, 3, 1 };

		private void Awake()
		{
			SpawnRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Spawn Rarity", 24, "Spawn rarity. Lower value means lower chance to spawn. (default = 24)").Value;
			SpawnOutsideChance = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Spawn Rarity Outside", 2, "Random chance percentage for this entity to spawn outside. (default = 2)").Value;
			DisguiseAsItemChance = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "Disguise As Item Chance", 45, "Random chance percentage for this entity to disguise itself as an item. (default = 45)").Value;
			ChangeLocationAfterTouch = ((BaseUnityPlugin)this).Config.Bind<bool>("Interaction", "Changes Location", true, "If 'true' the entity will change it's position to a random location after the animation. (default = true)").Value;
			DestroyEntityAfterTouch = ((BaseUnityPlugin)this).Config.Bind<bool>("Interaction", "Destroy After Touch", false, "If 'true' the entity will hide for the rest of the round after touch. It will teleport to a different location. (default = false)").Value;
			IncludeMonstersOnKill = ((BaseUnityPlugin)this).Config.Bind<bool>("Interaction", "Include Monsters On Kill", true, "If 'true' the entity will not pick favorites and will try killing monsters in the facility as well. (default = true)").Value;
			DestroyMonstersOnKill = ((BaseUnityPlugin)this).Config.Bind<bool>("Interaction", "Destroy Monsters On Kill", true, "If 'true' monsters will directly despawn to prevent lag and other potential issues. (default = true)").Value;
			IncludeUnkillableMonsters = ((BaseUnityPlugin)this).Config.Bind<bool>("Interaction", "Include Unkillable Monsters", true, "If 'true' the entity will also kill unkillable monsters too. (default = true)").Value;
			PlayMusic = ((BaseUnityPlugin)this).Config.Bind<bool>("Audio", "Play Music", true, "If 'true' the entity will play ominous music (Lobotomy Corp OST - Neutral 01) that can be heard in the distance, getting more noticeable the closer you get to it. (default = true)").Value;
			SpawnRarity = Mathf.Min(100, Mathf.Max(1, SpawnRarity));
			SpawnOutsideChance = Mathf.Min(100, Mathf.Max(0, SpawnOutsideChance));
			DisguiseAsItemChance = Mathf.Min(100, Mathf.Max(0, DisguiseAsItemChance));
			((BaseUnityPlugin)this).Config.Save();
			Assets.Init();
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patched!");
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
		}
	}
}
namespace DontTouchMe.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}