Decompiled source of DesaEnemies v1.0.0

DesaEnemies.dll

Decompiled 18 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using DesaEnemies;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Desay1")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a66823b48d3b9acf41c19244c83a3d5476f1f194")]
[assembly: AssemblyProduct("DesaEnemies")]
[assembly: AssemblyTitle("DesaEnemies")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[HarmonyPatch(typeof(MapToolController))]
public class MapToolControllerPatch
{
	[HarmonyPatch("Update")]
	[HarmonyPrefix]
	private static bool UpdatePrefix(MapToolController __instance)
	{
		if (__instance.PlayerAvatar.GetMapDebuffTimer().minimapDebuffTimer > 0f)
		{
			if (__instance.Active)
			{
				__instance.Active = false;
				__instance.HideLerp = 1f;
				((Component)__instance.VisualTransform).gameObject.SetActive(false);
				__instance.ToggleLocalShadows(false);
				Map.Instance.ActiveSet(false);
			}
			__instance.PlayerAvatar.GetMapDebuffTimer().minimapDebuffTimer -= Time.deltaTime;
			if (SemiFunc.InputDown((InputKey)8))
			{
				CameraGlitch.Instance.PlayTiny();
			}
			return false;
		}
		return true;
	}
}
public static class MinimapDebuffTimer
{
	private static readonly ConditionalWeakTable<PlayerAvatar, PlayerMinimapData> minimapsData = new ConditionalWeakTable<PlayerAvatar, PlayerMinimapData>();

	public static PlayerMinimapData GetMapDebuffTimer(this PlayerAvatar instance)
	{
		return minimapsData.GetOrCreateValue(instance);
	}
}
public class PlayerMinimapData
{
	public float minimapDebuffTimer = 0f;
}
public class Payayo : MonoBehaviour, IPunObservable
{
	public enum State
	{
		Spawn,
		Idle,
		Roam,
		Investigate,
		AttackStart,
		Attack,
		AttackEnd,
		MeleeStart,
		Melee,
		Seek,
		Leave,
		Stun,
		Despawn
	}

	internal enum AttackType
	{
		Normal,
		Quick,
		Sine,
		Circle,
		Targeted
	}

	internal int currentAttack = 0;

	public State currentState;

	public float stateTimer;

	private bool stateImpulse;

	private float stateTicker;

	internal Enemy enemy;

	internal PhotonView photonView;

	public PayayoAnim anim;

	public Transform aimVerticalTransform;

	public Transform hatTransform;

	public Transform bottomTransform;

	public SemiLaser laser;

	public Transform laserStartTransform;

	public Transform laserRayTransform;

	private Quaternion aimVerticalTarget;

	private Quaternion aimHorizontalTarget;

	public SpringQuaternion horizontalRotationSpring;

	private Quaternion horizontalRotationTarget = Quaternion.identity;

	[Space]
	public AnimationCurve aimHorizontalCurve;

	public float aimHorizontalSpread;

	public float aimHorizontalSpeed;

	private float aimHorizontalLerp;

	private float aimHorizontalResult;

	internal PlayerAvatar playerTarget;

	private Vector3 agentDestination;

	private Vector3 seekDestination;

	private Vector3 meleeTarget;

	private bool meleePlayer;

	private float laserCooldown;

	private float laserRange = 10f;

	private Vector3 hitPosition;

	private Vector3 hitPositionSmooth;

	private float hitPositionClientDistance;

	private bool hitPositionStartImpulse;

	private bool hitPositionImpact;

	private float hitPositionTimer;

	public ParticleSystem particleDeathSmoke;

	public ParticleSystem particleDeathBody;

	public ParticleSystem particleDeathNose;

	public ParticleSystem particleDeathHat;

	public ParticleSystem particleBottomSmoke;

	internal bool moveFast;

	internal float rotator = 0f;

	private void Awake()
	{
		enemy = ((Component)this).GetComponent<Enemy>();
		photonView = ((Component)this).GetComponent<PhotonView>();
	}

	private void Update()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Invalid comparison between Unknown and I4
		VerticalAimLogic();
		LaserLogic();
		MoveFastLogic();
		if ((!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient) && LevelGenerator.Instance.Generated)
		{
			if (enemy.IsStunned())
			{
				UpdateState(State.Stun);
			}
			if ((int)enemy.CurrentState == 11)
			{
				UpdateState(State.Despawn);
			}
			switch (currentState)
			{
			case State.Spawn:
				StateSpawn();
				break;
			case State.Idle:
				StateIdle();
				break;
			case State.Roam:
				StateRoam();
				break;
			case State.Investigate:
				StateInvestigate();
				break;
			case State.AttackStart:
				StateAttackStart();
				break;
			case State.Attack:
				StateAttack();
				break;
			case State.AttackEnd:
				StateAttackEnd();
				break;
			case State.MeleeStart:
				StateMeleeStart();
				break;
			case State.Melee:
				StateMelee();
				break;
			case State.Seek:
				StateSeek();
				break;
			case State.Leave:
				StateLeave();
				break;
			case State.Stun:
				StateStun();
				break;
			case State.Despawn:
				StateDespawn();
				break;
			}
			RotationLogic();
		}
	}

	private void StateSpawn()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
			stateImpulse = false;
			stateTimer = 2f;
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.Idle);
		}
	}

	private void StateIdle()
	{
		//IL_008d: 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 (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = Random.Range(4f, 8f);
			if (Random.Range(0, 7) == 0)
			{
				anim.idleSounds.Play(((Component)anim).transform.position, 1f, 1f, 1f, 1f);
			}
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
		}
		if (!SemiFunc.EnemySpawnIdlePause())
		{
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.Roam);
			}
			if (SemiFunc.EnemyForceLeave(enemy))
			{
				UpdateState(State.Leave);
			}
		}
	}

	private void StateRoam()
	{
		//IL_011c: 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_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: 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_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_0087: 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_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_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 999f;
			bool flag = false;
			LevelPoint 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)
			{
				return;
			}
			enemy.Rigidbody.notMovingTimer = 0f;
			stateImpulse = false;
		}
		enemy.NavMeshAgent.SetDestination(agentDestination);
		if (!enemy.Jump.jumping && Vector3.Distance(((Component)this).transform.position, enemy.NavMeshAgent.GetPoint()) < 1f)
		{
			UpdateState(State.Idle);
		}
		else if (enemy.Rigidbody.notMovingTimer >= 3f)
		{
			AttackNearestPhysObjectOrGoToIdle();
		}
		if (SemiFunc.EnemyForceLeave(enemy))
		{
			UpdateState(State.Leave);
		}
	}

	private void StateInvestigate()
	{
		//IL_0046: 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_0083: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 999f;
			enemy.Rigidbody.notMovingTimer = 0f;
		}
		else
		{
			enemy.NavMeshAgent.SetDestination(agentDestination);
			if (!enemy.Jump.jumping && (Vector3.Distance(((Component)enemy.Rigidbody).transform.position, enemy.NavMeshAgent.GetPoint()) < 1f || Vector3.Distance(((Component)enemy.Rigidbody).transform.position, agentDestination) < 1f))
			{
				UpdateState(State.Idle);
			}
			else if (enemy.Rigidbody.notMovingTimer >= 3f)
			{
				AttackNearestPhysObjectOrGoToIdle();
			}
		}
		if (SemiFunc.EnemyForceLeave(enemy))
		{
			UpdateState(State.Leave);
		}
	}

	private void StateAttackStart()
	{
		//IL_0158: 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_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: 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_01a1: 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_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			rotator = 0f;
			currentAttack = Random.Range(1, 5);
			aimHorizontalResult = 0f;
			stateImpulse = false;
			stateTimer = 1f;
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
			seekDestination = ((Component)playerTarget).transform.position;
			aimHorizontalLerp = 0f;
			if (currentAttack == 1)
			{
				aimHorizontalSpeed = 1.25f;
			}
			else
			{
				aimHorizontalSpeed = 0.5f;
			}
			if (currentAttack == 4)
			{
				aimHorizontalSpread = 0f;
				laserRange = 20f;
			}
			else
			{
				aimHorizontalSpread = 60f;
				laserRange = 10f;
			}
		}
		aimHorizontalResult = Mathf.Lerp(0f, 0f - aimHorizontalSpread, aimHorizontalCurve.Evaluate(aimHorizontalLerp));
		aimHorizontalLerp += 1.5f * Time.deltaTime;
		aimHorizontalTarget = Quaternion.LookRotation(playerTarget.PlayerVisionTarget.VisionTransform.position - ((Component)enemy.Rigidbody).transform.position);
		aimHorizontalTarget = Quaternion.Euler(0f, ((Quaternion)(ref aimHorizontalTarget)).eulerAngles.y, 0f);
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.Attack);
		}
	}

	private void StateAttack()
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			if (currentAttack == 3)
			{
				stateTimer = 2f;
			}
			else
			{
				stateTimer = 0.5f;
			}
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
			aimHorizontalLerp = 0f;
		}
		if (currentAttack == 4)
		{
			aimHorizontalResult = 0f;
		}
		else
		{
			aimHorizontalResult = Mathf.Lerp(0f - aimHorizontalSpread, aimHorizontalSpread, aimHorizontalCurve.Evaluate(aimHorizontalLerp));
		}
		aimHorizontalLerp += aimHorizontalSpeed * Time.deltaTime;
		if (aimHorizontalLerp >= 1f)
		{
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.AttackEnd);
			}
		}
	}

	private void StateAttackEnd()
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			if (currentAttack == 1)
			{
				stateTimer = 0.5f;
			}
			else
			{
				stateTimer = 2f;
			}
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
			aimHorizontalLerp = 0f;
		}
		aimHorizontalResult = Mathf.Lerp(aimHorizontalSpread, 0f, aimHorizontalCurve.Evaluate(aimHorizontalLerp));
		aimHorizontalLerp += 1.5f * Time.deltaTime;
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.Seek);
		}
	}

	private void StateMeleeStart()
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 0.5f;
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
			seekDestination = meleeTarget;
		}
		if (meleePlayer)
		{
			meleeTarget = ((Component)playerTarget).transform.position;
			seekDestination = meleeTarget;
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.Melee);
		}
	}

	private void StateMelee()
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 3f;
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.Seek);
		}
	}

	private void StateSeek()
	{
		//IL_00a1: 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)
		//IL_0042: 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_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: 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)
		if (stateImpulse)
		{
			stateTimer = 20f;
			stateImpulse = false;
			enemy.Rigidbody.notMovingTimer = 0f;
			if (Vector3.Distance(((Component)this).transform.position, seekDestination) >= 3f)
			{
				moveFast = true;
				if (SemiFunc.IsMultiplayer())
				{
					photonView.RPC("MoveFastRPC", (RpcTarget)1, new object[1] { moveFast });
				}
			}
		}
		enemy.NavMeshAgent.SetDestination(seekDestination);
		if (moveFast)
		{
			enemy.NavMeshAgent.OverrideAgent(enemy.NavMeshAgent.DefaultSpeed * 2f, enemy.NavMeshAgent.DefaultAcceleration * 2f, 0.1f);
		}
		if (Vector3.Distance(((Component)this).transform.position, enemy.NavMeshAgent.GetPoint()) < 1f)
		{
			LevelPoint levelPointAhead = enemy.GetLevelPointAhead(seekDestination);
			if (Object.op_Implicit((Object)(object)levelPointAhead))
			{
				seekDestination = ((Component)levelPointAhead).transform.position;
			}
			if (moveFast)
			{
				moveFast = false;
				if (SemiFunc.IsMultiplayer())
				{
					photonView.RPC("MoveFastRPC", (RpcTarget)1, new object[1] { moveFast });
				}
			}
		}
		if (enemy.Rigidbody.notMovingTimer >= 3f)
		{
			AttackNearestPhysObjectOrGoToIdle();
			return;
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.Idle);
		}
	}

	public void StateLeave()
	{
		//IL_011d: 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_013e: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateTimer = 999f;
			bool flag = false;
			LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 30f, 50f, false);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f);
			}
			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)
			{
				return;
			}
			SemiFunc.EnemyLeaveStart(enemy);
			enemy.Rigidbody.notMovingTimer = 0f;
			stateImpulse = false;
		}
		enemy.NavMeshAgent.SetDestination(agentDestination);
		if (Vector3.Distance(((Component)this).transform.position, enemy.NavMeshAgent.GetPoint()) < 1f)
		{
			UpdateState(State.Idle);
		}
		else if (enemy.Rigidbody.notMovingTimer >= 3f)
		{
			AttackNearestPhysObjectOrGoToIdle();
		}
	}

	private void StateStun()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
		}
		if (!enemy.IsStunned())
		{
			UpdateState(State.Idle);
		}
	}

	private void StateDespawn()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
			stateImpulse = false;
		}
	}

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

	public void OnVision()
	{
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: 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_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
		if (enemy.Jump.jumping)
		{
			return;
		}
		if (currentState == State.Roam || currentState == State.Idle || currentState == State.Seek || currentState == State.Leave || currentState == State.Investigate)
		{
			if ((Object)(object)playerTarget != (Object)(object)enemy.Vision.onVisionTriggeredPlayer)
			{
				playerTarget = enemy.Vision.onVisionTriggeredPlayer;
				if (GameManager.Multiplayer())
				{
					photonView.RPC("UpdatePlayerTargetRPC", (RpcTarget)0, new object[1] { playerTarget.photonView.ViewID });
				}
			}
			if (!playerTarget.isMoving || playerTarget.isCrouching || playerTarget.isCrawling)
			{
				UpdateState(State.Roam);
			}
			else if (Object.op_Implicit((Object)(object)playerTarget) && Vector3.Distance(((Component)this).transform.position, ((Component)playerTarget).transform.position) < 2.5f && Mathf.Abs(((Component)this).transform.position.y - ((Component)playerTarget).transform.position.y) < 1f)
			{
				meleeTarget = ((Component)playerTarget).transform.position;
				meleePlayer = true;
				UpdateState(State.MeleeStart);
			}
			else if (laserCooldown <= 0f)
			{
				UpdateState(State.AttackStart);
			}
			else
			{
				seekDestination = ((Component)playerTarget).transform.position;
				UpdateState(State.Seek);
			}
		}
		else if ((currentState == State.AttackStart || currentState == State.Attack || currentState == State.AttackEnd) && (Object)(object)playerTarget == (Object)(object)enemy.Vision.onVisionTriggeredPlayer)
		{
			seekDestination = ((Component)playerTarget).transform.position;
		}
	}

	public void OnInvestigate()
	{
		//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)
		if (SemiFunc.IsMasterClientOrSingleplayer() && (currentState == State.Idle || currentState == State.Roam || currentState == State.Seek || currentState == State.Investigate))
		{
			agentDestination = enemy.StateInvestigate.onInvestigateTriggeredPosition;
			UpdateState(State.Investigate);
		}
	}

	public void OnHurt()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		if (Random.Range(0, 10) == 0)
		{
			anim.soundHurtSpecial.Play(((Component)anim).transform.position, 1f, 1f, 1f, 1f);
		}
		else
		{
			anim.soundHurt.Play(((Component)anim).transform.position, 1f, 1f, 1f, 1f);
		}
		anim.soundHurtPauseTimer = 0.5f;
		if (SemiFunc.IsMasterClientOrSingleplayer() && currentState == State.Leave)
		{
			UpdateState(State.Idle);
		}
	}

	public void OnDeath()
	{
		//IL_0017: 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_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		anim.soundDeath.Play(((Component)anim).transform.position, 1f, 1f, 1f, 1f);
		GameDirector.instance.CameraShake.ShakeDistance(3f, 3f, 10f, enemy.CenterTransform.position, 0.5f);
		GameDirector.instance.CameraImpact.ShakeDistance(3f, 3f, 10f, enemy.CenterTransform.position, 0.05f);
		((Component)particleDeathSmoke).transform.position = enemy.CenterTransform.position;
		particleDeathSmoke.Play();
		((Component)particleDeathBody).transform.position = enemy.CenterTransform.position;
		particleDeathBody.Play();
		((Component)particleDeathNose).transform.position = laserStartTransform.position;
		particleDeathNose.Play();
		((Component)particleDeathHat).transform.position = hatTransform.position;
		particleDeathHat.Play();
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			enemy.EnemyParent.Despawn();
		}
	}

	private void UpdateState(State _state)
	{
		//IL_0068: 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)
		if (_state != currentState)
		{
			currentState = _state;
			stateImpulse = true;
			stateTimer = 0f;
			if (GameManager.Multiplayer())
			{
				photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState });
			}
			else
			{
				UpdateStateRPC(currentState);
			}
		}
	}

	private void AttackNearestPhysObjectOrGoToIdle()
	{
		//IL_0008: 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)
		//IL_0013: 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)
		meleeTarget = SemiFunc.EnemyGetNearestPhysObject(enemy);
		if (meleeTarget != Vector3.zero)
		{
			meleePlayer = false;
			UpdateState(State.Melee);
		}
		else
		{
			enemy.Jump.StuckReset();
			UpdateState(State.Idle);
		}
	}

	private void RotationLogic()
	{
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: 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_016e: 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_0065: 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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: 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_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: 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_0113: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		if (currentState == State.AttackStart || currentState == State.Attack || currentState == State.AttackEnd)
		{
			if (currentAttack == 2)
			{
				float num = 15f * Mathf.Sin(Time.time * 10f);
				horizontalRotationTarget = Quaternion.Euler(((Quaternion)(ref aimHorizontalTarget)).eulerAngles.x + num, ((Quaternion)(ref aimHorizontalTarget)).eulerAngles.y + aimHorizontalResult, ((Quaternion)(ref aimHorizontalTarget)).eulerAngles.z);
			}
			else if (currentAttack == 3)
			{
				rotator += 3f;
				horizontalRotationTarget = Quaternion.Euler(((Quaternion)(ref aimHorizontalTarget)).eulerAngles.x, ((Quaternion)(ref aimHorizontalTarget)).eulerAngles.y + rotator, ((Quaternion)(ref aimHorizontalTarget)).eulerAngles.z);
			}
			else
			{
				horizontalRotationTarget = Quaternion.Euler(((Quaternion)(ref aimHorizontalTarget)).eulerAngles.x, ((Quaternion)(ref aimHorizontalTarget)).eulerAngles.y + aimHorizontalResult, ((Quaternion)(ref aimHorizontalTarget)).eulerAngles.z);
			}
		}
		else if (currentState == State.MeleeStart)
		{
			if (Vector3.Distance(meleeTarget, ((Component)enemy.Rigidbody).transform.position) > 0.1f)
			{
				horizontalRotationTarget = Quaternion.LookRotation(meleeTarget - ((Component)enemy.Rigidbody).transform.position);
				((Quaternion)(ref horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref horizontalRotationTarget)).eulerAngles.y, 0f);
			}
		}
		else
		{
			Vector3 normalized = ((Vector3)(ref enemy.NavMeshAgent.AgentVelocity)).normalized;
			if (((Vector3)(ref normalized)).magnitude > 0.1f)
			{
				horizontalRotationTarget = Quaternion.LookRotation(((Vector3)(ref enemy.NavMeshAgent.AgentVelocity)).normalized);
				((Quaternion)(ref horizontalRotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref horizontalRotationTarget)).eulerAngles.y, 0f);
			}
		}
		if (currentState == State.Spawn || currentState == State.Idle || currentState == State.Roam || currentState == State.Investigate || currentState == State.Leave)
		{
			horizontalRotationSpring.speed = 5f;
			horizontalRotationSpring.damping = 0.7f;
		}
		else if (currentState == State.AttackStart || currentState == State.Attack || currentState == State.AttackEnd)
		{
			horizontalRotationSpring.speed = 15f;
			if (currentAttack == 3)
			{
				horizontalRotationSpring.speed = 5f;
			}
			horizontalRotationSpring.damping = 0.8f;
		}
		else
		{
			horizontalRotationSpring.speed = 10f;
			horizontalRotationSpring.damping = 0.8f;
		}
		((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(horizontalRotationSpring, horizontalRotationTarget, -1f);
	}

	private void VerticalAimLogic()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: 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_0144: 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_0166: 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_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_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: 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_012a: Unknown result type (might be due to invalid IL or missing references)
		if (currentState != State.AttackStart && currentState != State.Attack && currentState != State.AttackEnd)
		{
			aimVerticalTarget = Quaternion.identity;
		}
		else if (currentState == State.AttackStart || (currentState != State.Attack && aimHorizontalLerp < 0.1f))
		{
			Quaternion val = Quaternion.LookRotation(playerTarget.PlayerVisionTarget.VisionTransform.position - laserRayTransform.position);
			if (aimVerticalTarget == Quaternion.identity)
			{
				aimVerticalTarget = val;
			}
			else
			{
				aimVerticalTarget = Quaternion.Lerp(aimVerticalTarget, val, 2f * Time.deltaTime);
			}
			Quaternion rotation = laserRayTransform.rotation;
			laserRayTransform.rotation = aimVerticalTarget;
			aimVerticalTarget = laserRayTransform.localRotation;
			aimVerticalTarget = Quaternion.Euler(laserRayTransform.eulerAngles.x, 0f, 0f);
			laserRayTransform.rotation = rotation;
		}
		aimVerticalTransform.localRotation = Quaternion.Lerp(aimVerticalTransform.localRotation, aimVerticalTarget, 20f * Time.deltaTime);
		laserRayTransform.localRotation = aimVerticalTarget;
	}

	private void LaserLogic()
	{
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: 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)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: 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_0298: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: 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_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_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: 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)
		if (currentState != State.Attack && currentState != State.AttackStart && currentState != State.AttackEnd)
		{
			laserCooldown -= Time.deltaTime;
		}
		if (currentState == State.Attack)
		{
			laserCooldown = 3f;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				Transform val = laserStartTransform;
				Vector3 val2 = laserRayTransform.position - laserStartTransform.position;
				RaycastHit val3 = default(RaycastHit);
				if (Physics.Raycast(laserStartTransform.position, val2, ref val3, ((Vector3)(ref val2)).magnitude, LayerMask.GetMask(new string[1] { "Default" })))
				{
					val = laserRayTransform;
				}
				else if (Physics.OverlapSphere(laserStartTransform.position, 0.25f, LayerMask.GetMask(new string[1] { "Default" })).Length != 0)
				{
					val = laserRayTransform;
				}
				if (hitPositionTimer <= 0f)
				{
					hitPositionTimer = 0.05f;
					RaycastHit val4 = default(RaycastHit);
					if (Physics.Raycast(val.position, val.forward, ref val4, laserRange, LayerMask.GetMask(new string[1] { "Default" })))
					{
						hitPosition = ((RaycastHit)(ref val4)).point;
						hitPositionImpact = true;
					}
					else
					{
						hitPosition = val.position + val.forward * laserRange;
						hitPositionImpact = false;
					}
				}
				else
				{
					hitPositionTimer -= Time.deltaTime;
				}
				hitPositionSmooth = Vector3.Lerp(hitPositionSmooth, hitPosition, 20f * Time.deltaTime);
			}
			else
			{
				hitPositionSmooth = Vector3.MoveTowards(hitPositionSmooth, hitPosition, hitPositionClientDistance * Time.deltaTime * ((float)PhotonNetwork.SerializationRate * 0.8f));
			}
			if (hitPositionStartImpulse)
			{
				hitPositionSmooth = hitPosition;
				hitPositionStartImpulse = false;
			}
			Vector3 val5 = laserRayTransform.position - hitPosition;
			Vector3 val6 = laserRayTransform.position - hitPositionSmooth;
			if (((Vector3)(ref val5)).magnitude < ((Vector3)(ref val6)).magnitude)
			{
				val6 = Vector3.ClampMagnitude(val6, ((Vector3)(ref val5)).magnitude);
				hitPositionSmooth = laserRayTransform.position - val6;
			}
			laser.LaserActive(laserStartTransform.position, hitPositionSmooth, hitPositionImpact);
		}
		else
		{
			hitPositionTimer = 0f;
			hitPositionStartImpulse = true;
		}
	}

	private void MoveFastLogic()
	{
		if (currentState != State.Seek && moveFast)
		{
			moveFast = false;
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("MoveFastRPC", (RpcTarget)1, new object[1] { moveFast });
			}
		}
	}

	[PunRPC]
	private void UpdateStateRPC(State _state, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.MasterOnlyRPC(_info))
		{
			currentState = _state;
		}
	}

	[PunRPC]
	private void UpdatePlayerTargetRPC(int _photonViewID, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (!SemiFunc.MasterOnlyRPC(_info))
		{
			return;
		}
		foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
		{
			if (item.photonView.ViewID == _photonViewID)
			{
				playerTarget = item;
				break;
			}
		}
	}

	[PunRPC]
	private void MeleeTriggerRPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.MasterOnlyRPC(_info))
		{
			anim.meleeImpulse = true;
		}
	}

	[PunRPC]
	private void MoveFastRPC(bool _moveFast, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.MasterOnlyRPC(_info))
		{
			moveFast = _moveFast;
		}
	}

	public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.MasterOnlyRPC(info))
		{
			if (stream.IsWriting)
			{
				stream.SendNext((object)aimVerticalTarget);
				stream.SendNext((object)hitPosition);
				stream.SendNext((object)hitPositionImpact);
			}
			else
			{
				aimVerticalTarget = (Quaternion)stream.ReceiveNext();
				hitPosition = (Vector3)stream.ReceiveNext();
				hitPositionImpact = (bool)stream.ReceiveNext();
				hitPositionClientDistance = Vector3.Distance(hitPositionSmooth, hitPosition);
			}
		}
	}
}
public class PayayoAnim : MonoBehaviour
{
	public Enemy enemy;

