Decompiled source of Wesleys Enemies v1.0.2

WesleysEnemies.dll

Decompiled a week ago
using System;
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("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WesleysEnemies")]
[assembly: AssemblyTitle("WesleysEnemies")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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", "1.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");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			EnemySetup val2 = val.LoadAsset<EnemySetup>("EnemySetup - Gusher");
			EnemySetup val3 = val.LoadAsset<EnemySetup>("EnemySetup - Roaster");
			Enemies.RegisterEnemy(val2);
			Enemies.RegisterEnemy(val3);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "WesleysEnemies";

		public const string PLUGIN_NAME = "WesleysEnemies";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace WesleysEnemies.AI
{
	internal class Gusher : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			StartListen,
			Listen,
			EndListen,
			Attack,
			Wander,
			Stun,
			Despawn,
			Flee
		}

		private LayerMask layermask;

		private LayerMask playerLayermask;

		private Enemy _enemy;

		private PhotonView _photonView;

		public bool Terminator = false;

		private float _speedChangeCooldown;

		internal float _animSpeed;

		private float _despawnCool;

		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 Material _hurtMaterial;

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

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

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

		[SerializeField]
		private SkinnedMeshRenderer _skinnedMeshRenderer;

		[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");
			if ((Object)(object)_skinnedMeshRenderer != (Object)null)
			{
				_hurtMaterial = ((Renderer)_skinnedMeshRenderer).material;
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
		}

		private void Update()
		{
			if ((!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient) && LevelGenerator.Instance.Generated)
			{
				if (!_enemy.IsStunned())
				{
					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 (_despawnImpulse)
			{
				if (_despawnCool < 2f)
				{
					_despawnCool += Time.deltaTime;
				}
				else
				{
					_enemy.EnemyParent.Despawn();
				}
			}
		}

		private void StateSpawn()
		{
			//IL_001d: 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;
			}
			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(4f, 8f);
				}
				else
				{
					stateTimer = Random.Range(18f, 26f);
				}
				_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_0096: 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 });
				}
				_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();
			}
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				if (SemiFunc.EnemyForceLeave(_enemy))
				{
					UpdateState(State.Flee);
				}
				else
				{
					UpdateState(State.Wander);
				}
			}
		}

		private void StateWander()
		{
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: 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>());
				}
				if (Terminator)
				{
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("ChangeAnimSpeedRPC", (RpcTarget)0, new object[1] { 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
				{
					_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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: 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 });
				}
				_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_0051: 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>());
				}
				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 });
				}
			}
		}

		private void StateDespawn()
		{
		}

		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>());
				}
				UpdateState(State.Attack);
			}
		}

		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 if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					_enemy.EnemyParent.Despawn();
				}
			}
		}

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

		[PunRPC]
		private void RoamImpulseRPC()
		{
			_roamImpulse = 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 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);
			if ((Object)(object)_hurtMaterial != (Object)null)
			{
				_hurtMaterial.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
			}
			if (hurtLerp >= 1f)
			{
				hurtLerp = 0f;
				_hurtImpulse = false;
				if ((Object)(object)_hurtMaterial != (Object)null)
				{
					_hurtMaterial.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
			{
				_stateImpulse = true;
				_hearCount = 0;
				UpdateState(State.Attack);
			}
		}

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

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

		public void OnHurt()
		{
			_hurtImpulse = true;
		}

		public void OnDeath()
		{
			_deathImpulse = true;
			_despawnImpulse = true;
			_enemy.Stunned = false;
			UpdateState(State.Despawn);
		}
	}
	internal class GusherAnimationController : MonoBehaviour
	{
		[Header("References")]
		public Gusher Controller;

		public Animator animator;

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

		public ParticleSystem[] pukeParticles;

		public ParticleSystem[] pukeSplashParticles;

		public ParticleSystem[] pukeEndParticles;

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

		[SerializeField]
		private Sound hearSounds;

		[SerializeField]
		private Sound attackSounds;

		[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._deathImpulse)
			{
				Controller._deathImpulse = false;
				animator.SetTrigger("death");
				ParticleSystem[] array = deathParticles;
				for (int i = 0; i < array.Length; i++)
				{
					array[i].Play();
				}
			}
			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)
			attackSounds.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();
			}
		}
	}
	internal class LostDroid : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Idle,
			Wander,
			Stun,
			Notice,
			Follow,
			Transform,
			RAttack,
			Despawn
		}

		private Enemy _enemy;

		private PhotonView _photonView;

		public bool Terminator = false;

		public bool Transformed = false;

		private bool _stateImpulse = false;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Vector3 _agentDestination;

		private Vector3 _targetPosition;

		private PlayerAvatar _targetPlayer;

		private Material _hurtMaterial;

		private float _overrideAgentLerp;

		private bool _hurtImpulse;

		private float hurtLerp;

		private int _hurtAmount;

		internal bool _isWalking;

		internal bool _isSprinting;

		internal bool _isTurning;

		internal bool _transformImpulse;

		private float _transformCountMax;

		private float _transformCount;

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

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

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

		[SerializeField]
		private SkinnedMeshRenderer _skinnedMeshRenderer;

		[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()
		{
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			_transformCount = 8f;
			_transformCountMax = Random.Range(8f, 18f);
			if ((Object)(object)_skinnedMeshRenderer != (Object)null)
			{
				_hurtMaterial = ((Renderer)_skinnedMeshRenderer).material;
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
		}

		private void Update()
		{
			if ((GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (!_enemy.IsStunned())
			{
				switch (currentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Wander:
					StateWander();
					break;
				case State.Stun:
					StateStun();
					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();
				case State.RAttack:
					break;
				}
				RotationLogic();
			}
			else
			{
				UpdateState(State.Stun);
				StateStun();
			}
			HurtEffect();
			if (_transformCount < _transformCountMax)
			{
				_transformCount += Time.deltaTime * 0.25f;
			}
		}

		private void StateSpawn()
		{
			//IL_001f: 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 = 2f;
			}
			else
			{
				UpdateState(State.Wander);
			}
		}

		private void StateIdle()
		{
			//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(6f, 8f);
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
			}
			else
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.Wander);
				}
			}
		}

		private void StateWander()
		{
			//IL_0169: 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_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_0153: 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);
				stateTimer = 8f;
				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)
				{
					if (GameManager.Multiplayer())
					{
						_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { true });
					}
					_enemy.Rigidbody.notMovingTimer = 0f;
					_stateImpulse = false;
					_navMeshAgent.Agent.speed = 1.4f;
					_navMeshAgent.SetDestination(_agentDestination);
				}
			}
			else
			{
				_navMeshAgent.SetDestination(_agentDestination);
				if (_enemy.Rigidbody.notMovingTimer > 2f)
				{
					stateTimer -= Time.deltaTime;
				}
				if (stateTimer <= 0f || CheckPathCompletion())
				{
					UpdateState(State.Idle);
				}
			}
		}

		private void StateDespawn()
		{
		}

		private void StateTransform()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				stateTimer = 4f;
				_stateImpulse = 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 });
				}
			}
			else
			{
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.RAttack);
					Transformed = true;
				}
			}
		}

		private void StateStun()
		{
			if (_stateImpulse)
			{
				_stateImpulse = false;
			}
			if (!_enemy.IsStunned())
			{
				UpdateState(State.Transform);
			}
		}

		private void StateFollow()
		{
			//IL_0078: 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_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				stateTimer = 8f;
				_stateImpulse = false;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { true });
					_photonView.RPC("IsTurningRPC", (RpcTarget)0, new object[1] { false });
				}
				return;
			}
			if (Vector3.Distance(((Component)this).transform.position, ((Component)_targetPlayer).transform.position) > 2f)
			{
				_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);
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { true });
				}
			}
			else
			{
				_navMeshAgent.Agent.ResetPath();
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("IsSprintingRPC", (RpcTarget)0, new object[1] { false });
					_photonView.RPC("IsWalkingRPC", (RpcTarget)0, new object[1] { false });
				}
			}
			if (_transformCount > 0f)
			{
				_transformCount -= Time.deltaTime * 0.8f;
				stateTimer -= Time.deltaTime;
				if (stateTimer <= 0f)
				{
					UpdateState(State.Idle);
				}
			}
			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
			{
				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 if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					_enemy.EnemyParent.Despawn();
				}
			}
		}

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

		[PunRPC]
		private void IsWalkingRPC(bool value)
		{
			_isWalking = value;
			Debug.Log((object)_isWalking);
		}

		[PunRPC]
		private void IsSprintingRPC(bool value)
		{
			_isSprinting = value;
			Debug.Log((object)_isSprinting);
		}

		[PunRPC]
		private void IsTurningRPC(bool value)
		{
			_isTurning = value;
			Debug.Log((object)_isTurning);
		}

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

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

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

		public void OnGrab()
		{
			_targetPlayer = _enemy.Vision.onVisionTriggeredPlayer;
			if (GameManager.Multiplayer())
			{
				_photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { _targetPlayer.photonView.ViewID });
			}
			UpdateState(State.Notice);
		}

		public void OnVision()
		{
			if (Transformed)
			{
				return;
			}
			if (currentState != State.Stun && currentState != State.Despawn && currentState != State.Notice && currentState != State.Follow)
			{
				_targetPlayer = _enemy.Vision.onVisionTriggeredPlayer;
				UpdateState(State.Notice);
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("TargetPlayerRPC", (RpcTarget)0, new object[1] { _targetPlayer.photonView.ViewID });
				}
				Debug.Log((object)"Player spotted");
				Debug.Log((object)_targetPlayer);
			}
			else if ((currentState == State.Follow || currentState == State.Notice) && (Object)(object)_targetPlayer == (Object)(object)_enemy.Vision.onVisionTriggeredPlayer)
			{
				stateTimer = MathF.Max(stateTimer, 4f);
			}
		}

		private void RotationLogic()
		{
			//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_0154: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009a: 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)
			if (currentState != State.Stun && currentState != State.Idle && currentState != State.Notice)
			{
				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);
				}
			}
			if (currentState == State.Notice)
			{
				horizontalRotationSpring.speed = 10f;
				horizontalRotationSpring.damping = 1f;
				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);
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, _horizontalRotationTarget, -1f);
		}

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

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

		public Animator animator;

		private void Update()
		{
			animator.SetBool("isSprinting", Controller._isSprinting);
			animator.SetBool("isWalking", Controller._isWalking);
			animator.SetBool("isTurning", Controller._isTurning);
			if (Controller.Enemy.IsStunned())
			{
				animator.SetTrigger("stun");
			}
			if (Controller._transformImpulse)
			{
				Controller._transformImpulse = false;
				animator.SetTrigger("transform");
			}
		}
	}
	internal class Popper : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Idle,
			Wander,
			Stun,
			Despawn
		}

		private Enemy _enemy;

		private PhotonView _photonView;

		public bool Terminator = false;

		private bool _stateImpulse = false;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Material _hurtMaterial;

		private bool _hurtImpulse;

		private float hurtLerp;

		private int _hurtAmount;

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

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

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

		[SerializeField]
		private SkinnedMeshRenderer _skinnedMeshRenderer;

		[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()
		{
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			if ((Object)(object)_skinnedMeshRenderer != (Object)null)
			{
				_hurtMaterial = ((Renderer)_skinnedMeshRenderer).material;
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
		}

		private void Update()
		{
			if ((GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (!_enemy.IsStunned())
			{
				switch (currentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Wander:
					StateWander();
					break;
				case State.Idle:
					StateIdle();
					break;
				case State.Despawn:
					StateDespawn();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
				RotationLogic();
			}
			else
			{
				UpdateState(State.Stun);
				StateStun();
			}
			HurtEffect();
		}

		private void StateSpawn()
		{
		}

		private void StateWander()
		{
		}

		private void StateIdle()
		{
		}

		private void StateDespawn()
		{
		}

		private void StateStun()
		{
		}

		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 if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					_enemy.EnemyParent.Despawn();
				}
			}
		}

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

		private void RotationLogic()
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_007b: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (currentState != State.Stun && currentState != State.Idle)
			{
				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);
			if ((Object)(object)_hurtMaterial != (Object)null)
			{
				_hurtMaterial.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
			}
			if (hurtLerp >= 1f)
			{
				hurtLerp = 0f;
				_hurtImpulse = false;
				if ((Object)(object)_hurtMaterial != (Object)null)
				{
					_hurtMaterial.SetFloat(_hurtAmount, 0f);
				}
			}
		}
	}
	internal class PopperAnimationController : MonoBehaviour
	{
		[Header("References")]
		public Popper Controller;

		public Animator animator;
	}
	internal class TheLady : MonoBehaviour
	{
		public enum State
		{
			Spawn,
			Idle,
			Wander,
			Stun,
			Despawn
		}

		private Enemy _enemy;

		private PhotonView _photonView;

		public bool Terminator = false;

		private bool _stateImpulse = false;

		private Quaternion _horizontalRotationTarget = Quaternion.identity;

		private Material _hurtMaterial;

		private bool _hurtImpulse;

		private float hurtLerp;

		private int _hurtAmount;

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

		[SerializeField]
		public float stateTimer;

		[SerializeField]
		public float stateHaltTimer;

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

		[SerializeField]
		private SkinnedMeshRenderer _skinnedMeshRenderer;

		[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()
		{
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			_hurtAmount = Shader.PropertyToID("_ColorOverlayAmount");
			if ((Object)(object)_skinnedMeshRenderer != (Object)null)
			{
				_hurtMaterial = ((Renderer)_skinnedMeshRenderer).material;
			}
			hurtCurve = AssetManager.instance.animationCurveImpact;
		}

		private void Update()
		{
			if ((GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (!_enemy.IsStunned())
			{
				switch (currentState)
				{
				case State.Spawn:
					StateSpawn();
					break;
				case State.Wander:
					StateWander();
					break;
				case State.Idle:
					StateIdle();
					break;
				case State.Despawn:
					StateDespawn();
					break;
				default:
					throw new ArgumentOutOfRangeException();
				}
				RotationLogic();
			}
			else
			{
				UpdateState(State.Stun);
				StateStun();
			}
			HurtEffect();
		}

		private void StateSpawn()
		{
		}

		private void StateWander()
		{
		}

		private void StateIdle()
		{
		}

		private void StateDespawn()
		{
		}

		private void StateStun()
		{
		}

		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 if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					_enemy.EnemyParent.Despawn();
				}
			}
		}

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

		private void RotationLogic()
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_007b: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (currentState != State.Stun && currentState != State.Idle)
			{
				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);
			if ((Object)(object)_hurtMaterial != (Object)null)
			{
				_hurtMaterial.SetFloat(_hurtAmount, hurtCurve.Evaluate(hurtLerp));
			}
			if (hurtLerp >= 1f)
			{
				hurtLerp = 0f;
				_hurtImpulse = false;
				if ((Object)(object)_hurtMaterial != (Object)null)
				{
					_hurtMaterial.SetFloat(_hurtAmount, 0f);
				}
			}
		}
	}
	internal class TheLadyAnimationController : MonoBehaviour
	{
		[Header("References")]
		public TheLady Controller;

		public Animator animator;
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}