Decompiled source of Beanie Lib v1.1.0

LethalGravityControl.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using Dawn;
using GameNetcodeStuff;
using HarmonyLib;
using LethalGravityControl.NetcodePatcher;
using LethalLevelLoader;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations.Rigging;
using UnityEngine.Events;

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class BreakerBoxCustom : NetworkBehaviour
{
	[Header("Breaker Settings")]
	public int leversSwitchedOff = 2;

	public bool isPowerOn = false;

	[Header("References")]
	public Animator[] breakerSwitches;

	public AudioSource thisAudioSource;

	public AudioSource breakerBoxHum;

	public AudioClip switchPowerSFX;

	[Header("Events")]
	public UnityEvent onBreakerActivated;

	public UnityEvent onBreakerDeactivated;

	private void Start()
	{
		isPowerOn = false;
		SetSwitchesOff();
		if ((Object)(object)breakerBoxHum != (Object)null && breakerBoxHum.isPlaying)
		{
			breakerBoxHum.Stop();
		}
	}

	public void SetSwitchesOff()
	{
		int num = Mathf.Clamp(leversSwitchedOff, 0, breakerSwitches.Length);
		leversSwitchedOff = 0;
		Random random = new Random(StartOfRound.Instance.randomMapSeed);
		HashSet<int> hashSet = new HashSet<int>();
		while (hashSet.Count < num && hashSet.Count < breakerSwitches.Length)
		{
			int num2 = random.Next(0, breakerSwitches.Length);
			if (!hashSet.Contains(num2))
			{
				hashSet.Add(num2);
				AnimatedObjectTrigger component = ((Component)breakerSwitches[num2]).GetComponent<AnimatedObjectTrigger>();
				if (component.boolValue)
				{
					breakerSwitches[num2].SetBool("turnedLeft", false);
					component.boolValue = false;
					component.setInitialState = false;
					leversSwitchedOff++;
				}
			}
		}
	}

	public void SwitchBreaker(bool on)
	{
		if (on)
		{
			leversSwitchedOff--;
		}
		else
		{
			leversSwitchedOff++;
		}
		if (((NetworkBehaviour)this).IsServer)
		{
			if (leversSwitchedOff <= 0 && !isPowerOn)
			{
				isPowerOn = true;
				UnityEvent obj = onBreakerActivated;
				if (obj != null)
				{
					obj.Invoke();
				}
				if ((Object)(object)thisAudioSource != (Object)null && (Object)(object)switchPowerSFX != (Object)null)
				{
					thisAudioSource.PlayOneShot(switchPowerSFX);
				}
			}
			else if (leversSwitchedOff > 0 && isPowerOn)
			{
				isPowerOn = false;
				UnityEvent obj2 = onBreakerDeactivated;
				if (obj2 != null)
				{
					obj2.Invoke();
				}
				if ((Object)(object)thisAudioSource != (Object)null && (Object)(object)switchPowerSFX != (Object)null)
				{
					thisAudioSource.PlayOneShot(switchPowerSFX);
				}
			}
		}
		if (leversSwitchedOff <= 0)
		{
			if (!breakerBoxHum.isPlaying)
			{
				breakerBoxHum.Play();
			}
		}
		else if (leversSwitchedOff == 1)
		{
			breakerBoxHum.Stop();
		}
	}

	protected override void __initializeVariables()
	{
		((NetworkBehaviour)this).__initializeVariables();
	}

	protected override void __initializeRpcs()
	{
		((NetworkBehaviour)this).__initializeRpcs();
	}

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "BreakerBoxCustom";
	}
}
public class CustomShotgun : GrabbableObject
{
	[Serializable]
	public class PlayerDamageAndRangeSettings
	{
		public float PlayerSuperCloseRange = 5f;

		public float PlayerCloseRange = 15f;

		public float PlayerMediumRange = 23f;

		public float PlayerFarRange = 30f;

		public int PlayerSuperCloseDamage = 100;

		public int PlayerCloseDamage = 100;

		public int PlayerMediumDamage = 40;

		public int PlayerFarDamage = 20;

		[Tooltip("The Force at which the player ragdoll is thrown when dying of the shotgun blast")]
		public float RagdollForce = 30f;
	}

	[Serializable]
	public class EnemyDamageAndRangeSettings
	{
		[Tooltip("The Maximum Range of the shotgun blast for enemies. Must always be HIGHER than EnemyCloseRange and EnemyFarRange.")]
		public float EnemiesMaximumRange = 15f;

		public int EnemyFullDamage = 5;

		public int EnemyMediumDamage = 3;

		public int EnemyLowDamage = 2;

		[Tooltip("Enemies within THIS range from the shotgun will take (what you set as EnemyFullDamage). Past wherever this range ENDS is when the (EnemyMediumDamage) area begins. For example, if its set as 4, anything within 4 units of the shotgun takes full damage and past that it is considered medium.")]
		public float EnemyCloseRange = 3.7f;

		[Tooltip("Enemies between THIS range and the edge of the CLOSE range will take (EnemyMediumDamage) and anything PAST this range will take (EnemyLowDamage) So this basically sets the endpoint for medium damage and the start point for low damage. For example if the close range is 4 and t range is 8, anything within 4 units of the shotgun takes full damage, Anything within 4-8 units takes medium damage, and anything past 8 takes low damage.")]
		public float EnemyFarRange = 6f;
	}

	public UnityEvent ShotFired = new UnityEvent();

	public int gunCompatibleAmmoID = 211;

	public bool isReloading;

	public int shellsLoaded;

	public Animator gunAnimator;

	public AudioSource gunAudio;

	public AudioSource gunShootAudio;

	public AudioSource gunBulletsRicochetAudio;

	private Coroutine gunCoroutine;

	public AudioClip[] gunShootSFX;

	public AudioClip gunReloadSFX;

	public AudioClip gunReloadFinishSFX;

	public AudioClip noAmmoSFX;

	public AudioClip gunSafetySFX;

	public AudioClip switchSafetyOnSFX;

	public AudioClip switchSafetyOffSFX;

	public bool safetyOn;

	private float misfireTimer = 30f;

	private bool hasHitGroundWithSafetyOff = true;

	private int ammoSlotToUse = -1;

	private bool localClientSendingShootGunRPC;

	private PlayerControllerB previousPlayerHeldBy;

	public ParticleSystem gunShootParticle;

	public Transform shotgunRayPoint;

	public MeshRenderer shotgunShellLeft;

	public MeshRenderer shotgunShellRight;

	public MeshRenderer shotgunShellInHand;

	public Transform shotgunShellInHandTransform;

	private RaycastHit[] enemyColliders;

	private EnemyAI heldByEnemy;

	[Tooltip("If true, vanilla shotgun blast will occur alongside running the unity event")]
	public bool usegunblast = true;

	[Tooltip("If true, the left barrel reload animation will always play regardless of ammo count")]
	public bool UseLeftReloadAnimOnly = false;

	[Tooltip("Set Max Ammo that can be loaded")]
	public int maxShells = 2;

	[Tooltip("The Width of the blasts area of damage, this is NOT range. Only Width.")]
	public float ShotgunRadius = 5f;

	[Tooltip("How much ammo is added per item consumed")]
	public int ShotsPerReload = 1;

	[Tooltip("Will a tooltip showing loaded ammo be added to the gun?")]
	public bool showAmmoTooltip = false;

	[Tooltip("What to multiply the time it takes to reload by. Higher number = takes longer. For example 2 means twice as long and 0.5 means half as long")]
	public float ReloadSpeed = 1f;

	public PlayerDamageAndRangeSettings playerStuff;

	public EnemyDamageAndRangeSettings enemyStuff;

	public override void Start()
	{
		((GrabbableObject)this).Start();
		misfireTimer = 30f;
		hasHitGroundWithSafetyOff = true;
	}

	public override int GetItemDataToSave()
	{
		((GrabbableObject)this).GetItemDataToSave();
		return shellsLoaded;
	}

	public override void LoadItemSaveData(int saveData)
	{
		((GrabbableObject)this).LoadItemSaveData(saveData);
		safetyOn = true;
		shellsLoaded = saveData;
	}