	public Payayo controller;

	public bool noseEmission;

	private Animator animator;

	private int animSpawn = Animator.StringToHash("spawn");

	private int animDespawning = Animator.StringToHash("despawning");

	private int animStun = Animator.StringToHash("stun");

	private int animStunned = Animator.StringToHash("stunned");

	private int animMoving = Animator.StringToHash("moving");

	private int animMovingFast = Animator.StringToHash("movingFast");

	private int animJump = Animator.StringToHash("jump");

	private int animFalling = Animator.StringToHash("falling");

	private int animLand = Animator.StringToHash("land");

	private int animMelee = Animator.StringToHash("melee");

	private int animAttacking = Animator.StringToHash("attacking");

	private int animAttack = Animator.StringToHash("attack");

	public float springSpeedMultiplier;

	public float springDampingMultiplier;

	[Space]
	public SpringQuaternion springNose01;

	private float springNose01Speed;

	private float springNose01Damping;

	public Transform springNose01Target;

	public Transform springNose01Source;

	public SpringQuaternion springNose02;

	private float springNose02Speed;

	private float springNose02Damping;

	public Transform springNose02Target;

	public Transform springNose02Source;

	public SpringQuaternion springNose03;

	private float springNose03Speed;

	private float springNose03Damping;

	public Transform springNose03Target;

