Decompiled source of men stalker v2.5.5

menstalker_yaboiduckisnickerbar.dll

Decompiled 2 weeks ago
#define DEBUG
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using LethalLib.Modules;
using Menstalker_ybdkSKB.Configuration;
using Unity.Netcode;
using UnityEngine;
using menstalker_yaboiduckisnickerbar.NetcodePatcher;

[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 = "")]
[assembly: AssemblyCompany("menstalker_yaboiduckisnickerbar")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Example Enemy for Lethal Company.")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2")]
[assembly: AssemblyProduct("menstalker_yaboiduckisnickerbar")]
[assembly: AssemblyTitle("menstalker_yaboiduckisnickerbar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Menstalker_ybdkSKB
{
	internal class Menstalker_ybdkSKB : EnemyAI
	{
		private enum State
		{
			IDLE,
			STALK,
			PRERUSH,
			RUSH,
			ROAM
		}

		public Transform turnCompass;

		public Transform attackArea;

		private bool isDeadAnimationDone;

		public Vector3 spawnPosition;

		public AISearchRoutine roamMap;

		public float targetLostCooldown = 0f;

		private float targetLostTime;

		public bool targetLost;

		private const int stalkingCooldownScared = 60;

		private const int stalkingCooldownDetected = 40;

		public float stalkingCooldown = 40f;

		private const float stalkLOS_cooldown = 15f;

		public float stalkLOS_timer = 0f;

		private int chaseDuration;

		public int clawDamage = 20;

		public float currentChase = 0f;

		private const float longDistance = 14f;

		private bool flag = false;

		public float timeSinceHittingLocalPlayer;

		private const int preRushTimeout = 15;

		private const int roamTimeout = 10;

		private float TimeTick = 0f;

		private const float stunTime = 1f;

		public float stunCooldown = 0f;

		public int subState = 0;

		public Vector3 mainEntrancePos;

		[Conditional("DEBUG")]
		private void LogIfDebugBuild(string text)
		{
			Plugin.Logger.LogInfo((object)text);
		}

		public override void Start()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			base.targetPlayer = null;
			spawnPosition = ((Component)this).transform.position;
			targetLost = true;
			chaseDuration = 20 + StartOfRound.Instance.randomMapSeed % 11;
			targetLostTime = StartOfRound.Instance.randomMapSeed % 6 + 10;
			targetLostCooldown = targetLostTime;
			LogIfDebugBuild("Man-stalker spawned");
			timeSinceHittingLocalPlayer = 0f;
			isDeadAnimationDone = false;
			base.currentBehaviourStateIndex = 0;
			mainEntrancePos = RoundManager.FindMainEntrancePosition(false, false);
		}

		public override void Update()
		{
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					isDeadAnimationDone = true;
					base.creatureVoice.Stop();
					base.creatureVoice.PlayOneShot(base.dieSFX);
				}
				base.creatureAnimator.ResetTrigger("slash");
				base.creatureAnimator.SetBool("isAngry", false);
				return;
			}
			if (stunCooldown > 0f)
			{
				stunCooldown -= Time.deltaTime;
			}
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 1:
				if (targetLost)
				{
					targetLostCooldown -= Time.deltaTime;
					stalkingCooldown += Time.deltaTime * 3f;
				}
				else
				{
					stalkingCooldown -= Time.deltaTime;
				}
				break;
			case 2:
				TimeTick += Time.deltaTime;
				break;
			case 3:
				currentChase += Time.deltaTime;
				if ((double)timeSinceHittingLocalPlayer > 0.75)
				{
					base.creatureAnimator.SetBool("isAngry", true);
					base.creatureAnimator.ResetTrigger("slash");
				}
				else
				{
					timeSinceHittingLocalPlayer += Time.deltaTime;
				}
				if (stunCooldown < 0f)
				{
					base.creatureAnimator.SetBool("isAngry", true);
					base.creatureAnimator.ResetTrigger("stunned");
				}
				break;
			case 4:
				TimeTick += Time.deltaTime;
				break;
			}
			int currentBehaviourStateIndex = base.currentBehaviourStateIndex;
			animationManager();
			if ((Object)(object)base.targetPlayer != (Object)null && (currentBehaviourStateIndex == 1 || currentBehaviourStateIndex == 3))
			{
				Vector3 val = ((Component)this).transform.position - (((Component)base.targetPlayer).transform.position - ((Component)this).transform.position);
				turnCompass.LookAt(val);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(new Vector3(0f, turnCompass.eulerAngles.y, 0f)), 1f);
			}
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
		}

		private void animationManager()
		{
			if (base.currentBehaviourStateIndex != 3)
			{
				base.creatureAnimator.SetBool("isAngry", false);
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 3:
				if (!((double)timeSinceHittingLocalPlayer < 0.75) && !(stunCooldown > 0f))
				{
					base.creatureAnimator.speed = 1f;
					base.creatureAnimator.SetBool("isAngry", true);
				}
				break;
			case 1:
				base.creatureAnimator.speed = 1f;
				base.creatureAnimator.SetBool("isAngry", false);
				if (subState == 2)
				{
					base.creatureAnimator.SetBool("forwardWalk", false);
					base.creatureAnimator.SetBool("backwardWalk", false);
				}
				else if (subState == 0)
				{
					base.creatureAnimator.SetBool("forwardWalk", true);
					base.creatureAnimator.SetBool("backwardWalk", false);
				}
				else if (subState == 1)
				{
					base.creatureAnimator.SetBool("forwardWalk", false);
					base.creatureAnimator.SetBool("backwardWalk", true);
				}
				break;
			case 2:
			case 4:
				base.creatureAnimator.SetBool("forwardWalk", true);
				base.creatureAnimator.SetBool("backwardWalk", false);
				base.creatureAnimator.speed = 2f;
				break;
			case 0:
				base.creatureAnimator.SetBool("forwardWalk", false);
				base.creatureAnimator.SetBool("backwardWalk", false);
				break;
			}
		}

		public override void DoAIInterval()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0902: Unknown result type (might be due to invalid IL or missing references)
			//IL_0916: Unknown result type (might be due to invalid IL or missing references)
			//IL_0933: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0586: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: 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)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				base.creatureAnimator.SetBool("isAngry", false);
				return;
			}
			if (stunCooldown > 0f || base.stunNormalizedTimer > 0f)
			{
				base.agent.velocity = new Vector3(0f, 0f, 0f);
			}
			PlayerControllerB closestPlayer = ((EnemyAI)this).GetClosestPlayer(false, false, false);
			PlayerControllerB closestPlayer2 = ((EnemyAI)this).GetClosestPlayer(true, false, false);
			float num = 0f;
			if ((Object)(object)closestPlayer == (Object)null && base.currentBehaviourStateIndex != 1)
			{
				base.creatureAnimator.ResetTrigger("slash");
				base.creatureVoice.Stop();
				flag = false;
				currentChase = 0f;
				base.agent.speed = 10f;
				targetLost = true;
				if (Vector3.Distance(((Component)this).transform.position, mainEntrancePos) >= 42f)
				{
					base.agent.speed = 0f;
					Vector3 velocity = base.agent.velocity;
					((Vector3)(ref velocity)).Set(0f, 0f, 0f);
				}
				((EnemyAI)this).SetDestinationToPosition(((Component)((EnemyAI)this).ChooseFarthestNodeFromPosition(mainEntrancePos, false, 0, false, 50, false)).transform.position, false);
				((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				return;
			}
			float num2 = 0f;
			if ((Object)(object)closestPlayer != (Object)null)
			{
				num2 = Vector3.Distance(((Component)closestPlayer).transform.position, ((Component)this).transform.position);
			}
			if ((Object)(object)closestPlayer2 != (Object)null)
			{
				num = Vector3.Distance(((Component)closestPlayer2).transform.position, ((Component)this).transform.position);
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
			{
				base.creatureVoice.Stop();
				base.openDoorSpeedMultiplier = 1f;
				base.agent.speed = 1.5f;
				PlayerControllerB closestPlayer3 = ((EnemyAI)this).GetClosestPlayer(false, false, false);
				base.targetPlayer = null;
				if ((closestPlayer3.isCrouching || (!closestPlayer3.isSprinting && !closestPlayer3.isCrouching)) && Vector3.Distance(((Component)this).transform.position, ((Component)closestPlayer3).transform.position) <= 14f)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
					stalkingCooldown = 60f;
					if (roamMap.inProgress)
					{
						((EnemyAI)this).StopSearch(roamMap, true);
					}
				}
				else if ((closestPlayer3.isSprinting && (double)Vector3.Distance(((Component)this).transform.position, ((Component)closestPlayer3).transform.position) <= 31.5) || ((Object)(object)closestPlayer2 != (Object)null && closestPlayer2.playerLevelNumber == closestPlayer3.playerLevelNumber))
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(1);
					stalkingCooldown = 40f;
					if (roamMap.inProgress)
					{
						((EnemyAI)this).StopSearch(roamMap, true);
					}
				}
				else if (Vector3.Distance(((Component)this).transform.position, ((Component)closestPlayer3).transform.position) <= 56f)
				{
					base.agent.speed = 2f;
					((EnemyAI)this).SetMovingTowardsTargetPlayer(closestPlayer3);
					if (base.agent.velocity == new Vector3(0f, 0f, 0f) && !((EnemyAI)this).SetDestinationToPosition(((Component)closestPlayer3).transform.position, false))
					{
					}
				}
				else if (!((Object)(object)base.targetPlayer != (Object)null) && (Object)(object)base.targetPlayer == (Object)null && base.agent.velocity == new Vector3(0f, 0f, 0f))
				{
					roamMap = null;
					((EnemyAI)this).StartSearch(spawnPosition, roamMap);
				}
				break;
			}
			case 1:
				subState = 1;
				base.openDoorSpeedMultiplier = 1f;
				if (stalkingCooldown < 0f)
				{
					if (stalkLOS_timer >= 15f)
					{
						stalkLOS_timer = 0f;
						((EnemyAI)this).SwitchToBehaviourClientRpc(2);
					}
					else if ((double)num2 < 11.200000000000001)
					{
						base.agent.speed = 8f;
						stalkLOS_timer += 0.2f;
						AvoidClosestPlayer(11.48f, avoidLOS: false, closestPlayer);
					}
					else if (num2 > 14f && (Object)(object)closestPlayer2 == (Object)null)
					{
						base.agent.speed = 5f;
						if (!((Object)(object)closestPlayer == (Object)null))
						{
							((EnemyAI)this).SetMovingTowardsTargetPlayer(closestPlayer);
							if (base.agent.velocity == new Vector3(0f, 0f, 0f) && ((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false))
							{
								LogIfDebugBuild("Necesarry !");
							}
						}
					}
					else if ((Object)(object)closestPlayer2 != (Object)null || (double)num2 > 11.200000000000001)
					{
						subState = 2;
						stalkLOS_timer += 0.2f;
						base.agent.speed = 0f;
					}
					break;
				}
				if ((num2 > 38.5f && (Object)(object)closestPlayer2 == (Object)null) || (Object)(object)closestPlayer == (Object)null)
				{
					if (targetLostCooldown < 0f)
					{
						((EnemyAI)this).SwitchToBehaviourClientRpc(4);
						targetLostCooldown = targetLostTime;
						targetLost = true;
						stalkingCooldown = 40f;
						break;
					}
					subState = 0;
					base.agent.speed = 4f;
					targetLost = true;
					if (!((Object)(object)closestPlayer == (Object)null))
					{
						((EnemyAI)this).SetMovingTowardsTargetPlayer(closestPlayer);
						if (base.agent.velocity == new Vector3(0f, 0f, 0f) && !((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false))
						{
						}
					}
					break;
				}
				targetLost = false;
				targetLostCooldown = targetLostTime;
				if (num2 <= 2f)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(3);
					break;
				}
				if ((Object)(object)closestPlayer2 != (Object)null && num < 28f)
				{
					stalkLOS_timer += 0.2f;
					base.agent.speed = 12f;
					AvoidClosestPlayer(28f, avoidLOS: true, closestPlayer);
					break;
				}
				if (num2 < 14f)
				{
					base.agent.speed = 11f;
					AvoidClosestPlayer(14f, avoidLOS: true, closestPlayer);
					break;
				}
				if (num2 < 21f)
				{
					base.agent.speed = 5f;
					AvoidClosestPlayer(14f, avoidLOS: true, closestPlayer);
					break;
				}
				subState = 2;
				base.agent.speed = 0f;
				if ((Object)(object)closestPlayer2 != (Object)null)
				{
					stalkLOS_timer += 0.2f;
				}
				base.moveTowardsDestination = false;
				base.movingTowardsTargetPlayer = false;
				break;
			case 2:
				base.openDoorSpeedMultiplier = 1f;
				base.agent.speed = 8f;
				if (TimeTick > 15f)
				{
					TimeTick = 0f;
					((EnemyAI)this).SwitchToBehaviourClientRpc(3);
					break;
				}
				if (num2 < 2f)
				{
					TimeTick = 0f;
					((EnemyAI)this).SwitchToBehaviourClientRpc(3);
				}
				if (num2 < 14f)
				{
					AvoidClosestPlayer(14f, avoidLOS: true, closestPlayer);
				}
				break;
			case 3:
				base.agent.speed = 9.5f;
				scareLocalPlayer();
				base.openDoorSpeedMultiplier = 0.15f;
				if (base.enemyHP <= 2)
				{
					base.openDoorSpeedMultiplier = 2f;
				}
				((EnemyAI)this).SetMovingTowardsTargetPlayer(closestPlayer);
				if (!(base.agent.velocity == new Vector3(0f, 0f, 0f)) || ((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false))
				{
				}
				if (!flag && (Object)(object)closestPlayer2 == (Object)null)
				{
					currentChase = 0f;
					break;
				}
				flag = true;
				if (currentChase > (float)chaseDuration && (Object)(object)closestPlayer2 == (Object)null && num2 > 14f)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(4);
					flag = false;
					currentChase = 0f;
				}
				break;
			case 4:
				base.creatureVoice.Stop();
				if (num2 < 1.5f)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(3);
				}
				base.agent.speed = 10f;
				AvoidClosestPlayer(14f, avoidLOS: true, closestPlayer);
				if (num2 > 28f && (Object)(object)closestPlayer2 == (Object)null && TimeTick > 10f)
				{
					((EnemyAI)this).SwitchToBehaviourClientRpc(0);
				}
				break;
			default:
				LogIfDebugBuild("Error : invalid behavior index");
				break;
			}
		}

		public void AvoidClosestPlayer(float optimalDistance, bool avoidLOS, PlayerControllerB closestPlayer)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((EnemyAI)this).ChooseFarthestNodeFromPosition(((Component)closestPlayer).transform.position, avoidLOS, 0, false, 50, false);
			if ((Object)(object)val != (Object)null && base.mostOptimalDistance > optimalDistance && Physics.Linecast(((Component)val).transform.position, ((Component)closestPlayer.gameplayCamera).transform.position, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
			{
				base.targetNode = val;
				((EnemyAI)this).SetDestinationToPosition(base.targetNode.position, false);
			}
		}

		public void scareLocalPlayer()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (Vector3.Distance(((Component)this).transform.position, ((Component)GameNetworkManager.Instance.localPlayerController).transform.position) < 14f)
			{
				GameNetworkManager.Instance.localPlayerController.JumpToFearLevel(1f, true);
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if (!base.isEnemyDead && base.currentBehaviourStateIndex == 3 && !(timeSinceHittingLocalPlayer < 0.75f) && !(stunCooldown > 0f) && !base.isEnemyDead)
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if ((Object)(object)val != (Object)null)
				{
					base.creatureAnimator.SetBool("isAngry", false);
					DoAnimationClientRpc("slash");
					base.creatureSFX.PlayOneShot(base.currentBehaviourState.SFXClip);
					LogIfDebugBuild("Player " + val.playerUsername + " hit by dust stalker");
					timeSinceHittingLocalPlayer = 0f;
					val.DamagePlayer(clawDamage, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			if (base.isEnemyDead || stunCooldown > 0f)
			{
				return;
			}
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID = -1);
			base.enemyHP -= force;
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (base.enemyHP <= 0 && !base.isEnemyDead)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
					return;
				}
				base.creatureAnimator.SetBool("isAngry", false);
				DoAnimationClientRpc("stunned");
				stunCooldown = 1f;
				base.creatureVoice.PlayOneShot(base.dieSFX);
				((EnemyAI)this).SwitchToBehaviourClientRpc(3);
			}
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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 != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3719444039u, val, (RpcDelivery)0);
				bool flag = animationName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(animationName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3719444039u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				LogIfDebugBuild("Animation: " + animationName);
				base.creatureAnimator.SetTrigger(animationName);
			}
		}

		[ClientRpc]
		public void SwingAttackHitClientRpc()
		{
			//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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(121933789u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 121933789u, val, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost))
			{
				return;
			}
			LogIfDebugBuild("SwingAttackHitClientRPC");
			int num = 8;
			Collider[] array = Physics.OverlapBox(attackArea.position, attackArea.localScale, Quaternion.identity, num);
			if (array.Length == 0)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider val3 in array2)
			{
				PlayerControllerB val4 = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(val3, false, false);
				if ((Object)(object)val4 != (Object)null)
				{
					LogIfDebugBuild("Swing attack hit player!");
					timeSinceHittingLocalPlayer = 0f;
					val4.DamagePlayer(40, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				}
			}
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_Menstalker_ybdkSKB()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(3719444039u, new RpcReceiveHandler(__rpc_handler_3719444039));
			NetworkManager.__rpc_func_table.Add(121933789u, new RpcReceiveHandler(__rpc_handler_121933789));
		}

		private static void __rpc_handler_3719444039(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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string animationName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref animationName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Menstalker_ybdkSKB)(object)target).DoAnimationClientRpc(animationName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_121933789(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((Menstalker_ybdkSKB)(object)target).SwingAttackHitClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "Menstalker_ybdkSKB";
		}
	}
	[BepInPlugin("snickerbarYaboiDucki.menstalker_yaboiduckisnickerbar", "menstalker_yaboiduckisnickerbar", "1.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string pluginName = "Men stalker (Hostile entity)";

		public const string ModGUID = "snickerbarYaboiDucki.menstalker_yaboiduckisnickerbar";

		public const string pluginVersion = "1.2.2";

		internal static ManualLogSource Logger;

		public static AssetBundle ModAssets;

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig((BaseUnityPlugin)(object)this);
			InitializeNetworkBehaviours();
			string path = "yaboiduckimenstalkerassets";
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			EnemyType val = ModAssets.LoadAsset<EnemyType>("Menstalker_type");
			TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("duskStalkerTN");
			TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("duskStalkerTK");
			NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
			Enemies.RegisterEnemy(val, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, val2, val3);
			Logger.LogInfo((object)"Plugin menstalker_yaboiduckisnickerbar is loaded!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "menstalker_yaboiduckisnickerbar";

		public const string PLUGIN_NAME = "menstalker_yaboiduckisnickerbar";

		public const string PLUGIN_VERSION = "1.2.2";
	}
}
namespace Menstalker_ybdkSKB.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<int> SpawnWeight;

		public PluginConfig(BaseUnityPlugin plugin)
		{
			SpawnWeight = plugin.Config.Bind<int>("Man stalker", "Spawn weight", 20, "The spawn chance weight for ExampleEnemy, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			ClearUnusedEntries(plugin);
		}

		private void ClearUnusedEntries(BaseUnityPlugin plugin)
		{
			PropertyInfo property = ((object)plugin.Config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(plugin.Config, null);
			dictionary.Clear();
			plugin.Config.Save();
		}
	}
}
namespace menstalker_yaboiduckisnickerbar.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}