Decompiled source of Gooby Enemy v1.0.1

Gooby\EmpressXenomorph.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Empress")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EmpressXenomorph")]
[assembly: AssemblyTitle("EmpressXenomorph")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EmpressXenomorph
{
	internal static class EmpressXenomorphAudioBank
	{
		private static readonly string[] SearchFolders = new string[2]
		{
			string.Empty,
			"Audio"
		};

		private static readonly string[] AmbienceNames = new string[1] { "ambience" };

		private static readonly string[] AttackNames = new string[3] { "alien_claw", "alien claw", "claw" };

		private static readonly string[] HurtNames = new string[1] { "hurt" };

		private static readonly string[] SeeNames = new string[1] { "see" };

		private static readonly string[] DigivolutionNames = new string[2] { "Digivolution", "digivolution" };

		private static readonly string[] Extensions = new string[5] { ".ogg", ".wav", ".mp3", ".WAV", ".MP3" };

		private static bool _started;

		private static bool _loaded;

		internal static AudioClip? AmbienceClip { get; private set; }

		internal static AudioClip? AttackClip { get; private set; }

		internal static AudioClip? HurtClip { get; private set; }

		internal static AudioClip? SeeClip { get; private set; }

		internal static AudioClip? DigivolutionClip { get; private set; }

		internal static bool Loaded => _loaded;

		internal static IEnumerator LoadAudioAsync(string pluginDirectory, ManualLogSource log)
		{
			if (!_started)
			{
				_started = true;
				yield return LoadClipAsync(pluginDirectory, AmbienceNames, delegate(AudioClip clip)
				{
					AmbienceClip = clip;
				}, log);
				yield return LoadClipAsync(pluginDirectory, AttackNames, delegate(AudioClip clip)
				{
					AttackClip = clip;
				}, log);
				yield return LoadClipAsync(pluginDirectory, HurtNames, delegate(AudioClip clip)
				{
					HurtClip = clip;
				}, log);
				yield return LoadClipAsync(pluginDirectory, SeeNames, delegate(AudioClip clip)
				{
					SeeClip = clip;
				}, log);
				yield return LoadClipAsync(pluginDirectory, DigivolutionNames, delegate(AudioClip clip)
				{
					DigivolutionClip = clip;
				}, log);
				_loaded = true;
				log.LogInfo((object)$"Gooby audio load complete. ambience={(Object)(object)AmbienceClip != (Object)null}, attack={(Object)(object)AttackClip != (Object)null}, hurt={(Object)(object)HurtClip != (Object)null}, see={(Object)(object)SeeClip != (Object)null}, digivolution={(Object)(object)DigivolutionClip != (Object)null}");
			}
		}

		private static IEnumerator LoadClipAsync(string pluginDirectory, IReadOnlyList<string> names, Action<AudioClip> assign, ManualLogSource log)
		{
			string path = ResolveClipPath(pluginDirectory, names);
			if (string.IsNullOrEmpty(path))
			{
				yield break;
			}
			AudioType audioType = GetAudioType(path);
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, audioType);
			try
			{
				yield return request.SendWebRequest();
				if ((int)request.result != 1)
				{
					log.LogWarning((object)("Failed to load Gooby audio clip from " + path + ": " + request.error));
					yield break;
				}
				AudioClip content = DownloadHandlerAudioClip.GetContent(request);
				((Object)content).name = Path.GetFileNameWithoutExtension(path);
				((Object)content).hideFlags = (HideFlags)61;
				assign(content);
			}
			finally
			{
				((IDisposable)request)?.Dispose();
			}
		}

		private static string? ResolveClipPath(string pluginDirectory, IReadOnlyList<string> names)
		{
			string[] searchFolders = SearchFolders;
			foreach (string text in searchFolders)
			{
				string text2 = (string.IsNullOrEmpty(text) ? pluginDirectory : Path.Combine(pluginDirectory, text));
				if (!Directory.Exists(text2))
				{
					continue;
				}
				foreach (string name in names)
				{
					string[] extensions = Extensions;
					foreach (string text3 in extensions)
					{
						string text4 = Path.Combine(text2, name + text3);
						if (File.Exists(text4))
						{
							return text4;
						}
					}
				}
			}
			return null;
		}

		private static AudioType GetAudioType(string path)
		{
			//IL_002a: 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_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)
			string text = Path.GetExtension(path).ToLowerInvariant();
			if (!(text == ".wav"))
			{
				if (text == ".mp3")
				{
					return (AudioType)13;
				}
				return (AudioType)14;
			}
			return (AudioType)20;
		}
	}
	internal sealed class EmpressXenomorphAudioController : MonoBehaviour
	{
		private AudioSource _ambienceSource;

		private AudioSource _voiceSource;

		private AudioSource _combatSource;

		private AudioSource _transformSource;

		private bool _built;

		private bool _clipsAssigned;

		private float _ambienceTargetVolume;

		private float _transformTargetVolume;

		internal bool Ready => _built;

		internal void Build()
		{
			if (_built)
			{
				EnsureAudioRouting();
				EnsureClipsAssigned();
				return;
			}
			_ambienceSource = CreateSource("EmpressXenoAmbience", loop: true, 4f, 20f, 0.4f);
			_voiceSource = CreateSource("EmpressXenoVoice", loop: false, 3f, 18f, 0.4f);
			_combatSource = CreateSource("EmpressXenoCombat", loop: false, 2.5f, 15f, 0.4f);
			_transformSource = CreateSource("GoobyDigivolve", loop: true, 2f, 8f, 0.8f);
			_transformSource.spatialBlend = 0f;
			_transformSource.priority = 72;
			_transformSource.volume = 0f;
			_built = true;
			EnsureAudioRouting();
			EnsureClipsAssigned();
		}

		internal void SetAmbienceLevel(float amount)
		{
			_ambienceTargetVolume = Mathf.Clamp01(amount) * EmpressXenomorphPlugin.EnemySoundVolume;
			if (_ambienceTargetVolume > 0.01f)
			{
				EnsureClipsAssigned();
				if ((Object)(object)_ambienceSource.clip != (Object)null && !_ambienceSource.isPlaying)
				{
					_ambienceSource.volume = 0f;
					_ambienceSource.time = 0f;
					_ambienceSource.Play();
				}
			}
		}

		internal void PlayAttack()
		{
			EnsureClipsAssigned();
			if (!((Object)(object)_combatSource.clip == (Object)null))
			{
				_combatSource.pitch = Random.Range(0.95f, 1.06f);
				_combatSource.PlayOneShot(_combatSource.clip, 1f);
			}
		}

		internal void PlayHurt()
		{
			EnsureClipsAssigned();
			if (!((Object)(object)EmpressXenomorphAudioBank.HurtClip == (Object)null))
			{
				_voiceSource.pitch = Random.Range(0.93f, 1.03f);
				_voiceSource.PlayOneShot(EmpressXenomorphAudioBank.HurtClip, 1f);
			}
		}

		internal void PlaySee()
		{
			EnsureClipsAssigned();
			if (!((Object)(object)EmpressXenomorphAudioBank.SeeClip == (Object)null))
			{
				_voiceSource.pitch = Random.Range(0.97f, 1.04f);
				_voiceSource.PlayOneShot(EmpressXenomorphAudioBank.SeeClip, 1f);
			}
		}

		internal void SetTransformationActive(bool active)
		{
			_transformTargetVolume = ((active && (Object)(object)EmpressXenomorphAudioBank.DigivolutionClip != (Object)null) ? EmpressXenomorphPlugin.DigivolutionVolume : 0f);
			if (!(_transformTargetVolume <= 0.001f))
			{
				EnsureClipsAssigned();
				if ((Object)(object)_transformSource.clip != (Object)null && !_transformSource.isPlaying)
				{
					_transformSource.volume = 0f;
					_transformSource.time = 0f;
					_transformSource.Play();
				}
			}
		}

		internal void StopAll()
		{
			_ambienceTargetVolume = 0f;
			_transformTargetVolume = 0f;
			if (_ambienceSource.isPlaying)
			{
				_ambienceSource.Stop();
			}
			if (_voiceSource.isPlaying)
			{
				_voiceSource.Stop();
			}
			if (_combatSource.isPlaying)
			{
				_combatSource.Stop();
			}
			if (_transformSource.isPlaying)
			{
				_transformSource.Stop();
			}
		}

		private void Update()
		{
			if (_built)
			{
				EnsureAudioRouting();
				EnsureClipsAssigned();
				_ambienceSource.volume = Mathf.MoveTowards(_ambienceSource.volume, _ambienceTargetVolume, 1.8f * Time.deltaTime);
				_transformSource.volume = Mathf.MoveTowards(_transformSource.volume, _transformTargetVolume, 1.8f * Time.deltaTime);
				if (_ambienceTargetVolume <= 0.001f && _ambienceSource.isPlaying && _ambienceSource.volume <= 0.001f)
				{
					_ambienceSource.Stop();
				}
				if (_transformTargetVolume <= 0.001f && _transformSource.isPlaying && _transformSource.volume <= 0.001f)
				{
					_transformSource.Stop();
				}
			}
		}

		private void EnsureClipsAssigned()
		{
			if (!_clipsAssigned && (!((Object)(object)EmpressXenomorphAudioBank.AmbienceClip == (Object)null) || !((Object)(object)EmpressXenomorphAudioBank.AttackClip == (Object)null) || !((Object)(object)EmpressXenomorphAudioBank.HurtClip == (Object)null) || !((Object)(object)EmpressXenomorphAudioBank.SeeClip == (Object)null) || !((Object)(object)EmpressXenomorphAudioBank.DigivolutionClip == (Object)null)))
			{
				_ambienceSource.clip = EmpressXenomorphAudioBank.AmbienceClip;
				_combatSource.clip = EmpressXenomorphAudioBank.AttackClip;
				_transformSource.clip = EmpressXenomorphAudioBank.DigivolutionClip;
				_clipsAssigned = true;
			}
		}

		private void EnsureAudioRouting()
		{
			AudioMixerGroup val = (((Object)(object)AudioManager.instance != (Object)null) ? AudioManager.instance.SoundMasterGroup : null);
			if (!((Object)(object)val == (Object)null))
			{
				_ambienceSource.outputAudioMixerGroup = val;
				_voiceSource.outputAudioMixerGroup = val;
				_combatSource.outputAudioMixerGroup = val;
				_transformSource.outputAudioMixerGroup = val;
			}
		}

		private AudioSource CreateSource(string name, bool loop, float minDistance, float maxDistance, float baseVolume)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = ((Component)this).gameObject.layer
			};
			val.transform.SetParent(((Component)this).transform, false);
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.playOnAwake = false;
			obj.loop = loop;
			obj.volume = (loop ? 0f : baseVolume);
			obj.spatialBlend = 1f;
			obj.rolloffMode = (AudioRolloffMode)0;
			obj.minDistance = minDistance;
			obj.maxDistance = maxDistance;
			obj.dopplerLevel = 0f;
			obj.reverbZoneMix = 1f;
			obj.priority = 90;
			obj.spread = 20f;
			return obj;
		}
	}
	internal static class EmpressXenomorphBundle
	{
		private const string PreferredPrefabName = "PingForBitch";

		private static AssetBundle? _bundle;

		private static GameObject? _prefab;

		internal static GameObject? LoadPrefab()
		{
			if ((Object)(object)_prefab != (Object)null)
			{
				return _prefab;
			}
			string text = Path.Combine(EmpressXenomorphPlugin.PluginDirectory, "xeno");
			if (!File.Exists(text))
			{
				EmpressXenomorphPlugin.Log.LogError((object)("Missing Gooby bundle at '" + text + "'."));
				return null;
			}
			if (_bundle == null)
			{
				_bundle = AssetBundle.LoadFromFile(text);
			}
			if ((Object)(object)_bundle == (Object)null)
			{
				EmpressXenomorphPlugin.Log.LogError((object)"Failed to load the Gooby asset bundle.");
				return null;
			}
			((Object)_bundle).hideFlags = (HideFlags)61;
			_prefab = (from gameObject in _bundle.LoadAllAssets<GameObject>()
				where (Object)(object)gameObject != (Object)null && HasUsableVisual(gameObject)
				select gameObject).OrderByDescending(GetPrefabScore).FirstOrDefault();
			if ((Object)(object)_prefab == (Object)null)
			{
				string text2 = string.Join(", ", _bundle.GetAllAssetNames());
				EmpressXenomorphPlugin.Log.LogError((object)("No usable animated Gooby prefab was found in the bundle. Assets: " + text2));
				return null;
			}
			EmpressXenomorphPlugin.Log.LogInfo((object)("Loaded Gooby prefab '" + ((Object)_prefab).name + "' from bundle 'xeno'."));
			return _prefab;
		}

		internal static Animator? FindPreferredAnimator(Transform root)
		{
			Animator[] componentsInChildren = ((Component)root).GetComponentsInChildren<Animator>(true);
			Animator val = ((IEnumerable<Animator>)componentsInChildren).FirstOrDefault((Func<Animator, bool>)((Animator animator) => (Object)(object)animator != (Object)null && ((Object)((Component)animator).gameObject).name.IndexOf("XenoAnimator", StringComparison.OrdinalIgnoreCase) >= 0 && (Object)(object)animator.runtimeAnimatorController != (Object)null));
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Animator val2 = ((IEnumerable<Animator>)componentsInChildren).FirstOrDefault((Func<Animator, bool>)((Animator animator) => (Object)(object)animator != (Object)null && (Object)(object)animator.runtimeAnimatorController != (Object)null));
			if ((Object)(object)val2 != (Object)null)
			{
				return val2;
			}
			return ((IEnumerable<Animator>)componentsInChildren).FirstOrDefault((Func<Animator, bool>)((Animator animator) => (Object)(object)animator != (Object)null));
		}

		private static bool HasUsableVisual(GameObject prefab)
		{
			if (prefab.GetComponentsInChildren<Renderer>(true).Length != 0)
			{
				return (Object)(object)FindPreferredAnimator(prefab.transform) != (Object)null;
			}
			return false;
		}

		private static int GetPrefabScore(GameObject prefab)
		{
			int num = prefab.GetComponentsInChildren<Renderer>(true).Length;
			int num2 = prefab.GetComponentsInChildren<Animator>(true).Length;
			int num3 = num * 100 + num2 * 25;
			if (string.Equals(((Object)prefab).name, "PingForBitch", StringComparison.OrdinalIgnoreCase))
			{
				num3 += 5000;
			}
			if (((Object)prefab).name.IndexOf("xeno", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				num3 += 1000;
			}
			if (((Object)prefab).name.IndexOf("drone", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				num3 += 250;
			}
			return num3;
		}
	}
	internal sealed class EmpressXenomorphBrain : MonoBehaviour, IPunObservable
	{
		private const float SpawnIntroTime = 0.65f;

		private const float PassiveDecisionInterval = 1.3f;

		private const float PassiveSpeed = 1.85f;

		private const float PassiveAcceleration = 12f;

		private const float HurtRecoverTime = 0.95f;

		private const float HurtCooldown = 0.2f;

		private const float HurtRagdollImpulse = 6.5f;

		private const float PursueSpeed = 5.6f;

		private const float PursueAcceleration = 28f;

		private const float PursueHeight = 1.75f;

		private const float PursueCatchDistance = 2.2f;

		private const float PursueCatchHorizontalDistance = 1.7f;

		private const float PursueCatchVerticalDistance = 2.4f;

		private const float CarryDuration = 5f;

		private const float CarrySpeed = 6.35f;

		private const float CarryAcceleration = 34f;

		private const float CarryDecisionInterval = 0.65f;

		private const float CarryForce = 24f;

		private const float CarryRotationForce = 3.2f;

		private const float ThrowWindupTime = 0.2f;

		private const float ThrowForce = 42f;

		private const float ThrowTorque = 18f;

		private const float FusionCooldown = 15f;

		private const float FusionChargeTime = 4.6f;

		private const float FusionMonsterTime = 7.4f;

		private const float FusionMonsterSpeed = 4.65f;

		private const float FusionMonsterAcceleration = 26f;

		private const float FusionSmashWindup = 0.45f;

		private const float FusionSmashReach = 2.9f;

		private const int FusionSmashDamage = 999;

		private const float RetreatTime = 3.8f;

		private const float RetreatSpeed = 5.1f;

		private const float RetreatAcceleration = 24f;

		private const float VisionFreezeTime = 0.15f;

		private const float DoorCheckInterval = 0.08f;

		private const float BodyPushInterval = 0.08f;

		private const float DoorPushCooldown = 0.45f;

		private const float DoorPushForce = 3.6f;

		private const float DoorPushTorque = 3f;

		private const float BodyPushForce = 4.5f;

		private const float SeeSoundCooldown = 4f;

		private static readonly Dictionary<int, float> DoorPushCooldowns = new Dictionary<int, float>();

		private EnemyParent _enemyParent;

		private Enemy _enemy;

		private EnemyNavMeshAgent _enemyNavMeshAgent;

		private EmpressXenomorphVisual _visual;

		private EmpressXenomorphAudioController _audio;

		private Transform _centerTransform;

		private NavMeshAgent _navMeshAgent;

		private Rigidbody _bodyRigidbody;

		private EmpressXenomorphState _state;

		private PlayerAvatar? _targetPlayer;

		private PlayerAvatar? _carriedPlayer;

		private Quaternion _networkRotation;

		private Vector3 _moveDestination;

		private Vector3 _lastPosition;

		private float _stateTimer;

		private float _decisionTimer;

		private float _hurtReactionTimer;

		private float _fusionCooldownTimer;

		private float _doorCheckTimer;

		private float _bodyPushTimer;

		private float _seeSoundTimer;

		private float _carryTimer;

		private float _localVelX;

		private float _localVelZ;

		private int _networkTargetViewId = -1;

		private int _networkCarriedViewId = -1;

		private int _attackAudioSerial;

		private int _hurtAudioSerial;

		private int _seeAudioSerial;

		private int _remoteAttackAudioSerial;

		private int _remoteHurtAudioSerial;

		private int _remoteSeeAudioSerial;

		private int _playedAttackAudioSerial;

		private int _playedHurtAudioSerial;

		private int _playedSeeAudioSerial;

		private bool _spawnInitialized;

		private bool _initialized;

		private bool _fusionPending;

		private bool _fusionSmashApplied;

		private bool _wasStunned;

		private bool _throwApplied;

		private bool _ragdollActive;

		internal void Initialize(EnemyParent enemyParent, Enemy enemy, EnemyNavMeshAgent enemyNavMeshAgent, EmpressXenomorphVisual visual, EmpressXenomorphAudioController audio, Transform centerTransform)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			_enemyParent = enemyParent;
			_enemy = enemy;
			_enemyNavMeshAgent = enemyNavMeshAgent;
			_visual = visual;
			_audio = audio;
			_centerTransform = centerTransform;
			_navMeshAgent = RepoEnemyAccess.GetAgent(enemyNavMeshAgent);
			_bodyRigidbody = ((Component)this).GetComponent<Rigidbody>();
			_networkRotation = ((Component)this).transform.rotation;
			_lastPosition = ((Component)this).transform.position;
			_initialized = true;
		}

		internal void HandleSpawnEvent()
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			if (_initialized && EnsureRuntimeReady())
			{
				EndHurtRecoverPhysics();
				_state = EmpressXenomorphState.SpawnIntro;
				_stateTimer = 0.65f;
				_decisionTimer = 0f;
				_hurtReactionTimer = 0f;
				_fusionCooldownTimer = 0f;
				_doorCheckTimer = 0f;
				_seeSoundTimer = 0f;
				_carryTimer = 0f;
				_targetPlayer = null;
				_carriedPlayer = null;
				_fusionPending = false;
				_fusionSmashApplied = false;
				_throwApplied = false;
				_spawnInitialized = true;
				_wasStunned = false;
				_moveDestination = ((Component)this).transform.position;
				_networkTargetViewId = -1;
				_networkCarriedViewId = -1;
				_attackAudioSerial = 0;
				_hurtAudioSerial = 0;
				_seeAudioSerial = 0;
				_remoteAttackAudioSerial = 0;
				_remoteHurtAudioSerial = 0;
				_remoteSeeAudioSerial = 0;
				_playedAttackAudioSerial = 0;
				_playedHurtAudioSerial = 0;
				_playedSeeAudioSerial = 0;
				RepoEnemyAccess.SetTargetPlayer(_enemy, null, -1);
				_enemy.CurrentState = (EnemyState)1;
				HardStopAgent(0.1f);
				_audio.StopAll();
			}
		}

		internal void HandleHurt()
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if (!_initialized || !_spawnInitialized || _hurtReactionTimer > 0f || _state == EmpressXenomorphState.Death || _state == EmpressXenomorphState.Throw || (GameManager.Multiplayer() && !RepoEnemyAccess.GetMasterClient(_enemy)))
			{
				return;
			}
			EnemyHealth health = RepoEnemyAccess.GetHealth(_enemy);
			if ((Object)(object)health != (Object)null && (RepoEnemyAccess.GetEnemyHealthDeadImpulse(health) || RepoEnemyAccess.GetEnemyHealthDead(health)))
			{
				return;
			}
			if (_state == EmpressXenomorphState.FusionCharge)
			{
				if ((Object)(object)health != (Object)null)
				{
					RepoEnemyAccess.InvokeEnemyHealthDeath(health, ((Component)this).transform.forward);
				}
			}
			else if (_state != EmpressXenomorphState.FusionMonster && _state != EmpressXenomorphState.FusionSmash)
			{
				_hurtReactionTimer = 0.2f;
				TriggerHurtAudio();
				_targetPlayer = GetRandomValidPlayer();
				if ((Object)(object)_targetPlayer == (Object)null)
				{
					EnterRetreat();
					return;
				}
				_fusionPending = _fusionCooldownTimer <= 0f && Random.value < EmpressXenomorphPlugin.FusionChanceRatio;
				EnterHurtRecover();
			}
		}

		internal void HandleDeathStart()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (_initialized)
			{
				_state = EmpressXenomorphState.Death;
				_stateTimer = _visual.GetDeathDuration();
				_decisionTimer = 0f;
				_carryTimer = 0f;
				_fusionPending = false;
				_fusionSmashApplied = false;
				_throwApplied = true;
				_targetPlayer = null;
				_carriedPlayer = null;
				EndHurtRecoverPhysics();
				_enemy.CurrentState = (EnemyState)9;
				HardStopAgent(0.1f);
				_audio.StopAll();
			}
		}

		internal void HandleDeath()
		{
			if (_initialized)
			{
				_audio.StopAll();
				HardStopAgent(0.1f);
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					_enemyParent.Despawn();
				}
			}
		}

		private void Update()
		{
			//IL_00f1: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00aa: 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 (_initialized && _spawnInitialized && IsGameplayReady())
			{
				EnemyHealth health = RepoEnemyAccess.GetHealth(_enemy);
				if ((Object)(object)health != (Object)null && (RepoEnemyAccess.GetEnemyHealthDeadImpulse(health) || RepoEnemyAccess.GetEnemyHealthDead(health)))
				{
					_state = EmpressXenomorphState.Death;
					EndHurtRecoverPhysics();
					HardStopAgent(0.1f);
					UpdateVisuals();
					UpdateAudio();
					_lastPosition = ((Component)this).transform.position;
				}
				else if (GameManager.Multiplayer() && !RepoEnemyAccess.GetMasterClient(_enemy))
				{
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, _networkRotation, Time.deltaTime * 14f);
					UpdateRemoteTargets();
					UpdateVisuals();
					UpdateAudio();
					_lastPosition = ((Component)this).transform.position;
				}
				else
				{
					TickHostLogic();
					UpdateVisuals();
					UpdateAudio();
					_lastPosition = ((Component)this).transform.position;
				}
			}
		}

		private void FixedUpdate()
		{
			if (_initialized && _spawnInitialized && IsGameplayReady() && (!GameManager.Multiplayer() || RepoEnemyAccess.GetMasterClient(_enemy)) && _state == EmpressXenomorphState.Carry)
			{
				CarryVictimPhysics();
			}
		}

		private void TickHostLogic()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			if (!RepoEnemyAccess.GetSpawned(_enemyParent))
			{
				HardStopAgent(0.1f);
				return;
			}
			if ((int)_enemy.CurrentState == 11)
			{
				HardStopAgent(0.1f);
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					_enemyParent.Despawn();
				}
				return;
			}
			if (_hurtReactionTimer > 0f)
			{
				_hurtReactionTimer -= Time.deltaTime;
			}
			if (_fusionCooldownTimer > 0f)
			{
				_fusionCooldownTimer -= Time.deltaTime;
			}
			if (_doorCheckTimer > 0f)
			{
				_doorCheckTimer -= Time.deltaTime;
			}
			if (_bodyPushTimer > 0f)
			{
				_bodyPushTimer -= Time.deltaTime;
			}
			if (_seeSoundTimer > 0f)
			{
				_seeSoundTimer -= Time.deltaTime;
			}
			if (_stateTimer > 0f)
			{
				_stateTimer -= Time.deltaTime;
			}
			if (_decisionTimer > 0f)
			{
				_decisionTimer -= Time.deltaTime;
			}
			if (_enemy.IsStunned())
			{
				_state = EmpressXenomorphState.Stunned;
				_enemy.CurrentState = (EnemyState)9;
				HardStopAgent(0.1f);
				_wasStunned = true;
				SyncNetworkState();
				return;
			}
			if (_wasStunned)
			{
				_wasStunned = false;
				EnterPassive();
			}
			switch (_state)
			{
			case EmpressXenomorphState.SpawnIntro:
				TickSpawnIntro();
				break;
			case EmpressXenomorphState.Passive:
				TickPassive();
				break;
			case EmpressXenomorphState.HurtRecover:
				TickHurtRecover();
				break;
			case EmpressXenomorphState.Pursue:
				TickPursue();
				break;
			case EmpressXenomorphState.Carry:
				TickCarry();
				break;
			case EmpressXenomorphState.Throw:
				TickThrow();
				break;
			case EmpressXenomorphState.FusionCharge:
				TickFusionCharge();
				break;
			case EmpressXenomorphState.FusionMonster:
				TickFusionMonster();
				break;
			case EmpressXenomorphState.FusionSmash:
				TickFusionSmash();
				break;
			case EmpressXenomorphState.Retreat:
				TickRetreat();
				break;
			case EmpressXenomorphState.Stunned:
				EnterPassive();
				break;
			case EmpressXenomorphState.Death:
				TickDeath();
				break;
			}
			SyncNetworkState();
		}

		private void TickSpawnIntro()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			_enemy.CurrentState = (EnemyState)1;
			HardStopAgent(0.1f);
			if (_stateTimer <= 0f && !SemiFunc.EnemySpawnIdlePause())
			{
				EnterPassive();
			}
		}

		private void TickPassive()
		{
			//IL_0007: 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_0052: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			_enemy.CurrentState = (EnemyState)2;
			if (SemiFunc.EnemySpawnIdlePause())
			{
				HardStopAgent(0.1f);
				return;
			}
			if (((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh && _navMeshAgent.hasPath && Vector3.Distance(((Component)this).transform.position, _moveDestination) > 1f)
			{
				Vector3 desiredVelocity = _navMeshAgent.desiredVelocity;
				if (((Vector3)(ref desiredVelocity)).sqrMagnitude > 0.04f)
				{
					FaceTravelDirection(6f);
					TryPushDoorsForBody();
					TryPushPhysicsObjectsForBody();
					return;
				}
			}
			if (_decisionTimer > 0f)
			{
				FaceTravelDirection(6f);
				TryPushDoorsForBody();
				TryPushPhysicsObjectsForBody();
			}
			else
			{
				_decisionTimer = 1.3f;
				_moveDestination = FindPassiveDestination();
				SetMoveDestination(_moveDestination, 1.85f, 12f, 0.9f);
				FacePosition(_moveDestination, 6f);
			}
		}

		private void TickHurtRecover()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			_enemy.CurrentState = (EnemyState)9;
			HardStopAgent(0.1f);
			if (_stateTimer > 0f)
			{
				return;
			}
			EndHurtRecoverPhysics();
			if ((Object)(object)_targetPlayer != (Object)null && IsTargetValid(_targetPlayer))
			{
				if (_fusionPending)
				{
					EnterFusionCharge(_targetPlayer);
				}
				else
				{
					EnterPursue(_targetPlayer);
				}
			}
			else
			{
				EnterRetreat();
			}
		}

		private void TickPursue()
		{
			//IL_0029: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_00ca: 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_00d1: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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)
			if ((Object)(object)_targetPlayer == (Object)null || !IsTargetValid(_targetPlayer))
			{
				EnterRetreat();
				return;
			}
			_enemy.CurrentState = (EnemyState)4;
			Transform targetTransform = GetTargetTransform(_targetPlayer);
			Vector3 val = targetTransform.position + Vector3.up * 1.75f;
			if (CanCatchTarget(targetTransform, val))
			{
				HardStopAgent(0.05f);
				EnterCarry(_targetPlayer);
				return;
			}
			if (_decisionTimer <= 0f || Vector3.Distance(_moveDestination, val) > 1.2f || (((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh && !_navMeshAgent.hasPath))
			{
				_decisionTimer = 0.08f;
				_moveDestination = SampleNavMeshPosition(val, 2.2f, val);
			}
			SetMoveDestination(_moveDestination, 5.6f, 28f, 0.15f);
			FacePosition(targetTransform.position, 14f);
			TryPushDoorsForBody();
			TryPushPhysicsObjectsForBody();
		}

		private void TickCarry()
		{
			//IL_0029: 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_00a3: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_carriedPlayer == (Object)null || !IsTargetValid(_carriedPlayer))
			{
				EnterRetreat();
				return;
			}
			_enemy.CurrentState = (EnemyState)4;
			_carryTimer -= Time.deltaTime;
			if (_decisionTimer <= 0f || Vector3.Distance(((Component)this).transform.position, _moveDestination) <= 1.5f || (((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh && !_navMeshAgent.hasPath))
			{
				_decisionTimer = 0.65f;
				_moveDestination = FindCarryDestination();
			}
			SetMoveDestination(_moveDestination, 6.35f, 34f, 0.8f);
			FaceTravelDirection(12f);
			TryPushDoorsForBody();
			TryPushPhysicsObjectsForBody();
			if (_carryTimer <= 0f)
			{
				EnterThrow();
			}
		}

		private void TickThrow()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			_enemy.CurrentState = (EnemyState)3;
			HardStopAgent(0.12f);
			if (!_throwApplied)
			{
				_throwApplied = true;
				TriggerAttackAudio();
				ThrowVictim();
			}
			if (_stateTimer <= 0f)
			{
				EnterRetreat();
			}
		}

		private void TickFusionCharge()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			_enemy.CurrentState = (EnemyState)3;
			HardStopAgent(0.08f);
			if ((Object)(object)_targetPlayer != (Object)null && IsTargetValid(_targetPlayer))
			{
				FacePosition(((Component)_targetPlayer).transform.position, 6f);
			}
			if (_stateTimer <= 0f)
			{
				EnterFusionMonster();
			}
		}

		private void TickFusionMonster()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_targetPlayer == (Object)null || !IsTargetValid(_targetPlayer))
			{
				_targetPlayer = GetRandomValidPlayer();
				if ((Object)(object)_targetPlayer == (Object)null)
				{
					EnterRetreat();
					return;
				}
			}
			_enemy.CurrentState = (EnemyState)4;
			Transform targetTransform = GetTargetTransform(_targetPlayer);
			Vector3 position = targetTransform.position;
			if (_decisionTimer <= 0f || Vector3.Distance(_moveDestination, position) > 1.35f || (((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh && !_navMeshAgent.hasPath))
			{
				_decisionTimer = 0.08f;
				_moveDestination = SampleNavMeshPosition(position, 2.4f, position);
			}
			SetMoveDestination(_moveDestination, 4.65f, 26f, 0.35f);
			FacePosition(targetTransform.position, 15f);
			TryPushDoorsForBody();
			TryPushPhysicsObjectsForBody();
			if (Vector3.Distance(_centerTransform.position, targetTransform.position) <= 2.9f)
			{
				EnterFusionSmash();
			}
			else if (_stateTimer <= 0f)
			{
				EnterRetreat();
			}
		}

		private void TickFusionSmash()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			_enemy.CurrentState = (EnemyState)3;
			HardStopAgent(0.15f);
			if ((Object)(object)_targetPlayer != (Object)null && IsTargetValid(_targetPlayer))
			{
				FacePosition(((Component)_targetPlayer).transform.position, 10f);
			}
			if (!_fusionSmashApplied && _stateTimer <= 0.2475f)
			{
				_fusionSmashApplied = true;
				TriggerAttackAudio();
				if ((Object)(object)_targetPlayer != (Object)null && IsTargetValid(_targetPlayer))
				{
					Transform targetTransform = GetTargetTransform(_targetPlayer);
					if (Vector3.Distance(_centerTransform.position, targetTransform.position) <= 3.5f)
					{
						_targetPlayer.playerHealth.HurtOther(999, ((Component)_targetPlayer).transform.position, false, -1);
						_targetPlayer.PlayerDeath(-1);
						_targetPlayer.EnemyVisionFreezeTimerSet(0.6f);
					}
				}
			}
			if (_stateTimer <= 0f)
			{
				EnterRetreat();
			}
		}

		private void TickRetreat()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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)
			_enemy.CurrentState = (EnemyState)8;
			if (_stateTimer <= 0f)
			{
				EnterPassive();
				return;
			}
			bool flag = Vector3.Distance(((Component)this).transform.position, _moveDestination) <= 1.65f || (((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh && !_navMeshAgent.hasPath) || DistanceToClosestPlayer(((Component)this).transform.position) < 10f;
			if (_decisionTimer <= 0f || flag)
			{
				_decisionTimer = 0.45f;
				_moveDestination = FindRetreatDestination();
			}
			SetMoveDestination(_moveDestination, 5.1f, 24f, 1f);
			FaceTravelDirection(12f);
			TryPushDoorsForBody();
			TryPushPhysicsObjectsForBody();
		}

		private void TickDeath()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			_enemy.CurrentState = (EnemyState)9;
			HardStopAgent(0.1f);
		}

		private void EnterPassive()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			EndHurtRecoverPhysics();
			_state = EmpressXenomorphState.Passive;
			_stateTimer = 0f;
			_decisionTimer = 0f;
			_carryTimer = 0f;
			_fusionPending = false;
			_fusionSmashApplied = false;
			_targetPlayer = null;
			_carriedPlayer = null;
			_throwApplied = false;
			_enemy.CurrentState = (EnemyState)2;
			RepoEnemyAccess.SetTargetPlayer(_enemy, null, -1);
		}

		private void EnterHurtRecover()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			_state = EmpressXenomorphState.HurtRecover;
			_stateTimer = 0.95f;
			_decisionTimer = 0f;
			_carryTimer = 0f;
			_fusionSmashApplied = false;
			_carriedPlayer = null;
			_throwApplied = false;
			_enemy.CurrentState = (EnemyState)9;
			StartHurtRecoverPhysics();
		}

		private void EnterPursue(PlayerAvatar player)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			EndHurtRecoverPhysics();
			_state = EmpressXenomorphState.Pursue;
			_stateTimer = 0f;
			_decisionTimer = 0f;
			_carryTimer = 0f;
			_fusionPending = false;
			_fusionSmashApplied = false;
			_targetPlayer = player;
			_carriedPlayer = null;
			_throwApplied = false;
			_enemy.CurrentState = (EnemyState)4;
			TryTriggerSeeAudio();
		}

		private void EnterCarry(PlayerAvatar player)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			_state = EmpressXenomorphState.Carry;
			_stateTimer = 0f;
			_decisionTimer = 0f;
			_carryTimer = 5f;
			_fusionPending = false;
			_fusionSmashApplied = false;
			_targetPlayer = player;
			_carriedPlayer = player;
			_throwApplied = false;
			_enemy.CurrentState = (EnemyState)4;
			_moveDestination = FindCarryDestination();
			HardStopAgent(0.05f);
			player.tumble.TumbleRequest(true, false);
			player.tumble.TumbleOverrideTime(1f);
			player.EnemyVisionFreezeTimerSet(0.15f);
		}

		private void EnterThrow()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			_state = EmpressXenomorphState.Throw;
			_stateTimer = 0.2f;
			_decisionTimer = 0f;
			_fusionPending = false;
			_fusionSmashApplied = false;
			_enemy.CurrentState = (EnemyState)3;
			_throwApplied = false;
			HardStopAgent(0.12f);
		}

		private void EnterFusionCharge(PlayerAvatar player)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			EndHurtRecoverPhysics();
			_state = EmpressXenomorphState.FusionCharge;
			_stateTimer = 4.6f;
			_decisionTimer = 0f;
			_carryTimer = 0f;
			_fusionPending = false;
			_fusionSmashApplied = false;
			_targetPlayer = player;
			_carriedPlayer = null;
			_throwApplied = false;
			_enemy.CurrentState = (EnemyState)3;
			HardStopAgent(0.08f);
			TryTriggerSeeAudio();
		}

		private void EnterFusionMonster()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			_state = EmpressXenomorphState.FusionMonster;
			_stateTimer = 7.4f;
			_decisionTimer = 0f;
			_carryTimer = 0f;
			_fusionCooldownTimer = 15f;
			_fusionPending = false;
			_fusionSmashApplied = false;
			_carriedPlayer = null;
			_throwApplied = false;
			_enemy.CurrentState = (EnemyState)4;
		}

		private void EnterFusionSmash()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			_state = EmpressXenomorphState.FusionSmash;
			_stateTimer = 0.45f;
			_decisionTimer = 0f;
			_fusionSmashApplied = false;
			_enemy.CurrentState = (EnemyState)3;
			HardStopAgent(0.15f);
		}

		private void EnterRetreat()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			EndHurtRecoverPhysics();
			_state = EmpressXenomorphState.Retreat;
			_stateTimer = 3.8f;
			_decisionTimer = 0f;
			_carryTimer = 0f;
			_fusionPending = false;
			_fusionSmashApplied = false;
			_targetPlayer = null;
			_carriedPlayer = null;
			_throwApplied = false;
			_enemy.CurrentState = (EnemyState)8;
			RepoEnemyAccess.SetTargetPlayer(_enemy, null, -1);
			_moveDestination = FindRetreatDestination();
			SetMoveDestination(_moveDestination, 5.1f, 24f, 1f);
		}

		private void StartHurtRecoverPhysics()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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)
			if (!_ragdollActive)
			{
				_ragdollActive = true;
				HardStopAgent(0.1f);
				if (((Behaviour)_navMeshAgent).enabled)
				{
					_navMeshAgent.ResetPath();
					_navMeshAgent.isStopped = true;
					((Behaviour)_navMeshAgent).enabled = false;
				}
				((Behaviour)_enemyNavMeshAgent).enabled = false;
				_bodyRigidbody.useGravity = false;
				_bodyRigidbody.isKinematic = false;
				_bodyRigidbody.constraints = (RigidbodyConstraints)0;
				_bodyRigidbody.velocity = Vector3.zero;
				_bodyRigidbody.angularVelocity = Vector3.zero;
				Vector3 val = -((Component)this).transform.forward + Random.insideUnitSphere * 0.8f;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				normalized.y = Mathf.Abs(normalized.y) + 0.35f;
				_bodyRigidbody.AddForce(((Vector3)(ref normalized)).normalized * 6.5f, (ForceMode)1);
				_bodyRigidbody.AddTorque(Random.insideUnitSphere * 4.5499997f, (ForceMode)1);
			}
		}

		private void EndHurtRecoverPhysics()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0032: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (_ragdollActive)
			{
				_ragdollActive = false;
				NavMeshHit val = default(NavMeshHit);
				if (NavMesh.SamplePosition(_bodyRigidbody.position, ref val, 8f, -1))
				{
					((Component)this).transform.position = ((NavMeshHit)(ref val)).position;
					_bodyRigidbody.position = ((NavMeshHit)(ref val)).position;
				}
				_bodyRigidbody.velocity = Vector3.zero;
				_bodyRigidbody.angularVelocity = Vector3.zero;
				_bodyRigidbody.isKinematic = true;
				_bodyRigidbody.useGravity = false;
				_bodyRigidbody.constraints = (RigidbodyConstraints)112;
				((Behaviour)_navMeshAgent).enabled = true;
				NavMeshHit val2 = default(NavMeshHit);
				if (NavMesh.SamplePosition(((Component)this).transform.position, ref val2, 6f, -1))
				{
					_navMeshAgent.Warp(((NavMeshHit)(ref val2)).position);
				}
				_navMeshAgent.isStopped = false;
				((Behaviour)_enemyNavMeshAgent).enabled = true;
			}
		}

		private void CarryVictimPhysics()
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00d7: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_carriedPlayer == (Object)null) && IsTargetValid(_carriedPlayer))
			{
				PlayerTumble tumble = _carriedPlayer.tumble;
				Rigidbody playerTumbleRigidBody = RepoEnemyAccess.GetPlayerTumbleRigidBody(tumble);
				PhysGrabObject playerTumblePhysGrabObject = RepoEnemyAccess.GetPlayerTumblePhysGrabObject(tumble);
				if (!RepoEnemyAccess.GetPlayerTumbleIsTumbling(tumble))
				{
					tumble.TumbleSet(true, false);
				}
				tumble.TumbleOverrideTime(1f);
				_carriedPlayer.FallDamageResetSet(0.15f);
				tumble.OverrideEnemyHurt(0.15f);
				_carriedPlayer.EnemyVisionFreezeTimerSet(0.15f);
				playerTumblePhysGrabObject.OverrideMass(1f, 0.1f);
				playerTumblePhysGrabObject.OverrideAngularDrag(2.4f, 0.1f);
				playerTumblePhysGrabObject.OverrideDrag(1.8f, 0.1f);
				Vector3 val = SemiFunc.PhysFollowPosition(((Component)tumble).transform.position, _visual.CarryTransform.position, playerTumbleRigidBody.velocity, 24f);
				playerTumbleRigidBody.AddForce(val * (24f * Time.fixedDeltaTime), (ForceMode)1);
				Vector3 val2 = (_visual.CarryTransform.position - ((Component)tumble).transform.position) * 1.75f;
				playerTumbleRigidBody.AddForce(val2, (ForceMode)5);
				Vector3 val3 = SemiFunc.PhysFollowRotation(((Component)tumble).transform, _visual.CarryTransform.rotation, playerTumbleRigidBody, 0.25f);
				playerTumbleRigidBody.AddTorque(val3 * (3.2f * Time.fixedDeltaTime), (ForceMode)1);
			}
		}

		private void ThrowVictim()
		{
			//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_002b: 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_0096: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_carriedPlayer == (Object)null || !IsTargetValid(_carriedPlayer))
			{
				_carriedPlayer = null;
				return;
			}
			Vector3 onUnitSphere = Random.onUnitSphere;
			onUnitSphere.y = Mathf.Abs(onUnitSphere.y) * 0.5f + 0.5f;
			((Vector3)(ref onUnitSphere)).Normalize();
			_carriedPlayer.tumble.TumbleRequest(true, false);
			_carriedPlayer.tumble.TumbleOverrideTime(0.8f);
			_carriedPlayer.FallDamageResetSet(0.2f);
			_carriedPlayer.tumble.TumbleForce(onUnitSphere * 42f);
			_carriedPlayer.tumble.TumbleTorque(Random.onUnitSphere * 18f);
			_carriedPlayer.EnemyVisionFreezeTimerSet(0.3f);
			_carriedPlayer = null;
		}

		private bool CanCatchTarget(Transform targetTransform, Vector3 hoverTarget)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0052: 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)
			if (Vector3.Distance(_centerTransform.position, hoverTarget) <= 2.2f)
			{
				return true;
			}
			Vector3 position = ((Component)this).transform.position;
			position.y = 0f;
			Vector3 position2 = targetTransform.position;
			position2.y = 0f;
			float num = Vector3.Distance(position, position2);
			float num2 = Mathf.Abs(_centerTransform.position.y - targetTransform.position.y);
			if (num <= 1.7f)
			{
				return num2 <= 2.4f;
			}
			return false;
		}

		private PlayerAvatar? GetRandomValidPlayer()
		{
			List<PlayerAvatar> list = new List<PlayerAvatar>();
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (IsTargetValid(item))
				{
					list.Add(item);
				}
			}
			if (list.Count != 0)
			{
				return list[Random.Range(0, list.Count)];
			}
			return null;
		}

		private static bool IsTargetValid(PlayerAvatar? player)
		{
			if ((Object)(object)player != (Object)null && !RepoEnemyAccess.IsDisabled(player))
			{
				return !RepoEnemyAccess.IsDeadSet(player);
			}
			return false;
		}

		private static Transform GetTargetTransform(PlayerAvatar player)
		{
			if (!((Object)(object)player.PlayerVisionTarget != (Object)null))
			{
				return ((Component)player).transform;
			}
			return player.PlayerVisionTarget.VisionTransform;
		}

		private void UpdateVisuals()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_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_00ad: 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_0109: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)this).transform.position - _lastPosition;
			float num = Mathf.Max(Time.deltaTime, 0.0001f);
			Vector3 val2 = val / num;
			bool flag = ((Vector3)(ref val)).sqrMagnitude > 0.0009f;
			if (flag && ((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh)
			{
				Vector3 velocity = _navMeshAgent.velocity;
				if (((Vector3)(ref velocity)).sqrMagnitude > 0.0025f)
				{
					val2 = Vector3.Lerp(val2, _navMeshAgent.velocity, 0.45f);
					goto IL_0098;
				}
			}
			if (!flag)
			{
				val2 = Vector3.zero;
			}
			goto IL_0098;
			IL_0098:
			Vector3 val3 = ((Component)this).transform.InverseTransformDirection(val2);
			_localVelX = Mathf.Lerp(_localVelX, val3.x, 10f * Time.deltaTime);
			_localVelZ = Mathf.Lerp(_localVelZ, val3.z, 10f * Time.deltaTime);
			_visual.UpdatePose(_state, new Vector3(_localVelX, 0f, _localVelZ), execution: false, 0);
			_visual.UpdateFusionPresentation(_state == EmpressXenomorphState.FusionCharge, _state == EmpressXenomorphState.FusionMonster || _state == EmpressXenomorphState.FusionSmash, (_state == EmpressXenomorphState.FusionCharge) ? (1f - Mathf.Clamp01(_stateTimer / 4.6f)) : 0f, (_state == EmpressXenomorphState.FusionSmash) ? (1f - Mathf.Clamp01(_stateTimer / 0.45f)) : 0f, Time.time);
		}

		private void UpdateAudio()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_audio == (Object)null) && _audio.Ready)
			{
				ProcessReplicatedAudio();
				if (_state == EmpressXenomorphState.Death)
				{
					_audio.StopAll();
					return;
				}
				Vector2 val = new Vector2(_localVelX, _localVelZ);
				float magnitude = ((Vector2)(ref val)).magnitude;
				float ambienceLevel = _state switch
				{
					EmpressXenomorphState.SpawnIntro => 0.08f, 
					EmpressXenomorphState.Passive => (magnitude > 0.05f) ? 0.14f : 0.07f, 
					EmpressXenomorphState.HurtRecover => 0.12f, 
					EmpressXenomorphState.Pursue => 0.34f, 
					EmpressXenomorphState.Carry => 0.5f, 
					EmpressXenomorphState.Throw => 0.32f, 
					EmpressXenomorphState.FusionCharge => 0.42f, 
					EmpressXenomorphState.FusionMonster => 0.62f, 
					EmpressXenomorphState.FusionSmash => 0.58f, 
					EmpressXenomorphState.Retreat => 0.28f, 
					_ => 0f, 
				};
				_audio.SetAmbienceLevel(ambienceLevel);
				_audio.SetTransformationActive(_state == EmpressXenomorphState.FusionCharge);
			}
		}

		private void ProcessReplicatedAudio()
		{
			if (_remoteAttackAudioSerial != _playedAttackAudioSerial)
			{
				_playedAttackAudioSerial = _remoteAttackAudioSerial;
				if (_remoteAttackAudioSerial > 0)
				{
					_audio.PlayAttack();
				}
			}
			if (_remoteHurtAudioSerial != _playedHurtAudioSerial)
			{
				_playedHurtAudioSerial = _remoteHurtAudioSerial;
				if (_remoteHurtAudioSerial > 0)
				{
					_audio.PlayHurt();
				}
			}
			if (_remoteSeeAudioSerial != _playedSeeAudioSerial)
			{
				_playedSeeAudioSerial = _remoteSeeAudioSerial;
				if (_remoteSeeAudioSerial > 0)
				{
					_audio.PlaySee();
				}
			}
		}

		private void TriggerAttackAudio()
		{
			_attackAudioSerial++;
			_remoteAttackAudioSerial = _attackAudioSerial;
			_playedAttackAudioSerial = _attackAudioSerial;
			_audio.PlayAttack();
		}

		private void TriggerHurtAudio()
		{
			_hurtAudioSerial++;
			_remoteHurtAudioSerial = _hurtAudioSerial;
			_playedHurtAudioSerial = _hurtAudioSerial;
			_audio.PlayHurt();
		}

		private void TryTriggerSeeAudio()
		{
			if (!(_seeSoundTimer > 0f))
			{
				_seeSoundTimer = 4f;
				_seeAudioSerial++;
				_remoteSeeAudioSerial = _seeAudioSerial;
				_playedSeeAudioSerial = _seeAudioSerial;
				_audio.PlaySee();
			}
		}

		private void SyncNetworkState()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			_networkRotation = ((Component)this).transform.rotation;
			_networkTargetViewId = (((Object)(object)_targetPlayer != (Object)null) ? _targetPlayer.photonView.ViewID : (-1));
			_networkCarriedViewId = (((Object)(object)_carriedPlayer != (Object)null) ? _carriedPlayer.photonView.ViewID : (-1));
			int viewId = ((_networkCarriedViewId != -1) ? _networkCarriedViewId : _networkTargetViewId);
			RepoEnemyAccess.SetTargetPlayer(_enemy, _carriedPlayer ?? _targetPlayer, viewId);
		}

		private void UpdateRemoteTargets()
		{
			_targetPlayer = ResolvePlayerByViewId(_networkTargetViewId);
			_carriedPlayer = ResolvePlayerByViewId(_networkCarriedViewId);
			int viewId = ((_networkCarriedViewId != -1) ? _networkCarriedViewId : _networkTargetViewId);
			RepoEnemyAccess.SetTargetPlayer(_enemy, _carriedPlayer ?? _targetPlayer, viewId);
		}

		private static PlayerAvatar? ResolvePlayerByViewId(int viewId)
		{
			if (viewId == -1)
			{
				return null;
			}
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (!RepoEnemyAccess.IsDisabled(item) && item.photonView.ViewID == viewId)
				{
					return item;
				}
			}
			return null;
		}

		private void SetMoveDestination(Vector3 destination, float speed, float acceleration, float stoppingDistance)
		{
			//IL_005d: 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)
			if (EnsureRuntimeReady())
			{
				_enemyNavMeshAgent.UpdateAgent(speed, acceleration);
				_navMeshAgent.speed = speed;
				_navMeshAgent.acceleration = acceleration;
				_navMeshAgent.stoppingDistance = stoppingDistance;
				_enemyNavMeshAgent.Stop(0f);
				_navMeshAgent.isStopped = false;
				_enemyNavMeshAgent.SetDestination(destination);
				if (((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh)
				{
					_navMeshAgent.SetDestination(destination);
				}
			}
		}

		private void TryPushDoorsForBody()
		{
			//IL_0028: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_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)
			//IL_00c3: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			if (_doorCheckTimer > 0f)
			{
				return;
			}
			Vector3 val = ((((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh) ? _navMeshAgent.desiredVelocity : Vector3.zero);
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude <= 0.001f)
			{
				val = _moveDestination - ((Component)this).transform.position;
				val.y = 0f;
			}
			if (!(((Vector3)(ref val)).sqrMagnitude <= 0.001f))
			{
				_doorCheckTimer = 0.08f;
				((Vector3)(ref val)).Normalize();
				float currentBodyHitRadius = GetCurrentBodyHitRadius();
				Vector3 val2 = GetCurrentBodyHitCenter() + val * Mathf.Max(0.08f, currentBodyHitRadius * 0.35f);
				PushDoorsAroundBody(val2, currentBodyHitRadius + 0.18f, val);
				if (_state == EmpressXenomorphState.FusionMonster || _state == EmpressXenomorphState.FusionSmash)
				{
					PushDoorsAroundBody(val2 + val * currentBodyHitRadius * 0.8f, currentBodyHitRadius + 0.26f, val);
				}
			}
		}

		private void TryPushPhysicsObjectsForBody()
		{
			//IL_0028: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_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)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: 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)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			if (_bodyPushTimer > 0f)
			{
				return;
			}
			Vector3 val = ((((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh) ? _navMeshAgent.desiredVelocity : Vector3.zero);
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude <= 0.001f)
			{
				val = _moveDestination - ((Component)this).transform.position;
				val.y = 0f;
			}
			if (((Vector3)(ref val)).sqrMagnitude <= 0.001f)
			{
				return;
			}
			_bodyPushTimer = 0.08f;
			((Vector3)(ref val)).Normalize();
			float currentBodyHitRadius = GetCurrentBodyHitRadius();
			Vector3 val2 = GetCurrentBodyHitCenter() + val * Mathf.Max(0.22f, currentBodyHitRadius * 0.55f);
			float num = Mathf.Clamp(currentBodyHitRadius + 0.22f, 0.34f, 1.35f);
			Collider[] array = Physics.OverlapSphere(val2, num, LayerMask.GetMask(new string[2] { "PhysGrabObject", "Default" }), (QueryTriggerInteraction)1);
			HashSet<Rigidbody> hashSet = new HashSet<Rigidbody>();
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				if (!((Object)(object)val3 == (Object)null) && !((Component)val3).transform.IsChildOf(((Component)this).transform) && !((Object)(object)((Component)val3).GetComponentInParent<PhysGrabHinge>() != (Object)null))
				{
					Rigidbody attachedRigidbody = val3.attachedRigidbody;
					if (!((Object)(object)attachedRigidbody == (Object)null) && !((Object)(object)attachedRigidbody == (Object)(object)_bodyRigidbody) && hashSet.Add(attachedRigidbody))
					{
						attachedRigidbody.WakeUp();
						Vector3 val4 = val3.ClosestPoint(val2);
						attachedRigidbody.AddForce(val * 4.5f, (ForceMode)1);
						attachedRigidbody.AddForceAtPosition(val * 3.825f, val4, (ForceMode)1);
					}
				}
			}
		}

		private Vector3 GetCurrentBodyHitCenter()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.TransformPoint(_visual.PreferredHitCenterLocal);
		}

		private float GetCurrentBodyHitRadius()
		{
			float num = ((_state == EmpressXenomorphState.FusionMonster || _state == EmpressXenomorphState.FusionSmash) ? 1.22f : 1f);
			return Mathf.Clamp(_visual.PreferredHitRadius * num, 0.24f, 1.35f);
		}

		private static void PushDoorsAroundBody(Vector3 origin, float radius, Vector3 moveDirection)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_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_019c: 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_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			moveDirection.y = 0f;
			if (((Vector3)(ref moveDirection)).sqrMagnitude <= 0.001f)
			{
				moveDirection = Vector3.forward;
			}
			((Vector3)(ref moveDirection)).Normalize();
			Collider[] array = Physics.OverlapSphere(origin, radius, LayerMask.GetMask(new string[1] { "PhysGrabObjectHinge" }), (QueryTriggerInteraction)1);
			HashSet<PhysGrabHinge> hashSet = new HashSet<PhysGrabHinge>();
			Vector3 val = Vector3.Cross(Vector3.up, moveDirection);
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref val2)).sqrMagnitude <= 0.001f)
			{
				val2 = Vector3.right;
			}
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				PhysGrabHinge componentInParent = ((Component)val3).GetComponentInParent<PhysGrabHinge>();
				if ((Object)(object)componentInParent == (Object)null || !hashSet.Add(componentInParent) || RepoEnemyAccess.GetPhysGrabHingeBroken(componentInParent) || RepoEnemyAccess.GetPhysGrabHingeDead(componentInParent))
				{
					continue;
				}
				int instanceID = ((Object)componentInParent).GetInstanceID();
				if (DoorPushCooldowns.TryGetValue(instanceID, out var value) && value > Time.time)
				{
					continue;
				}
				Rigidbody physGrabHingeBody = RepoEnemyAccess.GetPhysGrabHingeBody(componentInParent);
				if ((Object)(object)physGrabHingeBody == (Object)null)
				{
					continue;
				}
				val = physGrabHingeBody.angularVelocity;
				if (!(((Vector3)(ref val)).sqrMagnitude > 6f))
				{
					val = physGrabHingeBody.velocity;
					if (!(((Vector3)(ref val)).sqrMagnitude > 2f))
					{
						float num = Mathf.Sign(Vector3.Dot(((Component)componentInParent).transform.position - origin, val2));
						if (Mathf.Approximately(num, 0f))
						{
							num = 1f;
						}
						Vector3 val4 = val3.ClosestPoint(origin) + val2 * num * 0.18f;
						physGrabHingeBody.WakeUp();
						physGrabHingeBody.AddForce(moveDirection * 3.6f, (ForceMode)1);
						physGrabHingeBody.AddForceAtPosition(moveDirection * 3.2399998f, val4, (ForceMode)1);
						physGrabHingeBody.AddTorque(Vector3.up * num * 3f, (ForceMode)1);
						if (RepoEnemyAccess.GetPhysGrabHingeClosed(componentInParent))
						{
							RepoEnemyAccess.InvokePhysGrabHingeOpenImpulse(componentInParent);
						}
						DoorPushCooldowns[instanceID] = Time.time + 0.45f;
						continue;
					}
				}
				DoorPushCooldowns[instanceID] = Time.time + 0.12f;
			}
		}

		private void HardStopAgent(float duration)
		{
			_enemyNavMeshAgent.Stop(duration);
			if (((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh)
			{
				_navMeshAgent.isStopped = true;
				_navMeshAgent.ResetPath();
			}
		}

		private void FacePosition(Vector3 position, float turnSpeed)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = position - ((Component)this).transform.position;
			val.y = 0f;
			if (!(((Vector3)(ref val)).sqrMagnitude <= 0.0001f))
			{
				Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up);
				((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, turnSpeed * Time.deltaTime);
			}
		}

		private void FaceTravelDirection(float turnSpeed)
		{
			//IL_001a: 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_0027: 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_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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh) ? _navMeshAgent.desiredVelocity : Vector3.zero);
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude <= 0.01f)
			{
				val = _moveDestination - ((Component)this).transform.position;
				val.y = 0f;
			}
			if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
			{
				FacePosition(((Component)this).transform.position + val, turnSpeed);
			}
		}

		private static Vector3 SampleNavMeshPosition(Vector3 desired, float range, Vector3 fallback)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(desired, ref val, range, -1))
			{
				return ((NavMeshHit)(ref val)).position;
			}
			if (NavMesh.SamplePosition(fallback, ref val, range, -1))
			{
				return ((NavMeshHit)(ref val)).position;
			}
			return fallback;
		}

		private Vector3 FindPassiveDestination()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 8f, 30f);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				return ((Component)this).transform.position;
			}
			return SampleNavMeshPosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, 6f, ((Component)val).transform.position);
		}

		private Vector3 FindCarryDestination()
		{
			//IL_0006: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 18f, 60f, false);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 8f);
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				return FindRetreatDestination();
			}
			return SampleNavMeshPosition(((Component)val).transform.position + Random.insideUnitSphere * 2.5f, 6f, ((Component)val).transform.position);
		}

		private Vector3 FindRetreatDestination()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			LevelPoint val = SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 8f);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 18f, 80f, false);
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				return FindPassiveDestination();
			}
			return SampleNavMeshPosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, 6f, ((Component)val).transform.position);
		}

		private float DistanceToClosestPlayer(Vector3 position)
		{
			//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)
			float num = float.MaxValue;
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (IsTargetValid(item))
				{
					float num2 = Vector3.Distance(position, ((Component)item).transform.position);
					if (num2 < num)
					{
						num = num2;
					}
				}
			}
			if (num != float.MaxValue)
			{
				return num;
			}
			return 99f;
		}

		private bool EnsureRuntimeReady()
		{
			//IL_0045: 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)
			if (_ragdollActive)
			{
				return true;
			}
			if (((Behaviour)_navMeshAgent).enabled && _navMeshAgent.isOnNavMesh)
			{
				if (!((Behaviour)_enemyNavMeshAgent).enabled)
				{
					((Behaviour)_enemyNavMeshAgent).enabled = true;
				}
				return true;
			}
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(((Component)this).transform.position, ref val, 6f, -1))
			{
				((Behaviour)_navMeshAgent).enabled = true;
				_navMeshAgent.Warp(((NavMeshHit)(ref val)).position);
				if (!((Behaviour)_enemyNavMeshAgent).enabled)
				{
					((Behaviour)_enemyNavMeshAgent).enabled = true;
				}
				return true;
			}
			return false;
		}

		private static bool IsGameplayReady()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Invalid comparison between Unknown and I4
			if ((Object)(object)LevelGenerator.Instance != (Object)null && LevelGenerator.Instance.Generated && (Object)(object)GameDirector.instance != (Object)null && (int)GameDirector.instance.currentState == 2 && !SemiFunc.RunIsLobbyMenu())
			{
				return !SemiFunc.MenuLevel();
			}
			return false;
		}

		public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(info))
			{
				if (stream.IsWriting)
				{
					stream.SendNext((object)(int)_state);
					stream.SendNext((object)((Component)this).transform.rotation);
					stream.SendNext((object)_stateTimer);
					stream.SendNext((object)_networkTargetViewId);
					stream.SendNext((object)_networkCarriedViewId);
					stream.SendNext((object)_attackAudioSerial);
					stream.SendNext((object)_hurtAudioSerial);
					stream.SendNext((object)_seeAudioSerial);
				}
				else
				{
					_state = (EmpressXenomorphState)(int)stream.ReceiveNext();
					_networkRotation = (Quaternion)stream.ReceiveNext();
					_stateTimer = (float)stream.ReceiveNext();
					_networkTargetViewId = (int)stream.ReceiveNext();
					_networkCarriedViewId = (int)stream.ReceiveNext();
					_remoteAttackAudioSerial = (int)stream.ReceiveNext();
					_remoteHurtAudioSerial = (int)stream.ReceiveNext();
					_remoteSeeAudioSerial = (int)stream.ReceiveNext();
				}
			}
		}
	}
	internal sealed class EmpressXenomorphImpactBridge : MonoBehaviour
	{
		private const float ImpactCooldown = 0.12f;

		private const float MinimumImpactSpeed = 4.2f;

		private const float MediumImpactSpeed = 8.5f;

		private const float HeavyImpactSpeed = 13.5f;

		private Enemy _enemy;

		private EnemyHealth _health;

		private float _impactCooldownTimer;

		internal void Initialize(Enemy enemy, EnemyHealth health)
		{
			_enemy = enemy;
			_health = health;
			_impactCooldownTimer = 0f;
		}

		private void Update()
		{
			if (_impactCooldownTimer > 0f)
			{
				_impactCooldownTimer -= Time.deltaTime;
			}
		}

		private void OnCollisionEnter(Collision collision)
		{
			TryHandleImpact(collision);
		}

		private void OnCollisionStay(Collision collision)
		{
			TryHandleImpact(collision);
		}

		private void TryHandleImpact(Collision collision)
		{
			//IL_00e0: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			if (_impactCooldownTimer > 0f || (Object)(object)_enemy == (Object)null || (Object)(object)_health == (Object)null || (GameManager.Multiplayer() && !RepoEnemyAccess.GetMasterClient(_enemy)) || RepoEnemyAccess.GetEnemyHealthDead(_health) || RepoEnemyAccess.GetEnemyHealthDeadImpulse(_health) || collision == null || (Object)(object)collision.transform == (Object)null || collision.transform.IsChildOf(((Component)this).transform))
			{
				return;
			}
			PhysGrabObject val = ((Component)collision.transform).GetComponentInParent<PhysGrabObject>();
			if ((Object)(object)val == (Object)null && (Object)(object)collision.rigidbody != (Object)null)
			{
				val = ((Component)collision.rigidbody).GetComponent<PhysGrabObject>();
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Rigidbody val2 = (((Object)(object)val.rb != (Object)null) ? val.rb : collision.rigidbody);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			Vector3 val3 = collision.relativeVelocity;
			float magnitude = ((Vector3)(ref val3)).magnitude;
			if (magnitude < 4.2f)
			{
				return;
			}
			int num = ((magnitude >= 13.5f) ? 18 : ((magnitude >= 8.5f) ? 10 : 4));
			val3 = val2.velocity;
			Vector3 normalized;
			if (!(((Vector3)(ref val3)).sqrMagnitude > 0.01f))
			{
				if (collision.contactCount <= 0)
				{
					val3 = ((Component)this).transform.position - collision.transform.position;
					normalized = ((Vector3)(ref val3)).normalized;
				}
				else
				{
					Vector3 position = ((Component)this).transform.position;
					ContactPoint contact = collision.GetContact(0);
					val3 = position - ((ContactPoint)(ref contact)).point;
					normalized = ((Vector3)(ref val3)).normalized;
				}
			}
			else
			{
				val3 = val2.velocity;
				normalized = ((Vector3)(ref val3)).normalized;
			}
			Vector3 val4 = normalized;
			if (((Vector3)(ref val4)).sqrMagnitude <= 0.001f)
			{
				val4 = ((Component)this).transform.forward;
			}
			_impactCooldownTimer = 0.12f;
			_health.Hurt(num, val4);
			RepoEnemyAccess.EnsureEnemyHealthOnObjectHurt(_health).Invoke();
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("omniscye.gooby", "Gooby", "1.0.0")]
	internal sealed class EmpressXenomorphPlugin : BaseUnityPlugin
	{
		private static readonly FieldInfo EnemySetupField = AccessTools.Field(typeof(EnemyContent), "_setup");

		private static readonly FieldInfo SpawnObjectsField = AccessTools.Field(typeof(EnemyContent), "_spawnObjects");

		internal const string PluginGuid = "omniscye.gooby";

		internal const string PluginName = "Gooby";

		internal const string PluginVersion = "1.0.0";

		internal const string TemplatePrefabName = "GoobyPrefab";

		internal const string BundleFileName = "xeno";

		internal const float DefaultEnemySoundVolume = 0.4f;

		internal const float DefaultDigivolutionVolume = 0.8f;

		private static Harmony? _harmony;

		private static bool _registered;

		private static GameObject? _runtimeHost;

		private static ConfigEntry<int>? _fusionChancePercentConfig;

		private static ConfigEntry<float>? _enemySoundVolumeConfig;

		private static ConfigEntry<float>? _digivolutionVolumeConfig;

		internal static ManualLogSource Log { get; private set; } = null;


		internal static string PluginDirectory { get; private set; } = string.Empty;


		internal static float FusionChanceRatio => Mathf.Clamp((float)(_fusionChancePercentConfig?.Value ?? 10) / 100f, 0f, 1f);

		internal static float EnemySoundVolume => Mathf.Clamp01(_enemySoundVolumeConfig?.Value ?? 0.4f);

		internal static float DigivolutionVolume => Mathf.Clamp01(_digivolutionVolumeConfig?.Value ?? 0.8f);

		internal static GameObject EnsureRuntimeHost()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if ((Object)(object)_runtimeHost != (Object)null)
			{
				return _runtimeHost;
			}
			_runtimeHost = new GameObject("GoobyRuntimeHost");
			((Object)_runtimeHost).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)_runtimeHost);
			return _runtimeHost;
		}

		private void Awake()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty;
			EnsureRuntimeHost();
			if (_fusionChancePercentConfig == null)
			{
				_fusionChancePercentConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Gooby", "FusionTransformChancePercent", 10, new ConfigDescription("Chance that Gooby performs the Digivolve-style fusion transformation after being hurt.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			}
			if (_enemySoundVolumeConfig == null)
			{
				_enemySoundVolumeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Gooby Audio", "GoobySoundVolume", 0.4f, new ConfigDescription("Master volume for Gooby's normal sounds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			}
			if (_digivolutionVolumeConfig == null)
			{
				_digivolutionVolumeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Gooby Audio", "DigivolutionVolume", 0.8f, new ConfigDescription("Volume for Gooby's Digivolution music.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			}
			if (_harmony == null)
			{
				_harmony = new Harmony("omniscye.gooby");
			}
			PatchTemplateGuards(_harmony);
			RegisterEnemy();
			((MonoBehaviour)this).StartCoroutine(EmpressXenomorphAudioBank.LoadAudioAsync(PluginDirectory, ((BaseUnityPlugin)this).Logger));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Gooby v1.0.0");
		}

		private void RegisterEnemy()
		{
			if (!_registered)
			{
				GameObject item = EmpressXenomorphTemplateBootstrap.CreateTemplate(((BaseUnityPlugin)this).Logger);
				RarityPreset val = ScriptableObject.CreateInstance<RarityPreset>();
				((Object)val).hideFlags = (HideFlags)61;
				((Object)val).name = "Rarity - Gooby";
				val.chance = 14f;
				EnemySetup val2 = ScriptableObject.CreateInstance<EnemySetup>();
				((Object)val2).hideFlags = (HideFlags)61;
				((Object)val2).name = "Enemy - Gooby";
				val2.spawnObjects = new List<PrefabRef>();
				val2.levelsCompletedCondition = false;
				val2.levelsCompletedMin = 0;
				val2.levelsCompletedMax = 10;
				val2.rarityPreset = val;
				val2.runsPlayed = 0;
				EnemyContent val3 = ScriptableObject.CreateInstance<EnemyContent>();
				((Object)val3).hideFlags = (HideFlags)61;
				((Object)val3).name = "EnemyContentGooby";
				EnemySetupField.SetValue(val3, val2);
				SpawnObjectsField.SetValue(val3, new List<GameObject> { item });
				Enemies.RegisterEnemy(val3);
				_registered = true;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered Gooby through REPOLib.");
			}
		}

		private static void PatchTemplateGuards(Harmony harmony)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Expected O, but got Unknown
			harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyParent), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressXenomorphPlugin), "SkipTemplateEnemyParentAwake", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyParent), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressXenomorphPlugin), "SkipTemplateEnemyParentUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(Enemy), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressXenomorphPlugin), "SkipTemplateEnemyAwake", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(Enemy), "Start", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressXenomorphPlugin), "SkipTemplateEnemyStart", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(Enemy), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressXenomorphPlugin), "SkipTemplateEnemyUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyNavMeshAgent), "Awake", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressXenomorphPlugin), "SkipTemplateEnemyNavMeshAgentAwake", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyNavMeshAgent), "OnEnable", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressXenomorphPlugin), "SkipTemplateEnemyNavMeshAgentOnEnable", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyNavMeshAgent), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressXenomorphPlugin), "SkipTemplateEnemyNavMeshAgentUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyStateSpawn), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressXenomorphPlugin), "SkipTemplateEnemyStateSpawnUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyStateStunned), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EmpressXenomorphPlugin), "SkipTemplateEnemyStateStunnedUpdate", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static bool SkipTemplateEnemyParentAwake(EnemyParent __instance)
		{
			return !EmpressXenomorphTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject);
		}

		private static bool SkipTemplateEnemyParentUpdate(EnemyParent __instance)
		{
			return !EmpressXenomorphTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject);
		}

		private static bool SkipTemplateEnemyAwake(Enemy __instance)
		{
			return !EmpressXenomorphTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject);
		}

		private static bool SkipTemplateEnemyStart(Enemy __instance)
		{
			return !EmpressXenomorphTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject);
		}

		private static bool SkipTemplateEnemyUpdate(Enemy __instance)
		{
			return !EmpressXenomorphTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject);
		}

		private static bool SkipTemplateEnemyNavMeshAgentAwake(EnemyNavMeshAgent __instance)
		{
			return !EmpressXenomorphTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject);
		}

		private static bool SkipTemplateEnemyNavMeshAgentOnEnable(EnemyNavMeshAgent __instance)
		{
			return !EmpressXenomorphTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject);
		}

		private static bool SkipTemplateEnemyNavMeshAgentUpdate(EnemyNavMeshAgent __instance)
		{
			return !EmpressXenomorphTemplateBootstrap.IsTemplateInstance(((Component)__instance).gameObject);
		}

		private static bool SkipTemplateEnemyStateSpawnUpdate(EnemyStateSpawn __instance)
		{
			return !EmpressXenomorphTemplateBootstrap.Is