	public Transform springNose03Source;

	private float moveTimer;

	private bool spawnImpulse = true;

	private bool stunImpulse = true;

	private bool stunEndImpulse;

	private bool jumpImpulse = true;

	private bool landImpulse = true;

	internal bool meleeImpulse = true;

	private bool attackImpulse = true;

	private Color emissionColor = Color.black;

	private Color emissionColorPrevious = Color.black;

	internal MaterialTrigger material = new MaterialTrigger();

	internal float soundHurtPauseTimer;

	public Sound soundMoveShort;

	public Sound soundMoveLong;

	[Space]
	public Sound soundFootstepSmall;

	public Sound soundFootstepBig;

	public Sound soundFootstepHuge;

	[Space]
	public Sound soundStunIntro;

	public Sound soundStunLoop;

	public Sound soundStunOutro;

	[Space]
	public Sound soundJump;

	public Sound soundLand;

	[Space]
	public Sound soundMeleeTell;

	public Sound soundMeleeKick;

	[Space]
	public bool soundAttackLoopActive;

	public Sound soundAttackIntro;

	public Sound soundAttackShort;

	public Sound soundAttackLong;

	private bool soundAttackPlayed;

	public AudioSource soundAttackSource;

	public Sound soundAttackOutro;

	[Space]
	public Sound soundHurt;

