Decompiled source of DesaEnemies v1.0.2

DesaEnemies.dll

Decompiled 17 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;
using UnityEngine.Serialization;

[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]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 class Mareo : MonoBehaviour
{
	public enum State
	{
		Spawn,
		Idle,
		Despawn,
		Roam,
		Investigate,
		Stun,
		Leave,
		Notice,
		Attack,
		Attached,
		Puke,
		Detach,
		IdlePuke,
		GoToPlayerOver,
		GoToPlayerUnder,
		MoveBackToNavmesh,
		GoToPlayer,
		Dead
	}

	public GameObject enemySlowMouthAttack;

	public GameObject localCameraMouthPrefab;

	public GameObject enemySlowMouthOnPlayerTop;

	public GameObject enemySlowMouthOnPlayerBot;

	public Transform particles;

	public Transform tentacles;

	private List<SpringTentacle> springTentacles = new List<SpringTentacle>();

	private List<ParticleSystem> spawnParticles = new List<ParticleSystem>();

	private bool movingRight;

	private bool movingLeft = true;

	private float moveThisDirectionTimer;

	private float looseTargetTimer;

	private float looseTargetTime;

	private float randomNudgeTimer;

	[FormerlySerializedAs("state")]
	public State currentState;

	private Vector3 agentDestination;

	public SemiPuke semiPuke;

	private EnemyVision enemyVision;

	public Transform mouthTransform;

	public Collider enemyCollider;

	public Transform enemyVisuals;

	private bool stateImpulse;

	private bool stateStartFixed;

	private float stateTimer;

	private PhotonView photonView;

	private PlayerAvatar attachTarget;

	private Enemy enemy;

	public EnemyRigidbody enemyRigidbody;

	public PhysGrabObject physGrabObject;

	public Transform followTarget;

	public Vector3 followTargetStartPosition;

	public Transform centerTransform;

	public AudioSource audioSourceVO;

	private float idleBreakerVOCooldown = 20f;

	private float idlePukeCooldown = 20f;

	private State idlePukePreviousState;

	public EnemySlowMouthAnim enemySlowMouthAnim;

	private Vector3 followPointPositionPrev;

	private Transform currentTarget;

	private SpringFloat spawnDespawnScaleSpring;

	private Vector3 targetDestination;

	private bool waitForTargettingLoop;

	private float visionTimer;

	private bool visionPrevious;

	private PlayerAvatar playerTarget;

	private float enemyHiddenTimer;

	private Vector3 moveBackPosition;

	private float targetForwardOffset = 1.5f;

	private Vector3 targetPosition;

	private float targetedPlayerTime;

	private float targetedPlayerTimeMax = 10f;

	private float moveBackTimer;

	private Vector3 enemyGroundPosition;

	internal Vector3 detachPosition;

	internal Quaternion detachRotation;

	private float attachedTimer;

	private float possessCooldown;

	private float stuckTimer;

	private Vector3 stuckPosition;

	private float aggroTimer;

	public Sound soundSpawnVO;

	public Sound soundIdleBreakerVO;

	public Sound soundHurtVO;

	public Sound soundDieVO;

	public Sound soundNoticeVO;

	public Sound soundChaseLoopVO;

	public Sound soundDetachVO;

	public Sound soundDetach;

	public Sound soundStunLoopVO;

	private void Start()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_004b: 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)
		spawnDespawnScaleSpring = new SpringFloat();
		spawnDespawnScaleSpring.damping = 0.5f;
		spawnDespawnScaleSpring.speed = 20f;
		photonView = ((Component)this).GetComponent<PhotonView>();
		enemy = ((Component)this).GetComponent<Enemy>();
		followTargetStartPosition = followTarget.localPosition;
		enemyVision = ((Component)this).GetComponent<EnemyVision>();
		spawnParticles = new List<ParticleSystem>(((Component)particles).GetComponentsInChildren<ParticleSystem>());
		springTentacles = new List<SpringTentacle>(((Component)tentacles).GetComponentsInChildren<SpringTentacle>());
	}

	private void AnimStateIdle()
	{
		enemySlowMouthAnim.UpdateState((State)0);
	}

	private void AnimStatePuke()
	{
		enemySlowMouthAnim.UpdateState((State)1);
	}

	private void AnimStateStunned()
	{
		enemySlowMouthAnim.UpdateState((State)2);
	}

	private void AnimStateTargetting()
	{
		enemySlowMouthAnim.UpdateState((State)3);
	}

	private void AnimStateAttached()
	{
		enemySlowMouthAnim.UpdateState((State)4);
	}

	private void AnimStateAggro()
	{
		enemySlowMouthAnim.UpdateState((State)5);
	}

	private void AnimStateSpawnDespawn()
	{
		enemySlowMouthAnim.UpdateState((State)6);
	}

	private void AnimStateDeath()
	{
		enemySlowMouthAnim.UpdateState((State)7);
	}

	private void AnimStateLeave()
	{
		enemySlowMouthAnim.UpdateState((State)8);
	}

	private void PlaySpawnParticles()
	{
		foreach (ParticleSystem spawnParticle in spawnParticles)
		{
			spawnParticle.Play();
		}
	}

	private void StateSpawn(bool fixedUpdate)
	{
		//IL_005f: 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_001e: 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)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				enemyVisuals.localScale = Vector3.zero;
				stateTimer = 3f;
				stateImpulse = false;
				PlaySpawnParticles();
			}
			float num = SemiFunc.SpringFloatGet(spawnDespawnScaleSpring, 1f, -1f);
			enemyVisuals.localScale = Vector3.one * num;
			AnimStateSpawnDespawn();
			if (stateTimer <= 0f)
			{
				enemyVisuals.localScale = Vector3.one;
				UpdateState(State.Idle);
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateIdle(bool fixedUpdate)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
				enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
				enemy.NavMeshAgent.ResetPath();
				stateTimer = Random.Range(5f, 10f);
			}
			AnimStateIdle();
			if (SemiFunc.IsMasterClientOrSingleplayer() && !SemiFunc.EnemySpawnIdlePause() && !IdlePukeLogic(0.1f))
			{
				IdleBreakerVOLogic();
				LookAtVelocityDirection(_moving: false);
				FloatAround();
				if (stateTimer <= 0f)
				{
					UpdateState(State.Roam);
				}
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateDespawn(bool fixedUpdate)
	{
		//IL_0074: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
				PlaySpawnParticles();
				soundDetach.Play(mouthTransform, 1f, 1f, 1f, 1f);
				stateTimer = 1f;
			}
			float num = SemiFunc.SpringFloatGet(spawnDespawnScaleSpring, 0f, -1f);
			enemyVisuals.localScale = Vector3.one * num;
			AnimStateSpawnDespawn();
			if (SemiFunc.IsMasterClientOrSingleplayer() && stateTimer <= 0f)
			{
				enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
				enemy.NavMeshAgent.ResetPath();
				enemy.EnemyParent.Despawn();
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateRoam(bool fixedUpdate)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
				agentDestination = SemiFunc.EnemyRoamFindPoint(((Component)this).transform.position);
				stateTimer = Random.Range(5f, 10f);
				followTarget.localPosition = new Vector3(0f, 1f, 0f);
			}
			AnimStateIdle();
			if (SemiFunc.IsMasterClientOrSingleplayer() && !IdlePukeLogic(0.1f))
			{
				IdleBreakerVOLogic();
				LookAtVelocityDirection(_moving: false);
				StuckLogic();
				enemy.NavMeshAgent.SetDestination(agentDestination);
				if (Vector3.Distance(((Component)this).transform.position, enemy.NavMeshAgent.GetPoint()) < 1f || stateTimer <= 0f)
				{
					UpdateState(State.Idle);
				}
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateInvestigate(bool fixedUpdate)
	{
		//IL_0034: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
				followTarget.localPosition = new Vector3(0f, 1f, 0f);
				enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
			}
			AnimStateIdle();
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			LookAtVelocityDirection(_moving: false);
			if (!IdlePukeLogic(0.2f))
			{
				IdleBreakerVOLogic();
				enemy.NavMeshAgent.SetDestination(agentDestination);
				if (Vector3.Distance(((Component)this).transform.position, enemy.NavMeshAgent.GetPoint()) < 1f)
				{
					UpdateState(State.Idle);
				}
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateStun(bool fixedUpdate)
	{
		//IL_0033: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				enemy.NavMeshAgent.Warp(((Component)enemy.Rigidbody).transform.position, false);
				enemy.NavMeshAgent.ResetPath();
				stateImpulse = false;
			}
			AnimStateStunned();
			foreach (SpringTentacle springTentacle in springTentacles)
			{
				if (SemiFunc.PerSecond(5f, (Object)(object)this))
				{
					springTentacle.springStart.springVelocity = Random.insideUnitSphere * 25f;
					springTentacle.springMid.springVelocity = Random.insideUnitSphere * 25f;
					springTentacle.springEnd.springVelocity = Random.insideUnitSphere * 25f;
				}
			}
			if (SemiFunc.IsMasterClientOrSingleplayer() && !enemy.IsStunned())
			{
				UpdateState(State.Idle);
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateLeave(bool fixedUpdate)
	{
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				if (!SemiFunc.EnemyLeavePoint(enemy, ref agentDestination))
				{
					return;
				}
				stateImpulse = false;
				followTarget.localPosition = new Vector3(0f, 1f, 0f);
				stateTimer = Random.Range(10f, 15f);
				PlaySpawnParticles();
				SemiFunc.EnemyLeaveStart(enemy);
			}
			enemy.NavMeshAgent.SetDestination(agentDestination);
			AnimStateLeave();
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				StuckLogic();
				IdleBreakerVOLogic();
				FastMoving(_lookAtTarget: false);
				enemyRigidbody.OverrideFollowPosition(0.1f, 5f, 10f);
				enemy.NavMeshAgent.OverrideAgent(8f, 8f, 0.1f);
				if (stateTimer <= 0f || Vector3.Distance(((Component)this).transform.position, enemy.NavMeshAgent.GetPoint()) < 1f)
				{
					UpdateState(State.Idle);
				}
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateNotice(bool fixedUpdate)
	{
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				TargettingPlayerStart();
				if (!audioSourceVO.isPlaying)
				{
					soundNoticeVO.Play(mouthTransform, 1f, 1f, 1f, 1f);
				}
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					UpdatePlayerTarget(enemyVision.onVisionTriggeredPlayer);
				}
				stateTimer = 1f;
				stateImpulse = false;
			}
			AnimStateIdle();
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				followTarget.localRotation = Quaternion.LookRotation(currentTarget.position - centerTransform.position, Vector3.up);
				if (stateTimer <= 0f)
				{
					UpdateState(State.GoToPlayer);
				}
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateAttack(bool fixedUpdate)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
				MareoAttaching component = Object.Instantiate<GameObject>(enemySlowMouthAttack, centerTransform.position, centerTransform.rotation).GetComponent<MareoAttaching>();
				component.targetPlayerAvatar = playerTarget;
				component.mareo = this;
				attachedTimer = 0f;
			}
			AnimStateAttached();
			OverrideHideEnemy();
			LookAtVelocityDirection(_moving: false);
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void DetatchLogic()
	{
		if (SemiFunc.PerSecond(5f, (Object)(object)this))
		{
			if (!Object.op_Implicit((Object)(object)playerTarget))
			{
				UpdateState(State.Detach);
			}
			else if (playerTarget.isDisabled)
			{
				UpdateState(State.Detach);
			}
		}
	}

	private void StateAttached(bool fixedUpdate)
	{
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
				if (attachedTimer <= 0f)
				{
					attachedTimer = Random.Range(20f, 60f);
				}
				stateTimer = Random.Range(1f, 15f);
			}
			OverrideHideEnemy();
			AnimStateAttached();
			PlayerEffects();
			enemy.EnemyParent.SpawnedTimerPause(1f);
			((Component)enemy).transform.position = ((Component)this).transform.position;
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			DetatchLogic();
			if (SemiFunc.PerSecond(5f, (Object)(object)this) && !Object.op_Implicit((Object)(object)((Component)playerTarget.playerAvatarVisuals).GetComponentInChildren<EnemySlowMouthAttached>()))
			{
				if (Object.op_Implicit((Object)(object)currentTarget))
				{
					detachPosition = currentTarget.position;
					detachRotation = currentTarget.rotation;
				}
				UpdateState(State.Detach);
			}
			IsPossessedBySeveral();
			attachedTimer -= Time.deltaTime;
			if (attachedTimer <= 0f || playerTarget.isDisabled)
			{
				if (Object.op_Implicit((Object)(object)currentTarget))
				{
					detachPosition = currentTarget.position;
					detachRotation = currentTarget.rotation;
					UpdateState(State.Detach);
				}
				else
				{
					enemy.EnemyParent.SpawnedTimerSet(0f);
					UpdateState(State.Despawn);
				}
			}
			else if (stateTimer <= 0f)
			{
				UpdateState(State.Puke);
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StatePuke(bool fixedUpdate)
	{
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
				stateTimer = Random.Range(0.5f, 3f);
				if (Random.Range(0, 30) == 0)
				{
					stateTimer = 6f;
				}
			}
			PlayerEffects();
			OverrideHideEnemy();
			AnimStateAttached();
			DetatchLogic();
			if (stateTimer <= 0f)
			{
				UpdateState(State.Attached);
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateDetach(bool fixedUpdate)
	{
		//IL_005d: 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_00e6: 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_00ed: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: 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_0115: 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_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: 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_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
				stateTimer = 0f;
				attachedTimer = 0f;
				possessCooldown = Random.Range(30f, 120f);
				((Component)enemy).transform.position = ((Component)this).transform.position;
			}
			PlayerEffects();
			OverrideHideEnemy();
			AnimStateAttached();
			if (!(stateTimer <= 0f))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)playerTarget))
			{
				enemy.EnemyParent.SpawnedTimerSet(0f);
				UpdateState(State.Despawn);
				return;
			}
			Transform overrideTransform = playerTarget.localCamera.GetOverrideTransform();
			Vector3 forward = overrideTransform.forward;
			Vector3 val = overrideTransform.position + forward * 0.3f;
			if (playerTarget.tumble.isTumbling)
			{
				val += Vector3.up;
			}
			float num = 0.2f;
			if (Physics.SphereCastAll(val, 0.45f, forward, num, LayerMask.GetMask(new string[1] { "Default" })).Length == 0)
			{
				Vector3 val2 = overrideTransform.position + forward * num;
				if (SemiFunc.IsMasterClientOrSingleplayer() && Object.op_Implicit((Object)(object)playerTarget) && Object.op_Implicit((Object)(object)playerTarget.tumble))
				{
					playerTarget.tumble.TumbleRequest(true, false);
				}
				physGrabObject.Teleport(val2, overrideTransform.rotation);
				enemy.NavMeshAgent.Warp(val2, false);
				soundDetach.Play(val2, 1f, 1f, 1f, 1f);
				soundDetachVO.Play(val2, 1f, 1f, 1f, 1f);
				enemy.EnemyParent.SpawnedTimerSet(2f);
				UpdateState(State.Leave);
			}
			else if (playerTarget.isDisabled)
			{
				enemy.EnemyParent.SpawnedTimerSet(0f);
				UpdateState(State.Despawn);
			}
			else
			{
				stateTimer = 0.25f;
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateIdlePuke(bool fixedUpdate)
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: 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_00e1: 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_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_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
				stateTimer = Random.Range(0.5f, 2f);
				if (Random.Range(0, 30) == 0)
				{
					stateTimer = 4f;
				}
			}
			AnimStatePuke();
			semiPuke.PukeActive(mouthTransform.position, mouthTransform.rotation);
			if (stateTimer <= 0f)
			{
				UpdateState(idlePukePreviousState);
			}
		}
		else
		{
			if (stateStartFixed)
			{
				stateStartFixed = false;
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				Vector3 val = Random.insideUnitSphere * 80f;
				enemyRigidbody.rb.AddTorque(val * Time.fixedDeltaTime, (ForceMode)0);
				Vector3 val2 = -mouthTransform.forward * 400f;
				enemyRigidbody.rb.AddForce(val2 * Time.fixedDeltaTime, (ForceMode)0);
			}
		}
	}

	private void StateGoToPlayerOver(bool fixedUpdate)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: 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_0181: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateTimer = 2f;
				stateImpulse = false;
				followTarget.localPosition = Vector3.zero;
			}
			followTarget.localPosition = currentTarget.localPosition;
			AnimStateTargetting();
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			FastMoving(_lookAtTarget: true);
			TargettingPlayer();
			if (IdlePukeLogic())
			{
				return;
			}
			AttachToPlayer();
			enemy.NavMeshAgent.Disable(0.1f);
			((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, targetPosition, enemy.NavMeshAgent.DefaultSpeed * 0.5f * Time.deltaTime);
			enemy.Vision.StandOverride(0.25f);
			if (playerTarget.PlayerVisionTarget.VisionTransform.position.y > ((Component)enemy.Rigidbody).transform.position.y + 1.5f)
			{
				((Component)this).transform.position = ((Component)enemy.Rigidbody).transform.position;
				((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, targetPosition, 2f);
			}
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(targetPosition, ref val, 0.5f, -1))
			{
				UpdateState(State.MoveBackToNavmesh);
			}
			else if (VisionBlocked() || !Object.op_Implicit((Object)(object)playerTarget) || playerTarget.isDisabled)
			{
				if (stateTimer <= 0f || enemy.Rigidbody.notMovingTimer > 1f)
				{
					UpdateState(State.MoveBackToNavmesh);
				}
			}
			else
			{
				stateTimer = 2f;
			}
			if (SemiFunc.EnemyForceLeave(enemy))
			{
				UpdateState(State.MoveBackToNavmesh);
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateGoToPlayerUnder(bool fixedUpdate)
	{
		//IL_0030: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateTimer = 2f;
				stateImpulse = false;
				followTarget.localPosition = Vector3.zero;
			}
			AnimStateTargetting();
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			FastMoving(_lookAtTarget: true);
			TargettingPlayer();
			AttachToPlayer();
			if (IdlePukeLogic())
			{
				return;
			}
			followTarget.localPosition = new Vector3(0f, 0.2f, 0f);
			enemy.NavMeshAgent.Disable(0.1f);
			((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, targetPosition, enemy.NavMeshAgent.DefaultSpeed * Time.deltaTime);
			enemy.Vision.StandOverride(0.25f);
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(targetPosition, ref val, 0.5f, -1))
			{
				UpdateState(State.MoveBackToNavmesh);
			}
			else if (VisionBlocked() || !Object.op_Implicit((Object)(object)playerTarget) || playerTarget.isDisabled)
			{
				if (stateTimer <= 0f)
				{
					UpdateState(State.MoveBackToNavmesh);
				}
			}
			else
			{
				stateTimer = 2f;
			}
			if (SemiFunc.EnemyForceLeave(enemy))
			{
				UpdateState(State.MoveBackToNavmesh);
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateMoveBackToNavmesh(bool fixedUpdate)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: 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_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: 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_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: 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_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
				stateTimer = 30f;
				followTarget.localPosition = Vector3.zero;
			}
			AnimStateTargetting();
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			FastMoving(_lookAtTarget: false);
			TargettingPlayer();
			enemy.NavMeshAgent.OverrideAgent(8f, 8f, 0.1f);
			if (!IdlePukeLogic())
			{
				enemy.NavMeshAgent.Disable(0.1f);
				((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, moveBackPosition, enemy.NavMeshAgent.DefaultSpeed * Time.deltaTime);
				enemy.Vision.StandOverride(0.25f);
				if (Vector3.Distance(((Component)this).transform.position, enemyGroundPosition) > 2f || enemy.Rigidbody.notMovingTimer > 2f)
				{
					Vector3 val = moveBackPosition - enemyGroundPosition;
					Vector3 normalized = ((Vector3)(ref val)).normalized;
					((Component)this).transform.position = ((Component)enemy.Rigidbody).transform.position;
					Transform transform = ((Component)this).transform;
					transform.position += normalized * 2f;
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Vector3.Distance(enemyGroundPosition, moveBackPosition) <= 0f || NavMesh.SamplePosition(enemyGroundPosition, ref val2, 0.5f, -1))
				{
					UpdateState(State.GoToPlayer);
				}
				else if (stateTimer <= 0f)
				{
					enemy.EnemyParent.SpawnedTimerSet(0f);
				}
			}
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateGoToPlayer(bool fixedUpdate)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: 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_0121: 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)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				followTarget.localPosition = Vector3.zero;
				stateImpulse = false;
				stateTimer = 5f;
				targetedPlayerTime = 0f;
				targetedPlayerTimeMax = Random.Range(8f, 22f);
			}
			AnimStateTargetting();
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			FastMoving(_lookAtTarget: true);
			TargettingPlayer();
			enemy.NavMeshAgent.OverrideAgent(8f, 8f, 0.1f);
			if (IdlePukeLogic())
			{
				return;
			}
			AttachToPlayer();
			enemy.NavMeshAgent.SetDestination(targetPosition);
			MoveBackPosition();
			enemy.Vision.StandOverride(0.25f);
			NavMeshHit val = default(NavMeshHit);
			if (!enemy.NavMeshAgent.CanReach(targetPosition, 1f) && Vector3.Distance(((Component)enemy.Rigidbody).transform.position, enemy.NavMeshAgent.GetPoint()) < 2f && !VisionBlocked() && !NavMesh.SamplePosition(targetPosition, ref val, 0.5f, -1))
			{
				if (playerTarget.isCrawling && Mathf.Abs(targetPosition.y - ((Component)enemy.Rigidbody).transform.position.y) < 0.3f)
				{
					UpdateState(State.GoToPlayerUnder);
					return;
				}
				if (targetPosition.y > ((Component)enemy.Rigidbody).transform.position.y)
				{
					UpdateState(State.GoToPlayerOver);
					return;
				}
			}
			LeaveCheck();
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateDead(bool fixedUpdate)
	{
		if (!fixedUpdate)
		{
			if (stateImpulse)
			{
				stateImpulse = false;
			}
			OverrideHideEnemy();
			AnimStateDeath();
		}
		else if (stateStartFixed)
		{
			stateStartFixed = false;
		}
	}

	private void StateMachine(bool fixedUpdate)
	{
		if (!fixedUpdate && stateTimer > 0f)
		{
			stateTimer -= Time.deltaTime;
		}
		if (fixedUpdate)
		{
			if (enemyHiddenTimer <= 0f && !enemyCollider.enabled)
			{
				PlaySpawnParticles();
				((Component)enemySlowMouthAnim).gameObject.SetActive(true);
				enemyCollider.enabled = true;
			}
			if (enemyHiddenTimer > 0f)
			{
				enemyHiddenTimer -= Time.fixedDeltaTime;
				if (enemyCollider.enabled)
				{
					PlaySpawnParticles();
					((Component)enemySlowMouthAnim).gameObject.SetActive(false);
					enemyCollider.enabled = false;
				}
			}
		}
		switch (currentState)
		{
		case State.Spawn:
			StateSpawn(fixedUpdate);
			break;
		case State.Idle:
			StateIdle(fixedUpdate);
			break;
		case State.Despawn:
			StateDespawn(fixedUpdate);
			break;
		case State.Roam:
			StateRoam(fixedUpdate);
			break;
		case State.Investigate:
			StateInvestigate(fixedUpdate);
			break;
		case State.Stun:
			StateStun(fixedUpdate);
			break;
		case State.Leave:
			StateLeave(fixedUpdate);
			break;
		case State.Notice:
			StateNotice(fixedUpdate);
			break;
		case State.Attack:
			StateAttack(fixedUpdate);
			break;
		case State.Attached:
			StateAttached(fixedUpdate);
			break;
		case State.Puke:
			StatePuke(fixedUpdate);
			break;
		case State.Detach:
			StateDetach(fixedUpdate);
			break;
		case State.IdlePuke:
			StateIdlePuke(fixedUpdate);
			break;
		case State.GoToPlayerOver:
			StateGoToPlayerOver(fixedUpdate);
			break;
		case State.GoToPlayerUnder:
			StateGoToPlayerUnder(fixedUpdate);
			break;
		case State.MoveBackToNavmesh:
			StateMoveBackToNavmesh(fixedUpdate);
			break;
		case State.GoToPlayer:
			StateGoToPlayer(fixedUpdate);
			break;
		}
	}

	public void UpdateState(State newState)
	{
		//IL_004a: 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)
		if (currentState != newState && SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { newState });
			}
			else
			{
				UpdateStateRPC(newState);
			}
		}
	}

	private void UpdatePlayerTarget(PlayerAvatar _player)
	{
		//IL_0052: 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)
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("UpdatePlayerTargetRPC", (RpcTarget)0, new object[1] { _player.photonView.ViewID });
			}
			else
			{
				UpdatePlayerTargetRPC(_player.photonView.ViewID);
			}
		}
	}

	[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;
				currentTarget = SemiFunc.PlayerGetFaceEyeTransform(item);
				break;
			}
		}
	}

	[PunRPC]
	public void UpdateStateRPC(State newState, PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.MasterOnlyRPC(_info))
		{
			currentState = newState;
			stateImpulse = true;
			stateStartFixed = true;
			stateTimer = 0f;
		}
	}

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

	public void OnHurt()
	{
		if (((Behaviour)audioSourceVO).isActiveAndEnabled)
		{
			soundHurtVO.Play(mouthTransform, 1f, 1f, 1f, 1f);
		}
	}

	public void OnVision()
	{
		if (currentState == State.Idle || currentState == State.Investigate || currentState == State.Roam || currentState == State.Leave)
		{
			UpdateState(State.Notice);
		}
	}

	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 OnDeath()
	{
		//IL_004b: 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)
		soundDieVO.Play(mouthTransform, 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);
		PlaySpawnParticles();
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			enemy.EnemyParent.Despawn();
			UpdateState(State.Dead);
		}
	}

	public void OnDespawn()
	{
		//IL_004b: 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)
		soundDieVO.Play(mouthTransform, 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);
		PlaySpawnParticles();
	}

	private void Update()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Invalid comparison between Unknown and I4
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		if (currentState != State.Stun)
		{
			physGrabObject.OverrideZeroGravity(0.1f);
		}
		if ((int)enemy.CurrentState == 11)
		{
			UpdateState(State.Despawn);
		}
		LoopSounds();
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (possessCooldown > 0f)
			{
				possessCooldown -= Time.deltaTime;
			}
			if (enemy.IsStunned() && enemyHiddenTimer <= 0f)
			{
				UpdateState(State.Stun);
			}
			enemyGroundPosition = new Vector3(((Component)enemy.Rigidbody).transform.position.x, ((Component)this).transform.position.y, ((Component)enemy.Rigidbody).transform.position.z);
			TargetPositionLogic();
		}
		StateMachine(fixedUpdate: false);
		if (SemiFunc.PerSecond(30f, (Object)(object)this))
		{
			followPointPositionPrev = followTarget.position;
		}
	}

	private void FixedUpdate()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: 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)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			Vector3 forward = ((Component)enemy.Rigidbody).transform.forward;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(centerTransform.position, forward, ref val, 1f, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct())) && !Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<PhysGrabHinge>()))
			{
				enemyRigidbody.rb.AddForce(-(forward * 600f) * Time.fixedDeltaTime, (ForceMode)0);
			}
		}
		StateMachine(fixedUpdate: true);
	}

	private void RandomNudge(float _force)
	{
		//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)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: 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_008e: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			soundIdleBreakerVO.Play(mouthTransform, 1f, 1f, 1f, 1f);
			Vector3 val = centerTransform.up;
			switch (Random.Range(0, 4))
			{
			case 0:
				val = centerTransform.up;
				break;
			case 1:
				val = centerTransform.right;
				break;
			case 2:
				val = -centerTransform.right;
				break;
			case 3:
				val = -centerTransform.up;
				break;
			}
			_ = centerTransform.position + val * 0.5f;
			randomNudgeTimer = 0f;
			enemyRigidbody.rb.AddForce(val * _force, (ForceMode)1);
		}
	}

	private void LookAtVelocityDirection(bool _moving)
	{
		//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_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			Vector3 velocity = enemyRigidbody.rb.velocity;
			Vector3 val = ((Vector3)(ref velocity)).normalized;
			if (_moving)
			{
				val = enemy.moveDirection;
			}
			if (((Vector3)(ref val)).magnitude > 0.001f)
			{
				Quaternion val2 = Quaternion.LookRotation(val, Vector3.up);
				followTarget.localRotation = Quaternion.Slerp(followTarget.localRotation, val2, Time.deltaTime * 2f);
			}
		}
	}

	private void FloatAround()
	{
		//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_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0098: 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)
		followTarget.localPosition = followTargetStartPosition + Vector3.up * Mathf.Sin(Time.time * 0.5f) * 0.5f;
		Transform obj = followTarget;
		obj.localPosition += Vector3.left * Mathf.Sin(Time.time * 0.2f) * 0.3f;
		Transform obj2 = followTarget;
		obj2.localPosition += Vector3.forward * Mathf.Sin(Time.time * 0.2f) * 2f;
	}

	private bool IdlePukeLogic(float _tickSpeed = 1f)
	{
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return false;
		}
		if (idlePukeCooldown > 0f)
		{
			idlePukeCooldown -= Time.deltaTime * _tickSpeed;
			return false;
		}
		IdlePukeExecute();
		return true;
	}

	private void IdlePukeExecute()
	{
		if (!audioSourceVO.isPlaying)
		{
			idlePukePreviousState = currentState;
			UpdateState(State.IdlePuke);
			idlePukeCooldown = Random.Range(5f, 10f);
			float force = Random.Range(5f, 20f);
			RandomNudge(force);
		}
	}

	private void IdleBreakerVOLogic()
	{
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (idleBreakerVOCooldown > 0f)
			{
				idleBreakerVOCooldown -= Time.deltaTime;
			}
			else
			{
				IdleBreakerVO();
			}
		}
	}

	public void IdleBreakerVO()
	{
		//IL_0043: 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 (!audioSourceVO.isPlaying && SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("IdleBreakerVORPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				IdleBreakerVORPC();
			}
			idleBreakerVOCooldown = Random.Range(15f, 45f);
		}
	}

	[PunRPC]
	public void IdleBreakerVORPC(PhotonMessageInfo _info = default(PhotonMessageInfo))
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.MasterOnlyRPC(_info) && ((Behaviour)enemySlowMouthAnim).enabled && ((Behaviour)audioSourceVO).enabled)
		{
			soundIdleBreakerVO.Play(mouthTransform, 1f, 1f, 1f, 1f);
		}
	}

	private void AttachToTarget()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		float num = Vector3.Distance(((Component)this).transform.position, targetDestination);
		if (!VisionBlocked() && num < 2f)
		{
			UpdateState(State.Attached);
		}
	}

	private void FastMoving(bool _lookAtTarget)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: 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)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		if (_lookAtTarget)
		{
			followTarget.localRotation = Quaternion.LookRotation(currentTarget.position - centerTransform.position, Vector3.up);
		}
		else
		{
			LookAtVelocityDirection(_moving: false);
		}
		enemyRigidbody.OverrideFollowPosition(0.1f, 4f, 4f);
	}

	private void OverrideHideEnemy()
	{
		enemyHiddenTimer = 0.2f;
	}

	private bool VisionBlocked()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		if (SemiFunc.PerSecond(5f, (Object)(object)this))
		{
			Vector3 val = playerTarget.PlayerVisionTarget.VisionTransform.position - enemy.CenterTransform.position;
			visionPrevious = Physics.Raycast(enemy.CenterTransform.position, val, ((Vector3)(ref val)).magnitude, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1);
		}
		return visionPrevious;
	}

	private void LeaveCheck()
	{
		if (SemiFunc.EnemyForceLeave(enemy) || targetedPlayerTime >= targetedPlayerTimeMax)
		{
			UpdateState(State.Leave);
		}
	}

	private void TargettingPlayerStart()
	{
		aggroTimer = Random.Range(8f, 15f);
		looseTargetTimer = 0f;
	}

	private void TargettingPlayer()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		StuckLogic();
		float num = currentTarget.position.y - ((Component)this).transform.position.y;
		if (num < 0.1f)
		{
			num = 0.1f;
		}
		if (num > 2f)
		{
			num = 2f;
		}
		followTarget.localPosition = new Vector3(0f, num, 0f);
		targetedPlayerTime += Time.deltaTime;
		if (SemiFunc.IsMasterClientOrSingleplayer())
		{
			float num2 = 1f;
			if (VisionBlocked())
			{
				num2 = 4f;
			}
			aggroTimer -= Time.deltaTime * num2;
			if ((Object.op_Implicit((Object)(object)playerTarget) && playerTarget.isDisabled) || !Object.op_Implicit((Object)(object)playerTarget) || aggroTimer <= 0f)
			{
				UpdateState(State.Leave);
			}
			if (VisionBlocked())
			{
				looseTargetTimer += Time.deltaTime;
				if (looseTargetTimer > 3f)
				{
					UpdateState(State.Leave);
					looseTargetTimer = 0f;
				}
			}
			else
			{
				looseTargetTimer = 0f;
			}
		}
		AudioSourceSmoothStop();
	}

	public void TargetPositionLogic()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		if ((currentState == State.GoToPlayer || currentState == State.GoToPlayerOver || currentState == State.GoToPlayerUnder) && Object.op_Implicit((Object)(object)playerTarget))
		{
			Vector3 val = ((currentState != State.GoToPlayer && currentState != State.GoToPlayerUnder && currentState != State.GoToPlayerOver) ? (((Component)playerTarget).transform.position + ((Component)playerTarget).transform.forward * targetForwardOffset) : (((Component)playerTarget).transform.position + ((Component)playerTarget).transform.forward * 1.5f));
			targetPosition = Vector3.Lerp(targetPosition, val, 20f * Time.deltaTime);
		}
	}

	private void AudioSourceSmoothStop()
	{
		if (audioSourceVO.isPlaying)
		{
			audioSourceVO.volume = Mathf.Lerp(audioSourceVO.volume, 0f, Time.deltaTime * 40f);
			if (audioSourceVO.volume <= 0.01f)
			{
				audioSourceVO.Stop();
				audioSourceVO.volume = 1f;
			}
		}
		else if (audioSourceVO.volume < 1f)
		{
			audioSourceVO.volume = 1f;
		}
	}

	private void LoopSounds()
	{
		bool flag = currentState == State.GoToPlayer || currentState == State.GoToPlayerOver || currentState == State.GoToPlayerUnder || currentState == State.MoveBackToNavmesh;
		soundChaseLoopVO.PlayLoop(flag, 2f, 2f, 1f, 1f);
		bool flag2 = currentState == State.Stun;
		soundStunLoopVO.PlayLoop(flag2, 2f, 2f, 1f, 1f);
	}

	private void AttachToPlayer()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: 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_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		if (!SemiFunc.IsMasterClientOrSingleplayer() || !Object.op_Implicit((Object)(object)playerTarget) || !Object.op_Implicit((Object)(object)currentTarget) || !(Vector3.Distance(centerTransform.position, currentTarget.position) < 1.8f))
		{
			return;
		}
		if (SemiFunc.PerSecond(30f, (Object)(object)this))
		{
			if (movingLeft)
			{
				enemyRigidbody.rb.AddForce(-centerTransform.right * 5f, (ForceMode)0);
				if (moveThisDirectionTimer <= 0f)
				{
					movingLeft = false;
					movingRight = true;
					moveThisDirectionTimer = Random.Range(0.2f, 3f);
				}
			}
			if (movingRight)
			{
				enemyRigidbody.rb.AddForce(centerTransform.right * 5f, (ForceMode)0);
				if (moveThisDirectionTimer <= 0f)
				{
					movingRight = false;
					movingLeft = true;
					moveThisDirectionTimer = Random.Range(0.2f, 3f);
				}
			}
		}
		if (moveThisDirectionTimer > 0f)
		{
			moveThisDirectionTimer -= Time.deltaTime;
		}
		if (Random.Range(0, 2) == 0 && possessCooldown <= 0f && !IsPossessed())
		{
			UpdateState(State.Attack);
			return;
		}
		IdlePukeExecute();
		if (Random.Range(0, 3) == 0)
		{
			idlePukePreviousState = State.Leave;
		}
	}

	public bool IsPossessed()
	{
		if (!Object.op_Implicit((Object)(object)playerTarget))
		{
			return true;
		}
		if (Object.op_Implicit((Object)(object)((Component)playerTarget.playerAvatarVisuals).GetComponentInChildren<EnemySlowMouthAttached>()))
		{
			return true;
		}
		return false;
	}

	private void PlayerEffects()
	{
		if (Object.op_Implicit((Object)(object)playerTarget))
		{
			if (Object.op_Implicit((Object)(object)playerTarget.voiceChat))
			{
				playerTarget.voiceChat.OverridePitch(0.75f, 1f, 2f, 0.1f, 0f, 0f);
			}
			playerTarget.OverridePupilSize(2f, 4, 1f, 1f, 5f, 0.5f, 0.1f);
			playerTarget.playerCosmetics.ConditionCustomSet((Type)0, 0.1f);
		}
	}

	private void StuckLogic()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//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)
		float num = Vector3.Distance(((Component)this).transform.position, stuckPosition);
		float num2 = 0.25f;
		if (currentState == State.GoToPlayer || currentState == State.GoToPlayerOver || currentState == State.GoToPlayerUnder)
		{
			num2 = 1.5f;
		}
		if (num > num2)
		{
			stuckPosition = ((Component)this).transform.position;
			stuckTimer = 0f;
			randomNudgeTimer = 0f;
			return;
		}
		stuckTimer += Time.deltaTime;
		randomNudgeTimer += Time.deltaTime;
		if (randomNudgeTimer > 2.5f)
		{
			float force = Random.Range(4f, 10f);
			RandomNudge(force);
			randomNudgeTimer = 0f;
			if (currentState == State.GoToPlayer)
			{
				if (Random.Range(0, 2) == 0)
				{
					UpdateState(State.GoToPlayerUnder);
				}
				else
				{
					UpdateState(State.GoToPlayerOver);
				}
			}
		}
		if (stuckTimer > 5f)
		{
			UpdateState(State.IdlePuke);
			stuckTimer = 0f;
		}
	}

	private void IsPossessedBySeveral()
	{
		if (SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.PerSecond(5f, (Object)(object)this) && Object.op_Implicit((Object)(object)playerTarget))
		{
			if (playerTarget.isDisabled)
			{
				UpdateState(State.Leave);
			}
			else if (((Component)playerTarget.playerAvatarVisuals).GetComponentsInChildren<EnemySlowMouthAttached>().Length > 1)
			{
				UpdateState(State.Leave);
			}
		}
	}

	private void MoveBackPosition()
	{
		//IL_0027: 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_0073: 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)
		if (moveBackTimer <= 0f)
		{
			moveBackTimer = 0.1f;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)this).transform.position, ref val, 0.5f, -1) && Physics.Raycast(((Component)this).transform.position, Vector3.down, 2f, LayerMask.GetMask(new string[1] { "Default" })))
			{
				moveBackPosition = ((NavMeshHit)(ref val)).position;
			}
		}
	}
}
public class MareoAttached : MonoBehaviour
{
	public enum State
	{
		Intro,
		Idle,
		Puke,
		Outro
	}

