Decompiled source of DrillerKiller v1.0.1

VyrusGames-DrillerKiller/DrillerKiller.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("VyrusGames")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DrillerKiller")]
[assembly: AssemblyTitle("DrillerKiller")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DrillerKiller
{
	[BepInPlugin("VyrusGames.DrillerKiller", "DrillerKiller", "1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class DrillerKiller : BaseUnityPlugin
	{
		internal static DrillerKiller Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		public static ConfigEntry<bool> EnableDebugGUI { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
			SetConfigs();
		}

		internal void Patch()
		{
			//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_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			LoadAssets();
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void SetConfigs()
		{
			EnableDebugGUI = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnableDebugGUI", false, "Enable the debug GUI");
		}

		internal void LoadAssets()
		{
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "driller");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			EnemySetup val2 = val.LoadAsset<EnemySetup>("Assets/REPO/Mods/plugins/DrillerKiller/Enemy - Driller.asset");
			Enemies.RegisterEnemy(val2);
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded assets!");
		}
	}
}
namespace DrillerKiller.AI
{
	public class EnemyDriller : MonoBehaviour
	{
		public enum States
		{
			Spawn,
			Idle,
			Roam,
			Investigate,
			Notice,
			Chase,
			Leave,
			Stun,
			Despawn
		}

		private Enemy _enemy;

		private PhotonView _photonView;

		private PlayerAvatar _targetPlayer;

		private bool _stateImpulse;

		private bool _deathImpulse;

		private Vector3 _agentDestination;

		[Header("Animation")]
		[SerializeField]
		private EnemyDrillerAnim anim;

		[SerializeField]
		private GameObject meshParent;

		[Header("State")]
		[SerializeField]
		private States _state;

		[SerializeField]
		private float _stateTimer;

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

		private Quaternion rotationTarget;

		[Header("Movement Speeds")]
		[SerializeField]
		private float _walkSpeed = 20f;

		[SerializeField]
		private float _runSpeed = 30f;

		[Header("Hurt Collider")]
		[SerializeField]
		private GameObject _hurtCollider;

		public Enemy Enemy => _enemy;

		public PlayerAvatar TargetPlayer => _targetPlayer;

		private EnemyNavMeshAgent _navMeshAgent => _enemy.NavMeshAgent;

		private EnemyRigidbody _rigidbody => _enemy.Rigidbody;

		public States State => _state;

		private void Awake()
		{
			_enemy = ((Component)this).GetComponent<Enemy>();
			_photonView = ((Component)this).GetComponent<PhotonView>();
			anim = meshParent.GetComponent<EnemyDrillerAnim>();
		}

		private void Update()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			if ((GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient) || !LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (Enemy.IsStunned())
			{
				UpdateState(States.Stun);
			}
			else if ((int)Enemy.CurrentState == 11)
			{
				UpdateState(States.Despawn);
			}
			RotationLogic();
			HurtboxLogic();
			switch (_state)
			{
			case States.Spawn:
				HandleSpawn();
				break;
			case States.Idle:
				HandleIdle();
				break;
			case States.Roam:
				HandleRoam();
				break;
			case States.Investigate:
				HandleInvestigate();
				break;
			case States.Notice:
				HandleNotice();
				break;
			case States.Chase:
				HandleChase();
				break;
			case States.Leave:
				HandleLeave();
				break;
			case States.Stun:
				HandleStun();
				break;
			case States.Despawn:
				HandleDespawn();
				break;
			default:
				throw new ArgumentOutOfRangeException();
			}
			SemiFunc.DoNotLookEffect(((Component)this).gameObject, true, true, true, true, true, false);
			if (_state == States.Notice && Object.op_Implicit((Object)(object)_targetPlayer))
			{
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("RPC_CameraVFX", (RpcTarget)1, new object[1] { _targetPlayer.photonView.ViewID });
				}
				else
				{
					RPC_CameraVFX(_targetPlayer.photonView.ViewID);
				}
			}
			if (GameManager.Multiplayer())
			{
				_photonView.RPC("RPC_AnimateWalk", (RpcTarget)0, new object[1] { ((Vector3)(ref _navMeshAgent.AgentVelocity)).magnitude });
			}
			else
			{
				RPC_AnimateWalk(((Vector3)(ref _navMeshAgent.AgentVelocity)).magnitude);
			}
			if (GameManager.Multiplayer())
			{
				_photonView.RPC("RPC_AnimateRunning", (RpcTarget)0, new object[1] { _state == States.Chase });
			}
			else
			{
				RPC_AnimateRunning(_state == States.Chase);
			}
			if (GameManager.Multiplayer())
			{
				_photonView.RPC("RPC_AnimateBlendChaseArmLayer", (RpcTarget)0, new object[1] { (_state == States.Chase) ? 1f : 0f });
			}
			else
			{
				RPC_AnimateBlendChaseArmLayer((_state == States.Chase) ? 1f : 0f);
			}
		}

		private void UpdateState(States newState)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer() && _state != newState)
			{
				_state = newState;
				_stateImpulse = true;
				_stateTimer = 0f;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("RPC_UpdateState", (RpcTarget)1, new object[1] { newState });
				}
				else
				{
					RPC_UpdateState(newState);
				}
			}
		}

		private void HandleSpawn()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_enemy.NavMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_enemy.NavMeshAgent.ResetPath();
				_stateImpulse = false;
				_stateTimer = 2f;
			}
			if (!SemiFunc.EnemySpawnIdlePause())
			{
				_stateTimer -= Time.deltaTime;
				if (_stateTimer <= 0f)
				{
					UpdateState(States.Idle);
				}
			}
		}

		private void HandleIdle()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_enemy.NavMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_enemy.NavMeshAgent.ResetPath();
				_stateImpulse = false;
				_stateTimer = Random.Range(2f, 5f);
			}
			_stateTimer -= Time.deltaTime;
			if (_stateTimer <= 0f)
			{
				UpdateState(States.Roam);
			}
		}

		private void HandleRoam()
		{
			//IL_0124: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_enemy.StuckCount = 0;
				bool flag = false;
				_stateTimer = Random.Range(3f, 5f);
				LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 10f, 25f);
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((NavMeshHit)(ref val2)).position;
					flag = true;
				}
				if (!flag)
				{
					return;
				}
				_rigidbody.notMovingTimer = 0f;
				_stateImpulse = false;
			}
			else
			{
				_navMeshAgent.SetDestination(_agentDestination);
				if (_rigidbody.notMovingTimer > 2f)
				{
					_stateTimer -= Time.deltaTime;
				}
				if (_stateTimer <= 0f || !_navMeshAgent.HasPath())
				{
					UpdateState(States.Idle);
				}
			}
			if (SemiFunc.EnemyForceLeave(_enemy))
			{
				UpdateState(States.Leave);
			}
		}

		private void HandleInvestigate()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_rigidbody.notMovingTimer = 0f;
				_stateTimer = 5f;
				return;
			}
			_navMeshAgent.SetDestination(_agentDestination);
			if (_rigidbody.notMovingTimer > 2f)
			{
				_stateTimer -= Time.deltaTime;
			}
			if (_stateTimer <= 0f || !_navMeshAgent.HasPath())
			{
				UpdateState(States.Idle);
			}
		}

		private void HandleNotice()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_navMeshAgent.ResetPath();
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_stateImpulse = false;
				_stateTimer = 0.5f;
				if (GameManager.Multiplayer())
				{
					_photonView.RPC("RPC_PlaySFXStinger", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					RPC_PlaySFXStinger();
				}
			}
			_stateTimer -= Time.deltaTime;
			if (_stateTimer <= 0f)
			{
				UpdateState(States.Chase);
			}
		}

		private void HandleChase()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_stateImpulse = false;
				_stateTimer = 5f;
			}
			_stateTimer -= Time.deltaTime;
			if (Object.op_Implicit((Object)(object)_targetPlayer))
			{
				_agentDestination = ((Component)_targetPlayer).transform.position;
			}
			else
			{
				UpdateState(States.Idle);
			}
			float num = ((Vector3.Distance(((Component)_targetPlayer).transform.position, ((Component)_rigidbody).transform.position) > 10f) ? 0.25f : 1f);
			_navMeshAgent.OverrideAgent(_runSpeed, _navMeshAgent.DefaultAcceleration, 0.2f);
			_rigidbody.OverrideFollowPosition(1f, _runSpeed, -1f);
			_navMeshAgent.SetDestination(_agentDestination + new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f) * 2f));
			if (_stateTimer <= 0f)
			{
				UpdateState(States.Idle);
			}
		}

		private void HandleLeave()
		{
			//IL_0124: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_enemy.StuckCount = 0;
				bool flag = false;
				_stateTimer = Random.Range(3f, 5f);
				LevelPoint val = SemiFunc.LevelPointGet(((Component)this).transform.position, 10f, 25f);
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = SemiFunc.LevelPointGet(((Component)this).transform.position, 0f, 999f);
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (Object.op_Implicit((Object)(object)val) && NavMesh.SamplePosition(((Component)val).transform.position + Random.insideUnitSphere * 3f, ref val2, 5f, -1) && Physics.Raycast(((NavMeshHit)(ref val2)).position, Vector3.down, 5f, LayerMask.GetMask(new string[1] { "Default" })))
				{
					_agentDestination = ((NavMeshHit)(ref val2)).position;
					flag = true;
				}
				if (flag)
				{
					_rigidbody.notMovingTimer = 0f;
					_stateImpulse = false;
				}
			}
			else
			{
				_navMeshAgent.SetDestination(_agentDestination);
				if (_rigidbody.notMovingTimer > 2f)
				{
					_stateTimer -= Time.deltaTime;
				}
				if (_stateTimer <= 0f || Vector3.Distance(((Component)this).transform.position, _agentDestination) < 1f)
				{
					UpdateState(States.Idle);
				}
			}
		}

		private void HandleStun()
		{
			if (_stateImpulse)
			{
				_enemy.NavMeshAgent.ResetPath();
				_stateImpulse = false;
				_stateTimer = 2f;
				return;
			}
			_stateTimer -= Time.deltaTime;
			if (_stateTimer <= 0f)
			{
				UpdateState(States.Idle);
			}
		}

		private void HandleDespawn()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (_stateImpulse)
			{
				_navMeshAgent.ResetPath();
				_navMeshAgent.Warp(((Component)_rigidbody).transform.position);
				_stateImpulse = false;
			}
		}

		private void RotationLogic()
		{
			//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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00cd: 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_00d6: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			if (_state == States.Idle || _state == States.Roam || _state == States.Investigate)
			{
				rotationSpring.damping = 0.7f;
				rotationSpring.speed = 3f;
				if (((Vector3)(ref _navMeshAgent.AgentVelocity)).magnitude > 0.01f)
				{
					Quaternion rotation = ((Component)this).transform.rotation;
					((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref _navMeshAgent.AgentVelocity)).normalized);
					((Component)this).transform.eulerAngles = new Vector3(0f, ((Component)this).transform.eulerAngles.y, 0f);
					Quaternion rotation2 = ((Component)this).transform.rotation;
					((Component)this).transform.rotation = rotation;
					rotationTarget = rotation2;
				}
			}
			else if (_state == States.Chase || _state == States.Notice)
			{
				rotationSpring.damping = 0.5f;
				rotationSpring.speed = 5f;
				rotationTarget = Quaternion.LookRotation(((Component)_targetPlayer).transform.position - ((Component)_rigidbody).transform.position);
				((Quaternion)(ref rotationTarget)).eulerAngles = new Vector3(0f, ((Quaternion)(ref rotationTarget)).eulerAngles.y, 0f);
			}
			((Component)this).transform.rotation = SemiFunc.SpringQuaternionGet(rotationSpring, rotationTarget, -1f);
		}

		private void HurtboxLogic()
		{
			if (_state == States.Chase)
			{
				_hurtCollider.SetActive(true);
			}
			else
			{
				_hurtCollider.SetActive(false);
			}
		}

		public void OnVision()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (_state == States.Idle || _state == States.Roam || _state == States.Investigate)
				{
					_targetPlayer = _enemy.Vision.onVisionTriggeredPlayer;
					UpdateState(States.Notice);
				}
				else if (_state == States.Chase)
				{
					_stateTimer = 5f;
				}
			}
		}

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

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

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

		[PunRPC]
		private void RPC_UpdateTargetPlayer(int id)
		{
			foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
			{
				if (item.photonView.ViewID == id)
				{
					_targetPlayer = item;
					break;
				}
			}
		}

		[PunRPC]
		private void RPC_UpdateState(States state)
		{
			_state = state;
		}

		[PunRPC]
		private void RPC_AnimateWalk(float mag)
		{
			anim.AnimateWalk(mag);
		}

		[PunRPC]
		private void RPC_AnimateRunning(bool isRunning)
		{
			anim.SetRunning(isRunning);
		}

		[PunRPC]
		private void RPC_AnimateBlendChaseArmLayer(float blend)
		{
			anim.BlendChaseArmLayer(blend);
		}

		[PunRPC]
		private void RPC_PlaySFXStinger()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			anim.SFXStinger();
			if (_targetPlayer.isLocal)
			{
				GameDirector.instance.CameraShake.ShakeDistance(3f, 3f, 10f, ((Component)this).transform.position, 0.5f);
				CameraGlitch.Instance.PlayShort();
			}
		}

		[PunRPC]
		private void RPC_CameraVFX(int id)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (_targetPlayer.photonView.ViewID == id)
			{
				SemiFunc.DoNotLookEffect(((Component)this).gameObject, true, true, true, true, true, true);
				CameraZoom.Instance.OverrideZoomSet(40f, 0.1f, 1f, 1f, ((Component)this).gameObject, 50);
				SemiFunc.PlayerEyesOverride(_targetPlayer, _enemy.CenterTransform.position, 0.1f, ((Component)this).gameObject);
				Color val = default(Color);
				((Color)(ref val))..ctor(0.8f, 0f, 0f, 1f);
				PostProcessing.Instance.VignetteOverride(val, 0.75f, 1f, 3.5f, 2.5f, 0.5f, ((Component)this).gameObject);
			}
		}

		private void OnGUI()
		{
			//IL_0032: 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)
			if (DrillerKiller.EnableDebugGUI.Value && SemiFunc.IsMasterClientOrSingleplayer())
			{
				GUI.Label(new Rect(10f, 10f, 200f, 20f), "State: " + _state);
				GUI.Label(new Rect(10f, 30f, 200f, 20f), "State Timer: " + _stateTimer);
			}
		}
	}
	public class EnemyDrillerAnim : MonoBehaviour
	{
		private int speed = Animator.StringToHash("Speed");

		private int running = Animator.StringToHash("Running");

		[SerializeField]
		private Animator _animator;

		[SerializeField]
		private Enemy _enemy;

		[SerializeField]
		private EnemyDriller _controller;

		private float _movementMagnitude;

		[Header("SFX")]
		[SerializeField]
		private Sound drillSound;

		[SerializeField]
		private Sound drillSound2;

		[SerializeField]
		private Sound footstepSound;

		[SerializeField]
		private Sound stingerSound;

		private EnemyNavMeshAgent _enemyNavMeshAgent => _enemy.NavMeshAgent;

		private EnemyRigidbody _enemyRigidbody => _enemy.Rigidbody;

		private void Update()
		{
			if (_enemyRigidbody.frozen)
			{
				_animator.speed = 0f;
			}
			else
			{
				_animator.speed = 1f;
			}
			SFXDrill();
		}

		public void SFXDrill()
		{
			drillSound.PlayLoop(_controller.State == EnemyDriller.States.Chase, 5f, 5f, 1f);
			drillSound2.PlayLoop(_controller.State == EnemyDriller.States.Chase, 5f, 5f, 1f);
		}

		public void SFXFootstep()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (_movementMagnitude > 0.1f)
			{
				footstepSound.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
		}

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

		public void AnimateWalk(float mag)
		{
			_animator.SetFloat(speed, mag);
			_movementMagnitude = mag;
		}

		public void SetRunning(bool isRunning)
		{
			_animator.SetFloat(running, (float)(isRunning ? 1 : 0));
		}

		public void BlendChaseArmLayer(float blend)
		{
			_animator.SetLayerWeight(1, blend);
		}
	}
}