	public Sound soundHurtSpecial;

	public Sound soundDeath;

	public Sound idleSounds;

	private void Awake()
	{
		animator = ((Component)this).GetComponent<Animator>();
		animator.keepAnimatorStateOnDisable = true;
		springNose01Speed = springNose01.speed;
		springNose01Damping = springNose01.damping;
		springNose02Speed = springNose02.speed;
		springNose02Damping = springNose02.damping;
		springNose03Speed = springNose03.speed;
		springNose03Damping = springNose03.damping;
	}

	private void Update()
	{
		//IL_0134: 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_01cb: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: 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_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_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_040b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
		if (enemy.Rigidbody.frozen)
		{
			animator.speed = 0f;
		}
		else
		{
			animator.speed = 1f;
		}
		if (controller.currentState == Payayo.State.Stun)
		{
			if (stunImpulse)
			{
				soundStunIntro.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				animator.SetTrigger(animStun);
				stunImpulse = false;
			}
			animator.SetBool(animStunned, true);
			if (soundHurtPauseTimer > 0f)
			{
				soundStunLoop.PlayLoop(false, 5f, 5f, 1f, 1f);
			}
			else
			{
				soundStunLoop.PlayLoop(true, 5f, 5f, 1f, 1f);
			}
			stunEndImpulse = true;
		}
		else
		{
			if (stunEndImpulse)
			{
				soundStunOutro.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				stunEndImpulse = false;
			}
			animator.SetBool(animStunned, false);
			soundStunLoop.PlayLoop(false, 5f, 5f, 1f, 1f);
			stunImpulse = true;
		}
		if (noseEmission)
		{
			emissionColor = Color.Lerp(emissionColor, Color.white, Time.deltaTime * 10f);
		}
		else
		{
			emissionColor = Color.Lerp(emissionColor, Color.black, Time.deltaTime * 10f);
		}
		if (emissionColor != emissionColorPrevious)
		{
			emissionColorPrevious = emissionColor;
			enemy.Health.instancedMaterials[0].SetColor("_EmissionColor", emissionColor);
		}
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (!enemy.Jump.jumping && !enemy.IsStunned() && (controller.currentState == Payayo.State.MeleeStart || controller.currentState == Payayo.State.Melee))
			{
				if (meleeImpulse)
				{
					if (SemiFunc.IsMultiplayer())
					{
						controller.photonView.RPC("MeleeTriggerRPC", (RpcTarget)1, Array.Empty<object>());
					}
					animator.SetTrigger(animMelee);
					meleeImpulse = false;
				}
			}
			else
			{
				meleeImpulse = true;
			}
		}
		else if (meleeImpulse)
		{
			animator.SetTrigger(animMelee);
			meleeImpulse = false;
		}
		if (controller.currentState == Payayo.State.AttackStart || controller.currentState == Payayo.State.Attack)
		{
			if (attackImpulse)
			{
				attackImpulse = false;
				animator.SetTrigger(animAttack);
			}
			animator.SetBool(animAttacking, true);
		}
		else
		{
			attackImpulse = true;
			animator.SetBool(animAttacking, false);
		}
		if (controller.currentState == Payayo.State.Attack)
		{
			if (!soundAttackPlayed)
			{
				if (controller.currentAttack == 3)
				{
					soundAttackLong.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				}
				else
				{
					soundAttackShort.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				}
				soundAttackPlayed = true;
			}
		}
		else
		{
			soundAttackPlayed = false;
		}
		if ((controller.currentState == Payayo.State.Roam || controller.currentState == Payayo.State.Investigate || controller.currentState == Payayo.State.Seek || controller.currentState == Payayo.State.Leave) && (((Vector3)(ref enemy.Rigidbody.velocity)).magnitude > 0.5f || ((Vector3)(ref enemy.Rigidbody.physGrabObject.rbAngularVelocity)).magnitude > 5f))
		{
			moveTimer = 0.25f;
		}
		if (moveTimer > 0f)
		{
			moveTimer -= Time.deltaTime;
			animator.SetBool(animMoving, true);
		}
		else
		{
			animator.SetBool(animMoving, false);
		}
		animator.SetBool(animMovingFast, controller.moveFast);
		if (enemy.Jump.jumping || enemy.Jump.jumpingDelay)
		{
			if (jumpImpulse)
			{
				if (!enemy.IsStunned())
				{
					animator.SetTrigger(animJump);
				}
				animator.SetBool(animFalling, false);
				jumpImpulse = false;
				landImpulse = true;
			}
			else if (controller.enemy.Rigidbody.physGrabObject.rbVelocity.y < -0.5f)
			{
				animator.SetBool(animFalling, true);
			}
		}
		else
		{
			if (landImpulse)
			{
				if (!enemy.IsStunned())
				{
					animator.SetTrigger(animLand);
				}
				moveTimer = 0f;
				landImpulse = false;
			}
			animator.SetBool(animFalling, false);
			jumpImpulse = true;
		}
		if (controller.currentState == Payayo.State.Spawn)
		{
			if (spawnImpulse)
			{
				spawnImpulse = false;
				animator.SetTrigger(animSpawn);
			}
		}
		else
		{
			spawnImpulse = true;
		}
		if (controller.currentState == Payayo.State.Despawn)
		{
			animator.SetBool(animDespawning, true);
		}
		else
		{
			animator.SetBool(animDespawning, false);
		}
		if (soundHurtPauseTimer > 0f)
		{
			soundHurtPauseTimer -= Time.deltaTime;
		}
	}

	public void Despawn()
	{
		enemy.EnemyParent.Despawn();
	}

	public void FootstepSmall()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//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)
		soundFootstepSmall.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		Materials.Instance.Impulse(enemy.Rigidbody.physGrabObject.centerPoint + Vector3.down * 0.5f, Vector3.down, (SoundType)0, false, false, material, (HostType)2);
	}

	public void FootstepBig()
	{
		//IL_0020: 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_006b: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		GameDirector.instance.CameraShake.ShakeDistance(2f, 5f, 10f, ((Component)this).transform.position, 0.25f);
		GameDirector.instance.CameraImpact.ShakeDistance(2f, 5f, 10f, ((Component)this).transform.position, 0.1f);
		soundFootstepBig.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		Materials.Instance.Impulse(enemy.Rigidbody.physGrabObject.centerPoint + Vector3.down * 0.5f, Vector3.down, (SoundType)2, false, false, material, (HostType)2);
	}

	public void FootstepHuge()
	{
		//IL_0020: 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_006b: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		GameDirector.instance.CameraShake.ShakeDistance(2.5f, 5f, 15f, ((Component)this).transform.position, 0.25f);
		GameDirector.instance.CameraImpact.ShakeDistance(2.5f, 5f, 15f, ((Component)this).transform.position, 0.1f);
		soundFootstepHuge.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		Materials.Instance.Impulse(enemy.Rigidbody.physGrabObject.centerPoint + Vector3.down * 0.5f, Vector3.down, (SoundType)2, false, false, material, (HostType)2);
	}

	public void Jump()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		((Component)controller.particleBottomSmoke).transform.position = controller.bottomTransform.position;
		controller.particleBottomSmoke.Play();
		soundJump.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		GameDirector.instance.CameraShake.ShakeDistance(5f, 5f, 10f, ((Component)this).transform.position, 0.5f);
		GameDirector.instance.CameraImpact.ShakeDistance(5f, 5f, 10f, ((Component)this).transform.position, 0.1f);
		Materials.Instance.Impulse(enemy.Rigidbody.physGrabObject.centerPoint + Vector3.down * 0.5f, Vector3.down, (SoundType)2, false, false, material, (HostType)2);
	}

	public void Land()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		((Component)controller.particleBottomSmoke).transform.position = controller.bottomTransform.position;
		controller.particleBottomSmoke.Play();
		soundLand.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		GameDirector.instance.CameraShake.ShakeDistance(5f, 5f, 10f, ((Component)this).transform.position, 0.5f);
		GameDirector.instance.CameraImpact.ShakeDistance(5f, 5f, 10f, ((Component)this).transform.position, 0.1f);
		Materials.Instance.Impulse(enemy.Rigidbody.physGrabObject.centerPoint + Vector3.down * 0.5f, Vector3.down, (SoundType)2, false, false, material, (HostType)2);
	}

	public void MoveShort()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		soundMoveShort.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void MoveLong()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		soundMoveLong.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void MeleeTell()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		soundMeleeTell.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void MeleeKick()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		soundMeleeKick.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void AttackIntro()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		soundAttackIntro.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void AttackOutro()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		soundAttackOutro.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}
}
public class PibePlateadoAnim : MonoBehaviour
{
	public Enemy enemy;