	internal bool debug;

	internal Mareo mareo;

	internal State state;

	internal State statePrev;

	private bool stateStart = true;

	private float stateTimer;

	internal PlayerAvatar playerTarget;

	internal bool showDebug;

	public Transform localParentTransform;

	public SemiPuke semiPuke;

	public AnimationCurve curveIntroOutro;

	public Transform pukeCapsuleTransform;

	public MeshRenderer pukeCapsuleRenderer;

	public Transform topJawTransform;

	public Transform botJawTransform;

	private Quaternion topJawStartRotation;

	private Quaternion botJawStartRotation;

	private Quaternion topJawTargetRotation;

	private Quaternion botJawTargetRotation;

	private Vector3 jawStartPosition;

	private Vector3 jawTargetPosition;

	private SpringQuaternion topJawSpring;

	private SpringQuaternion botJawSpring;

	private SpringVector3 jawPositionSpring;

	private float openAngleTarget = 125f;

	private float pukeTimer;

	public List<ParticleSystem> pukeParticles;

	public SemiPuke otherSemiPuke;

	public Transform otherTopJawTransform;

	public Transform otherBotJawTransform;

	public Transform particles;

	private SpringFloat springFloatScale;

	private float scaleTarget = 1f;

	public List<Transform> eyeTransforms;