	public override void Update()
	{
		((GrabbableObject)this).Update();
		if (!((NetworkBehaviour)this).IsOwner || shellsLoaded <= 0 || isReloading || (Object)(object)heldByEnemy != (Object)null || base.isPocketed)
		{
			return;
		}
		if (base.hasHitGround && !safetyOn && !hasHitGroundWithSafetyOff && !base.isHeld)
		{
			if (Random.Range(0, 100) < 5)
			{
				ShootGunAndSync(heldByPlayer: false);
			}
			hasHitGroundWithSafetyOff = true;
		}
		else if (!safetyOn && misfireTimer <= 0f && !StartOfRound.Instance.inShipPhase)
		{
			if (Random.Range(0, 100) < 4)
			{
				ShootGunAndSync(base.isHeld);
			}
			if (Random.Range(0, 100) < 5)
			{
				misfireTimer = 2f;
			}
			else
			{
				misfireTimer = Random.Range(28f, 50f);
			}
		}
		else if (!safetyOn)
		{
			misfireTimer -= Time.deltaTime;
		}
	}

	public override void EquipItem()
	{
		((GrabbableObject)this).EquipItem();
		previousPlayerHeldBy = base.playerHeldBy;
		previousPlayerHeldBy.equippedUsableItemQE = true;
		hasHitGroundWithSafetyOff = false;
	}

	public override void GrabItemFromEnemy(EnemyAI enemy)
	{
		((GrabbableObject)this).GrabItemFromEnemy(enemy);
		heldByEnemy = enemy;
		hasHitGroundWithSafetyOff = false;
	}