	public PibePlateado enemyBirthdayBoy;

	[HideInInspector]
	public Animator animator;

	public Transform leftEyePivot;

	public Transform rightEyePivot;

	public PlayerAvatar lookTarget;

	public Rigidbody rb;

	public Transform headPivot;

	public SpringQuaternion topHairRightSpring = new SpringQuaternion();

	public Transform topHairRightTransform;

	public Transform topHairRightTarget;

	[Space]
	public SpringQuaternion topHairLeftSpring = new SpringQuaternion();

	public Transform topHairLeftTransform;

	public Transform topHairLeftTarget;

	[Space]
	public SpringQuaternion sideHairLeftSpring = new SpringQuaternion();

	public Transform sideHairLeftTransform;

	public Transform sideHairLeftTarget;

	[Space]
	public SpringQuaternion sideHairRightSpring = new SpringQuaternion();

	public Transform sideHairRightTransform;

	public Transform sideHairRightTarget;

	[Space]
	public SpringQuaternion middleHairSpring = new SpringQuaternion();

	public Transform middleHairTransform;

	public Transform middleHairTarget;

	[Space]
	public SpringQuaternion BackHairSpring = new SpringQuaternion();

	public Transform BackHairTransform;

	public Transform BackHairTarget;

	public ParticleSystem spawnSmokeParticle;

	public ParticleSystem runningSpitParticle;

	public ParticleSystem balloonPopParticle;

	public GameObject deathParticlePrefab;

	public ParticleSystem droolParticle;

	public ParticleSystem runningSmokeParticle;

	internal MaterialTrigger material = new MaterialTrigger();

	private bool noticed;

	private bool floating;

	public bool breaker;

	private Quaternion prevHeadLookRotation;

	private Quaternion prevRigidBodyRotation;

	private float moveSoundRigidBodyTimer;

	private float moveSoundHeadTimer;

	public Sound footStepSound;

	public Sound footStepGlobalSound;

	public Sound footStepHardSound;

	public Sound balloonSqueakSound;

	public Sound moveLightSound;

	public Sound moveHeavySound;

	public Sound balloonPopSound;

	public Sound balloonBlowSound;

	public Sound balloonTieSound;

	[Space]
	public Sound deathSound;

	public Sound hurtSound;

	public Sound idleLoop;

	public Sound runLoop;

	public Sound aggroLoop;

	public Sound idleBreaker;

	public List<AudioClip> idleBreakers;

	public Sound attackSwoosh;

	public Sound jumpSound;

	public Sound landSound;

	public Sound inhaleSound;

	public Sound noticeSound;

	public Sound crackSound;

	public Sound balloonPopGlobal;

	private static readonly int animDespawn = Animator.StringToHash("despawn");

	private static readonly int animDespawnTrigger = Animator.StringToHash("despawn_trigger");

	private static readonly int animFloat = Animator.StringToHash("float");

	private static readonly int animFloatTrigger = Animator.StringToHash("float_trigger");

	private void Awake()
	{
		animator = ((Component)this).GetComponent<Animator>();
		animator.keepAnimatorStateOnDisable = true;
	}

