Decompiled source of Wesleys Enemies v1.3.4

WesleysEnemies.dll

Decompiled 3 days ago
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 Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.AI;

[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("Magic_Wesley")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2025 Magic_Wesley")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+0e950b77c6ee9c88c5d0162785bf867afc16ad2f")]
[assembly: AssemblyProduct("WesleysEnemies")]
[assembly: AssemblyTitle("WesleysEnemies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WesleysEnemies
{
	[BepInPlugin("WesleysEnemies", "WesleysEnemies", "2.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class WesleysEnemies : BaseUnityPlugin
	{
		private void Awake()
		{
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			string text = Path.Combine(directoryName, "wesleysenemies_enemyprefabs");
			string[] array = new string[12]
			{
				"EnemySetup - Gusher", "EnemySetup - 2GusherGroup", "EnemySetup - 4GusherGroup", "EnemySetup - Roaster", "EnemySetup - 2RoasterGroup", "EnemySetup - LostDroid", "EnemySetup - 2LostDroidGroup", "EnemySetup - 3LostDroidGroup", "EnemySetup - Shotgunner", "EnemySetup - LostDestroyer",
				"EnemySetup - Voodoo", "EnemySetup - 2DestroyerGroup"
			};
			List<string> list = new List<string> { "Valuables - Wizard", "Valuables - Manor" };
			AssetBundle val = AssetBundle.LoadFromFile(text);
			GameObject val2 = val.LoadAsset<GameObject>("SmallVoodooDoll");
			Valuables.RegisterValuable(val2, list);
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				Enemies.RegisterEnemy(val.LoadAsset<EnemySetup>(text2));
				Debug.Log((object)("Loaded " + text2));
			}
			Debug.Log((object)"Please, if you don't like a mod, at least be respectful about it, do not call someones work 'dogshit' while calling them 'bluddingtons'..");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "WesleysEnemies";

		public const string PLUGIN_NAME = "WesleysEnemies";

		public const string PLUGIN_VERSION = "2.0.0";
	}
}
namespace WesleysEnemies.AI
{
	internal class Centipede : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Stun,
			Roam,
			Notice,
			Charge,
			Idle,
			GrabPlayer,
			Attack,
			Flee,
			Scare,
			Despawn
		}

		public CentipedeAnimationController VoodooAnim;

		public EnemyRigidbody EnemyRigidbody;

		internal Enemy _enemy;

		private PhotonView _photonView;

		private List<Material> _hurtMaterial = new List<Material>();

		[Header("State")]
		[SerializeField]
		public State CurrentState;

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

		private bool _hurtImpulse;

		private float hurtLerp;

		private int _hurtAmount;

		internal bool _stateImpulse;

		[Header("Animation")]
		[SerializeField]
		private AnimationCurve hurtCurve;

		[SerializeField]
		private SkinnedMeshRenderer[] _skinnedMeshRenderer;

		[SerializeField]
		private MeshRenderer[] _MeshRenderer;

		[Header("Rotation")]
		public SpringQuaternion horizontalRotationSpring;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Vector3 _agentDestination;

		private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;

		private EnemyRigidbody _rigidbody => _enemy.Rigidbody;

		private EnemyParent _enemyParent => _enemy.EnemyParent;

		private EnemyVision _Vision => _enemy.Vision;

		public Enemy Enemy => _enemy;

		private void Awake()
		{
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			SkinnedMeshRenderer[] skinnedMeshRenderer = _skinnedMeshRenderer;
			foreach (SkinnedMeshRenderer val in skinnedMeshRenderer)
			{
				if ((Object)(object)val != (Object)null)
				{
					_hurtMaterial.AddRange(((Renderer)val).materials);
				}
			}
			MeshRenderer[] meshRenderer = _MeshRenderer;
			for (int j = 0; j < meshRenderer.Length; j++)
			{
				Renderer val2 = (Renderer)(object)meshRenderer[j];
				if ((Object)(object)val2 != (Object)null)
				{
					_hurtMaterial.AddRange(val2.materials);
				}
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
			int levelsCompleted = RunManager.instance.levelsCompleted;
		}

		private void Update()
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (!_enemy.Stunned)
			{
				switch (CurrentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Roam:
					StateRoam();
					break;
				case State.Idle:
					StateIdle();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				case State.Stun:
				case State.Notice:
				case State.Charge:
				case State.GrabPlayer:
				case State.Attack:
				case State.Flee:
				case State.Scare:
				case State.Despawn:
					break;
				}
			}
			else
			{
				UpdateState(State.Stun);
			}
			HurtEffect();
			RotationLogic();
		}

		private void StateSpawn()
		{
			if (_stateImpulse)
			{
				stateTimer = 4f;
				_stateImpulse = false;
			}
			else if (stateTimer > 0f)
			{
				stateTimer -= Time.deltaTime;
			}
			else
			{
				UpdateState(State.Roam);
			}
		}

		private void StateRoam()
		{
			//IL_0118: 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_004d: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				stateTimer = 15f;
				bool flag = false;
				LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 20f, 60f);
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 4f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((NavMeshHit)(ref val2)).position;
					flag = true;
				}
				if (!flag)
				{
					Debug.Log((object)"FAILED");
					return;
				}
				_navMeshAgent.SetDestination(_agentDestination);
				_stateImpulse = false;
			}
			else
			{
				_navMeshAgent.SetDestination(_agentDestination);
				if (CheckPathCompletion())
				{
					UpdateState(State.Idle);
				}
				else if (stateTimer > 0f)
				{
					stateTimer -= Time.deltaTime;
				}
				else
				{
					UpdateState(State.Idle);
				}
			}
		}

		private void StateIdle()
		{
			if (_stateImpulse)
			{
				stateTimer = 2f;
				_stateImpulse = false;
			}
			else if (stateTimer > 0f)
			{
				stateTimer -= Time.deltaTime;
			}
			else
			{
				UpdateState(State.Roam);
			}
		}

		[PunRPC]
		private void UpdateStateRPC(State _state)
		{
			CurrentState = _state;
			Debug.Log((object)CurrentState);
		}

		public void UpdateState(State _newState)
		{
			if (CurrentState != _newState)
			{
				CurrentState = _newState;
				stateTimer = 0f;
				_stateImpulse = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { CurrentState });
				}
				else
				{
					UpdateStateRPC(CurrentState);
				}
			}
		}

		private void HurtEffect()
		{
			if (!_hurtImpulse)
			{
				return;
			}
			hurtLerp += 2.5f * Time.deltaTime;
			hurtLerp = Mathf.Clamp01(hurtLerp);
			foreach (Material item in _hurtMaterial)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
				}
				if (hurtLerp >= 1f)
				{
					hurtLerp = 0f;
					_hurtImpulse = false;
					if ((Object)(object)item != (Object)null)
					{
						item.SetFloat(_hurtAmount, 0f);
					}
				}
			}
		}

		public void OnSpawn()
		{
			UpdateState(State.Spawn);
		}

		private void RotationLogic()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0071: 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)
			horizontalRotationSpring.speed = 10f;
			horizontalRotationSpring.damping = 1f;
			Vector3 normalized = ((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized;
			if (((Vector3)(ref normalized)).magnitude > 0.1f)
			{
				_horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized);
				((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
		}

		private bool CheckPathCompletion()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			NavMeshAgent agent = _navMeshAgent.Agent;
			float remainingDistance = agent.remainingDistance;
			if (remainingDistance <= 0.05f)
			{
				Vector3 velocity = _navMeshAgent.Agent.velocity;
				if (((Vector3)(ref velocity)).magnitude > 0.05f)
				{
					return true;
				}
			}
			return false;
		}
	}
	internal class CentipedeAnimationController : MonoBehaviour
	{
		[Header("References")]
		public Centipede Controller;

		public Animator animator;
	}
	internal class CentipedeBodypart : MonoBehaviour
	{
		public bool canTurn = true;

		public bool enable = true;

		public Transform bodyAttachedPoint;

		public Transform bodyPartPoint;

		public float rotationSpeed;

		private void Update()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bodyAttachedPoint != (Object)null && (Object)(object)bodyPartPoint != (Object)null && enable)
			{
				bodyPartPoint.position = bodyAttachedPoint.position;
				if (canTurn)
				{
					bodyPartPoint.rotation = Quaternion.Lerp(bodyPartPoint.rotation, bodyAttachedPoint.rotation, Time.deltaTime * rotationSpeed);
				}
			}
		}
	}
	internal class Fogblow : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Roam,
			Idle,
			GoToCeiling,
			OnCeiling,
			DropFromCeiling,
			Attack,
			Notice,
			Follow,
			Stun,
			Despawn
		}

		public FogblowAnimationController VoodooAnim;

		public EnemyRigidbody EnemyRigidbody;

		internal Enemy _enemy;

		private PhotonView _photonView;

		private List<Material> _hurtMaterial = new List<Material>();

		[Header("State")]
		[SerializeField]
		public State CurrentState;

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

		private Vector3 _agentDestination;

		private bool _hurtImpulse;

		private float hurtLerp;

		private int _hurtAmount;

		internal bool _stateImpulse;

		[Header("Animation")]
		[SerializeField]
		private AnimationCurve hurtCurve;

		[SerializeField]
		private SkinnedMeshRenderer[] _skinnedMeshRenderer;

		[SerializeField]
		private MeshRenderer[] _MeshRenderer;

		[Header("Rotation")]
		public SpringQuaternion horizontalRotationSpring;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private PlayerAvatar _playerTarget;

		private LevelPoint hangPoint;

		private Vector3 _ceilingPosition;

		private Vector3 _startPosition;

		private Vector3 _distanceFromGround;

		private Vector3 _attackPosition;

		public float jumpTime = 1f;

		private float _jumpElapsedTime;

		private float _noticeCooldown;

		[Header("LeapCurves")]
		[SerializeField]
		private AnimationCurve UpCurve;

		private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;

		private EnemyRigidbody _rigidbody => _enemy.Rigidbody;

		private EnemyParent _enemyParent => _enemy.EnemyParent;

		private EnemyVision _Vision => _enemy.Vision;

		public Enemy Enemy => _enemy;

		private void Awake()
		{
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			SkinnedMeshRenderer[] skinnedMeshRenderer = _skinnedMeshRenderer;
			foreach (SkinnedMeshRenderer val in skinnedMeshRenderer)
			{
				if ((Object)(object)val != (Object)null)
				{
					_hurtMaterial.AddRange(((Renderer)val).materials);
				}
			}
			MeshRenderer[] meshRenderer = _MeshRenderer;
			for (int j = 0; j < meshRenderer.Length; j++)
			{
				Renderer val2 = (Renderer)(object)meshRenderer[j];
				if ((Object)(object)val2 != (Object)null)
				{
					_hurtMaterial.AddRange(val2.materials);
				}
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
			int levelsCompleted = RunManager.instance.levelsCompleted;
		}

		private void Update()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && LevelGenerator.Instance.Generated)
			{
				if (!_enemy.Stunned)
				{
					switch (CurrentState)
					{
					case State.Spawn:
						StateSpawn();
						break;
					case State.Stun:
						StateStun();
						break;
					case State.Despawn:
						StateDespawn();
						break;
					case State.Roam:
						StateRoam();
						break;
					case State.Attack:
						StateAttack();
						break;
					case State.Notice:
						StateNotice();
						break;
					case State.Follow:
						StateFollow();
						break;
					case State.Idle:
						StateIdle();
						break;
					case State.GoToCeiling:
						StateGoToCeiling();
						break;
					case State.OnCeiling:
						StateOnCeiling();
						break;
					case State.DropFromCeiling:
						StateDropFromCeiling();
						break;
					default:
						throw new ArgumentOutOfRangeException();
					}
				}
				else
				{
					UpdateState(State.Stun);
					StateStun();
				}
				HurtEffect();
				RotationLogic();
			}
			if (_noticeCooldown > 0f)
			{
				_noticeCooldown -= Time.deltaTime;
			}
		}

		private void StateSpawn()
		{
			if (_stateImpulse)
			{
				stateTimer = 4f;
				_stateImpulse = false;
			}
			else if (stateTimer > 0f)
			{
				stateTimer -= Time.deltaTime;
			}
			else
			{
				UpdateState(State.Roam);
			}
		}

		private void StateRoam()
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				hangPoint = SemiFunc.LevelPointGet(((Component)this).transform.position, 20f, 80f);
				bool flag = false;
				if ((Object)(object)hangPoint == (Object)null)
				{
					hangPoint = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
				}
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(((Component)hangPoint).transform.position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })) && Physics.Raycast(((Component)hangPoint).transform.position, Vector3.up, ref val, 15f, LayerMask.GetMask(new string[1] { "Default" })) && ((Component)((RaycastHit)(ref val)).transform).CompareTag("Ceiling"))
				{
					flag = true;
					_agentDestination = ((Component)hangPoint).transform.position;
					_navMeshAgent.SetDestination(_agentDestination);
				}
				if (flag)
				{
					stateTimer = 20f;
					_stateImpulse = false;
				}
			}
			else
			{
				_navMeshAgent.SetDestination(_agentDestination);
				if (CheckPathCompletion())
				{
					UpdateState(State.GoToCeiling);
					Debug.Log((object)"PositionFound");
				}
				else if (stateTimer > 0f)
				{
					stateTimer -= Time.deltaTime;
				}
				else
				{
					UpdateState(State.Idle);
				}
			}
		}

		private void StateIdle()
		{
			//IL_002a: 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)
			if (_stateImpulse)
			{
				stateTimer = 1.8f;
				_stateImpulse = false;
				_navMeshAgent.SetDestination(((Component)this).transform.position);
				_navMeshAgent.Warp(((Component)this).transform.position);
			}
			else if (stateTimer > 0f)
			{
				stateTimer -= Time.deltaTime;
			}
			else
			{
				UpdateState(State.Roam);
			}
		}

		private void StateAttack()
		{
			//IL_0018: 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 (_stateImpulse)
			{
				_navMeshAgent.SetDestination(((Component)this).transform.position);
				_navMeshAgent.Warp(((Component)this).transform.position);
				stateTimer = 2f;
				_stateImpulse = false;
			}
			else if (stateTimer > 0f)
			{
				stateTimer -= Time.deltaTime;
			}
			else
			{
				UpdateState(State.Idle);
			}
		}

		private void StateNotice()
		{
			//IL_0018: 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_0081: 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)
			if (_stateImpulse)
			{
				_navMeshAgent.SetDestination(((Component)this).transform.position);
				_navMeshAgent.Warp(((Component)this).transform.position);
				_stateImpulse = false;
				stateTimer = 0.8f;
				return;
			}
			if (stateTimer > 0f)
			{
				stateTimer -= Time.deltaTime;
				return;
			}
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)_playerTarget).transform.position);
			if (num < 0.35f)
			{
				UpdateState(State.Attack);
			}
			else if (num < 8f)
			{
				UpdateState(State.Follow);
			}
			else
			{
				UpdateState(State.Roam);
			}
		}

		private void StateFollow()
		{
			//IL_0088: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				stateTimer = 3f;
				_stateImpulse = false;
				NavMeshHit val = default(NavMeshHit);
				if (NavMesh.SamplePosition(((Component)_playerTarget).transform.position, ref val, 10f, -1))
				{
					_agentDestination = ((NavMeshHit)(ref val)).position;
				}
				_navMeshAgent.SetDestination(_agentDestination);
				_navMeshAgent.Agent.speed = 3f;
				return;
			}
			NavMeshHit val2 = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)_playerTarget).transform.position, ref val2, 10f, -1))
			{
				_agentDestination = ((NavMeshHit)(ref val2)).position;
			}
			_navMeshAgent.SetDestination(_agentDestination);
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)_playerTarget).transform.position);
			if (stateTimer <= 0f)
			{
				_navMeshAgent.Agent.speed = 2f;
				UpdateState(State.Idle);
			}
			else if (num < 1f)
			{
				_navMeshAgent.Agent.speed = 2f;
				UpdateState(State.Attack);
			}
			else if (stateTimer > 0f)
			{
				stateTimer -= Time.deltaTime;
			}
		}

		private void StateGoToCeiling()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0104: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_navMeshAgent.SetDestination(((Component)this).transform.position);
				_navMeshAgent.Warp(((Component)this).transform.position);
				bool flag = false;
				RaycastHit val = default(RaycastHit);
				if (Physics.Raycast(((Component)hangPoint).transform.position, Vector3.up, ref val, 15.5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					flag = true;
					_ceilingPosition = ((RaycastHit)(ref val)).point;
				}
				if (!flag)
				{
					UpdateState(State.Roam);
				}
				_rigidbody.rb.useGravity = false;
				_jumpElapsedTime = 0f;
				_startPosition = ((Component)this).transform.position;
				_stateImpulse = false;
			}
			else
			{
				if (_jumpElapsedTime < jumpTime)
				{
					_jumpElapsedTime += Time.deltaTime / 1.5f;
					_distanceFromGround = Vector3.Lerp(_startPosition, _ceilingPosition, UpCurve.Evaluate(_jumpElapsedTime));
				}
				else
				{
					UpdateState(State.OnCeiling);
				}
				((Component)this).transform.position = _distanceFromGround;
			}
		}

		private void StateOnCeiling()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				stateTimer = 8f;
				_stateImpulse = false;
			}
			else if (stateTimer > 0f)
			{
				stateTimer -= Time.deltaTime;
			}
			else
			{
				UpdateState(State.DropFromCeiling);
			}
			((Component)this).transform.position = _distanceFromGround;
		}

		private void StateDropFromCeiling()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_rigidbody.rb.useGravity = true;
				stateTimer = 3f;
				_stateImpulse = false;
				_navMeshAgent.SetDestination(_startPosition);
				_navMeshAgent.Warp(_startPosition);
			}
			else if (stateTimer > 0f)
			{
				stateTimer -= Time.deltaTime;
			}
			else
			{
				UpdateState(State.Roam);
			}
		}

		private void StateStun()
		{
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_rigidbody.rb.useGravity = true;
			}
			else if (!_enemy.IsStunned())
			{
				UpdateState(State.Roam);
			}
		}

		private void StateDespawn()
		{
			//IL_0018: 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 (_stateImpulse)
			{
				_navMeshAgent.SetDestination(((Component)this).transform.position);
				_navMeshAgent.Warp(((Component)this).transform.position);
				_stateImpulse = false;
				_rigidbody.rb.useGravity = true;
			}
		}

		[PunRPC]
		private void UpdateStateRPC(State _state)
		{
			CurrentState = _state;
		}

		public void UpdateState(State _newState)
		{
			if (CurrentState != _newState)
			{
				CurrentState = _newState;
				stateTimer = 0f;
				_stateImpulse = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { CurrentState });
				}
				else
				{
					UpdateStateRPC(CurrentState);
				}
			}
		}

		public void OnSpawn()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(_enemy))
			{
				UpdateState(State.Spawn);
			}
		}

		public void OnVision()
		{
			if (CurrentState == State.Roam || (CurrentState == State.Idle && _noticeCooldown <= 0f))
			{
				UpdateState(State.Notice);
				_playerTarget = _enemy.Vision.onVisionTriggeredPlayer;
				_noticeCooldown = 6f;
			}
		}

		public void OnGrab()
		{
			if (CurrentState == State.Roam || (CurrentState == State.Idle && _noticeCooldown <= 0f))
			{
				UpdateState(State.Notice);
				_playerTarget = _enemy.Rigidbody.onGrabbedPlayerAvatar;
			}
		}

		public void OnDeath()
		{
			_enemy.EnemyParent.Despawn();
		}

		private void HurtEffect()
		{
			if (!_hurtImpulse)
			{
				return;
			}
			hurtLerp += 2.5f * Time.deltaTime;
			hurtLerp = Mathf.Clamp01(hurtLerp);
			foreach (Material item in _hurtMaterial)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
				}
				if (hurtLerp >= 1f)
				{
					hurtLerp = 0f;
					_hurtImpulse = false;
					if ((Object)(object)item != (Object)null)
					{
						item.SetFloat(_hurtAmount, 0f);
					}
				}
			}
		}

		private void RotationLogic()
		{
			//IL_0046: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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)
			//IL_00d2: 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_00da: 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)
			//IL_00e1: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			horizontalRotationSpring.speed = 6f;
			horizontalRotationSpring.damping = 0.8f;
			if (CurrentState == State.Roam || CurrentState == State.Follow)
			{
				Vector3 normalized = ((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized;
				if (((Vector3)(ref normalized)).magnitude > 0.1f)
				{
					_horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized);
					((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
				}
			}
			else if (CurrentState == State.Notice)
			{
				Vector3 val = ((Component)_playerTarget).transform.position - ((Component)this).transform.position;
				_horizontalRotationTarget = Quaternion.LookRotation(val);
				((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
		}

		private bool CheckPathCompletion()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			NavMeshAgent agent = _navMeshAgent.Agent;
			float remainingDistance = agent.remainingDistance;
			if (remainingDistance <= 0.05f)
			{
				Vector3 velocity = _navMeshAgent.Agent.velocity;
				if (((Vector3)(ref velocity)).magnitude > 0.05f)
				{
					return true;
				}
			}
			return false;
		}
	}
	internal class FogblowAnimationController : MonoBehaviour
	{
		[Header("References")]
		public Fogblow Controller;

		public Animator animator;
	}
	internal class Gusher : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			StartListen,
			Listen,
			EndListen,
			Attack,
			Wander,
			Stun,
			Despawn,
			Flee
		}

		public GusherAnimationController GusherAnim;

		private LayerMask layermask;

		private LayerMask playerLayermask;

		internal Enemy _enemy;

		private PhotonView _photonView;

		public Transform feetTransform;

		public bool Terminator = false;

		private float _speedChangeCooldown;

		private int _hitAmount;

		internal float _animSpeed;

		private float _spawnCool;

		private bool _stateImpulse;

		internal bool _deathImpulse;

		internal bool _despawnImpulse;

		internal bool _roamImpulse;

		internal bool _attackImpulse;

		internal bool _hearImpulse;

		internal bool _isListening;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Vector3 _agentDestination;

		private Vector3 _investigatePoint;

		private int _hearCount;

		private int _hurtAmount;

		private bool _hurtImpulse;

		private float hurtLerp;

		private float _hearCooldown;

		private List<Material> _hurtMaterial = new List<Material>();

		[Header("State")]
		[SerializeField]
		public State CurrentState;

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

		[Header("Animation")]
		[SerializeField]
		private AnimationCurve hurtCurve;

		[SerializeField]
		private SkinnedMeshRenderer[] _skinnedMeshRenderer;

		[SerializeField]
		private MeshRenderer[] _MeshRenderer;

		[Header("Rotation and LookAt")]
		public SpringQuaternion horizontalRotationSpring;

		[SerializeField]
		private Transform _listenPoint;

		private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;

		private EnemyRigidbody _rigidbody => _enemy.Rigidbody;

		private EnemyParent _enemyParent => _enemy.EnemyParent;

		private EnemyVision _Vision => _enemy.Vision;

		public Enemy Enemy => _enemy;

		private void Awake()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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)
			layermask = LayerMask.op_Implicit(LayerMask.GetMask(new string[5] { "Default", "PhysGrabObject", "PhysGrabObjectCart", "PhysGrabObjectHinge", "StaticGrabObject" }));
			playerLayermask = LayerMask.op_Implicit(LayerMask.GetMask(new string[1] { "Player" }));
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			SkinnedMeshRenderer[] skinnedMeshRenderer = _skinnedMeshRenderer;
			foreach (SkinnedMeshRenderer val in skinnedMeshRenderer)
			{
				if ((Object)(object)val != (Object)null)
				{
					_hurtMaterial.AddRange(((Renderer)val).materials);
				}
			}
			MeshRenderer[] meshRenderer = _MeshRenderer;
			for (int j = 0; j < meshRenderer.Length; j++)
			{
				Renderer val2 = (Renderer)(object)meshRenderer[j];
				if ((Object)(object)val2 != (Object)null)
				{
					_hurtMaterial.AddRange(val2.materials);
				}
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
		}

		private void Update()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (!_enemy.IsStunned())
			{
				if ((int)_enemy.EnemyParent.Enemy.CurrentState == 11 && CurrentState != State.Despawn)
				{
					UpdateState(State.Despawn);
				}
				switch (CurrentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Listen:
					StateListen();
					break;
				case State.StartListen:
					StateStartListen();
					break;
				case State.EndListen:
					StateEndListen();
					break;
				case State.Attack:
					StateAttack();
					break;
				case State.Wander:
					StateWander();
					break;
				case State.Flee:
					StateFlee();
					break;
				case State.Stun:
					StateStun();
					break;
				case State.Despawn:
					StateDespawn();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
				RotationLogic();
			}
			else
			{
				UpdateState(State.Stun);
				StateStun();
			}
			HurtEffect();
			if (_spawnCool > 0f)
			{
				_spawnCool -= Time.deltaTime;
			}
		}

		private void StateSpawn()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
				_stateImpulse = false;
				stateTimer = 2f;
				_navMeshAgent.Agent.speed = 1f;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 1f });
				}
				else
				{
					ChangeAnimSpeedRPC(1f);
				}
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.Wander);
			}
		}

		private void StateListen()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				if (Terminator)
				{
					stateTimer = Random.Range(7f, 12f);
				}
				else
				{
					stateTimer = Random.Range(20f, 33f);
				}
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
			}
			if (!SemiFunc.EnemySpawnIdlePause())
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					_hearCount = 0;
					UpdateState(State.EndListen);
				}
				if (_hearCooldown > 0f)
				{
					_hearCooldown -= Time.deltaTime;
				}
			}
		}

		private void StateStartListen()
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_hearCount = 0;
				_isListening = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsListeningRPC", (RpcTarget)1, new object[1] { _isListening });
					_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 1f });
				}
				else
				{
					IsListeningRPC(_isListening);
					ChangeAnimSpeedRPC(1f);
				}
				_stateImpulse = false;
				stateTimer = 1f;
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.Listen);
			}
		}

		private void StateEndListen()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				stateTimer = 1f;
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
				Debug.Log((object)CrazyCalculation());
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				if (SemiFunc.EnemyForceLeave(_enemy))
				{
					UpdateState(State.Flee);
				}
				else
				{
					UpdateState(State.Wander);
				}
			}
		}

		private void StateWander()
		{
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_isListening = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsListeningRPC", (RpcTarget)1, new object[1] { _isListening });
					_photonView.RPC("RoamImpulseRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					IsListeningRPC(_isListening);
					RoamImpulseRPC();
				}
				if (Terminator)
				{
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 6f });
					}
					else
					{
						ChangeAnimSpeedRPC(6f);
					}
					_navMeshAgent.Agent.speed = 12f;
				}
				else
				{
					_navMeshAgent.Agent.speed = 0.05f;
				}
				bool flag = false;
				LevelPoint val;
				if (Terminator)
				{
					stateTimer = Random.Range(4f, 10f);
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 5f, 15f);
				}
				else
				{
					stateTimer = Random.Range(8f, 12f);
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 10f, 25f);
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((NavMeshHit)(ref val2)).position;
					flag = true;
				}
				if (flag)
				{
					_enemy.Rigidbody.notMovingTimer = 0f;
					_stateImpulse = false;
					_navMeshAgent.SetDestination(_agentDestination);
				}
				return;
			}
			_navMeshAgent.SetDestination(_agentDestination);
			if (_navMeshAgent.Agent.speed <= 4f && !Terminator)
			{
				if (_speedChangeCooldown <= 0f)
				{
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { _navMeshAgent.Agent.speed / 1.5f + 1f });
						_speedChangeCooldown = 1f;
					}
					else
					{
						ChangeAnimSpeedRPC(_navMeshAgent.Agent.speed / 1.5f + 1f);
						_speedChangeCooldown = 1f;
					}
				}
				else
				{
					_speedChangeCooldown -= Time.deltaTime;
				}
				NavMeshAgent agent = _navMeshAgent.Agent;
				agent.speed += 0.4f * Time.deltaTime;
			}
			if (_enemy.Rigidbody.notMovingTimer > 2f)
			{
				stateTimer -= Time.deltaTime;
			}
			if (stateTimer <= 0f || CheckPathCompletion())
			{
				UpdateState(State.StartListen);
			}
		}

		private void StateFlee()
		{
			//IL_0109: 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_0135: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: 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)
			if (_stateImpulse)
			{
				_isListening = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsListeningRPC", (RpcTarget)1, new object[1] { _isListening });
					_photonView.RPC("RoamImpulseRPC", (RpcTarget)0, Array.Empty<object>());
					_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 7f });
				}
				else
				{
					IsListeningRPC(_isListening);
					RoamImpulseRPC();
					ChangeAnimSpeedRPC(7f);
				}
				_navMeshAgent.Agent.speed = 24f;
				stateTimer = 5f;
				stateHaltTimer = 1f;
				bool flag = false;
				LevelPoint val = ((!Terminator) ? SemiFunc.LevelPointGet(((Component)this).transform.position, 15f, 80f) : SemiFunc.LevelPointGet(((Component)this).transform.position, 10f, 30f));
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((Component)val).transform.position;
					flag = true;
				}
				if (flag)
				{
					_navMeshAgent.SetDestination(_agentDestination);
					_enemy.Rigidbody.notMovingTimer = 0f;
					_stateImpulse = false;
				}
				return;
			}
			if (_enemy.Rigidbody.notMovingTimer > 2f)
			{
				stateTimer -= Time.deltaTime;
			}
			stateHaltTimer -= Time.deltaTime;
			if (stateHaltTimer <= 0f)
			{
				SemiFunc.EnemyCartJump(_enemy);
				if (stateTimer <= 0f || CheckPathCompletion())
				{
					SemiFunc.EnemyCartJumpReset(_enemy);
					UpdateState(State.StartListen);
				}
			}
		}

		private void StateAttack()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("AttackImpulseRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					AttackImpulseRPC();
				}
				stateTimer = 5f;
				_stateImpulse = false;
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_navMeshAgent.ResetPath();
				return;
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.Flee);
				_isListening = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsListeningRPC", (RpcTarget)1, new object[1] { _isListening });
				}
				else
				{
					IsListeningRPC(_isListening);
				}
			}
		}

		private void StateDespawn()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_enemy.NavMeshAgent.Warp(feetTransform.position);
				_enemy.NavMeshAgent.ResetPath();
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("DespawnImpulseRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					DespawnImpulseRPC();
				}
			}
		}

		private void StateStun()
		{
			if (_stateImpulse)
			{
				_stateImpulse = false;
			}
			if (!_enemy.IsStunned())
			{
				_hearCount = 0;
				_isListening = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsListeningRPC", (RpcTarget)1, new object[1] { _isListening });
					_photonView.RPC("AttackImpulseRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					IsListeningRPC(_isListening);
					AttackImpulseRPC();
				}
				if (_spawnCool <= 0f)
				{
					UpdateState(State.Attack);
				}
				else
				{
					UpdateState(State.Wander);
				}
			}
		}

		private void UpdateState(State _newState)
		{
			if (CurrentState != _newState)
			{
				CurrentState = _newState;
				stateTimer = 0f;
				_stateImpulse = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { CurrentState });
				}
				else
				{
					UpdateStateRPC(CurrentState);
				}
			}
		}

		[PunRPC]
		private void UpdateStateRPC(State _state)
		{
			CurrentState = _state;
			if (CurrentState == State.Spawn)
			{
				GusherAnim.SetSpawn();
			}
		}

		[PunRPC]
		private void RoamImpulseRPC()
		{
			_roamImpulse = true;
		}

		[PunRPC]
		private void DespawnImpulseRPC()
		{
			_despawnImpulse = true;
		}

		[PunRPC]
		private void AttackImpulseRPC()
		{
			_attackImpulse = true;
		}

		[PunRPC]
		private void HearImpulseRPC()
		{
			_hearImpulse = true;
		}

		[PunRPC]
		private void IsListeningRPC(bool value)
		{
			_isListening = value;
		}

		[PunRPC]
		private void ChangeAnimSpeedRPC(float value)
		{
			_animSpeed = value;
		}

		private bool CheckPathCompletion()
		{
			NavMeshAgent agent = _navMeshAgent.Agent;
			float remainingDistance = agent.remainingDistance;
			if (remainingDistance <= 0.07f)
			{
				return true;
			}
			return false;
		}

		private float CrazyCalculation()
		{
			return 5.5f;
		}

		private void RotationLogic()
		{
			//IL_00d5: 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_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_008c: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			if (CurrentState != State.Stun && CurrentState != State.StartListen && CurrentState != State.Listen && CurrentState != State.EndListen && CurrentState != State.Attack)
			{
				horizontalRotationSpring.speed = 8f;
				horizontalRotationSpring.damping = 0.85f;
				Vector3 normalized = ((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized;
				if (((Vector3)(ref normalized)).magnitude > 0.1f)
				{
					_horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized);
					((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
				}
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
		}

		private void HurtEffect()
		{
			if (!_hurtImpulse)
			{
				return;
			}
			hurtLerp += 2.5f * Time.deltaTime;
			hurtLerp = Mathf.Clamp01(hurtLerp);
			foreach (Material item in _hurtMaterial)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
				}
				if (hurtLerp >= 1f)
				{
					hurtLerp = 0f;
					_hurtImpulse = false;
					if ((Object)(object)item != (Object)null)
					{
						item.SetFloat(_hurtAmount, 0f);
					}
				}
			}
		}

		public void OnInvestigate()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_004d: 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)
			if (CurrentState != State.Listen || !(_hearCooldown <= 0f))
			{
				return;
			}
			_investigatePoint = _enemy.StateInvestigate.onInvestigateTriggeredPosition;
			Vector3 position = _listenPoint.position;
			if (!(Vector3.Distance(_investigatePoint, position) < 14f))
			{
				return;
			}
			int num;
			float hearCooldown;
			if (Terminator)
			{
				num = 2;
				hearCooldown = 1f;
			}
			else
			{
				num = 4;
				hearCooldown = 2f;
			}
			if (_hearCount < num)
			{
				_hearCooldown = hearCooldown;
				_hearCount++;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("HearImpulseRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					HearImpulseRPC();
				}
			}
			else
			{
				_stateImpulse = true;
				_hearCount = 0;
				UpdateState(State.Attack);
			}
		}

		public void OnSpawn()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(_enemy))
			{
				UpdateState(State.Spawn);
			}
			_spawnCool = 8f;
			if (CheckIfSmxrezInLobby())
			{
				_enemy.EnemyParent.Despawn();
			}
		}

		private bool CheckIfSmxrezInLobby()
		{
			return false;
		}

		public void OnGrab()
		{
			if (CurrentState == State.Listen)
			{
				_hearCount = 0;
				UpdateState(State.Attack);
				_stateImpulse = true;
			}
		}

		public void OnHurt()
		{
			_hurtImpulse = true;
			if (CurrentState == State.Listen && !(_spawnCool > 0f))
			{
				if ((float)_hitAmount < 2f)
				{
					_hitAmount++;
				}
				else
				{
					UpdateState(State.Attack);
				}
			}
		}

		public void OnDeath()
		{
			_deathImpulse = true;
			_despawnImpulse = true;
			_enemy.Stunned = false;
			GusherAnim.PlayDeathParticles();
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				_enemy.EnemyParent.Despawn();
			}
		}
	}
	internal class GusherAnimationController : MonoBehaviour
	{
		[Header("References")]
		public Gusher Controller;

		public Animator animator;

		[Header("Particles")]
		public ParticleSystem[] pukeParticles;

		public ParticleSystem[] pukeSplashParticles;

		public ParticleSystem[] pukeEndParticles;

		public ParticleSystem[] Deathparticles;

		[Header("Sounds")]
		[SerializeField]
		private Sound roamSounds;

		[SerializeField]
		private Sound hearSounds;

		[SerializeField]
		private Sound attackSounds;

		[SerializeField]
		private Sound attackGlobalSounds;

		[SerializeField]
		private Sound hurtSounds;

		[SerializeField]
		private Sound deathSounds;

		private void Update()
		{
			if (Controller.Enemy.IsStunned())
			{
				animator.SetTrigger("stun");
				EndPukePart();
				ChangeAnimSpeed(1f);
			}
			if (Controller._roamImpulse)
			{
				Controller._roamImpulse = false;
				animator.SetTrigger("roam");
			}
			if (Controller._attackImpulse)
			{
				Controller._attackImpulse = false;
				animator.SetTrigger("attack");
			}
			if (Controller._despawnImpulse)
			{
				Controller._despawnImpulse = false;
				animator.SetTrigger("despawn");
			}
			if (Controller._deathImpulse)
			{
				Controller._deathImpulse = false;
				animator.SetTrigger("death");
			}
			if (Controller._hearImpulse)
			{
				Controller._hearImpulse = false;
				animator.SetTrigger("hear");
			}
			if (Controller._isListening)
			{
				animator.SetBool("isListening", true);
			}
			else
			{
				animator.SetBool("isListening", false);
			}
			if (Controller._animSpeed != animator.speed)
			{
				animator.speed = Controller._animSpeed;
			}
		}

		public void ChangeAnimSpeed(float value)
		{
			animator.speed = value;
		}

		public void PlayRoamSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			roamSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayHurtSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			hurtSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayDeathSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			deathSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayAttackSound()
		{
			//IL_0017: 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)
			attackSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
			attackGlobalSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void PlayHearSound()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			hearSounds.Play(Controller.Enemy.CenterTransform.position, 1f, 1f, 1f, 1f);
		}

		public void StartPukePart()
		{
			ParticleSystem[] array = pukeSplashParticles;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Play();
			}
			ParticleSystem[] array2 = pukeParticles;
			for (int j = 0; j < array2.Length; j++)
			{
				array2[j].Play();
			}
		}

		public void StartRandomPukePart()
		{
			ParticleSystem[] array = pukeSplashParticles;
			ParticleSystem[] array2 = pukeParticles;
			int num = Random.Range(0, array.Length);
			array[num].Play();
			array2[num].Play();
		}

		public void EndPukePart()
		{
			ParticleSystem[] array = pukeEndParticles;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Play();
			}
			ParticleSystem[] array2 = pukeParticles;
			for (int j = 0; j < array2.Length; j++)
			{
				array2[j].Stop();
			}
		}

		public void PlayDeathParticles()
		{
			PlayDeathSound();
			ParticleSystem[] deathparticles = Deathparticles;
			foreach (ParticleSystem val in deathparticles)
			{
				val.Play();
			}
		}

		public void SetDespawn()
		{
			Controller._enemy.EnemyParent.Despawn();
		}

		public void SetSpawn()
		{
			animator.Play("New State", -1, 0f);
		}

		public void Despawn()
		{
			Controller._enemy.EnemyParent.Despawn();
		}
	}
	internal class LostDroid : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Idle,
			Wander,
			RWander,
			RSwing,
			Stun,
			Notice,
			Follow,
			Transform,
			RAttack,
			RShortAttack,
			Despawn
		}

		public LostDroidAnimationController LostDroidAnim;

		internal Enemy _enemy;

		private PhotonView _photonView;

		public Renderer[] renderers;

		private Color[] colors = (Color[])(object)new Color[5];

		private int droidVariant;

		public Transform _bulletPosition;

		public Transform feetTransform;

		public GameObject bulletPrefab;

		[Header("Sounds")]
		public Sound soundHit;

		public Sound genericLines;

		public Sound SadLines;

		public Sound EnvyLines;

		public Sound HateLines;

		public Sound CuteLines;

		public Sound MurderLines;

		public Sound RageLines;

		public AnimationCurve shootLineWidthCurve;

		public ParticleSystem minigunParticles;

		public bool Terminator = false;

		public bool Transformed = false;

		private bool _stateImpulse = false;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Vector3 _agentDestination;

		private Vector3 _targetPosition;

		private Vector3 _turnPosition;

		private PlayerAvatar _targetPlayer;

		private List<Material> _hurtMaterial = new List<Material>();

		private float _overrideAgentLerp;

		private bool _hurtImpulse;

		private float hurtLerp;

		private float _attackCooldown;

		private int _hurtAmount;

		private float _talkTimer;

		private float _avoidDist;

		private bool _talker;

		private float _bulletSpread;

		internal bool _isWalking;

		internal bool _isSprinting;

		internal bool _isTurning;

		internal bool _deathImpulse;

		internal bool _despawnImpulse;

		internal bool _attackImpulse;

		internal bool _attackShortImpulse;

		internal bool _fireBullets;

		internal bool _swingImpulse;

		internal bool _firstStun;

		internal bool _hasSpawned;

		internal bool _isTurningToPlayer;

		internal bool _transformImpulse;

		internal bool _isStun;

		internal int _damageAmount;

		internal float _animSpeed = 1f;

		internal float _transformCountMax;

		internal float _transformCount;

		private float _bulletFireCooldown;

		[Header("State")]
		[SerializeField]
		public State CurrentState;

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

		[Header("Animation")]
		[SerializeField]
		private AnimationCurve hurtCurve;

		[SerializeField]
		private SkinnedMeshRenderer[] _skinnedMeshRenderer;

		[SerializeField]
		private MeshRenderer[] _MeshRenderer;

		[Header("Rotation and LookAt")]
		public SpringQuaternion horizontalRotationSpring;

		private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;

		private EnemyRigidbody _rigidbody => _enemy.Rigidbody;

		private EnemyParent _enemyParent => _enemy.EnemyParent;

		private EnemyVision _Vision => _enemy.Vision;

		public Enemy Enemy => _enemy;

		private void Awake()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_006e: 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_0093: 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_00b8: 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)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			colors[0] = new Color(1f, 0.1764706f, 0.1764706f, 0f);
			colors[1] = new Color(0.4117647f, 7f / 15f, 1f, 0f);
			colors[2] = new Color(1f, 0.7607843f, 0f, 0f);
			colors[3] = new Color(0.95686275f, 0.08627451f, 40f / 51f, 0f);
			colors[4] = new Color(1f, 1f, 1f, 0f);
			if (Terminator)
			{
				_transformCount = 5f;
				_transformCountMax = Random.Range(5f, 10f);
				_bulletSpread = 10f;
			}
			else
			{
				_transformCount = 8f;
				_transformCountMax = Random.Range(6f, 12f);
				_bulletSpread = 20f;
			}
			_talker = Random.value < 0.5f;
			_talkTimer = Random.Range(5f, 28f);
			_avoidDist = Random.Range(2f, 4f);
			SkinnedMeshRenderer[] skinnedMeshRenderer = _skinnedMeshRenderer;
			foreach (SkinnedMeshRenderer val in skinnedMeshRenderer)
			{
				if ((Object)(object)val != (Object)null)
				{
					_hurtMaterial.AddRange(((Renderer)val).materials);
				}
			}
			MeshRenderer[] meshRenderer = _MeshRenderer;
			for (int j = 0; j < meshRenderer.Length; j++)
			{
				Renderer val2 = (Renderer)(object)meshRenderer[j];
				if ((Object)(object)val2 != (Object)null)
				{
					_hurtMaterial.AddRange(val2.materials);
				}
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
		}

		private void Update()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (!_enemy.IsStunned())
			{
				if ((int)_enemy.EnemyParent.Enemy.CurrentState == 11 && CurrentState != State.Despawn)
				{
					UpdateState(State.Despawn);
				}
				switch (CurrentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Wander:
					StateWander();
					break;
				case State.RAttack:
					StateRAttack();
					break;
				case State.RShortAttack:
					StateRShortAttack();
					break;
				case State.Stun:
					StateStun();
					break;
				case State.RWander:
					StateWander();
					break;
				case State.RSwing:
					StateRSwing();
					break;
				case State.Notice:
					StateNotice();
					break;
				case State.Idle:
					StateIdle();
					break;
				case State.Follow:
					StateFollow();
					break;
				case State.Despawn:
					StateDespawn();
					break;
				case State.Transform:
					StateTransform();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
				RotationLogic();
			}
			else
			{
				UpdateState(State.Stun);
				StateStun();
			}
			HurtEffect();
			if (_transformCount < _transformCountMax)
			{
				_transformCount += Time.deltaTime * 0.25f;
			}
			if (_attackCooldown > 0f)
			{
				_attackCooldown -= Time.deltaTime;
			}
			if (_talkTimer > 0f)
			{
				_talkTimer -= Time.deltaTime;
				return;
			}
			Talk();
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				_talkTimer = Random.Range(5f, 28f);
			}
		}

		private void StateSpawn()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 1f });
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsTurningRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					ChangeAnimSpeedRPC(1f);
					IsSprintingRPC(value: false);
					IsWalkingRPC(value: false);
					IsTurningRPC(value: false);
				}
				stateTimer = 2f;
			}
			else
			{
				UpdateState(State.Wander);
				_hasSpawned = true;
			}
		}

		private void StateIdle()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_isTurningToPlayer = false;
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				stateTimer = Random.Range(6f, 8f);
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsTurningRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					IsSprintingRPC(value: false);
					IsWalkingRPC(value: false);
					IsTurningRPC(value: false);
				}
			}
			else
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.Wander);
				}
			}
		}

		private void StateWander()
		{
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				bool flag = false;
				LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 10f, 20f);
				if (Transformed)
				{
					stateTimer = 30f;
				}
				else
				{
					stateTimer = 18f;
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 5f, 999f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 4f, ref val2, 8f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((NavMeshHit)(ref val2)).position;
					flag = true;
				}
				if (!flag)
				{
					return;
				}
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { true });
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsTurningRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					IsWalkingRPC(value: true);
					IsTurningRPC(value: false);
					IsSprintingRPC(value: false);
				}
				_enemy.Rigidbody.notMovingTimer = 0f;
				_stateImpulse = false;
				if (Transformed)
				{
					if (Terminator)
					{
						_navMeshAgent.Agent.speed = 0.75f;
						if (GameManager.Multiplayer())
						{
							_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 3f });
						}
						else
						{
							ChangeAnimSpeedRPC(3f);
						}
					}
					else
					{
						_navMeshAgent.Agent.speed = 0.25f;
					}
				}
				else
				{
					_navMeshAgent.Agent.speed = 1.4f;
				}
				_navMeshAgent.SetDestination(_agentDestination);
				return;
			}
			_navMeshAgent.SetDestination(_agentDestination);
			if (_enemy.Rigidbody.notMovingTimer > 2f)
			{
				stateTimer -= Time.deltaTime;
			}
			if (stateTimer <= 0f || CheckPathCompletion())
			{
				if (Transformed)
				{
					UpdateState(State.RWander);
					_stateImpulse = true;
				}
				else
				{
					UpdateState(State.Idle);
				}
			}
		}

		private void StateDespawn()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_enemy.NavMeshAgent.Warp(feetTransform.position);
				_enemy.NavMeshAgent.ResetPath();
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("DespawnImpulseRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					DespawnImpulseRPC();
				}
			}
		}

		private void StateRSwing()
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				if (Terminator)
				{
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 2f });
					}
					else
					{
						ChangeAnimSpeedRPC(2f);
					}
					stateTimer = 1.2f;
				}
				else
				{
					stateTimer = 2.4f;
				}
				_stateImpulse = false;
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				_turnPosition = ((Component)_targetPlayer).transform.position;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("SwingImpulseRPC", (RpcTarget)0, Array.Empty<object>());
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					SwingImpulseRPC();
					IsWalkingRPC(value: false);
				}
				return;
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				float num = Vector3.Distance(((Component)_targetPlayer).transform.position, ((Component)this).transform.position);
				if (num < 1f)
				{
					UpdateState(State.RSwing);
					_stateImpulse = true;
				}
				else
				{
					UpdateState(State.RWander);
				}
			}
		}

		private void StateRShortAttack()
		{
			//IL_001b: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				_stateImpulse = false;
				stateTimer = 5.5f;
				if ((Object)(object)_targetPlayer != (Object)null)
				{
					_turnPosition = ((Component)_targetPlayer).transform.position;
				}
				if (Terminator)
				{
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 1f });
					}
					else
					{
						ChangeAnimSpeedRPC(1f);
					}
				}
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("AttackShortImpulseRPC", (RpcTarget)0, Array.Empty<object>());
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					AttackShortImpulseRPC();
					IsWalkingRPC(value: false);
				}
			}
			else
			{
				FireBullets();
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.RWander);
				}
			}
		}

		private void StateRAttack()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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)
			if (_stateImpulse)
			{
				if (Terminator)
				{
					stateTimer = 17f;
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 1f });
					}
					else
					{
						ChangeAnimSpeedRPC(1f);
					}
				}
				else
				{
					stateTimer = 19.4f;
				}
				_attackCooldown = Random.Range(22f, 32f);
				_stateImpulse = false;
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				_turnPosition = ((Component)this).transform.position;
				if ((Object)(object)_targetPlayer != (Object)null)
				{
					_turnPosition = ((Component)_targetPlayer).transform.position;
				}
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("AttackImpulseRPC", (RpcTarget)0, Array.Empty<object>());
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					AttackImpulseRPC();
					IsWalkingRPC(value: false);
				}
			}
			else
			{
				FireBullets();
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.RWander);
				}
			}
		}

		private void StateTransform()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				stateTimer = 12f;
				_stateImpulse = false;
				_isTurningToPlayer = false;
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("TransformImpulseRPC", (RpcTarget)0, Array.Empty<object>());
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsTurningRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					TransformImpulseRPC();
					IsSprintingRPC(value: false);
					IsWalkingRPC(value: false);
					IsTurningRPC(value: false);
				}
			}
			else
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.RAttack);
					Transformed = true;
				}
			}
		}

		private void StateStun()
		{
			if (_stateImpulse)
			{
				_isTurningToPlayer = false;
				if (Terminator)
				{
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 1f });
					}
					else
					{
						ChangeAnimSpeedRPC(1f);
					}
				}
				_stateImpulse = false;
				if (!Transformed)
				{
					if (!_firstStun && _hasSpawned)
					{
						if (GameManager.Multiplayer())
						{
							_photonView.RPC("IsStunnedRPC", (RpcTarget)0, new object[1] { true });
						}
						else
						{
							IsStunnedRPC(value: true);
						}
						_firstStun = true;
					}
				}
				else if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsStunnedRPC", (RpcTarget)0, new object[1] { true });
				}
				else
				{
					IsStunnedRPC(value: true);
				}
			}
			if (_enemy.IsStunned())
			{
				return;
			}
			if (GameManager.Multiplayer())
			{
				_photonView.RPC("IsStunnedRPC", (RpcTarget)0, new object[1] { false });
			}
			else
			{
				IsStunnedRPC(value: false);
			}
			if (Transformed)
			{
				if (_attackCooldown > 0f)
				{
					UpdateState(State.RShortAttack);
				}
				else
				{
					UpdateState(State.RAttack);
				}
			}
			else
			{
				UpdateState(State.Transform);
			}
		}

		private void StateFollow()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				stateTimer = 6f;
				_stateImpulse = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { true });
					_photonView.RPC("IsTurningRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					IsSprintingRPC(value: true);
					IsTurningRPC(value: false);
				}
				return;
			}
			if (Vector3.Distance(((Component)this).transform.position, ((Component)_targetPlayer).transform.position) > _avoidDist)
			{
				_overrideAgentLerp -= Time.deltaTime / 0.01f;
				_enemy.Rigidbody.OverrideFollowPosition(0.2f, 5f, 30f);
				_overrideAgentLerp = Mathf.Clamp(_overrideAgentLerp, 0f, 1f);
				float num = 25f;
				float num2 = 25f;
				float num3 = Mathf.Lerp(_enemy.NavMeshAgent.DefaultSpeed, num, _overrideAgentLerp);
				float num4 = Mathf.Lerp(_enemy.Rigidbody.positionSpeedChase, num2, _overrideAgentLerp);
				_enemy.NavMeshAgent.OverrideAgent(num3 * 2f, _enemy.NavMeshAgent.DefaultAcceleration, 0.2f);
				_enemy.Rigidbody.OverrideFollowPosition(1f, num4 * 2f, -1f);
				_targetPosition = ((Component)_targetPlayer).transform.position;
				_enemy.NavMeshAgent.SetDestination(_targetPosition);
				_isTurningToPlayer = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { true });
					_photonView.RPC("IsTurningRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					IsSprintingRPC(value: true);
					IsTurningRPC(value: false);
				}
			}
			else
			{
				_navMeshAgent.Agent.ResetPath();
				_isTurningToPlayer = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					IsSprintingRPC(value: false);
					IsWalkingRPC(value: false);
				}
			}
			if (_transformCount > 0f)
			{
				_transformCount -= Time.deltaTime * 0.8f;
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.Wander);
				}
			}
			else
			{
				UpdateState(State.Transform);
			}
		}

		private void StateNotice()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_navMeshAgent.Warp(((Component)this).transform.position);
				_navMeshAgent.ResetPath();
				stateTimer = Random.Range(2f, 4f);
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
				else
				{
					IsSprintingRPC(value: false);
					IsWalkingRPC(value: false);
				}
				return;
			}
			if (_transformCount > 0f)
			{
				_transformCount -= Time.deltaTime * 0.4f;
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.Idle);
				}
			}
			else
			{
				UpdateState(State.Transform);
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.Follow);
			}
		}

		private void UpdateState(State _newState)
		{
			if (CurrentState != _newState)
			{
				CurrentState = _newState;
				stateTimer = 0f;
				_stateImpulse = true;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { CurrentState });
				}
				else
				{
					UpdateStateRPC(CurrentState);
				}
			}
		}

		[PunRPC]
		private void PickRandomVariantRPC(int value)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			droidVariant = value;
			Renderer[] array = renderers;
			foreach (Renderer val in array)
			{
				val.material.SetColor("_AlbedoColor", colors[droidVariant]);
			}
		}

		[PunRPC]
		private void UpdateStateRPC(State _state)
		{
			CurrentState = _state;
			if (CurrentState == State.Spawn)
			{
				LostDroidAnim.SetSpawn();
			}
		}

		[PunRPC]
		private void IsWalkingRPC(bool value)
		{
			_isWalking = value;
		}

		[PunRPC]
		private void IsSprintingRPC(bool value)
		{
			_isSprinting = value;
		}

		[PunRPC]
		private void IsTurningRPC(bool value)
		{
			_isTurning = value;
		}

		[PunRPC]
		private void TransformImpulseRPC()
		{
			_transformImpulse = true;
		}

		[PunRPC]
		private void IsStunnedRPC(bool value)
		{
			_isStun = value;
		}

		[PunRPC]
		private void AttackImpulseRPC()
		{
			_attackImpulse = true;
		}

		[PunRPC]
		private void AttackShortImpulseRPC()
		{
			_attackShortImpulse = true;
		}

		[PunRPC]
		private void SwingImpulseRPC()
		{
			_swingImpulse = true;
		}

		[PunRPC]
		private void DespawnImpulseRPC()
		{
			_despawnImpulse = true;
		}

		[PunRPC]
		private void TargetPlayerRPC(int _playerID)
		{
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (player.photonView.ViewID == _playerID)
				{
					_targetPlayer = player;
				}
			}
		}

		[PunRPC]
		private void FireBulletRPC()
		{
			//IL_001b: 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)
			//IL_002b: 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_0054: 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_0063: 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_006c: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				Vector3 endPosition = _bulletPosition.position;
				bool hit = false;
				bool flag = false;
				Vector3 forward = _bulletPosition.forward;
				float num = Random.Range(0f, _bulletSpread);
				float num2 = Random.Range(0f, 360f);
				Vector3 val = Vector3.Cross(forward, Random.onUnitSphere);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				Quaternion val2 = Quaternion.AngleAxis(num, normalized);
				val = Quaternion.AngleAxis(num2, forward) * val2 * forward;
				forward = ((Vector3)(ref val)).normalized;
				RaycastHit val3 = default(RaycastHit);
				if (Physics.Raycast(_bulletPosition.position, forward, ref val3, 80f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) + LayerMask.GetMask(new string[1] { "enemy" })))
				{
					endPosition = ((RaycastHit)(ref val3)).point;
					hit = true;
				}
				else
				{
					flag = true;
				}
				if (flag)
				{
					endPosition = _bulletPosition.position + _bulletPosition.forward * 80f;
				}
				ShootBullet(endPosition, hit);
			}
		}

		[PunRPC]
		public void ShootBulletRPC(Vector3 _endPosition, bool _hit)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			ItemGunBullet component = Object.Instantiate<GameObject>(bulletPrefab, _bulletPosition.position, _bulletPosition.rotation).GetComponent<ItemGunBullet>();
			component.hitPosition = _endPosition;
			component.bulletHit = _hit;
			soundHit.Play(_endPosition, 1f, 1f, 1f, 1f);
			component.shootLineWidthCurve = shootLineWidthCurve;
			component.ActivateAll();
		}

		[PunRPC]
		private void ChangeAnimSpeedRPC(float value)
		{
			_animSpeed = value;
		}

		[PunRPC]
		private void PlayVoicelineRPC(int value)
		{
			//IL_0042: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			switch (value)
			{
			case 0:
				HateLines.Play(((Component)genericLines.Source).transform.position, 1f, 1f, 1f, 1f);
				break;
			case 1:
				SadLines.Play(((Component)genericLines.Source).transform.position, 1f, 1f, 1f, 1f);
				break;
			case 2:
				EnvyLines.Play(((Component)genericLines.Source).transform.position, 1f, 1f, 1f, 1f);
				break;
			case 3:
				CuteLines.Play(((Component)genericLines.Source).transform.position, 1f, 1f, 1f, 1f);
				break;
			case 4:
				genericLines.Play(((Component)genericLines.Source).transform.position, 1f, 1f, 1f, 1f);
				break;
			case 5:
				RageLines.Play(((Component)genericLines.Source).transform.position, 1f, 1f, 1f, 1f);
				break;
			case 6:
				MurderLines.Play(((Component)genericLines.Source).transform.position, 1f, 1f, 1f, 1f);
				break;
			}
		}

		public void OnHurt()
		{
			if (!Transformed)
			{
				if (_damageAmount < 2)
				{
					_damageAmount++;
				}
				else
				{
					UpdateState(State.Transform);
				}
			}
		}

		public void OnSpawn()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.EnemySpawn(_enemy))
			{
				UpdateState(State.Spawn);
			}
			_damageAmount = 0;
			_talker = Random.value < 0.5f;
			_talkTimer = Random.Range(5f, 28f);
			_avoidDist = Random.Range(2f, 4f);
			if (GameManager.Multiplayer())
			{
				_photonView.RPC("IsStunnedRPC", (RpcTarget)0, new object[1] { false });
			}
			else
			{
				IsStunnedRPC(value: false);
			}
			if (!Terminator)
			{
				int num = Random.Range(0, colors.Length);
				if (GameManager.Multiplayer() && SemiFunc.IsMasterClientOrSingleplayer())
				{
					_photonView.RPC("PickRandomVariantRPC", (RpcTarget)0, new object[1] { num });
				}
				else
				{
					PickRandomVariantRPC(num);
				}
			}
		}

		public void OnGrab()
		{
			_targetPlayer = _enemy.Vision.onVisionTriggeredPlayer;
			if (CurrentState == State.Idle || CurrentState == State.Wander)
			{
				if (GameManager.Multiplayer() && (Object)(object)_targetPlayer != (Object)null)
				{
					_photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { _targetPlayer.photonView.ViewID });
				}
				if ((Object)(object)_targetPlayer != (Object)null)
				{
					UpdateState(State.Notice);
				}
			}
			else if (CurrentState == State.RWander)
			{
				if (GameManager.Multiplayer() && (Object)(object)_targetPlayer != (Object)null)
				{
					_photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { _targetPlayer.photonView.ViewID });
				}
				UpdateState(State.RSwing);
			}
		}

		public void OnDeath()
		{
			_deathImpulse = true;
			_enemy.Stunned = false;
			LostDroidAnim.PlayDeathParticles();
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				_enemy.EnemyParent.Despawn();
			}
		}

		public void OnVision()
		{
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			if (!Transformed)
			{
				if (CurrentState == State.Wander || CurrentState == State.Idle)
				{
					_targetPlayer = _enemy.Vision.onVisionTriggeredPlayer;
					if (!_targetPlayer.isCrawling && !_targetPlayer.isCrouching)
					{
						UpdateState(State.Notice);
						if (GameManager.Multiplayer())
						{
							_photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { _targetPlayer.photonView.ViewID });
						}
					}
				}
				else if ((CurrentState == State.Follow || CurrentState == State.Notice) && (Object)(object)_targetPlayer == (Object)(object)_enemy.Vision.onVisionTriggeredPlayer && !_targetPlayer.isCrawling && !_targetPlayer.isCrouching)
				{
					stateTimer = MathF.Max(stateTimer, 6f);
				}
			}
			else
			{
				if (CurrentState != State.RWander)
				{
					return;
				}
				_targetPlayer = _enemy.Vision.onVisionTriggeredPlayer;
				if (!_targetPlayer.isCrawling)
				{
					if (Vector3.Distance(((Component)_targetPlayer).transform.position, ((Component)this).transform.position) < 3f)
					{
						UpdateState(State.RSwing);
					}
					else if (_attackCooldown > 0f)
					{
						UpdateState(State.RShortAttack);
					}
					else
					{
						UpdateState(State.RAttack);
					}
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { _targetPlayer.photonView.ViewID });
					}
				}
			}
		}

		public void OnDestroyerVision()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (CurrentState != State.RWander)
			{
				return;
			}
			_targetPlayer = _enemy.StateInvestigate.Player.playerAvatarScript;
			if (!_targetPlayer.isCrawling && !_targetPlayer.isCrouching)
			{
				if (Vector3.Distance(((Component)_targetPlayer).transform.position, ((Component)this).transform.position) < 2f)
				{
					UpdateState(State.RSwing);
				}
				else
				{
					UpdateState(State.RShortAttack);
				}
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { _targetPlayer.photonView.ViewID });
				}
			}
		}

		private void Talk()
		{
			if (!_talker)
			{
				return;
			}
			if (!Terminator && !Transformed && CurrentState != State.Transform)
			{
				if (_transformCount < _transformCountMax / 6f * 2f)
				{
					PlayVoicelineMultiplayer(5);
				}
				else if (Random.value < 0.95f)
				{
					switch (droidVariant)
					{
					case 0:
						PlayVoicelineMultiplayer(0);
						break;
					case 1:
						PlayVoicelineMultiplayer(1);
						break;
					case 2:
						PlayVoicelineMultiplayer(2);
						break;
					case 3:
						PlayVoicelineMultiplayer(3);
						break;
					case 4:
						PlayVoicelineMultiplayer(4);
						break;
					}
				}
				else
				{
					PlayVoicelineMultiplayer(4);
				}
			}
			else
			{
				PlayVoicelineMultiplayer(6);
			}
		}

		private void PlayVoicelineMultiplayer(int value)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("PlayVoicelineRPC", (RpcTarget)0, new object[1] { value });
				}
				else
				{
					PlayVoicelineRPC(value);
				}
			}
		}

		private void ShootBullet(Vector3 _endPosition, bool _hit)
		{
			//IL_0050: 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 (SemiFunc.IsMasterClientOrSingleplayer())
			{
				minigunParticles.Play();
				if (SemiFunc.IsMultiplayer())
				{
					_photonView.RPC("ShootBulletRPC", (RpcTarget)0, new object[2] { _endPosition, _hit });
				}
				else
				{
					ShootBulletRPC(_endPosition, _hit);
				}
			}
		}

		public void FireBullets()
		{
			if (_fireBullets)
			{
				if (_bulletFireCooldown <= 0f)
				{
					_bulletFireCooldown = 0.02f;
					FireBulletRPC();
				}
				_bulletFireCooldown -= Time.deltaTime;
			}
		}

		private void RotationLogic()
		{
			//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_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: 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_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			if (CurrentState != State.Stun && CurrentState != State.Idle && CurrentState != State.Notice && CurrentState != State.Transform && CurrentState != State.RAttack && CurrentState != State.RShortAttack && CurrentState != State.RSwing)
			{
				horizontalRotationSpring.speed = 10f;
				horizontalRotationSpring.damping = 1f;
				Vector3 normalized = ((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized;
				if (((Vector3)(ref normalized)).magnitude > 0.1f)
				{
					_horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized);
					((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
				}
				else if (_isTurningToPlayer)
				{
					Vector3 val = ((Component)_targetPlayer).transform.position - ((Component)this).transform.position;
					_horizontalRotationTarget = Quaternion.LookRotation(val, Vector3.up);
					((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
					TurnDroid();
				}
			}
			else if (CurrentState == State.Notice)
			{
				horizontalRotationSpring.speed = 10f;
				horizontalRotationSpring.damping = 1f;
				Vector3 val2 = ((Component)_targetPlayer).transform.position - ((Component)this).transform.position;
				if (val2 != Vector3.zero)
				{
					_horizontalRotationTarget = Quaternion.LookRotation(val2, Vector3.up);
					((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
				}
				TurnDroid();
			}
			else if (CurrentState == State.RSwing || CurrentState == State.RShortAttack || (CurrentState == State.RAttack && _isTurningToPlayer))
			{
				horizontalRotationSpring.speed = 5f;
				horizontalRotationSpring.damping = 0.5f;
				Vector3 val3 = _turnPosition - ((Component)this).transform.position;
				if (val3 != Vector3.zero)
				{
					_horizontalRotationTarget = Quaternion.LookRotation(val3, Vector3.up);
					((Quaternion)(ref _horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref _horizontalRotationTarget)).eulerAngles.y, 0f);
				}
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
		}

		private void TurnDroid()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			float num = Quaternion.Angle(((Component)this).transform.rotation, _horizontalRotationTarget);
			if (num > 7f || num < -7f)
			{
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsTurningRPC", (RpcTarget)0, new object[1] { true });
				}
				else
				{
					IsTurningRPC(value: true);
				}
			}
			else if (GameManager.Multiplayer())
			{
				_photonView.RPC("IsTurningRPC", (RpcTarget)0, new object[1] { false });
			}
			else
			{
				IsTurningRPC(value: false);
			}
		}

		private void HurtEffect()
		{
			if (!_hurtImpulse)
			{
				return;
			}
			hurtLerp += 2.5f * Time.deltaTime;
			hurtLerp = Mathf.Clamp01(hurtLerp);
			foreach (Material item in _hurtMaterial)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
				}
				if (hurtLerp >= 1f)
				{
					hurtLerp = 0f;
					_hurtImpulse = false;
					if ((Object)(object)item != (Object)null)
					{
						item.SetFloat(_hurtAmount, 0f);
					}
				}
			}
		}

		private bool CheckPathCompletion()
		{
			NavMeshAgent agent = _navMeshAgent.Agent;
			float remainingDistance = agent.remainingDistance;
			if (remainingDistance <= 0.07f)
			{
				return true;
			}
			return false;
		}
	}
	internal class LostDroidAnimationController : MonoBehaviour
	{
		[Header("References")]
		public LostDroid Controller;

		public Animator animator;

		public Transform minigunFirePosition;

		public GameObject ExplosionPrefab;

		[Header("Particles")]
		public ParticleSystem[] Deathparticles;

		public ParticleSystem footstepParticles;

		public ParticleSystem goreExplosion;

		[Header("Sounds")]
		[SerializeField]
		private Sound mediumFootstepSounds;

		[SerializeField]
		private Sound mediumWoodFootstepSounds;

		[SerializeField]
		private Sound mediumStoneFootstepSounds;

		[SerializeField]
		private Sound smallFootstepSounds;

		[SerializeField]
		private Sound largeFootstepSounds;

		[SerializeField]
		private Sound transformSounds;

		[SerializeField]
		private Sound stingerSounds;

		[SerializeField]