	public override void DiscardItemFromEnemy()
	{
		((GrabbableObject)this).DiscardItemFromEnemy();
		heldByEnemy = null;
	}

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		((GrabbableObject)this).ItemActivate(used, buttonDown);
		if (!isReloading)
		{
			if (shellsLoaded == 0)
			{
				StartReloadGun();
			}
			else if (safetyOn)
			{
				gunAudio.PlayOneShot(gunSafetySFX);
			}
			else if (((NetworkBehaviour)this).IsOwner)
			{
				ShootGunAndSync(heldByPlayer: true);
			}
		}
	}

	public void ShootGunAndSync(bool heldByPlayer)
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0067: 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_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		Vector3 shotgunPosition;
		Vector3 forward;
		if (!heldByPlayer)
		{
			shotgunPosition = shotgunRayPoint.position;
			forward = shotgunRayPoint.forward;
		}
		else
		{
			shotgunPosition = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.position - ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.up * 0.45f;
			forward = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.forward;
		}
		Debug.Log((object)"Calling shoot gun....");
		ShootGun(shotgunPosition, forward);
		Debug.Log((object)"Calling shoot gun and sync");
		localClientSendingShootGunRPC = true;
		ShootGunServerRpc(shotgunPosition, forward);
	}

	[ServerRpc(RequireOwnership = false)]
	public void ShootGunServerRpc(Vector3 shotgunPosition, Vector3 shotgunForward)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1348103381u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref shotgunPosition);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref shotgunForward);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 1348103381u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				ShootGunClientRpc(shotgunPosition, shotgunForward);
			}
		}
	}

	[ClientRpc]
	public void ShootGunClientRpc(Vector3 shotgunPosition, Vector3 shotgunForward)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val2 = default(ClientRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2841551309u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe(ref shotgunPosition);
			((FastBufferWriter)(ref val)).WriteValueSafe(ref shotgunForward);
			((NetworkBehaviour)this).__endSendClientRpc(ref val, 2841551309u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			Debug.Log((object)"Shoot gun client rpc received");
			if (localClientSendingShootGunRPC)
			{
				localClientSendingShootGunRPC = false;
				Debug.Log((object)"localClientSendingShootGunRPC was true");
			}
			else
			{
				ShootGun(shotgunPosition, shotgunForward);
			}
		}
	}

	public void ShootGun(Vector3 shotgunPosition, Vector3 shotgunForward)
	{
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: 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_013c: 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_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0336: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_041e: Unknown result type (might be due to invalid IL or missing references)
		//IL_045d: Unknown result type (might be due to invalid IL or missing references)
		//IL_046b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0502: Unknown result type (might be due to invalid IL or missing references)
		isReloading = false;
		bool flag = false;
		if (base.isHeld && (Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController)
		{
			base.playerHeldBy.playerBodyAnimator.SetTrigger("ShootShotgun");
			flag = true;
		}
		RoundManager.PlayRandomClip(gunShootAudio, gunShootSFX, true, 1f, 1840, 1000);
		WalkieTalkie.TransmitOneShotAudio(gunShootAudio, gunShootSFX[0], 1f);
		gunShootParticle.Play(true);
		shellsLoaded = Mathf.Clamp(shellsLoaded - 1, 0, maxShells);
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		if ((Object)(object)localPlayerController == (Object)null)
		{
			return;
		}
		if (usegunblast)
		{
			float num = Vector3.Distance(((Component)localPlayerController).transform.position, ((Component)shotgunRayPoint).transform.position);
			bool flag2 = false;
			int num2 = 0;
			float num3 = 0f;
			Vector3 val = localPlayerController.playerCollider.ClosestPoint(shotgunPosition);
			if (!flag && !Physics.Linecast(shotgunPosition, val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && Vector3.Angle(shotgunForward, val - shotgunPosition) < 30f)
			{
				flag2 = true;
			}
			if (num < playerStuff.PlayerSuperCloseRange)
			{
				num3 = 0.8f;
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
				num2 = playerStuff.PlayerSuperCloseDamage;
			}
			if (num < playerStuff.PlayerCloseRange)
			{
				num3 = 0.5f;
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
				num2 = playerStuff.PlayerCloseDamage;
			}
			else if (num < playerStuff.PlayerMediumRange)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
				num2 = playerStuff.PlayerMediumDamage;
			}
			else if (num < playerStuff.PlayerFarRange)
			{
				num2 = playerStuff.PlayerFarDamage;
			}
			if (num3 > 0f && SoundManager.Instance.timeSinceEarsStartedRinging > 16f)
			{
				((MonoBehaviour)this).StartCoroutine(delayedEarsRinging(num3));
			}
			Ray val2 = default(Ray);
			((Ray)(ref val2))..ctor(shotgunPosition, shotgunForward);
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val2, ref val3, playerStuff.PlayerFarRange, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				((Component)gunBulletsRicochetAudio).transform.position = ((Ray)(ref val2)).GetPoint(((RaycastHit)(ref val3)).distance - 0.5f);
				gunBulletsRicochetAudio.Play();
			}
			if (flag2)
			{
				localPlayerController.DamagePlayer(num2, true, true, (CauseOfDeath)7, 0, false, shotgunRayPoint.forward * playerStuff.RagdollForce);
			}
			if (!((NetworkBehaviour)this).IsOwner)
			{
				return;
			}
			if (enemyColliders == null)
			{
				enemyColliders = (RaycastHit[])(object)new RaycastHit[10];
			}
			((Ray)(ref val2))..ctor(shotgunPosition - shotgunForward * 10f, shotgunForward);
			int num4 = Physics.SphereCastNonAlloc(val2, ShotgunRadius, enemyColliders, enemyStuff.EnemiesMaximumRange, 524288, (QueryTriggerInteraction)2);
			List<EnemyAI> list = new List<EnemyAI>();
			IHittable val4 = default(IHittable);
			for (int i = 0; i < num4; i++)
			{
				if (!Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref enemyColliders[i])).transform).GetComponent<EnemyAICollisionDetect>()))
				{
					continue;
				}
				EnemyAI mainScript = ((Component)((RaycastHit)(ref enemyColliders[i])).transform).GetComponent<EnemyAICollisionDetect>().mainScript;
				if ((Object)(object)heldByEnemy != (Object)null && (Object)(object)heldByEnemy == (Object)(object)mainScript)
				{
					continue;
				}
				if (((RaycastHit)(ref enemyColliders[i])).distance == 0f)
				{
					Debug.Log((object)"Spherecast started inside enemy collider");
				}
				else if (!Physics.Linecast(shotgunPosition, ((RaycastHit)(ref enemyColliders[i])).point, ref val3, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && ((Component)((RaycastHit)(ref enemyColliders[i])).transform).TryGetComponent<IHittable>(ref val4))
				{
					float num5 = Vector3.Distance(shotgunPosition, ((RaycastHit)(ref enemyColliders[i])).point);
					int num6 = ((num5 < enemyStuff.EnemyCloseRange) ? enemyStuff.EnemyFullDamage : ((!(num5 < enemyStuff.EnemyFarRange)) ? enemyStuff.EnemyLowDamage : enemyStuff.EnemyMediumDamage));
					EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref enemyColliders[i])).collider).GetComponent<EnemyAICollisionDetect>();
					if ((!((Object)(object)component != (Object)null) || (!((Object)(object)component.mainScript == (Object)null) && !list.Contains(component.mainScript))) && val4.Hit(num6, shotgunForward, base.playerHeldBy, true, -1) && (Object)(object)component != (Object)null)
					{
						list.Add(component.mainScript);
					}
				}
			}
		}
		ShotFired.Invoke();
	}

	private IEnumerator delayedEarsRinging(float effectSeverity)
	{
		yield return (object)new WaitForSeconds(0.6f);
		SoundManager.Instance.earsRingingTimer = effectSeverity;
	}

	public override void ItemInteractLeftRight(bool right)
	{
		((GrabbableObject)this).ItemInteractLeftRight(right);
		if ((Object)(object)base.playerHeldBy == (Object)null)
		{
			return;
		}
		Debug.Log((object)$"r/l activate: {right}");
		if (!right)
		{
			if (safetyOn)
			{
				safetyOn = false;
				gunAudio.PlayOneShot(switchSafetyOffSFX);
				WalkieTalkie.TransmitOneShotAudio(gunAudio, switchSafetyOffSFX, 1f);
				SetSafetyControlTip();
			}
			else
			{
				safetyOn = true;
				gunAudio.PlayOneShot(switchSafetyOnSFX);
				WalkieTalkie.TransmitOneShotAudio(gunAudio, switchSafetyOnSFX, 1f);
				SetSafetyControlTip();
			}
			base.playerHeldBy.playerBodyAnimator.SetTrigger("SwitchGunSafety");
		}
		else if (!isReloading && shellsLoaded < maxShells)
		{
			StartReloadGun();
		}
	}

	public override void SetControlTipsForItem()
	{
		string[] toolTips = base.itemProperties.toolTips;
		if (toolTips.Length <= 2)
		{
			Debug.LogError((object)"Shotgun control tips array length is too short to set tips!");
			return;
		}
		if (safetyOn)
		{
			toolTips[2] = "Turn safety off: [Q]";
		}
		else
		{
			toolTips[2] = "Turn safety on: [Q]";
		}
		HUDManager.Instance.ChangeControlTipMultiple(toolTips, true, base.itemProperties);
	}

	private void SetSafetyControlTip()
	{
		string text = ((!safetyOn) ? "Turn safety on: [Q]" : "Turn safety off: [Q]");
		if (((NetworkBehaviour)this).IsOwner)
		{
			HUDManager.Instance.ChangeControlTip(3, text, false);
		}
	}

	private void StartReloadGun()
	{
		if (ReloadedGun())
		{
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (gunCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(gunCoroutine);
				}
				gunCoroutine = ((MonoBehaviour)this).StartCoroutine(reloadGunAnimation());
			}
		}
		else
		{
			gunAudio.PlayOneShot(noAmmoSFX);
		}
	}

	[ServerRpc]
	public void ReloadGunEffectsServerRpc(bool start = true)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Invalid comparison between Unknown and I4
		//IL_0122: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val2 = default(ServerRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3990329482u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref start, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendServerRpc(ref val, 3990329482u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			ReloadGunEffectsClientRpc(start);
		}
	}

	[ClientRpc]
	public void ReloadGunEffectsClientRpc(bool start = true)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val2 = default(ClientRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1424635684u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref start, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val, 1424635684u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsClient && !networkManager.IsHost))
		{
			return;
		}
		((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
		if (!((NetworkBehaviour)this).IsOwner)
		{
			if (start)
			{
				gunAudio.PlayOneShot(gunReloadSFX);
				WalkieTalkie.TransmitOneShotAudio(gunAudio, gunReloadSFX, 1f);
				gunAnimator.SetBool("Reloading", true);
				isReloading = true;
			}
			else
			{
				shellsLoaded = Mathf.Clamp(shellsLoaded + ShotsPerReload, 0, maxShells);
				gunAudio.PlayOneShot(gunReloadFinishSFX);
				gunAnimator.SetBool("Reloading", false);
				isReloading = false;
			}
		}
	}

	private IEnumerator reloadGunAnimation()
	{
		isReloading = true;
		if (shellsLoaded <= 0 || UseLeftReloadAnimOnly)
		{
			base.playerHeldBy.playerBodyAnimator.SetBool("ReloadShotgun", true);
			((Renderer)shotgunShellLeft).enabled = false;
			((Renderer)shotgunShellRight).enabled = false;
		}
		else
		{
			base.playerHeldBy.playerBodyAnimator.SetBool("ReloadShotgun2", true);
			((Renderer)shotgunShellRight).enabled = false;
		}
		yield return (object)new WaitForSeconds(0.3f * ReloadSpeed);
		gunAudio.PlayOneShot(gunReloadSFX);
		gunAnimator.SetBool("Reloading", true);
		ReloadGunEffectsServerRpc();
		yield return (object)new WaitForSeconds(0.95f * ReloadSpeed);
		((Renderer)shotgunShellInHand).enabled = true;
		shotgunShellInHandTransform.SetParent(base.playerHeldBy.leftHandItemTarget);
		shotgunShellInHandTransform.localPosition = new Vector3(-0.0555f, 0.1469f, -0.0655f);
		shotgunShellInHandTransform.localEulerAngles = new Vector3(-1.956f, 143.856f, -16.427f);
		yield return (object)new WaitForSeconds(0.95f * ReloadSpeed);
		base.playerHeldBy.DestroyItemInSlotAndSync(ammoSlotToUse);
		ammoSlotToUse = -1;
		shellsLoaded = Mathf.Clamp(shellsLoaded + ShotsPerReload, 0, maxShells);
		((Renderer)shotgunShellLeft).enabled = true;
		if (shellsLoaded >= 2)
		{
			((Renderer)shotgunShellRight).enabled = true;
		}
		else
		{
			((Renderer)shotgunShellRight).enabled = false;
		}
		((Renderer)shotgunShellInHand).enabled = false;
		shotgunShellInHandTransform.SetParent(((Component)this).transform);
		yield return (object)new WaitForSeconds(0.45f * ReloadSpeed);
		gunAudio.PlayOneShot(gunReloadFinishSFX);
		gunAnimator.SetBool("Reloading", false);
		base.playerHeldBy.playerBodyAnimator.SetBool("ReloadShotgun", false);
		base.playerHeldBy.playerBodyAnimator.SetBool("ReloadShotgun2", false);
		isReloading = false;
		ReloadGunEffectsServerRpc(start: false);
	}

	private bool ReloadedGun()
	{
		int num = FindAmmoInInventory();
		if (num == -1)
		{
			Debug.Log((object)"not reloading");
			return false;
		}
		Debug.Log((object)"reloading!");
		ammoSlotToUse = num;
		return true;
	}

	private int FindAmmoInInventory()
	{
		for (int i = 0; i < base.playerHeldBy.ItemSlots.Length; i++)
		{
			if (!((Object)(object)base.playerHeldBy.ItemSlots[i] == (Object)null))
			{
				GrabbableObject obj = base.playerHeldBy.ItemSlots[i];
				GunAmmo val = (GunAmmo)(object)((obj is GunAmmo) ? obj : null);
				Debug.Log((object)$"Ammo null in slot #{i}?: {(Object)(object)val == (Object)null}");
				if ((Object)(object)val != (Object)null)
				{
					Debug.Log((object)$"Ammo in slot #{i} id: {val.ammoType}");
				}
				if ((Object)(object)val != (Object)null && val.ammoType == gunCompatibleAmmoID)
				{
					return i;
				}
			}
		}
		return -1;
	}

	public override void PocketItem()
	{
		((GrabbableObject)this).PocketItem();
		StopUsingGun();
	}

	public override void DiscardItem()
	{
		((GrabbableObject)this).DiscardItem();
		StopUsingGun();
	}

	private void StopUsingGun()
	{
		previousPlayerHeldBy.equippedUsableItemQE = false;
		if (isReloading)
		{
			if (gunCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(gunCoroutine);
			}
			gunAnimator.SetBool("Reloading", false);
			gunAudio.Stop();
			if ((Object)(object)previousPlayerHeldBy != (Object)null)
			{
				previousPlayerHeldBy.playerBodyAnimator.SetBool("ReloadShotgun", false);
				previousPlayerHeldBy.playerBodyAnimator.SetBool("ReloadShotgun2", false);
			}
			((Renderer)shotgunShellInHand).enabled = false;
			shotgunShellInHandTransform.SetParent(((Component)this).transform);
			isReloading = false;
		}
	}

	protected override void __initializeVariables()
	{
		((GrabbableObject)this).__initializeVariables();
	}

	protected override void __initializeRpcs()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		((NetworkBehaviour)this).__registerRpc(1348103381u, new RpcReceiveHandler(__rpc_handler_1348103381), "ShootGunServerRpc");
		((NetworkBehaviour)this).__registerRpc(2841551309u, new RpcReceiveHandler(__rpc_handler_2841551309), "ShootGunClientRpc");
		((NetworkBehaviour)this).__registerRpc(3990329482u, new RpcReceiveHandler(__rpc_handler_3990329482), "ReloadGunEffectsServerRpc");
		((NetworkBehaviour)this).__registerRpc(1424635684u, new RpcReceiveHandler(__rpc_handler_1424635684), "ReloadGunEffectsClientRpc");
		((GrabbableObject)this).__initializeRpcs();
	}

	private static void __rpc_handler_1348103381(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0043: 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_0052: 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)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			Vector3 shotgunPosition = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref shotgunPosition);
			Vector3 shotgunForward = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref shotgunForward);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((CustomShotgun)(object)target).ShootGunServerRpc(shotgunPosition, shotgunForward);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_2841551309(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0043: 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_0052: 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)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			Vector3 shotgunPosition = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref shotgunPosition);
			Vector3 shotgunForward = default(Vector3);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref shotgunForward);
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((CustomShotgun)(object)target).ShootGunClientRpc(shotgunPosition, shotgunForward);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_3990329482(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_0023: 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_0029: 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_0082: 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_00ab: 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_0055: Invalid comparison between Unknown and I4
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId)
		{
			if ((int)networkManager.LogLevel <= 1)
			{
				Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
			}
		}
		else
		{
			bool start = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref start, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((CustomShotgun)(object)target).ReloadGunEffectsServerRpc(start);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	private static void __rpc_handler_1424635684(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
	{
		//IL_002f: 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_0044: 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)
		NetworkManager networkManager = target.NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			bool start = default(bool);
			((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref start, default(ForPrimitives));
			target.__rpc_exec_stage = (__RpcExecStage)1;
			((CustomShotgun)(object)target).ReloadGunEffectsClientRpc(start);
			target.__rpc_exec_stage = (__RpcExecStage)0;
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining)]
	protected internal override string __getTypeName()
	{
		return "CustomShotgun";
	}
}
internal static class DawnLibCompat
{
	private static bool? _enabled;

	public static bool Enabled
	{
		get
		{
			bool valueOrDefault = _enabled == true;
			if (!_enabled.HasValue)
			{
				valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.github.teamxiaolan.dawnlib");
				_enabled = valueOrDefault;
			}
			return _enabled.Value;
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	internal static HashSet<string> GetDawnLibTags(SelectableLevel selectableLevel)
	{
		List<string> list = (from tag in ((DawnBaseInfo<DawnMoonInfo>)(object)SelectableLevelExtensions.GetDawnInfo(selectableLevel)).AllTags()
			select tag.Key).ToList();
		for (int num = 0; num < list.Count; num++)
		{
			list[num] = list[num].Replace("_", " ");
		}
		return list.ToHashSet();
	}
}
public class ExplosiveButler : EnemyAI
{
	private Vector3[] lastSeenPlayerPositions;

	public UnityEvent Popping = new UnityEvent();

	private bool[] seenPlayers;

	private float[] timeOfLastSeenPlayers;

	private float timeSinceSeeingMultiplePlayers;

	private float timeSinceCheckingForMultiplePlayers;

	private float timeUntilNextCheck;

	private int playersInVicinity;

	private int currentSpecialAnimation;

	private float timeSinceLastSpecialAnimation;

	private bool doingKillAnimation;

	private int previousBehaviourState = -1;

	private int playersInView;

	private Vector3 agentLocalVelocity;

	public Transform animationContainer;

	private float velX;

	private float velZ;

	private Vector3 previousPosition;

	private PlayerControllerB watchingPlayer;

	public Transform lookTarget;

	public MultiAimConstraint headLookRig;

	public Transform turnCompass;

	public Transform headLookTarget;

	private float sweepFloorTimer;

	private bool isSweeping;

	public AISearchRoutine roamAndSweepFloor;

	public AISearchRoutine hoverAroundTargetPlayer;

	public float idleMovementSpeedBase = 3.5f;

	public float timeSinceChangingItem;

	private float timeSinceHittingPlayer;

	public AudioSource ambience1;

	public AudioSource buzzingAmbience;

	public AudioSource sweepingAudio;

	public AudioClip[] footsteps;

	public AudioClip[] broomSweepSFX;

	private float timeAtLastFootstep;

	private float pingAttentionTimer;

	private int focusLevel;

	private Vector3 pingAttentionPosition;

	private float timeSincePingingAttention;

	private Coroutine checkForPlayersCoroutine;

	private bool hasPlayerInSight;

	private float timeSinceNoticingFirstPlayer;

	private bool lostPlayerInChase;

	private float loseInChaseTimer;

	private bool startedMurderMusic;

	private PlayerControllerB targetedPlayerAlonePreviously;

	private bool checkedForTargetedPlayerPosition;

	private float timeAtLastTargetPlayerSync;

	private PlayerControllerB syncedTargetPlayer;

	private bool trackingTargetPlayerDownToMurder;

	private float premeditationTimeMultiplier = 1f;

	private float timeSpentWaitingForPlayer;

	[Space(3f)]
	[Header("Death sequence")]
	private bool startedButlerDeathAnimation;

	public ParticleSystem popParticle;

	public AudioSource popAudio;

	public AudioSource popAudioFar;

	public EnemyType butlerBeesEnemyType;

	private float timeAtLastButlerDamage;

	public ParticleSystem stabBloodParticle;

	private float timeAtLastHeardNoise;

	private bool killedLastTarget;

	private bool startedCrimeSceneTimer;

	private float leaveCrimeSceneTimer;

	private PlayerControllerB lastMurderedTarget;

	public GameObject knifePrefab;

	public AudioSource ambience2;

	public static AudioSource murderMusicAudio;

	public static bool increaseMurderMusicVolume;

	public static float murderMusicVolume;

	public bool madlySearchingForPlayers;

	private float ambushSpeedMeter;

	private float timeSinceStealthStab;

	private float berserkModeTimer;

	private void LateUpdate()
	{
		if ((Object)(object)ambience2 == (Object)(object)murderMusicAudio)
		{
			if (increaseMurderMusicVolume)
			{
				increaseMurderMusicVolume = false;
			}
			else
			{
				murderMusicVolume = Mathf.Max(murderMusicVolume - Time.deltaTime * 0.4f, 0f);
			}
			if ((Object)(object)murderMusicAudio != (Object)null)
			{
				murderMusicAudio.volume = murderMusicVolume;
			}
		}
	}

	public override void Start()
	{
		((EnemyAI)this).Start();
		lastSeenPlayerPositions = (Vector3[])(object)new Vector3[4];
		seenPlayers = new bool[4];
		timeOfLastSeenPlayers = new float[4];
		if ((Object)(object)murderMusicAudio == (Object)null)
		{
			((Component)ambience2).transform.SetParent(RoundManager.Instance.spawnedScrapContainer);
			murderMusicAudio = ambience2;
		}
		if (StartOfRound.Instance.connectedPlayersAmount == 0)
		{
			base.enemyHP = 2;
			idleMovementSpeedBase *= 0.75f;
		}
	}

	public override void KillEnemy(bool destroy = false)
	{
		((EnemyAI)this).KillEnemy(destroy);
		if (base.currentSearch.inProgress)
		{
			((EnemyAI)this).StopSearch(base.currentSearch, true);
		}
		ambience1.Stop();
		ambience1.volume = 0f;
		ambience2.Stop();
		ambience2.volume = 0f;
		base.agent.speed = 0f;
		base.agent.acceleration = 1000f;
		if (!startedButlerDeathAnimation)
		{
			startedButlerDeathAnimation = true;
			((MonoBehaviour)this).StartCoroutine(ButlerBlowUpAndPop());
		}
	}

	private IEnumerator ButlerBlowUpAndPop()
	{
		base.creatureAnimator.SetTrigger("Popping");
		base.creatureAnimator.SetLayerWeight(1, 0f);
		popAudio.PlayOneShot(base.enemyType.audioClips[3]);
		yield return (object)new WaitForSeconds(1.1f);
		base.creatureAnimator.SetBool("popFinish", true);
		popAudio.Play();
		popAudioFar.Play();
		popParticle.Play(true);
		Popping.Invoke();
		float num = Vector3.Distance(((Component)GameNetworkManager.Instance.localPlayerController).transform.position, ((Component)this).transform.position);
		if (num < 8f)
		{
			Landmine.SpawnExplosion(((Component)this).transform.position + Vector3.up * 0.15f, false, 0f, 5f, 60, 20f, (GameObject)null, false);
			HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			SoundManager.Instance.earsRingingTimer = 0.8f;
		}
		else if (num < 27f)
		{
			HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
		}
	}

	public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
	{
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
		base.enemyHP -= force;
		if (hitID == 5)
		{
			base.enemyHP -= 100;
		}
		if ((Object)(object)playerWhoHit != (Object)null)
		{
			berserkModeTimer = 8f;
		}
		if (base.enemyHP <= 0 && ((NetworkBehaviour)this).IsOwner)
		{
			((EnemyAI)this).KillEnemyOnOwnerClient(false);
		}
		else if ((Object)(object)playerWhoHit != (Object)null && (base.currentBehaviourStateIndex != 2 || (Object)(object)playerWhoHit != (Object)(object)base.targetPlayer))
		{
			PingAttention(5, 0.6f, ((Component)playerWhoHit).transform.position, sync: false);
			timeAtLastButlerDamage = Time.realtimeSinceStartup;
		}
	}

	public override void DoAIInterval()
	{
		//IL_0198: 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_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DoAIInterval();
		if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead || previousBehaviourState != base.currentBehaviourStateIndex)
		{
			return;
		}
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
			if (killedLastTarget && !startedCrimeSceneTimer)
			{
				Debug.Log((object)"Starting leave crime scene timer");
				Debug.Log((object)$"Target player: {base.targetPlayer.playerClientId}");
				startedCrimeSceneTimer = true;
				leaveCrimeSceneTimer = 15f;
				base.movingTowardsTargetPlayer = false;
				if (hoverAroundTargetPlayer.inProgress)
				{
					((EnemyAI)this).StopSearch(hoverAroundTargetPlayer, true);
				}
				if (roamAndSweepFloor.inProgress)
				{
					((EnemyAI)this).StopSearch(roamAndSweepFloor, true);
				}
				((EnemyAI)this).SetDestinationToPosition(((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)this).transform.position, false, 0, false, 50, -1).position, false);
			}
			LookForChanceToMurder(1f);
			break;
		case 1:
			LookForChanceToMurder(4f);
			break;
		case 2:
		{
			if ((Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)(object)base.targetPlayer || !((NetworkBehaviour)this).IsOwner)
			{
				break;
			}
			if (base.targetPlayer.isPlayerDead && ((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer.deadBody.bodyParts[5]).transform.position, 120f, 60, 2f, (Transform)null))
			{
				if (playersInVicinity < 2 || berserkModeTimer > 0f)
				{
					PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForPlayer(100f, 50, 2);
					if ((Object)(object)val != (Object)null)
					{
						base.targetPlayer = val;
						SwitchOwnershipAndSetToStateServerRpc(2, base.targetPlayer.actualClientId, berserkModeTimer);
						Debug.Log((object)"State 2, changing ownership A");
						break;
					}
				}
				Debug.Log((object)"State 2, Switching to state 0, killed target");
				SyncKilledLastTargetServerRpc((int)base.targetPlayer.playerClientId);
				((EnemyAI)this).SwitchToBehaviourState(0);
				((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
				break;
			}
			if (timeSinceChangingItem < 1.7f || (pingAttentionTimer > 0f && berserkModeTimer <= 0f) || base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
				break;
			}
			base.agent.speed = 8f;
			base.creatureAnimator.SetBool("Running", true);
			if (lostPlayerInChase)
			{
				if (!hoverAroundTargetPlayer.inProgress)
				{
					base.movingTowardsTargetPlayer = false;
					((EnemyAI)this).StartSearch(lastSeenPlayerPositions[base.targetPlayer.playerClientId], hoverAroundTargetPlayer);
				}
				PlayerControllerB val2 = ((EnemyAI)this).CheckLineOfSightForPlayer(100f, 50, 2);
				if ((Object)(object)val2 == (Object)null)
				{
					loseInChaseTimer += base.AIIntervalTime;
					if (loseInChaseTimer > 12f)
					{
						targetedPlayerAlonePreviously = base.targetPlayer;
						Debug.Log((object)"State 2, Switching to state 0, lost in chase");
						((EnemyAI)this).SwitchToBehaviourState(0);
						((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
					}
				}
				else if ((Object)(object)val2 == (Object)(object)base.targetPlayer && playersInVicinity < 2)
				{
					lostPlayerInChase = false;
					loseInChaseTimer = 0f;
				}
				else if (berserkModeTimer <= 0f)
				{
					targetedPlayerAlonePreviously = base.targetPlayer;
					Debug.Log((object)"State 2, Switching to state 0, found another player or multiple players 1");
					((EnemyAI)this).SwitchToBehaviourState(0);
					((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
				}
				break;
			}
			PlayerControllerB val3 = ((EnemyAI)this).CheckLineOfSightForPlayer(100f, 50, 2);
			if ((Object)(object)val3 == (Object)null)
			{
				loseInChaseTimer += base.AIIntervalTime;
				if (loseInChaseTimer > 3.5f)
				{
					lostPlayerInChase = true;
				}
			}
			else
			{
				if (((Object)(object)val3 != (Object)(object)base.targetPlayer || playersInVicinity > 1) && berserkModeTimer <= 0f)
				{
					targetedPlayerAlonePreviously = base.targetPlayer;
					Debug.Log((object)"State 2, Switching to state 0, found another player or multiple players 2");
					((EnemyAI)this).SwitchToBehaviourState(0);
					((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
					break;
				}
				if ((Object)(object)val3 == (Object)(object)base.targetPlayer)
				{
					loseInChaseTimer = 0f;
				}
			}
			((EnemyAI)this).SetMovingTowardsTargetPlayer(base.targetPlayer);
			break;
		}
		}
	}

	public void LookForChanceToMurder(float waitForTime = 5f)
	{
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_050d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0518: Unknown result type (might be due to invalid IL or missing references)
		//IL_0658: Unknown result type (might be due to invalid IL or missing references)
		//IL_065d: Unknown result type (might be due to invalid IL or missing references)
		//IL_052f: Unknown result type (might be due to invalid IL or missing references)
		//IL_053e: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_079a: Unknown result type (might be due to invalid IL or missing references)
		if (!((NetworkBehaviour)this).IsOwner)
		{
			return;
		}
		if (base.currentBehaviourStateIndex == 1 && playersInVicinity > 1)
		{
			((EnemyAI)this).SwitchToBehaviourState(0);
		}
		if (playersInVicinity <= 0)
		{
			if (killedLastTarget)
			{
				leaveCrimeSceneTimer -= base.AIIntervalTime;
				if (leaveCrimeSceneTimer <= 0f)
				{
					killedLastTarget = false;
					startedCrimeSceneTimer = false;
					base.creatureAnimator.SetInteger("HeldItem", 1);
					base.creatureAnimator.SetBool("Running", false);
					SyncKilledLastTargetFalseClientRpc();
					Debug.Log((object)"Exiting leave crime scene mode, 0");
				}
				return;
			}
			if (!roamAndSweepFloor.inProgress)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, roamAndSweepFloor);
				sweepFloorTimer = 5f;
			}
			hasPlayerInSight = false;
			checkedForTargetedPlayerPosition = false;
			timeSinceSeeingMultiplePlayers = 0f;
			timeSinceCheckingForMultiplePlayers = 3f;
			timeSpentWaitingForPlayer += base.AIIntervalTime;
			if (timeSpentWaitingForPlayer > 6f && !madlySearchingForPlayers)
			{
				madlySearchingForPlayers = true;
				roamAndSweepFloor.searchPrecision = 16f;
				SyncSearchingMadlyServerRpc(isSearching: true);
			}
			return;
		}
		if (!hasPlayerInSight)
		{
			hasPlayerInSight = true;
			timeSpentWaitingForPlayer = 0f;
			timeSinceNoticingFirstPlayer = 0f;
			ButlerNoticePlayerServerRpc();
			if (killedLastTarget)
			{
				if (playersInVicinity < 2 && !Physics.Linecast(((Component)base.targetPlayer.gameplayCamera).transform.position, ((Component)lastMurderedTarget.deadBody.bodyParts[6]).transform.position + Vector3.up * 0.5f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					killedLastTarget = false;
					startedCrimeSceneTimer = false;
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
					SwitchOwnershipAndSetToStateServerRpc(2, base.targetPlayer.actualClientId);
					Debug.Log((object)"Found a player; Caught red-handed, entering murder state");
					for (int i = 0; i < seenPlayers.Length; i++)
					{
						Debug.Log((object)$"Seen player {i}: {seenPlayers[i]}");
					}
				}
				else
				{
					killedLastTarget = false;
					startedCrimeSceneTimer = false;
					leaveCrimeSceneTimer = 0f;
					base.creatureAnimator.SetInteger("HeldItem", 1);
					base.creatureAnimator.SetBool("Running", false);
					SyncKilledLastTargetFalseClientRpc();
					PingAttention(4, 0.6f, ((Component)lastMurderedTarget.deadBody.bodyParts[0]).transform.position);
				}
			}
			if (roamAndSweepFloor.inProgress)
			{
				((EnemyAI)this).StopSearch(roamAndSweepFloor, true);
			}
			if (!hoverAroundTargetPlayer.inProgress)
			{
				((EnemyAI)this).StartSearch(((Component)base.targetPlayer).transform.position, hoverAroundTargetPlayer);
			}
			if (base.currentBehaviourStateIndex == 1 && (Object)(object)((EnemyAI)this).CheckLineOfSightForPlayer(120f, 50, 2) == (Object)(object)base.targetPlayer && playersInVicinity < 2 && timeSpentWaitingForPlayer > 8f)
			{
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
				SwitchOwnershipAndSetToStateServerRpc(2, base.targetPlayer.actualClientId);
				return;
			}
			premeditationTimeMultiplier -= base.AIIntervalTime * 0.04f;
			if (!checkedForTargetedPlayerPosition && Time.realtimeSinceStartup - timeOfLastSeenPlayers[base.targetPlayer.playerClientId] > 4f)
			{
				checkedForTargetedPlayerPosition = true;
				PingAttention(4, 0.8f, lastSeenPlayerPositions[base.targetPlayer.playerClientId]);
			}
		}
		if (madlySearchingForPlayers)
		{
			madlySearchingForPlayers = false;
			SyncSearchingMadlyServerRpc(isSearching: false);
			roamAndSweepFloor.searchPrecision = 10f;
		}
		if (Time.realtimeSinceStartup - timeAtLastButlerDamage < 3f)
		{
			((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
			SwitchOwnershipAndSetToStateServerRpc(2, base.targetPlayer.actualClientId);
			return;
		}
		if (berserkModeTimer <= 0f)
		{
			ButlerEnemyAI[] array = Object.FindObjectsByType<ButlerEnemyAI>((FindObjectsSortMode)0);
			for (int j = 0; j < array.Length; j++)
			{
				if (array[j].berserkModeTimer > 2f && Vector3.Distance(((Component)array[j]).transform.position, ((Component)this).transform.position) < 15f && !Physics.Linecast(base.eye.position, ((EnemyAI)array[j]).eye.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
				{
					berserkModeTimer = array[j].berserkModeTimer;
					break;
				}
			}
		}
		if (playersInVicinity > 1 && base.currentBehaviourStateIndex == 1 && berserkModeTimer <= 0f)
		{
			((EnemyAI)this).SwitchToBehaviourState(0);
		}
		else if (trackingTargetPlayerDownToMurder || berserkModeTimer > 0f)
		{
			PlayerControllerB val = ((EnemyAI)this).CheckLineOfSightForPlayer(100f, 50, 2);
			if ((Object)(object)val != (Object)null)
			{
				if ((Object)(object)val == (Object)(object)base.targetPlayer)
				{
					((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(2);
					SwitchOwnershipAndSetToStateServerRpc(2, base.targetPlayer.actualClientId, berserkModeTimer);
				}
				else
				{
					((EnemyAI)this).SwitchToBehaviourState(0);
				}
			}
		}
		hoverAroundTargetPlayer.currentSearchStartPosition = ((Component)base.targetPlayer).transform.position;
		if (timeSinceCheckingForMultiplePlayers > timeUntilNextCheck && timeSinceNoticingFirstPlayer > 1.5f)
		{
			StartCheckForPlayers();
		}
		else
		{
			timeSinceCheckingForMultiplePlayers += base.AIIntervalTime;
		}
		if (timeSinceSeeingMultiplePlayers > waitForTime * premeditationTimeMultiplier && !trackingTargetPlayerDownToMurder)
		{
			if (timeSinceCheckingForMultiplePlayers > 5f)
			{
				StartCheckForPlayers();
			}
			else
			{
				if (!(timeSinceCheckingForMultiplePlayers > 2f) || !(timeSinceCheckingForMultiplePlayers < 4f))
				{
					return;
				}
				if (base.currentBehaviourStateIndex == 0)
				{
					if ((Object)(object)base.targetPlayer == (Object)(object)targetedPlayerAlonePreviously)
					{
						SwitchOwnershipAndSetToStateServerRpc(2, base.targetPlayer.actualClientId);
					}
					else
					{
						((EnemyAI)this).SwitchToBehaviourState(1);
					}
				}
				else if (base.currentBehaviourStateIndex == 1)
				{
					trackingTargetPlayerDownToMurder = true;
					PingAttention(4, 0.5f, lastSeenPlayerPositions[base.targetPlayer.playerClientId]);
				}
			}
		}
		else
		{
			timeSinceSeeingMultiplePlayers += base.AIIntervalTime;
		}
	}

	private void ForgetSeenPlayers()
	{
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < timeOfLastSeenPlayers.Length; i++)
		{
			if (seenPlayers[i])
			{
				if (StartOfRound.Instance.allPlayerScripts[i].isPlayerDead)
				{
					seenPlayers[i] = false;
				}
				float num = Time.realtimeSinceStartup - timeOfLastSeenPlayers[i];
				float num2 = ((i != (int)base.targetPlayer.playerClientId) ? 6f : 12f);
				if (num > num2 || (Time.realtimeSinceStartup - timeOfLastSeenPlayers[i] > 2f && timeSinceCheckingForMultiplePlayers > 2f && timeSinceCheckingForMultiplePlayers < 4f))
				{
					seenPlayers[i] = false;
				}
			}
		}
		if (base.currentBehaviourStateIndex != 2 && (Object)(object)base.targetPlayer != (Object)null && Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.7f, ((Component)base.targetPlayer.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && isSweeping)
		{
			isSweeping = false;
			SetSweepingAnimServerRpc(sweeping: false);
		}
	}

	public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).DetectNoise(noisePosition, noiseLoudness, timesPlayedInOneSpot, noiseID);
		if ((!((NetworkBehaviour)this).IsOwner && noiseID != 75) || base.isEnemyDead || Time.realtimeSinceStartup - timeAtLastHeardNoise < 3f || Vector3.Distance(noisePosition, ((Component)this).transform.position + Vector3.up * 0.4f) < 0.75f || ((Object)(object)base.targetPlayer != (Object)null && Time.realtimeSinceStartup - timeOfLastSeenPlayers[base.targetPlayer.playerClientId] < 7f && Vector3.Distance(noisePosition + Vector3.up * 0.4f, ((Component)base.targetPlayer).transform.position) < 1f) || (base.currentBehaviourStateIndex == 2 && (Vector3.Angle(((Component)this).transform.forward, noisePosition - ((Component)this).transform.position) < 60f || (!lostPlayerInChase && Vector3.Distance(((Component)base.targetPlayer).transform.position, noisePosition) < 2f))))
		{
			return;
		}
		float num = Vector3.Distance(noisePosition, ((Component)this).transform.position);
		float num2 = noiseLoudness / num;
		if (Physics.Linecast(((Component)this).transform.position, noisePosition, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
		{
			num2 *= 0.5f;
		}
		if (pingAttentionTimer > 0f)
		{
			if (focusLevel >= 3)
			{
				if (num > 3f || num2 <= 0.12f)
				{
					return;
				}
			}
			else if (focusLevel == 2)
			{
				if (num > 25f || num2 <= 0.09f)
				{
					return;
				}
			}
			else if (focusLevel <= 1 && (num > 40f || num2 <= 0.06f))
			{
				return;
			}
		}
		if (!(num2 <= 0.03f))
		{
			timeAtLastHeardNoise = Time.realtimeSinceStartup;
			PingAttention(3, 0.5f, noisePosition + Vector3.up * 0.6f);
		}
	}

	public override void Update()
	{
		//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0920: Unknown result type (might be due to invalid IL or missing references)
		//IL_0925: Unknown result type (might be due to invalid IL or missing references)
		//IL_092f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0934: Unknown result type (might be due to invalid IL or missing references)
		//IL_0889: Unknown result type (might be due to invalid IL or missing references)
		//IL_088e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0898: Unknown result type (might be due to invalid IL or missing references)
		//IL_089d: Unknown result type (might be due to invalid IL or missing references)
		((EnemyAI)this).Update();
		if (GameNetworkManager.Instance.localPlayerController.isPlayerDead)
		{
			ambience2.volume = Mathf.Lerp(ambience2.volume, 0f, base.AIIntervalTime * 9f);
		}
		if (!base.ventAnimationFinished || base.isEnemyDead)
		{
			base.creatureAnimator.SetLayerWeight(1, 0f);
		}
		else
		{
			base.creatureAnimator.SetLayerWeight(1, 1f);
		}
		if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
		{
			return;
		}
		timeSinceLastSpecialAnimation += Time.deltaTime;
		if (berserkModeTimer > 0f)
		{
			timeSinceChangingItem += Time.deltaTime * 6f;
		}
		else
		{
			timeSinceChangingItem += Time.deltaTime;
		}
		timeSinceHittingPlayer += Time.deltaTime;
		timeSinceNoticingFirstPlayer += Time.deltaTime;
		pingAttentionTimer -= Time.deltaTime;
		timeSincePingingAttention += Time.deltaTime;
		berserkModeTimer -= Time.deltaTime;
		CalculateAnimationDirection();
		if (((NetworkBehaviour)this).IsOwner)
		{
			CheckLOS();
			ForgetSeenPlayers();
		}
		AnimateLooking();
		switch (base.currentBehaviourStateIndex)
		{
		case 0:
			if (previousBehaviourState != base.currentBehaviourStateIndex)
			{
				if ((Object)(object)base.targetPlayer != (Object)null)
				{
					Debug.Log((object)$"Target player: {base.targetPlayer.playerClientId}; is dead?: {base.targetPlayer.isPlayerDead}");
				}
				base.creatureSFX.PlayOneShot(base.enemyType.audioClips[1]);
				WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, base.enemyType.audioClips[1], 1f);
				timeSinceChangingItem = 0f;
				buzzingAmbience.pitch = 1f;
				buzzingAmbience.volume = 0.6f;
				checkedForTargetedPlayerPosition = false;
				timeSinceSeeingMultiplePlayers = 0f;
				base.movingTowardsTargetPlayer = false;
				trackingTargetPlayerDownToMurder = false;
				base.addPlayerVelocityToDestination = 0f;
				base.agent.acceleration = 26f;
				previousBehaviourState = base.currentBehaviourStateIndex;
			}
			if (killedLastTarget || madlySearchingForPlayers)
			{
				base.creatureAnimator.SetInteger("HeldItem", 0);
				base.creatureAnimator.SetBool("Running", true);
			}
			else
			{
				base.creatureAnimator.SetInteger("HeldItem", 1);
				base.creatureAnimator.SetBool("Running", false);
			}
			if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.75f, 70f, 30, 2f, -1))
			{
				ambience1.volume = Mathf.Lerp(ambience1.volume, 1f, Time.deltaTime * 1.5f);
			}
			else
			{
				ambience1.volume = Mathf.Lerp(ambience1.volume, 0f, Time.deltaTime * 8f);
			}
			if (murderMusicAudio.isPlaying && murderMusicAudio.volume <= 0.01f)
			{
				murderMusicAudio.Stop();
			}
			if (!ambience1.isPlaying)
			{
				ambience1.Play();
			}
			startedMurderMusic = false;
			if (!((NetworkBehaviour)this).IsOwner)
			{
				break;
			}
			SetButlerWalkSpeed();
			if (timeSinceNoticingFirstPlayer > 1f && !madlySearchingForPlayers)
			{
				if (sweepFloorTimer <= 0f)
				{
					sweepFloorTimer = Random.Range(3.5f, 8f);
					isSweeping = !isSweeping;
					SetSweepingAnimServerRpc(isSweeping);
				}
				else
				{
					sweepFloorTimer -= Time.deltaTime;
				}
			}
			break;
		case 1:
			if (previousBehaviourState != base.currentBehaviourStateIndex)
			{
				base.creatureAnimator.SetInteger("HeldItem", 0);
				base.creatureSFX.PlayOneShot(base.enemyType.audioClips[1]);
				WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, base.enemyType.audioClips[1], 1f);
				base.creatureAnimator.SetBool("Sweeping", false);
				base.creatureAnimator.SetBool("Running", false);
				sweepingAudio.Stop();
				isSweeping = false;
				buzzingAmbience.pitch = 1.15f;
				buzzingAmbience.volume = 0.8f;
				checkedForTargetedPlayerPosition = false;
				base.movingTowardsTargetPlayer = false;
				startedCrimeSceneTimer = false;
				killedLastTarget = false;
				madlySearchingForPlayers = false;
				previousBehaviourState = base.currentBehaviourStateIndex;
			}
			if (murderMusicAudio.isPlaying && murderMusicAudio.volume <= 0.01f)
			{
				murderMusicAudio.Stop();
			}
			if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.75f, 70f, 30, 2f, -1))
			{
				ambience1.volume = Mathf.Lerp(ambience1.volume, 1f, Time.deltaTime * 0.75f);
			}
			else
			{
				ambience1.volume = Mathf.Lerp(ambience1.volume, 0f, Time.deltaTime * 8f);
			}
			SetButlerWalkSpeed();
			break;
		case 2:
			if (previousBehaviourState != base.currentBehaviourStateIndex)
			{
				base.creatureAnimator.SetInteger("HeldItem", 2);
				base.creatureSFX.PlayOneShot(base.enemyType.audioClips[2]);
				WalkieTalkie.TransmitOneShotAudio(base.creatureSFX, base.enemyType.audioClips[2], 1f);
				timeSinceChangingItem = 0f;
				base.creatureAnimator.SetBool("Sweeping", false);
				sweepingAudio.Stop();
				buzzingAmbience.pitch = 1.5f;
				buzzingAmbience.volume = 1f;
				if (roamAndSweepFloor.inProgress)
				{
					((EnemyAI)this).StopSearch(roamAndSweepFloor, true);
				}
				if (hoverAroundTargetPlayer.inProgress)
				{
					((EnemyAI)this).StopSearch(hoverAroundTargetPlayer, true);
				}
				ambushSpeedMeter = 1f;
				startedCrimeSceneTimer = false;
				killedLastTarget = false;
				madlySearchingForPlayers = false;
				hasPlayerInSight = false;
				previousBehaviourState = base.currentBehaviourStateIndex;
			}
			base.addPlayerVelocityToDestination = Mathf.Lerp(base.addPlayerVelocityToDestination, 2f, Time.deltaTime);
			if (timeSinceChangingItem > 1.7f)
			{
				ambushSpeedMeter = Mathf.Max(ambushSpeedMeter - Time.deltaTime * 1.2f, 0f);
			}
			if (lostPlayerInChase && ((NetworkBehaviour)this).IsOwner)
			{
				if (startedMurderMusic && murderMusicAudio.isPlaying && murderMusicAudio.volume <= 0.01f)
				{
					murderMusicAudio.Stop();
				}
				break;
			}
			if (!startedMurderMusic)
			{
				if (GameNetworkManager.Instance.localPlayerController.isInsideFactory && GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.7f, 100f, 18, 1f, -1))
				{
					startedMurderMusic = true;
				}
				break;
			}
			ambience1.volume = Mathf.Lerp(ambience1.volume, 0f, Time.deltaTime * 7f);
			if (GameNetworkManager.Instance.localPlayerController.isInsideFactory)
			{
				if (GameNetworkManager.Instance.localPlayerController.HasLineOfSightToPosition(((Component)this).transform.position + Vector3.up * 0.7f, 100f, 18, 1f, -1))
				{
					murderMusicVolume = Mathf.Max(murderMusicVolume, Mathf.Lerp(murderMusicVolume, 0.7f, Time.deltaTime * 3f));
				}
				else
				{
					murderMusicVolume = Mathf.Max(murderMusicVolume, Mathf.Lerp(murderMusicVolume, 0.36f, Time.deltaTime * 3f));
				}
				increaseMurderMusicVolume = true;
			}
			if (ambience1.isPlaying && ambience1.volume <= 0.01f)
			{
				ambience1.Stop();
			}
			if (!murderMusicAudio.isPlaying)
			{
				murderMusicAudio.Play();
			}
			break;
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void SyncSearchingMadlyServerRpc(bool isSearching)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2396187445u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref isSearching, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2396187445u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				madlySearchingForPlayers = isSearching;
				SyncSearchingMadlyClientRpc(isSearching);
			}
		}
	}

	[ClientRpc]
	public void SyncSearchingMadlyClientRpc(bool isSearching)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val2 = default(ClientRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(581165582u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref isSearching, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendClientRpc(ref val, 581165582u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!((NetworkBehaviour)this).IsServer)
			{
				madlySearchingForPlayers = isSearching;
			}
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void SyncKilledLastTargetServerRpc(int playerId)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(464969932u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, playerId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 464969932u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				killedLastTarget = true;
				lastMurderedTarget = StartOfRound.Instance.allPlayerScripts[playerId];
				SyncKilledLastTargetClientRpc();
			}
		}
	}

	[ClientRpc]
	public void SyncKilledLastTargetClientRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val2 = default(ClientRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(4068043815u, val2, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendClientRpc(ref val, 4068043815u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!((NetworkBehaviour)this).IsServer)
			{
				killedLastTarget = true;
			}
		}
	}

	[ServerRpc(RequireOwnership = false)]
	public void SyncKilledLastTargetFalseServerRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(4286063857u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 4286063857u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				killedLastTarget = false;
				SyncKilledLastTargetClientRpc();
			}
		}
	}

	[ClientRpc]
	public void SyncKilledLastTargetFalseClientRpc()
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			ClientRpcParams val2 = default(ClientRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(3737741027u, val2, (RpcDelivery)0);
			((NetworkBehaviour)this).__endSendClientRpc(ref val, 3737741027u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			if (!((NetworkBehaviour)this).IsServer)
			{
				Debug.Log((object)"Client received sync killed last target false client rpc");
				killedLastTarget = false;
			}
		}
	}

	[ServerRpc]
	public void SwitchOwnershipAndSetToStateServerRpc(int state, ulong newOwner, float berserkTimer = -1f)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Invalid comparison between Unknown and I4
		//IL_013c: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val2 = default(ServerRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1217960904u, val2, (RpcDelivery)0);
			BytePacker.WriteValueBitPacked(val, state);
			BytePacker.WriteValueBitPacked(val, newOwner);
			((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref berserkTimer, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendServerRpc(ref val, 1217960904u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
		{
			return;
		}
		((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
		if (StartOfRound.Instance.ClientPlayerList.TryGetValue(newOwner, out var value))
		{
			if (((Component)this).gameObject.GetComponent<NetworkObject>().OwnerClientId != newOwner)
			{
				base.thisNetworkObject.ChangeOwnership(newOwner);
			}
			base.currentOwnershipOnThisClient = value;
			base.targetPlayer = StartOfRound.Instance.allPlayerScripts[value];
			watchingPlayer = base.targetPlayer;
			if (berserkTimer != -1f)
			{
				berserkModeTimer = berserkTimer;
			}
			SwitchOwnershipAndSetToStateClientRpc(value, state, berserkModeTimer);
		}
	}

	[ClientRpc]
	public void SwitchOwnershipAndSetToStateClientRpc(int playerVal, int state, float berserkTimer)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(661327553u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, playerVal);
				BytePacker.WriteValueBitPacked(val, state);
				((FastBufferWriter)(ref val)).WriteValueSafe<float>(ref berserkTimer, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 661327553u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				base.currentOwnershipOnThisClient = playerVal;
				((EnemyAI)this).SwitchToBehaviourStateOnLocalClient(state);
				base.targetPlayer = StartOfRound.Instance.allPlayerScripts[playerVal];
				watchingPlayer = base.targetPlayer;
				berserkModeTimer = berserkTimer;
			}
		}
	}

	public void SetButlerWalkSpeed()
	{
		if (!((NetworkBehaviour)this).IsOwner)
		{
			return;
		}
		if (timeSinceCheckingForMultiplePlayers < 2f || timeSinceChangingItem < 2f || isSweeping || base.stunNormalizedTimer > 0f)
		{
			base.agent.speed = 0f;
		}
		else if (trackingTargetPlayerDownToMurder || base.creatureAnimator.GetBool("Running"))
		{
			if (base.currentBehaviourStateIndex == 2)
			{
				base.agent.speed = idleMovementSpeedBase + 5f + 4f * ambushSpeedMeter;
				base.agent.acceleration = 38f + 16f * ambushSpeedMeter;
			}
			base.agent.speed = idleMovementSpeedBase + 5f;
		}
		else
		{
			base.agent.speed = idleMovementSpeedBase;
		}
	}

	private void StartCheckForPlayers()
	{
		timeSinceCheckingForMultiplePlayers = 0f;
		timeUntilNextCheck = Random.Range(8f, 11f);
		TurnAndCheckForPlayers();
		Debug.Log((object)"Butler: Checking for players");
	}

	[ServerRpc]
	public void SetButlerRunningServerRpc(bool isRunning)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Invalid comparison between Unknown and I4
		//IL_0122: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val2 = default(ServerRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(3869762771u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref isRunning, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendServerRpc(ref val, 3869762771u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			SetButlerRunningClientRpc(isRunning);
		}
	}

	[ClientRpc]
	public void SetButlerRunningClientRpc(bool isRunning)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1137980093u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref isRunning, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1137980093u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				base.creatureAnimator.SetBool("Running", isRunning);
			}
		}
	}

	[ServerRpc]
	public void SetSweepingAnimServerRpc(bool sweeping)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Invalid comparison between Unknown and I4
		//IL_0122: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Invalid comparison between Unknown and I4
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager == null || !networkManager.IsListening)
		{
			return;
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
		{
			if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId)
			{
				if ((int)networkManager.LogLevel <= 1)
				{
					Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!");
				}
				return;
			}
			ServerRpcParams val2 = default(ServerRpcParams);
			FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1379547418u, val2, (RpcDelivery)0);
			((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref sweeping, default(ForPrimitives));
			((NetworkBehaviour)this).__endSendServerRpc(ref val, 1379547418u, val2, (RpcDelivery)0);
		}
		if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
		{
			((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
			SetSweepingAnimClientRpc(sweeping);
		}
	}

	[ClientRpc]
	public void SetSweepingAnimClientRpc(bool sweeping)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Invalid comparison between Unknown and I4
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: 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)
		NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
		if (networkManager != null && networkManager.IsListening)
		{
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val2 = default(ClientRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(2996428583u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref sweeping, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 2996428583u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				base.creatureAnimator.SetBool("Sweeping", sweeping);
				sweepingAudio.Play();
			}
		}
	}

	private void CalculateAnimationDirection(float maxSpeed = 1f)
	{
		//IL_000e: 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_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		agentLocalVelocity = animationContainer.InverseTransformDirection(Vector3.ClampMagnitude(((Component)this).transform.position - previousPosition, 1f) / (Time.deltaTime * 2f));
		velX = Mathf.Lerp(velX, agentLocalVelocity.x, 10f * Time.deltaTime);
		base.creatureAnimator.SetFloat("MoveX", Mathf.Clamp(velX, 0f - maxSpeed, maxSpeed));
		velZ = Mathf.Lerp(velZ, agentLocalVelocity.z, 10f * Time.deltaTime);
		base.creatureAnimator.SetFloat("MoveZ", Mathf.Clamp(velZ, 0f - maxSpeed, maxSpeed));
		previousPosition = ((Component)this).transform.position;
	}

	public void PingAttention(int newFocusLevel, float timeToLook, Vector3 attentionPosition, bool sync = true)
	{
		//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_00ac: 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_00c8: 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)
		if ((pingAttentionTimer >= 0f && newFocusLevel < focusLevel) || (base.currentBehaviourStateIndex == 0 && timeSincePingingAttention < 0.5f) || (base.currentBehaviourStateIndex == 1 && timeSincePingingAttention < 0.2f) || (base.currentBehaviourStateIndex == 2 && timeSincePingingAttention < 1f))
		{
			return;
		}
		if (berserkModeTimer > 0f)
		{
			if (timeSincePingingAttention < 4f)
			{
				return;
			}
			timeToLook *= 0.5f;
		}
		Debug.Log((object)"Butler: pinged attention to position");
		Debug.DrawLine(base.eye.position, attentionPosition, Color.yellow, timeToLook);
		focusLevel = newFocusLevel;
		pingAttentionTimer = timeToLook;
		pingAttentionPosition = attentionPosition;
		if (sync)
		{
			PingButlerAttentionRpc(timeToLook, attentionPosition);
		}
	}

	[Rpc(/*Could not decode attribute arguments.*/)]
	public void PingButlerAttentionRpc(float timeToLook, Vector3 attentionPosition)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Invalid comparison between Unknown and I4
		//IL_0043: 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_005f: 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_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might