	private void LateUpdate()
	{
		//IL_0125: 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_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: 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_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: 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)
		//IL_00ca: 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_00d9: 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_00e9: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: 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_010c: 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)
		if (enemyBirthdayBoy.currentState == PibePlateado.State.CreepyStare || enemyBirthdayBoy.currentState == PibePlateado.State.Attack || enemyBirthdayBoy.currentState == PibePlateado.State.AttackOver || enemyBirthdayBoy.currentState == PibePlateado.State.AttackUnder)
		{
			PlayerAvatar val = ((!Object.op_Implicit((Object)(object)enemyBirthdayBoy.playerTarget)) ? lookTarget : enemyBirthdayBoy.playerTarget);
			if (Object.op_Implicit((Object)(object)val))
			{
				Vector3 val2 = ((!SemiFunc.IsMultiplayer() || val.isLocal) ? ((Component)val.localCamera).transform.position : val.playerAvatarVisuals.headLookAtTransform.position);
				val2.y -= 0.3f;
				Quaternion rotation = Quaternion.LookRotation(val2 - leftEyePivot.position, Vector3.up);
				leftEyePivot.rotation = rotation;
				Quaternion rotation2 = Quaternion.LookRotation(val2 - rightEyePivot.position, Vector3.up);
				rightEyePivot.rotation = rotation2;
			}
		}
		else
		{
			leftEyePivot.localRotation = Quaternion.Slerp(leftEyePivot.localRotation, Quaternion.identity, Time.deltaTime * 5f);
			rightEyePivot.localRotation = Quaternion.Slerp(rightEyePivot.localRotation, Quaternion.identity, Time.deltaTime * 5f);
		}
	}

	private void Update()
	{
		//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fa: Invalid comparison between Unknown and I4
		TurnSoundLogic();
		AnimateSprings();
		bool flag = enemyBirthdayBoy.AttackState() || enemyBirthdayBoy.currentState == PibePlateado.State.GoToPlayerAngry || enemyBirthdayBoy.currentState == PibePlateado.State.GoToBalloonAngry;
		bool flag2 = (((Vector3)(ref enemy.Rigidbody.velocity)).magnitude > 0.1f || ((Vector3)(ref enemy.Rigidbody.physGrabObject.rbAngularVelocity)).magnitude > 0.5f || enemy.IsStunned()) && enemyBirthdayBoy.currentState != PibePlateado.State.Idle && enemyBirthdayBoy.currentState != PibePlateado.State.PlaceBalloon && !flag;
		bool flag3 = enemyBirthdayBoy.currentState != PibePlateado.State.PlaceBalloon && enemyBirthdayBoy.currentState != PibePlateado.State.PlayerNotice && enemyBirthdayBoy.currentState != PibePlateado.State.Despawn && !flag && !flag2 && !breaker;
		runLoop.PlayLoop(flag2, 1f, 1f, 1f, 1f);
		idleLoop.PlayLoop(flag3, 1f, 1f, 1f, 1f);
		aggroLoop.PlayLoop(flag, 1f, 1f, 1f, 1f);
		if (flag2 || enemyBirthdayBoy.currentState == PibePlateado.State.GoToPlayerAngry || enemyBirthdayBoy.currentState == PibePlateado.State.GoToBalloonAngry)
		{
			animator.SetBool("move", true);
		}
		else
		{
			animator.SetBool("move", false);
		}
		if (enemyBirthdayBoy.currentState == PibePlateado.State.Attack && ((Vector3)(ref enemy.Rigidbody.velocity)).magnitude > 1f && !enemy.Jump.jumping && !enemy.Jump.jumpingDelay && !enemy.Jump.landDelay)
		{
			if (!runningSmokeParticle.isPlaying)
			{
				runningSmokeParticle.Play(true);
			}
		}
		else if (runningSmokeParticle.isPlaying)
		{
			runningSmokeParticle.Stop(true);
		}
		if (enemyBirthdayBoy.currentState == PibePlateado.State.Attack)
		{
			if (!runningSpitParticle.isPlaying)
			{
				runningSpitParticle.Play();
			}
		}
		else if (runningSpitParticle.isPlaying)
		{
			runningSpitParticle.Stop();
		}
		if (enemyBirthdayBoy.currentState == PibePlateado.State.Attack || enemyBirthdayBoy.currentState == PibePlateado.State.AttackUnder || enemyBirthdayBoy.currentState == PibePlateado.State.AttackOver)
		{
			animator.SetBool("attack", true);
		}
		else
		{
			animator.SetBool("attack", false);
		}
		if (enemy.IsStunned())
		{
			animator.SetBool("stun", true);
		}
		else
		{
			animator.SetBool("stun", false);
		}
		if (!enemy.IsStunned() && (enemy.Jump.jumping || enemy.Jump.jumpingDelay))
		{
			animator.SetBool("jump", true);
		}
		else
		{
			animator.SetBool("jump", false);
		}
		if (enemyBirthdayBoy.currentState == PibePlateado.State.AttackUnderStart || enemyBirthdayBoy.currentState == PibePlateado.State.AttackUnder || enemyBirthdayBoy.currentState == PibePlateado.State.AttackUnderEnd)
		{
			animator.SetBool("crawl", true);
		}
		else
		{
			animator.SetBool("crawl", false);
		}
		if (enemyBirthdayBoy.currentState == PibePlateado.State.PlayerNotice && !noticed)
		{
			animator.SetTrigger("player_notice");
			noticed = true;
		}
		else if (enemyBirthdayBoy.currentState != PibePlateado.State.PlayerNotice)
		{
			noticed = false;
		}
		if (enemyBirthdayBoy.currentState == PibePlateado.State.FlyBackUp || enemyBirthdayBoy.currentState == PibePlateado.State.FlyBackToNavMesh)
		{
			if (!animator.GetBool(animFloat))
			{
				animator.SetTrigger(animFloatTrigger);
			}
			animator.SetBool(animFloat, true);
		}
		else
		{
			animator.SetBool(animFloat, false);
		}
		if (enemyBirthdayBoy.currentState == PibePlateado.State.Despawn || (int)enemy.CurrentState == 11)
		{
			if (!animator.GetBool(animDespawn))
			{
				animator.ResetTrigger(animFloatTrigger);
				animator.ResetTrigger("stun_trigger");
				droolParticle.Stop();
				spawnSmokeParticle.Play();
				animator.SetTrigger(animDespawnTrigger);
			}
			animator.SetBool(animDespawn, true);
		}
		else
		{
			animator.SetBool(animDespawn, false);
			if (!droolParticle.isPlaying)
			{
				droolParticle.Play();
			}
		}
	}