	private float loudnessAdd;

	private SpringFloat loudnessSpring;

	private float loudnessTarget;

	private void Start()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		//IL_0089: 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_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Expected O, but got Unknown
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		jawPositionSpring = new SpringVector3();
		jawPositionSpring.damping = 0.5f;
		jawPositionSpring.speed = 20f;
		topJawSpring = new SpringQuaternion();
		topJawSpring.damping = 0.5f;
		topJawSpring.speed = 20f;
		botJawSpring = new SpringQuaternion();
		botJawSpring.damping = 0.5f;
		botJawSpring.speed = 20f;
		topJawStartRotation = topJawTransform.localRotation;
		botJawStartRotation = botJawTransform.localRotation;
		topJawTargetRotation = topJawStartRotation;
		botJawTargetRotation = topJawStartRotation;
		jawStartPosition = localParentTransform.localPosition;
		loudnessSpring = new SpringFloat();
		loudnessSpring.damping = 0.5f;
		loudnessSpring.speed = 20f;
		springFloatScale = new SpringFloat();
		springFloatScale.damping = 0.35f;
		springFloatScale.speed = 10f;
		otherTopJawTransform.localScale = Vector3.one * 2f;
		springFloatScale.lastPosition = 2f;
	}

	private void StateIntro()
	{
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		if (stateStart)
		{
			stateStart = false;
			stateTimer = 1f;
			if (Object.op_Implicit((Object)(object)playerTarget) && playerTarget.isLocal)
			{
				float num = 125f;
				topJawTransform.localRotation = Quaternion.Euler(num, 0f, 0f);
				botJawTransform.localRotation = Quaternion.Euler(0f - num, 0f, 0f);
				topJawSpring.lastRotation = topJawTransform.localRotation;
				botJawSpring.lastRotation = botJawTransform.localRotation;
				jawTargetPosition = jawStartPosition;
				localParentTransform.localPosition = jawTargetPosition + new Vector3(0f, -1f, -1f);
				jawPositionSpring.lastPosition = localParentTransform.localPosition;
			}
		}
		loudnessTarget = 0f;
		scaleTarget = 1f;
		if (Object.op_Implicit((Object)(object)playerTarget) && playerTarget.isLocal)
		{
			float num2 = curveIntroOutro.Evaluate(1f - stateTimer);
			openAngleTarget = Mathf.LerpUnclamped(125f, 0f, num2);
			topJawTargetRotation = topJawStartRotation * Quaternion.Euler(openAngleTarget, 0f, 0f);
			botJawTargetRotation = botJawStartRotation * Quaternion.Euler(0f - openAngleTarget, 0f, 0f);
		}
		if (stateTimer < 0f)
		{
			StateSet(State.Idle);
		}
	}

	private void StateIdle()
	{
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: 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_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: 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_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		if (stateStart)
		{
			stateStart = false;
			if (Object.op_Implicit((Object)(object)playerTarget) && playerTarget.isLocal)
			{
				botJawTargetRotation = botJawStartRotation;
				topJawTargetRotation = topJawStartRotation;
				jawTargetPosition = jawStartPosition;
				if (statePrev == State.Puke)
				{
					GameDirector.instance.CameraShake.ShakeDistance(8f, 3f, 8f, localParentTransform.position, 0.1f);
					GameDirector.instance.CameraImpact.ShakeDistance(12f, 3f, 8f, localParentTransform.position, 0.1f);
				}
			}
		}
		loudnessTarget = 0f;
		scaleTarget = 1f;
		if (Object.op_Implicit((Object)(object)playerTarget) && playerTarget.isLocal)
		{
			botJawTargetRotation = botJawStartRotation * Quaternion.Euler(-2f * Mathf.Sin(Time.time * 2f), 0f, 0f);
			topJawTargetRotation = topJawStartRotation * Quaternion.Euler(2f * Mathf.Sin(Time.time * 2f), 0f, 0f);
			float num = 10f;
			botJawSpring.speed = 20f;
			topJawSpring.speed = 20f;
			if (Object.op_Implicit((Object)(object)playerTarget.voiceChat))
			{
				num = playerTarget.voiceChat.clipLoudness * 100f;
			}
			num = Mathf.Clamp(num, 0f, 10f);
			topJawTargetRotation *= Quaternion.Euler(topJawStartRotation.x + num, topJawStartRotation.y, topJawStartRotation.z);
			botJawTargetRotation *= Quaternion.Euler(botJawStartRotation.x - num, botJawStartRotation.y, botJawStartRotation.z);
			if (SemiFunc.PerSecond(15f, (Object)(object)this))
			{
				topJawSpring.springVelocity = Random.insideUnitSphere * 0.2f;
				botJawSpring.springVelocity = Random.insideUnitSphere * 0.2f;
			}
		}
	}

	private void StatePuke()
	{
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: 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_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: 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_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: 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_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		if (stateStart)
		{
			stateStart = false;
			if (playerTarget.isLocal)
			{
				Vector3 localScale = pukeCapsuleTransform.localScale;
				localScale.x = 0f;
				GameDirector.instance.CameraShake.ShakeDistance(8f, 3f, 8f, localParentTransform.position, 0.1f);
				GameDirector.instance.CameraImpact.ShakeDistance(12f, 3f, 8f, localParentTransform.position, 0.1f);
				pukeCapsuleTransform.localScale = localScale;
			}
		}
		float num = Mathf.Sin(Time.time * 40f) * 0.05f;
		loudnessTarget = 0.2f + num;
		scaleTarget = 1f;
		if (playerTarget.isLocal)
		{
			GameDirector.instance.CameraShake.ShakeDistance(4f, 3f, 8f, localParentTransform.position, 0.1f);
		}
		if (((Component)semiPuke).gameObject.activeInHierarchy)
		{
			semiPuke.PukeActive(((Component)semiPuke).transform.position, ((Component)playerTarget.localCamera).transform.rotation);
		}
		else
		{
			otherSemiPuke.PukeActive(((Component)otherSemiPuke).transform.position, playerTarget.localCamera.GetOverrideTransform().rotation);
		}
		pukeTimer = 0.2f;
		if (playerTarget.isLocal)
		{
			botJawTargetRotation = botJawStartRotation * Quaternion.Euler(-25f, 0f, 0f);
			topJawTargetRotation = topJawStartRotation * Quaternion.Euler(25f, 0f, 0f);
			if (SemiFunc.PerSecond(15f, (Object)(object)this))
			{
				topJawSpring.springVelocity = Random.insideUnitSphere * 5f;
				botJawSpring.springVelocity = Random.insideUnitSphere * 5f;
			}
		}
	}

	private void StateOutro()
	{
		//IL_008a: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		if (stateStart)
		{
			stateStart = false;
			stateTimer = 1f;
			((Component)particles).gameObject.SetActive(true);
		}
		loudnessTarget = 0f;
		scaleTarget = 0f;
		if (playerTarget.isLocal)
		{
			float num = curveIntroOutro.Evaluate(1f - stateTimer);
			openAngleTarget = Mathf.LerpUnclamped(0f, 125f, num);
			topJawTargetRotation = topJawStartRotation * Quaternion.Euler(openAngleTarget, 0f, 0f);
			botJawTargetRotation = botJawStartRotation * Quaternion.Euler(0f - openAngleTarget, 0f, 0f);
			jawTargetPosition = Vector3.LerpUnclamped(jawStartPosition, jawStartPosition + new Vector3(0f, 0.2f, -0.4f), num);
		}
		if (stateTimer < 0f)
		{
			if (Object.op_Implicit((Object)(object)mareo) && mareo.currentState != Mareo.State.Detach && mareo.currentState != Mareo.State.Leave)
			{
				mareo.UpdateState(Mareo.State.Detach);
			}
			Object.Destroy((Object)(object)((Component)otherTopJawTransform).gameObject);
			Object.Destroy((Object)(object)((Component)otherBotJawTransform).gameObject);
			Object.Destroy((Object)(object)((Component)localParentTransform).gameObject);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}

	private void StateSynchingWithParentEnemy()
	{
		if (!Object.op_Implicit((Object)(object)mareo) && !debug)
		{
			StateSet(State.Outro);
			return;
		}
		bool flag = Object.op_Implicit((Object)(object)mareo) && mareo.currentState == Mareo.State.Puke;
		bool flag2 = Object.op_Implicit((Object)(object)mareo) && (mareo.currentState == Mareo.State.Attached || mareo.currentState == Mareo.State.Puke || mareo.currentState == Mareo.State.Detach);
		if (debug || flag2)
		{
			if (flag)
			{
				StateSet(State.Puke);
			}
			else if (state != State.Intro)
			{
				StateSet(State.Idle);
			}
		}
		else
		{
			StateSet(State.Outro);
		}
	}

	private void StateMachine()
	{
		if (stateTimer > 0f)
		{
			stateTimer -= Time.deltaTime;
		}
		switch (state)
		{
		case State.Intro:
			StateIntro();
			break;
		case State.Idle:
			StateIdle();
			break;
		case State.Puke:
			StatePuke();
			break;
		case State.Outro:
			StateOutro();
			break;
		}
	}

	public void StateSet(State newState)
	{
		if (state != newState)
		{
			statePrev = state;
			state = newState;
			stateStart = true;
			stateTimer = 0f;
		}
	}

	private void PukeParticles(bool _play)
	{
		foreach (ParticleSystem pukeParticle in pukeParticles)
		{
			if (_play)
			{
				if (!pukeParticle.isPlaying)
				{
					pukeParticle.Play();
				}
			}
			else if (pukeParticle.isPlaying)
			{
				pukeParticle.Stop();
			}
		}
	}

	private void Update()
	{
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: 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_01b7: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: 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_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_039d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)playerTarget) && Object.op_Implicit((Object)(object)playerTarget.voiceChat))
		{
			playerTarget.voiceChat.OverrideClipLoudnessAnimationValue(loudnessAdd);
		}
		loudnessAdd = SemiFunc.SpringFloatGet(loudnessSpring, loudnessTarget, -1f);
		if (Object.op_Implicit((Object)(object)playerTarget))
		{
			Quaternion rotation = playerTarget.playerAvatarVisuals.playerEyes.eyeLeft.rotation;
			Quaternion rotation2 = playerTarget.playerAvatarVisuals.playerEyes.eyeRight.rotation;
			eyeTransforms[0].rotation = rotation;
			eyeTransforms[1].rotation = rotation2;
		}
		StateSynchingWithParentEnemy();
		StateMachine();
		otherTopJawTransform.localScale = Vector3.one * SemiFunc.SpringFloatGet(springFloatScale, scaleTarget, -1f);
		otherBotJawTransform.localScale = Vector3.one * SemiFunc.SpringFloatGet(springFloatScale, scaleTarget, -1f);
		if (Object.op_Implicit((Object)(object)playerTarget) && playerTarget.isLocal)
		{
			if (pukeTimer > 0f && ((Component)localParentTransform).gameObject.activeInHierarchy)
			{
				PukeParticles(_play: true);
				pukeTimer -= Time.deltaTime;
				pukeCapsuleTransform.localScale = Vector3.Lerp(pukeCapsuleTransform.localScale, Vector3.one, Time.deltaTime * 5f);
				Transform obj = pukeCapsuleTransform;
				obj.localScale += Vector3.one * Mathf.Sin(Time.time * 30f) * 0.01f;
				Transform obj2 = pukeCapsuleTransform;
				obj2.localScale += Vector3.one * Mathf.Sin(Time.time * 60f) * 0.01f;
				Vector2 textureOffset = ((Renderer)pukeCapsuleRenderer).material.GetTextureOffset("_MainTex");
				textureOffset.x -= Time.deltaTime * 1.5f;
				((Renderer)pukeCapsuleRenderer).material.SetTextureOffset("_MainTex", textureOffset);
				if (!((Component)pukeCapsuleTransform).gameObject.activeSelf)
				{
					pukeCapsuleTransform.localScale = Vector3.zero;
					((Component)pukeCapsuleTransform).gameObject.SetActive(true);
				}
			}
			else
			{
				PukeParticles(_play: false);
				pukeCapsuleTransform.localScale = Vector3.Lerp(pukeCapsuleTransform.localScale, Vector3.zero, Time.deltaTime * 5f);
				if (pukeCapsuleTransform.localScale.x < 0.01f && ((Component)pukeCapsuleTransform).gameObject.activeSelf)
				{
					pukeCapsuleTransform.localScale = Vector3.zero;
					((Component)pukeCapsuleTransform).gameObject.SetActive(false);
				}
			}
			localParentTransform.localPosition = SemiFunc.SpringVector3Get(jawPositionSpring, jawTargetPosition, -1f);
			topJawTransform.localRotation = SemiFunc.SpringQuaternionGet(topJawSpring, topJawTargetRotation, -1f);
			botJawTransform.localRotation = SemiFunc.SpringQuaternionGet(botJawSpring, botJawTargetRotation, -1f);
		}
		if (Object.op_Implicit((Object)(object)playerTarget) && playerTarget.isLocal)
		{
			bool flag = showDebug || playerTarget.localCamera.GetOverrideActive() || playerTarget.playerAvatarVisuals.showSelfOverrideTimer > 0f;
			((Component)localParentTransform).gameObject.SetActive(!flag);
			((Component)otherTopJawTransform).gameObject.SetActive(flag);
			((Component)otherBotJawTransform).gameObject.SetActive(flag);
		}
	}

	private void OnDisable()
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		if (Object.op_Implicit((Object)(object)playerTarget) && playerTarget.isDisabled)
		{
			if (Object.op_Implicit((Object)(object)mareo))
			{
				mareo.UpdateState(Mareo.State.Detach);
				Transform overrideTransform = playerTarget.localCamera.GetOverrideTransform();
				mareo.detachPosition = overrideTransform.position;
				mareo.detachRotation = overrideTransform.rotation;
			}
			Object.Destroy((Object)(object)((Component)otherTopJawTransform).gameObject);
			Object.Destroy((Object)(object)((Component)otherBotJawTransform).gameObject);
			Object.Destroy((Object)(object)((Component)localParentTransform).gameObject);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
public class MareoAttaching : MonoBehaviour
{
	internal Mareo mareo;

	public Transform tentaclesTransform;

	public List<Transform> eyeTransforms = new List<Transform>();

	public Transform topJaw;

	public Transform bottomJaw;

	public Transform particleTransform;

	private List<ParticleSystem> particleSystems = new List<ParticleSystem>();

	private Quaternion startRotationTopJaw;

	private Quaternion startRotationBottomJaw;

	private Transform targetTransform;

	public PlayerAvatar targetPlayerAvatar;

	private SpringQuaternion springQuaternion;

	private bool isActive;

	private Vector3 startPosition;

	private SpringFloat springFloatScale;

	private float targetScale = 1f;

	public GameObject localPlayerJaw;

	[Space(20f)]
	public Sound soundAttachVO;

	public Sound soundAttach;

	private void Start()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		springQuaternion = new SpringQuaternion();
		springQuaternion.damping = 0.5f;
		springQuaternion.speed = 20f;
		springFloatScale = new SpringFloat();
		springFloatScale.damping = 0.5f;
		springFloatScale.speed = 20f;
		startRotationTopJaw = topJaw.localRotation;
		startRotationBottomJaw = bottomJaw.localRotation;
		startPosition = ((Component)this).transform.position;
		particleSystems = new List<ParticleSystem>(((Component)particleTransform).GetComponentsInChildren<ParticleSystem>());
		GoTime();
	}

	public void GoTime()
	{
		//IL_0073: 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_00be: Unknown result type (might be due to invalid IL or missing references)
		PlayParticles(finalPlay: false);
		if (targetPlayerAvatar.isLocal)
		{
			CameraGlitch.Instance.PlayLong();
		}
		SetTarget(targetPlayerAvatar);
		springFloatScale.springVelocity = 50f;
		isActive = true;
		targetScale = 1f;
		GameDirector.instance.CameraShake.ShakeDistance(3f, 3f, 8f, ((Component)this).transform.position, 0.1f);
		GameDirector.instance.CameraImpact.ShakeDistance(2f, 3f, 8f, ((Component)this).transform.position, 0.1f);
		soundAttachVO.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
	}

	private void PlayParticles(bool finalPlay)
	{
		foreach (ParticleSystem particleSystem in particleSystems)
		{
			particleSystem.Play();
			if (finalPlay)
			{
				((Component)particleSystem).transform.parent = null;
				Object.Destroy((Object)(object)((Component)particleSystem).gameObject, 4f);
			}
		}
	}

	private void SpawnPlayerJaw()
	{
		//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)
		//IL_0033: 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_011c: 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_013e: 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_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Object.Instantiate<GameObject>(localPlayerJaw, ((Component)this).transform.position, Quaternion.identity, ((Component)targetPlayerAvatar.playerAvatarVisuals).transform);
		val.transform.localPosition = Vector3.zero;
		val.transform.localRotation = Quaternion.identity;
		MareoAttached component = val.GetComponent<MareoAttached>();
		component.mareo = mareo;
		component.playerTarget = targetPlayerAvatar;
		if (targetPlayerAvatar.isLocal)
		{
			component.localParentTransform.parent = ((Component)targetPlayerAvatar.localCamera).transform;
			((Object)((Component)component.localParentTransform).gameObject).name = "SlowMouthJawLocal";
			component.localParentTransform.localPosition = Vector3.zero;
			component.localParentTransform.localRotation = Quaternion.identity;
			((Component)component.localParentTransform).gameObject.SetActive(true);
		}
		Transform attachPointJawTop = targetPlayerAvatar.playerAvatarVisuals.attachPointJawTop;
		Transform attachPointJawBottom = targetPlayerAvatar.playerAvatarVisuals.attachPointJawBottom;
		component.otherTopJawTransform.parent = attachPointJawTop;
		component.otherTopJawTransform.localPosition = Vector3.zero;
		component.otherTopJawTransform.rotation = Quaternion.identity;
		component.otherTopJawTransform.localRotation = Quaternion.identity;
		component.otherBotJawTransform.parent = attachPointJawBottom;
		component.otherBotJawTransform.localPosition = Vector3.zero;
		component.otherBotJawTransform.rotation = Quaternion.identity;
		component.otherBotJawTransform.localRotation = Quaternion.identity;
		if (targetPlayerAvatar.isLocal)
		{
			UpdateLocalRenderers(component.otherTopJawTransform);
			UpdateLocalRenderers(component.otherBotJawTransform);
			if (!targetPlayerAvatar.localCamera.GetOverrideActive())
			{
				((Component)component.otherTopJawTransform).gameObject.SetActive(false);
				((Component)component.otherBotJawTransform).gameObject.SetActive(false);
			}
		}
	}

	private void UpdateLocalRenderers(Transform _transform)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		LayerMask val = LayerMask.op_Implicit(LayerMask.NameToLayer("PlayerVisualsLocal"));
		Renderer[] componentsInChildren = ((Component)_transform).GetComponentsInChildren<Renderer>();
		Renderer[] array = componentsInChildren;
		foreach (Renderer val2 in array)
		{
			if (Object.op_Implicit((Object)(object)val2))
			{
				((Component)val2).gameObject.layer = LayerMask.op_Implicit(val);
				val2.shadowCastingMode = targetPlayerAvatar.playerAvatarVisuals.localVisibility;
			}
		}
	}

	private void Update()
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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_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)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: 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_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		bool flag = !Object.op_Implicit((Object)(object)targetTransform) || !Object.op_Implicit((Object)(object)targetPlayerAvatar);
		if (!isActive)
		{
			return;
		}
		if (flag)
		{
			Detach();
			return;
		}
		Quaternion val = Quaternion.LookRotation(targetTransform.position - ((Component)this).transform.position);
		((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(springQuaternion, val, -1f);
		float num = SemiFunc.SpringFloatGet(springFloatScale, targetScale, -1f);
		((Component)this).transform.localScale = Vector3.one * num;
		float num2 = Vector3.Distance(((Component)this).transform.position, targetTransform.position);
		float num3 = num2 * 2f;
		if (num3 < 4f)
		{
			num3 = 4f;
		}
		if (num3 > 10f)
		{
			num3 = 10f;
		}
		((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, targetTransform.position, Time.deltaTime * num3);
		if (num2 < 1f)
		{
			targetScale = 2.5f;
		}
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			if (!Object.op_Implicit((Object)(object)mareo) || mareo.currentState != Mareo.State.Attack)
			{
				if (!targetPlayerAvatar.isDisabled && (!Object.op_Implicit((Object)(object)mareo) || !mareo.IsPossessed()))
				{
					AttachToPlayer();
				}
				else
				{
					Detach();
				}
			}
			if (targetPlayerAvatar.isLocal)
			{
				GameDirector.instance.CameraShake.Shake(4f, 0.1f);
			}
		}
		if (!SemiFunc.IsMasterClientOrSingleplayer())
		{
			return;
		}
		if (!targetPlayerAvatar.isDisabled && Object.op_Implicit((Object)(object)mareo) && !mareo.IsPossessed())
		{
			if (num2 < 0.1f)
			{
				AttachToPlayer();
				mareo.UpdateState(Mareo.State.Attached);
				isActive = false;
			}
		}
		else
		{
			Detach();
		}
		if (targetPlayerAvatar.isLocal)
		{
			CameraAim.Instance.AimTargetSet(((Component)this).transform.position, 0.2f, 20f, ((Component)this).gameObject, 100);
			CameraZoom.Instance.OverrideZoomSet(30f, 0.1f, 8f, 1f, ((Component)this).gameObject, 50);
		}
		tentaclesTransform.localScale = new Vector3(1f + Mathf.Sin(Time.time * 40f) * 0.2f, 1f + Mathf.Sin(Time.time * 60f) * 0.1f, 1f);
		tentaclesTransform.localRotation = Quaternion.Euler(0f, 0f, Mathf.Sin(Time.time * 20f) * 10f);
		topJaw.localRotation = startRotationTopJaw * Quaternion.Euler(Mathf.Sin(Time.time * 60f) * 3f, 0f, 0f);
		bottomJaw.localRotation = startRotationBottomJaw * Quaternion.Euler(Mathf.Sin(Time.time * 60f) * 10f, 0f, 0f);
		foreach (Transform eyeTransform in eyeTransforms)
		{
			eyeTransform.localScale = new Vector3(1.5f + Mathf.Sin(Time.time * 40f) * 0.5f, 1.5f + Mathf.Sin(Time.time * 60f) * 0.5f, 1.5f);
		}
	}

	private void AttachToPlayer()
	{
		if (!targetPlayerAvatar.isDisabled && !Object.op_Implicit((Object)(object)((Component)targetPlayerAvatar.playerAvatarVisuals).GetComponentInChildren<EnemySlowMouthAttached>()))
		{
			SpawnPlayerJaw();
			Despawn();
		}
	}

	private void Detach()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		soundAttach.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		PlayParticles(finalPlay: true);
		if (Object.op_Implicit((Object)(object)mareo) && SemiFunc.IsMasterClientOrSingleplayer())
		{
			mareo.detachPosition = ((Component)this).transform.position;
			mareo.detachRotation = ((Component)this).transform.rotation;
			mareo.UpdateState(Mareo.State.Detach);
		}
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}

	private void Despawn()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		soundAttach.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		PlayParticles(finalPlay: true);
		if (targetPlayerAvatar.isLocal)
		{
			GameDirector.instance.CameraImpact.Shake(8f, 0.1f);
			GameDirector.instance.CameraShake.Shake(5f, 0.1f);
			CameraGlitch.Instance.PlayLong();
		}
		else
		{
			GameDirector.instance.CameraShake.ShakeDistance(3f, 3f, 8f, ((Component)this).transform.position, 0.1f);
			GameDirector.instance.CameraImpact.ShakeDistance(2f, 3f, 8f, ((Component)this).transform.position, 0.1f);
		}
		Object.Destroy((Object)(object)((Component)this).gameObject);