Decompiled source of UnrealTentacle v1.0.2

Data/DreWulff-UnrealTentacle.dll

Decompiled 3 hours ago
#define DEBUG
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DreWulff-UnrealTentacle.NetcodePatcher;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnrealTentacle.Configuration;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DreWulff-UnrealTentacle")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b89419b1dd7ebe640d7a6293d040d128afb4fd20")]
[assembly: AssemblyProduct("UnrealTentacle")]
[assembly: AssemblyTitle("DreWulff-UnrealTentacle")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace UnrealTentacle
{
	[RequireComponent(typeof(Rigidbody))]
	internal class UnrealTentacleAI : EnemyAI
	{
		private enum State
		{
			ROAMING,
			ASLEEP,
			ATTACK
		}

		[SerializeField]
		private Transform baseTentacleBone;

		[SerializeField]
		private Transform tentacleBone;

		[SerializeField]
		private Transform tentacleTip;

		[SerializeField]
		private GameObject barbProjectile;

		[SerializeField]
		private float barbSpeed;

		[SerializeField]
		private float searchRoofTimer;

		[SerializeField]
		private SpotVerifier spotVerifier;

		private Vector3 projectedPosition;

		private float searchRandomFactor;

		[SerializeField]
		private float range;

		private bool spottedPlayer = false;

		private bool spawned = false;

		private float lookAroundTimer;

		private List<PlayerControllerB> closePlayers = new List<PlayerControllerB>();

		private List<PlayerControllerB> onSightPlayers = new List<PlayerControllerB>();

		private Vector3 targetPlayerPosition;

		[Tooltip("Cooldown for damage instances.")]
		[SerializeField]
		private float damageCooldown;

		[Tooltip("Damage done to the player when hit while close.")]
		[SerializeField]
		private int stingDamage;

		[Tooltip("Damage done to the player when hit by the projectile.")]
		[SerializeField]
		private int barbDamage;

		[SerializeField]
		private GameObject mapDotObj;

		[SerializeField]
		private GameObject colliderObj;

		[SerializeField]
		private GameObject modelObj;

		[SerializeField]
		private GameObject scanNodeObj;

		[SerializeField]
		private int copiesToBeSpawned = 3;

		private float timeSinceDamagingPlayer;

		private float timeOfDeath;

		private Vector3 deadStartingPosition;

		private Vector3 deadTargetPosition;

		private bool onCeiling = false;

		[HideInInspector]
		public Rigidbody rb;

		public void StartAttack()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(2);
			DoAnimationClientRpc("Attack");
		}

		private void AttackUpdate()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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)
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.targetPlayer != (Object)null)
			{
				SyncTargetPlayerServerRpc();
				targetPlayerPosition = ((Component)base.targetPlayer).transform.position;
			}
			RotateTowardsPlayer(targetPlayerPosition);
		}

		private void AttackAI()
		{
			if (!TargetClosestPlayer())
			{
				Sleep();
			}
		}

		public void ShootProjectile()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.targetPlayer != (Object)null)
			{
				ShootProjectile(((Component)base.targetPlayer).transform.position);
			}
		}

		public void ShootProjectile(Vector3 target)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_006c: 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)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00aa: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			TentacleProjectile component = Object.Instantiate<GameObject>(barbProjectile, ((Component)tentacleTip).transform.position, ((Component)tentacleTip).transform.rotation, RoundManager.Instance.mapPropsContainer.transform).GetComponent<TentacleProjectile>();
			Vector3 val = target + new Vector3(0f, 2f, 0f) - tentacleTip.position;
			component.StartTrajectory(((Vector3)(ref val)).normalized * barbSpeed);
			NetworkObject component2 = ((Component)component).GetComponent<NetworkObject>();
			component2.Spawn(false);
			val = target + new Vector3(0f, 2f, 0f) - tentacleTip.position;
			component.SyncVelocity(((Vector3)(ref val)).normalized * barbSpeed);
		}

		private void RotateTowardsPlayer(Vector3 target)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			tentacleBone.LookAt(target);
			if (((Component)this).transform.eulerAngles.z == 180f)
			{
				tentacleBone.eulerAngles = new Vector3(tentacleBone.eulerAngles.x - 45f, tentacleBone.eulerAngles.y, tentacleBone.localScale.z + 180f);
			}
		}

		private void StartRoam()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			base.inSpecialAnimation = false;
			searchRandomFactor = Random.Range(0f, searchRoofTimer / 2f);
			DisableScanNodeClientRpc();
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		private void RoamAI()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//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_001d: 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_0076: 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)
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)this).transform.position, -Physics.gravity);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, 20f, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && ((RaycastHit)(ref val2)).distance < 15f && ((RaycastHit)(ref val2)).distance > 2f && searchRoofTimer <= searchRandomFactor)
			{
				projectedPosition = ((RaycastHit)(ref val2)).point;
				((Component)spotVerifier).transform.position = projectedPosition;
				if (spotVerifier.collisionCounter <= 0)
				{
					ValidateSpotClientRpc();
				}
			}
			if (searchRoofTimer <= 0f)
			{
				StartSleep();
				return;
			}
			base.agent.speed = 500f;
			searchRoofTimer -= base.AIIntervalTime;
		}

		[ClientRpc]
		public void ValidateSpotClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2372634560u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2372634560u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					StartSleep();
					((Component)this).transform.position = projectedPosition - new Vector3(0f, 0.05f, 0f);
					((Component)this).transform.eulerAngles = new Vector3(180f, (float)Random.Range(0, 360), 0f);
				}
			}
		}

		[ClientRpc]
		private void DisableScanNodeClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2689186813u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2689186813u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					((Behaviour)base.agent).enabled = true;
					scanNodeObj.SetActive(false);
				}
			}
		}

		public void StartSleep()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			for (int i = 1; i < copiesToBeSpawned; i++)
			{
				SpawnCopy();
			}
			((EnemyAI)this).StopSearch(base.currentSearch, true);
			base.inSpecialAnimation = false;
			base.agent.speed = 0f;
			((Behaviour)base.agent).enabled = false;
			spottedPlayer = false;
			base.moveTowardsDestination = false;
			ReEnableEnemyClientRpc();
			SetSleepSpeedClientRpc(1f);
		}

		public void Sleep()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(1);
			spottedPlayer = false;
			lookAroundTimer = Random.Range(10, 20);
			spawned = true;
			DoAnimationClientRpc("Idle");
		}

		public void SleepAI()
		{
			if (TargetClosestPlayer() && !spottedPlayer)
			{
				spottedPlayer = true;
				DoAnimationClientRpc("Alert");
			}
			if (lookAroundTimer > 0f)
			{
				lookAroundTimer -= base.AIIntervalTime;
				return;
			}
			DoAnimationClientRpc("LookAround");
			lookAroundTimer = Random.Range(10, 20);
		}

		[ClientRpc]
		private void ReEnableEnemyClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2585290693u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2585290693u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					modelObj.SetActive(true);
					mapDotObj.SetActive(true);
					scanNodeObj.SetActive(true);
					colliderObj.SetActive(true);
				}
			}
		}

		private bool TargetClosestPlayer()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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)
			base.mostOptimalDistance = 2000f;
			base.targetPlayer = null;
			for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
			{
				base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
				if (base.tempDist < base.mostOptimalDistance && CheckLineOfSightForPosition(((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) && base.tempDist < range)
				{
					base.mostOptimalDistance = base.tempDist;
					base.targetPlayer = StartOfRound.Instance.allPlayerScripts[i];
				}
			}
			if ((Object)(object)base.targetPlayer != (Object)null)
			{
				return true;
			}
			return false;
		}

		public bool CheckLineOfSightForPosition(Vector3 objectPosition)
		{
			//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)
			RaycastHit val = default(RaycastHit);
			if (Physics.Linecast(base.eye.position, objectPosition, ref val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				return false;
			}
			return true;
		}

		[ServerRpc]
		public void SyncTargetPlayerServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Invalid comparison between Unknown and I4
			//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_00c2: 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
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((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(810546370u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 810546370u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost) && !((Object)(object)base.targetPlayer == (Object)null))
			{
				ReceiveTargetPlayerClientRpc(((Component)base.targetPlayer).transform.position);
			}
		}

		[ClientRpc]
		public void ReceiveTargetPlayerClientRpc(Vector3 target)
		{
			//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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(4161937017u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref target);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 4161937017u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
				{
					targetPlayerPosition = target;
				}
			}
		}

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//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)
			((EnemyAI)this).Start();
			float num = Random.Range(0.8f, 1f);
			((Component)((Component)this).gameObject.transform).transform.localScale = num * ((Component)((Component)this).gameObject.transform).transform.localScale;
			rb = ((Component)this).gameObject.GetComponent<Rigidbody>();
			timeSinceDamagingPlayer = damageCooldown;
			LogIfDebugBuild("Unreal Tentacle Spawned");
			StartRoam();
		}

		public override void Update()
		{
			if (!base.isEnemyDead)
			{
				((EnemyAI)this).Update();
			}
		}

		public void LateUpdate()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (base.isEnemyDead)
			{
				if (timeOfDeath < 1f)
				{
					timeOfDeath += Time.deltaTime;
					Transform transform = ((Component)this).transform;
					Vector3 val = deadStartingPosition;
					Vector3 val2 = deadTargetPosition;
					float num = timeOfDeath * 10f;
					Vector3 val3 = deadTargetPosition - deadStartingPosition;
					transform.position = Vector3.Lerp(val, val2, num / ((Vector3)(ref val3)).magnitude);
				}
			}
			else
			{
				switch (base.currentBehaviourStateIndex)
				{
				case 0:
					break;
				case 1:
					break;
				case 2:
					AttackUpdate();
					break;
				}
			}
		}

		public override void DoAIInterval()
		{
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			((EnemyAI)this).DoAIInterval();
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				RoamAI();
				break;
			case 1:
				if (spawned)
				{
					SleepAI();
				}
				break;
			case 2:
				AttackAI();
				break;
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB? playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (base.isEnemyDead)
			{
				return;
			}
			base.enemyHP -= force;
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (base.enemyHP <= 0 && !base.isEnemyDead)
				{
					((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
				else if (base.enemyHP > 0)
				{
					DoAnimationServerRpc("Stun");
				}
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			((EnemyAI)this).KillEnemy(destroy);
			SetDeathPositionClientRpc();
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
			if ((Object)(object)val != (Object)null && timeSinceDamagingPlayer >= damageCooldown)
			{
				val.DamagePlayer(stingDamage, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				timeSinceDamagingPlayer = 0f;
			}
		}

		[ServerRpc]
		public void DoAnimationServerRpc(string animationName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Invalid comparison between Unknown and I4
			//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_00ce: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Invalid comparison between Unknown and I4
			//IL_0100: 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.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(942661263u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 942661263u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				DoAnimationClientRpc(animationName);
			}
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0088: 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_00ba: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(704630064u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 704630064u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				base.creatureAnimator.SetTrigger(animationName);
			}
		}

		[ClientRpc]
		public void SetSleepSpeedClientRpc(float value)
		{
			//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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2450141289u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<float>(ref value, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2450141289u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					base.creatureAnimator.SetFloat("AnimationSpeed", value);
				}
			}
		}

		[ClientRpc]
		public void SetDeathPositionClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00ea: 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_00fa: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1154018643u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1154018643u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				deadStartingPosition = ((Component)this).transform.position;
				Ray val3 = default(Ray);
				((Ray)(ref val3))..ctor(base.eye.position, Vector3.down);
				RaycastHit val4 = default(RaycastHit);
				if (Physics.Linecast(base.eye.position, base.eye.position + Vector3.down * 20f, ref val4, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					deadTargetPosition = ((RaycastHit)(ref val4)).point + new Vector3(0f, 0.2f, 0f);
				}
				timeOfDeath = 0f;
			}
		}

		public void SpawnCopy()
		{
			//IL_001d: 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 (((NetworkBehaviour)this).IsOwner)
			{
				UnrealTentacleAI component = Object.Instantiate<GameObject>(base.enemyType.enemyPrefab, ((Component)this).transform.position, ((Component)this).transform.rotation, RoundManager.Instance.mapPropsContainer.transform).GetComponent<UnrealTentacleAI>();
				NetworkObject component2 = ((Component)component).GetComponent<NetworkObject>();
				component2.Spawn(false);
				component.DontSpawnCopiesClientRpc();
			}
		}

		[ClientRpc]
		private void DontSpawnCopiesClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1200460606u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1200460606u, val, (RpcDelivery)0);
				}
				if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					copiesToBeSpawned = 0;
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_UnrealTentacleAI()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(2372634560u, new RpcReceiveHandler(__rpc_handler_2372634560));
			NetworkManager.__rpc_func_table.Add(2689186813u, new RpcReceiveHandler(__rpc_handler_2689186813));
			NetworkManager.__rpc_func_table.Add(2585290693u, new RpcReceiveHandler(__rpc_handler_2585290693));
			NetworkManager.__rpc_func_table.Add(810546370u, new RpcReceiveHandler(__rpc_handler_810546370));
			NetworkManager.__rpc_func_table.Add(4161937017u, new RpcReceiveHandler(__rpc_handler_4161937017));
			NetworkManager.__rpc_func_table.Add(942661263u, new RpcReceiveHandler(__rpc_handler_942661263));
			NetworkManager.__rpc_func_table.Add(704630064u, new RpcReceiveHandler(__rpc_handler_704630064));
			NetworkManager.__rpc_func_table.Add(2450141289u, new RpcReceiveHandler(__rpc_handler_2450141289));
			NetworkManager.__rpc_func_table.Add(1154018643u, new RpcReceiveHandler(__rpc_handler_1154018643));
			NetworkManager.__rpc_func_table.Add(1200460606u, new RpcReceiveHandler(__rpc_handler_1200460606));
		}

		private static void __rpc_handler_2372634560(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnrealTentacleAI)(object)target).ValidateSpotClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2689186813(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnrealTentacleAI)(object)target).DisableScanNodeClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2585290693(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnrealTentacleAI)(object)target).ReEnableEnemyClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_810546370(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_0076: 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_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!");
				}
			}
			else
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((UnrealTentacleAI)(object)target).SyncTargetPlayerServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_4161937017(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 target2 = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref target2);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnrealTentacleAI)(object)target).ReceiveTargetPlayerClientRpc(target2);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_942661263(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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			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;
			}
			bool flag = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
			string animationName = null;
			if (flag)
			{
				((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
			}
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((UnrealTentacleAI)(object)target).DoAnimationServerRpc(animationName);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}

		private static void __rpc_handler_704630064(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_0061: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnrealTentacleAI)(object)target).DoAnimationClientRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2450141289(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)
			{
				float sleepSpeedClientRpc = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref sleepSpeedClientRpc, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnrealTentacleAI)(object)target).SetSleepSpeedClientRpc(sleepSpeedClientRpc);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1154018643(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnrealTentacleAI)(object)target).SetDeathPositionClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1200460606(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((UnrealTentacleAI)(object)target).DontSpawnCopiesClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "UnrealTentacleAI";
		}
	}
	[BepInPlugin("DreWulff-UnrealTentacle", "UnrealTentacle", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			InitializeNetworkBehaviours();
			string path = "unreal-tentacle-assets";
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			EnemyType val = ModAssets.LoadAsset<EnemyType>("NaliTentacle");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("NaliTentacleTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("NaliTentacleTK");
			GameObject val4 = ModAssets.LoadAsset<GameObject>("Barb");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val4);
			Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>
			{
				{
					(LevelTypes)4,
					50
				},
				{
					(LevelTypes)8,
					50
				},
				{
					(LevelTypes)16,
					200
				},
				{
					(LevelTypes)32,
					30
				},
				{
					(LevelTypes)2048,
					150
				},
				{
					(LevelTypes)(-1),
					30
				},
				{
					(LevelTypes)1024,
					50
				}
			};
			Dictionary<string, int> dictionary2 = new Dictionary<string, int>
			{
				{ "46 Infernis", 300 },
				{ "84 Junic", 300 },
				{ "6 Mazon", 200 },
				{ "Halation", 100 }
			};
			Enemies.RegisterEnemy(val, dictionary, dictionary2, val2, val3);
			Logger.LogInfo((object)"Plugin DreWulff-UnrealTentacle is loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	internal class SpotVerifier : MonoBehaviour
	{
		[HideInInspector]
		public int collisionCounter = 0;

		private void OnTriggerEnter(Collider other)
		{
			if ((StartOfRound.Instance.collidersAndRoomMaskAndDefault & (1 << ((Component)other).gameObject.layer)) != 0)
			{
				collisionCounter++;
			}
		}

		private void OnTriggerExit(Collider other)
		{
			if ((StartOfRound.Instance.collidersAndRoomMaskAndDefault & (1 << ((Component)other).gameObject.layer)) != 0)
			{
				collisionCounter--;
			}
		}
	}
	internal class TentacleAnimationEvents : MonoBehaviour
	{
		[SerializeField]
		private UnrealTentacleAI mainAI;

		public void EndSpawn()
		{
			mainAI.Sleep();
		}

		public void StartAttack()
		{
			mainAI.StartAttack();
		}

		public void Shoot()
		{
			mainAI.ShootProjectile();
		}

		public void EndStun()
		{
			mainAI.DoAnimationClientRpc("Alert");
		}
	}
	internal class TentacleProjectile : NetworkBehaviour
	{
		[SerializeField]
		private int damage = 20;

		private Rigidbody rb;

		private float TTL;

		private void Awake()
		{
			TTL = 3f;
			rb = ((Component)this).GetComponent<Rigidbody>();
		}

		private void Update()
		{
			if (TTL < 0f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				TTL -= Time.deltaTime;
			}
		}

		public void StartTrajectory(Vector3 speed)
		{
			//IL_0007: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			rb.velocity = speed;
			((Component)this).transform.LookAt(((Component)this).transform.position + speed);
			((Component)this).transform.Rotate(-90f, 0f, 0f);
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_0029: 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)
			if (((Component)other).gameObject.CompareTag("Player"))
			{
				((Component)other).GetComponent<PlayerControllerB>().DamagePlayer(damage, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else if ((0x100B08u & (uint)(1 << ((Component)other).gameObject.layer)) != 0)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		[ClientRpc]
		private void StartTrajectoryClientRpc(Vector3 speed)
		{
			//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_0089: 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_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_00f4: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(486986001u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe(ref speed);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 486986001u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && !((NetworkBehaviour)this).IsOwner)
				{
					rb.velocity = speed;
					((Component)this).transform.LookAt(((Component)this).transform.position + speed);
					((Component)this).transform.Rotate(-90f, 0f, 0f);
				}
			}
		}

		public void SyncVelocity(Vector3 velocity)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			StartTrajectoryClientRpc(velocity);
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_TentacleProjectile()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(486986001u, new RpcReceiveHandler(__rpc_handler_486986001));
		}

		private static void __rpc_handler_486986001(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 speed = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref speed);
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((TentacleProjectile)(object)target).StartTrajectoryClientRpc(speed);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "TentacleProjectile";
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "DreWulff-UnrealTentacle";

		public const string PLUGIN_NAME = "UnrealTentacle";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace UnrealTentacle.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<int> SpawnWeight;

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 20, "The spawn chance weight for UnrealTentacle, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			ClearUnusedEntries(cfg);
		}

		private void ClearUnusedEntries(ConfigFile cfg)
		{
			PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
			dictionary.Clear();
			cfg.Save();
		}
	}
}
namespace DreWulff-UnrealTentacle.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}