	private void AnimateSprings()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: 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_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		topHairRightTransform.rotation = SemiFunc.SpringQuaternionGet(topHairRightSpring, topHairRightTarget.rotation, -1f);
		topHairLeftTransform.rotation = SemiFunc.SpringQuaternionGet(topHairLeftSpring, topHairLeftTarget.rotation, -1f);
		sideHairLeftTransform.rotation = SemiFunc.SpringQuaternionGet(sideHairLeftSpring, sideHairLeftTarget.rotation, -1f);
		sideHairRightTransform.rotation = SemiFunc.SpringQuaternionGet(sideHairRightSpring, sideHairRightTarget.rotation, -1f);
		middleHairTransform.rotation = SemiFunc.SpringQuaternionGet(middleHairSpring, middleHairTarget.rotation, -1f);
		BackHairTransform.rotation = SemiFunc.SpringQuaternionGet(BackHairSpring, BackHairTarget.rotation, -1f);
	}

	public void BlowBalloonAnimationTrigger()
	{
		animator.SetTrigger("blow_balloon_trigger");
	}

	public void DoneWithBalloonBlow()
	{
		enemyBirthdayBoy.OnBalloonBlowComplete();
	}

	public void StoreBalloonLocation()
	{
		enemyBirthdayBoy.StoreBalloonLocation();
	}

	public void SetBlowingFalse()
	{
		enemyBirthdayBoy.blowing = false;
	}

	public void SetBlowingTrue()
	{
		enemyBirthdayBoy.blowing = true;
	}

	public void SetSpawn()
	{
		animator.Play("Birthday Boy - Spawn", 0, 0f);
		spawnSmokeParticle.Play();
	}

	public void SetDespawn()
	{
		enemy.EnemyParent.Despawn();
	}

	public void CrouchedDown()
	{
		enemyBirthdayBoy.CrouchedDown();
	}

	public void FootStepSound()
	{
		//IL_000d: 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_007a: Unknown result type (might be due to invalid IL or missing references)
		footStepSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		MaterialSound();
		if (enemyBirthdayBoy.AttackState())
		{
			footStepSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			footStepHardSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		}
	}

	public void MoveLightSound()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		moveLightSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void MoveHeavySound()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		moveHeavySound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void BalloonSqueakSound()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		balloonSqueakSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void InterruptBalloonPop()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		balloonPopParticle.Play(true);
		balloonPopSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void BalloonBloWSound()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		balloonBlowSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void BalloonTieSound()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		balloonTieSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	private void MaterialSound()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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_002f: Unknown result type (might be due to invalid IL or missing references)
		Materials.Instance.Impulse(enemy.Rigidbody.physGrabObject.centerPoint + Vector3.down * 0.5f, Vector3.down, (SoundType)0, true, true, material, (HostType)2);
	}

	private void TurnSoundLogic()
	{
		//IL_0015: 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_0092: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: 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)
		//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)
		if (SemiFunc.PerSecond(5f, (Object)(object)this))
		{
			if (Quaternion.Angle(prevHeadLookRotation, headPivot.rotation) > 30f && moveSoundHeadTimer <= 0f)
			{
				moveLightSound.Play(headPivot.position, 1f, 1f, 1f, 1f);
				prevHeadLookRotation = headPivot.rotation;
				moveSoundHeadTimer = 0.2f;
			}
			if (Quaternion.Angle(prevRigidBodyRotation, rb.rotation) > 20f && moveSoundRigidBodyTimer <= 0f)
			{
				moveSoundRigidBodyTimer = 0.5f;
				moveHeavySound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				prevRigidBodyRotation = rb.rotation;
			}
			prevHeadLookRotation = headPivot.rotation;
			prevRigidBodyRotation = rb.rotation;
		}
		if (moveSoundRigidBodyTimer > 0f)
		{
			moveSoundRigidBodyTimer -= Time.deltaTime;
		}
		if (moveSoundHeadTimer > 0f)
		{
			moveSoundHeadTimer -= Time.deltaTime;
		}
	}

	public void PlayDeathParticles()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		Object.Instantiate<GameObject>(deathParticlePrefab, ((Component)this).transform.position, Quaternion.identity).GetComponent<ParticleSystem>().Play(true);
	}

	public void AttackSwoosh()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		attackSwoosh.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void JumpSound()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		jumpSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void LandSound()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		landSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void InhaleSound()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		inhaleSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void NoticeSound()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		noticeSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	public void CrackSound()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		crackSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}
}
public class ÑacaÑaca : MonoBehaviour
{
	public enum State
	{
		Spawn,
		Idle,
		Roam,
		Investigate,
		PlayerNotice,
		PlayerGoTo,
		PlayerPickup,
		PlayerMove,
		PlayerRelease,
		PlayerReleaseWait,
		Leave,
		Stun,
		StunEnd,
		Despawn
	}

	[Space]
	public State currentState;

	private bool stateImpulse;

	private float stateTimer;

	[Space]
	public Enemy enemy;

	public ÑacaÑacaAnim enemyHiddenAnim;

	private PhotonView photonView;

	[Space]
	public Transform playerPickupTransform;

	public AnimationCurve playerPickupCurveUp;

	public AnimationCurve playerPickupCurveSide;

	private float playerPickupLerpUp;

	private float playerPickupLerpSide;

	private Vector3 playerPickupPositionOriginal;

	[Space]
	public SpringQuaternion rotationSpring;

	private Quaternion rotationTarget;

	private Vector3 agentDestination;

	private PlayerAvatar playerTarget;

	private bool agentSet;

	private float grabAggroTimer;

	private float maxMoveTimer;

	private void Awake()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		photonView = ((Component)this).GetComponent<PhotonView>();
		playerPickupPositionOriginal = playerPickupTransform.localPosition;
	}

	private void Update()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Invalid comparison between Unknown and I4
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (grabAggroTimer > 0f)
			{
				grabAggroTimer -= Time.deltaTime;
			}
			RotationLogic();
			PlayerPickupTransformLogic();
			if (enemy.IsStunned())
			{
				UpdateState(State.Stun);
			}
			if ((int)enemy.CurrentState == 11 && !enemy.IsStunned())
			{
				UpdateState(State.Despawn);
			}
			switch (currentState)
			{
			case State.Spawn:
				StateSpawn();
				break;
			case State.Idle:
				StateIdle();
				break;
			case State.Roam:
				StateRoam();
				break;
			case State.Investigate:
				StateInvestigate();
				break;
			case State.PlayerNotice:
				StatePlayerNotice();
				break;
			case State.PlayerGoTo:
				StatePlayerGoTo();
				break;
			case State.PlayerPickup:
				StatePlayerPickup();
				break;
			case State.PlayerMove:
				StatePlayerMove();
				break;
			case State.PlayerRelease:
				StatePlayerRelease();
				break;
			case State.PlayerReleaseWait:
				StatePlayerReleaseWait();
				break;
			case State.Leave:
				StateLeave();
				break;
			case State.Stun:
				StateStun();
				break;
			case State.StunEnd:
				StateStunEnd();
				break;
			case State.Despawn:
				StateDespawn();
				break;
			}
		}
	}

	private void FixedUpdate()
	{
		PlayerTumbleLogic();
	}

	private void StateSpawn()
	{
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 1f;
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.Idle);
		}
	}

	private void StateIdle()
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = Random.Range(2f, 5f);
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
		}
		if (!SemiFunc.EnemySpawnIdlePause())
		{
			stateTimer -= Time.deltaTime;
			if (stateTimer <= 0f)
			{
				UpdateState(State.Roam);
			}
			if (SemiFunc.EnemyForceLeave(enemy))
			{
				UpdateState(State.Leave);
			}
		}
	}

	private void StateRoam()
	{
		//IL_0029: 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_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_0087: 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_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_00e0: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 5f;
			bool flag = false;
			LevelPoint 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" })))
			{
				enemy.NavMeshAgent.SetDestination(((NavMeshHit)(ref val2)).position);
				flag = true;
			}
			if (!flag)
			{
				return;
			}
			enemy.Rigidbody.notMovingTimer = 0f;
		}
		else
		{
			SemiFunc.EnemyCartJump(enemy);
			if (enemy.Rigidbody.notMovingTimer > 2f)
			{
				stateTimer -= Time.deltaTime;
			}
			if (stateTimer <= 0f || !enemy.NavMeshAgent.HasPath())
			{
				SemiFunc.EnemyCartJumpReset(enemy);
				UpdateState(State.Idle);
			}
		}
		if (SemiFunc.EnemyForceLeave(enemy))
		{
			UpdateState(State.Leave);
		}
	}

	private void StateInvestigate()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateTimer = 5f;
			enemy.Rigidbody.notMovingTimer = 0f;
			stateImpulse = false;
		}
		else
		{
			enemy.NavMeshAgent.SetDestination(agentDestination);
			SemiFunc.EnemyCartJump(enemy);
			if (enemy.Rigidbody.notMovingTimer > 2f)
			{
				stateTimer -= Time.deltaTime;
			}
			if (stateTimer <= 0f || !enemy.NavMeshAgent.HasPath())
			{
				SemiFunc.EnemyCartJumpReset(enemy);
				UpdateState(State.Idle);
			}
		}
		if (SemiFunc.EnemyForceLeave(enemy))
		{
			UpdateState(State.Leave);
		}
	}

	private void StatePlayerNotice()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			enemy.NavMeshAgent.ResetPath();
			stateImpulse = false;
			stateTimer = 2f;
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.PlayerGoTo);
		}
	}

	private void StatePlayerGoTo()
	{
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: 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)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: 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_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 2f;
			agentSet = true;
		}
		stateTimer -= Time.deltaTime;
		if (!Object.op_Implicit((Object)(object)playerTarget) || playerTarget.isDisabled || stateTimer <= 0f)
		{
			UpdateState(State.Leave);
			return;
		}
		SemiFunc.EnemyCartJump(enemy);
		if (enemy.Jump.jumping)
		{
			enemy.NavMeshAgent.Disable(0.5f);
			((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, ((Component)playerTarget).transform.position, 5f * Time.deltaTime);
			agentSet = true;
		}
		else if (!enemy.NavMeshAgent.IsDisabled())
		{
			if (!agentSet && enemy.NavMeshAgent.HasPath() && Vector3.Distance(((Component)enemy.Rigidbody).transform.position + Vector3.down * 0.75f, enemy.NavMeshAgent.GetDestination()) < 0.25f)
			{
				enemy.Jump.StuckTrigger(((Component)enemy.Rigidbody).transform.position - ((Component)playerTarget).transform.position);
			}
			enemy.NavMeshAgent.SetDestination(((Component)playerTarget).transform.position);
			enemy.NavMeshAgent.OverrideAgent(5f, 10f, 0.25f);
			agentSet = false;
		}
		if (Vector3.Distance(((Component)enemy.Rigidbody).transform.position, ((Component)playerTarget).transform.position) < 1.5f)
		{
			SemiFunc.EnemyCartJumpReset(enemy);
			UpdateState(State.PlayerPickup);
		}
	}

	private void StatePlayerPickup()
	{
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 1f;
		}
		if (!Object.op_Implicit((Object)(object)playerTarget) || playerTarget.isDisabled)
		{
			UpdateState(State.Leave);
			return;
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.PlayerMove);
		}
	}

	private void StatePlayerMove()
	{
		//IL_002d: 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_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_0087: 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_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_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateTimer = 5f;
			maxMoveTimer = 15f;
			bool flag = false;
			LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 50f, 999f, false);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f);
			}
			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)
			{
				stateTimer = 0f;
			}
			stateImpulse = false;
		}
		if (enemy.Rigidbody.notMovingTimer > 2f)
		{
			stateTimer -= Time.deltaTime;
		}
		if (!Object.op_Implicit((Object)(object)playerTarget) || playerTarget.isDisabled)
		{
			UpdateState(State.Leave);
			return;
		}
		enemy.NavMeshAgent.SetDestination(agentDestination);
		SemiFunc.EnemyCartJump(enemy);
		enemy.NavMeshAgent.OverrideAgent(10f, 15f, 0.1f);
		enemy.Rigidbody.OverrideFollowPosition(0.1f, 15f, 30f);
		enemy.Jump.GapJumpOverride(0.1f, 20f, 20f);
		maxMoveTimer -= Time.deltaTime;
		if (!enemy.NavMeshAgent.HasPath() || Vector3.Distance(((Component)this).transform.position, agentDestination) < 1f || Vector3.Distance(((Component)enemy.Rigidbody).transform.position, ((Component)playerTarget).transform.position) > 5f || stateTimer <= 0f || maxMoveTimer <= 0f)
		{
			SemiFunc.EnemyCartJumpReset(enemy);
			UpdateState(State.PlayerRelease);
		}
	}

	private void StatePlayerRelease()
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 2f;
		}
		stateTimer -= Time.deltaTime;
		if (Object.op_Implicit((Object)(object)playerTarget))
		{
			playerTarget.GetMapDebuffTimer().minimapDebuffTimer = 30f;
		}
		if (!Object.op_Implicit((Object)(object)playerTarget) || playerTarget.isDisabled)
		{
			UpdateState(State.Leave);
		}
		else if (stateTimer <= 0f || Vector3.Distance(((Component)enemy.Rigidbody).transform.position, ((Component)playerTarget).transform.position) > 5f)
		{
			UpdateState(State.PlayerReleaseWait);
		}
	}

	private void StatePlayerReleaseWait()
	{
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 2f;
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.Leave);
		}
	}

	private void StateLeave()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		if (stateImpulse)
		{
			stateTimer = 5f;
			bool flag = false;
			LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 30f, 50f, false);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f);
			}
			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, 10f, LayerMask.GetMask(new string[1] { "Default" })))
			{
				agentDestination = ((NavMeshHit)(ref val2)).position;
				flag = true;
			}
			SemiFunc.EnemyLeaveStart(enemy);
			if (!flag)
			{
				return;
			}
			stateImpulse = false;
			enemy.EnemyParent.SpawnedTimerSet(1f);
		}
		if (enemy.Rigidbody.notMovingTimer > 2f)
		{
			stateTimer -= Time.deltaTime;
		}
		enemy.NavMeshAgent.SetDestination(agentDestination);
		enemy.NavMeshAgent.OverrideAgent(5f, 10f, 0.25f);
		SemiFunc.EnemyCartJump(enemy);
		if (Vector3.Distance(((Component)this).transform.position, agentDestination) < 1f || stateTimer <= 0f)
		{
			SemiFunc.EnemyCartJumpReset(enemy);
			UpdateState(State.Idle);
		}
	}

	private void StateStun()
	{
		if (!enemy.IsStunned())
		{
			UpdateState(State.StunEnd);
		}
	}

	private void StateStunEnd()
	{
		if (stateImpulse)
		{
			stateImpulse = false;
			stateTimer = 1f;
		}
		stateTimer -= Time.deltaTime;
		if (stateTimer <= 0f)
		{
			UpdateState(State.Leave);
		}
	}

	private void StateDespawn()
	{
		if (stateImpulse)
		{
			stateImpulse = false;
			enemy.EnemyParent.Despawn();
			UpdateState(State.Spawn);
		}
	}

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

	public void OnHurt()
	{
		enemyHiddenAnim.Hurt();
	}

	public void OnDeath()
	{
		enemyHiddenAnim.Death();
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			enemy.EnemyParent.Despawn();
		}
	}

	public void OnInvestigate()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMasterClientOrSingleplayer() && (currentState == State.Idle || currentState == State.Roam || currentState == State.Investigate))
		{
			agentDestination = enemy.StateInvestigate.onInvestigateTriggeredPosition;
			UpdateState(State.Investigate);
		}
	}

	public void OnVision()
	{
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		if (currentState == State.Idle || currentState == State.Roam || currentState == State.Investigate || currentState == State.Leave)
		{
			playerTarget = enemy.Vision.onVisionTriggeredPlayer;
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("UpdatePlayerTargetRPC", (RpcTarget)0, new object[1] { playerTarget.photonView.ViewID });
			}
			UpdateState(State.PlayerNotice);
		}
		else if (currentState == State.PlayerGoTo)
		{
			stateTimer = 2f;
		}
	}

	public void OnGrabbed()
	{
		if (SemiFunc.IsMasterClientOrSingleplayer() && !(grabAggroTimer > 0f) && currentState == State.Leave)
		{
			grabAggroTimer = 60f;
			playerTarget = enemy.Rigidbody.onGrabbedPlayerAvatar;
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("UpdatePlayerTargetRPC", (RpcTarget)0, new object[1] { playerTarget.photonView.ViewID });
			}
			UpdateState(State.PlayerNotice);
		}
	}

	private void UpdateState(State _state)
	{
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMasterClientOrSingleplayer() && _state != currentState)
		{
			enemy.Rigidbody.StuckReset();
			currentState = _state;
			stateImpulse = true;
			stateTimer = 0f;
			if (currentState == State.Leave)
			{
				SemiFunc.EnemyLeaveStart(enemy);
			}
			if (GameManager.Multiplayer())
			{
				photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { currentState });
			}
			else
			{
				UpdateStateRPC(currentState);
			}
		}
	}

	private void RotationLogic()
	{
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: 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_010d: 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_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)
		//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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		if (currentState == State.PlayerNotice || currentState == State.PlayerGoTo)
		{
			if (Vector3.Distance(((Component)playerTarget).transform.position, ((Component)this).transform.position) > 0.1f)
			{
				rotationTarget = Quaternion.LookRotation(((Component)playerTarget).transform.position - ((Component)this).transform.position);
				((Quaternion)(ref rotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref rotationTarget)).eulerAngles.y, 0f);
			}
		}
		else
		{
			Vector3 normalized = ((Vector3)(ref enemy.NavMeshAgent.AgentVelocity)).normalized;
			if (((Vector3)(ref normalized)).magnitude > 0.1f)
			{
				rotationTarget = Quaternion.LookRotation(((Vector3)(ref enemy.NavMeshAgent.AgentVelocity)).normalized);
				((Quaternion)(ref rotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref rotationTarget)).eulerAngles.y, 0f);
			}
		}
		((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(rotationSpring, rotationTarget, -1f);
	}

	private void PlayerTumbleLogic()
	{
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		if ((currentState != State.PlayerPickup && currentState != State.PlayerMove && currentState != State.PlayerRelease) || !Object.op_Implicit((Object)(object)playerTarget) || playerTarget.isDisabled)
		{