Decompiled source of BrolyCulo v1.2.5

RivalSilver97.BrolyCulo.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
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 CustomEnnemies.Configuration;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FrenchPlatypus.BrolyCulo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FrenchPlatypus.BrolyCulo")]
[assembly: AssemblyTitle("FrenchPlatypus.BrolyCulo")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CustomEnnemies
{
	internal class BrolyAI : EnemyAI
	{
		public Transform turnCompass;

		public Transform attackArea;

		public Transform assParent;

		public Transform playerParent;

		public AudioSource stepSound;

		private float timeSinceHittingLocalPlayer;

		private float timeSinceNewRandPos;

		private Vector3 positionRandomness;

		private Vector3 spawnPos;

		private Random enemyRandom;

		private bool isDeadAnimationDone;

		private bool attackingPlayer;

		private bool isInterrupted;

		private float fleaTimer;

		private Coroutine attackingPlayerCoroutine;

		private Ray playerRay;

		public bool carryingPlayerBody;

		private Vector3 targetLastPos;

		public DeadBodyInfo bodyBeingCarried;

		private FlowermanAI flowermanTarget;

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

		public override void Start()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Start();
			timeSinceHittingLocalPlayer = 0f;
			timeSinceNewRandPos = 0f;
			DoAnimationClientRpc("startWalk");
			positionRandomness = Vector3.zero;
			base.agent.acceleration = 15f;
			base.agent.angularSpeed = 1000f;
			spawnPos = ((Component)this).transform.position;
			enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
			isDeadAnimationDone = false;
			MuteVoiceClientRpc(mute: true);
			MuteStepsClientRpc(mute: false);
			base.currentBehaviourStateIndex = 0;
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
		}

		public override void Update()
		{
			//IL_0078: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (base.isEnemyDead)
			{
				if (!isDeadAnimationDone)
				{
					isDeadAnimationDone = true;
					MuteVoiceClientRpc(mute: true);
					MuteStepsClientRpc(mute: true);
					DoAnimationClientRpc("killEnemy");
					PlayDeathSoundClientRpc();
				}
				return;
			}
			if ((Object)(object)base.targetPlayer != (Object)null && base.currentBehaviourStateIndex == 1 && (Object)(object)turnCompass != (Object)null)
			{
				turnCompass.LookAt(((Component)base.targetPlayer.gameplayCamera).transform.position);
				((Component)this).transform.rotation = Quaternion.Lerp(((Component)this).transform.rotation, Quaternion.Euler(0f, turnCompass.eulerAngles.y, 0f), 6f * Time.deltaTime);
			}
			if (base.stunNormalizedTimer > 0f)
			{
				base.agent.speed = 0f;
			}
			if (fleaTimer > 0f)
			{
				fleaTimer -= Time.deltaTime;
			}
		}

		public override void OnGainedOwnership()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			((NetworkBehaviour)this).OnGainedOwnership();
			if (((NetworkBehaviour)this).IsOwner)
			{
				if (base.currentBehaviourStateIndex == 0)
				{
					DoAnimationClientRpc("startWalk");
					MuteVoiceClientRpc(mute: true);
					MuteStepsClientRpc(mute: false);
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				else if (base.currentBehaviourStateIndex == 1)
				{
					FoundClosestPlayerInRange(20f, 4f);
				}
			}
		}

		public override void DoAIInterval()
		{
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: 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_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).DoAIInterval();
			if (base.isEnemyDead || StartOfRound.Instance.allPlayersDead)
			{
				return;
			}
			switch (base.currentBehaviourStateIndex)
			{
			case 0:
				base.agent.speed = 2.5f;
				if (!((NetworkBehaviour)this).IsServer && ((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).ChangeOwnershipOfEnemy(StartOfRound.Instance.allPlayerScripts[0].actualClientId);
				}
				else if (FoundBrackenInMap() && (Object)(object)flowermanTarget != (Object)null)
				{
					DoAnimationClientRpc("chaseBracken");
					((EnemyAI)this).SwitchToBehaviourState(2);
					MuteStepsClientRpc(mute: true);
					MuteVoiceClientRpc(mute: true);
				}
				else if (FoundClosestPlayerInRange(20f, 4f) && (Object)(object)base.targetPlayer != (Object)null)
				{
					DoAnimationClientRpc("chasePlayer");
					((EnemyAI)this).SwitchToBehaviourState(1);
					MuteStepsClientRpc(mute: true);
					MuteVoiceClientRpc(mute: false);
				}
				break;
			case 1:
				base.agent.speed = 7f;
				if ((Object)(object)base.targetPlayer == (Object)null)
				{
					FoundClosestPlayerInRange(20f, 4f);
				}
				if ((Object)(object)base.targetPlayer != (Object)null)
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
					if (((NetworkBehaviour)this).IsOwner && (Object)(object)base.targetPlayer != (Object)(object)GameNetworkManager.Instance.localPlayerController)
					{
						((EnemyAI)this).ChangeOwnershipOfEnemy(base.targetPlayer.actualClientId);
					}
				}
				if ((Object)(object)base.targetPlayer == (Object)null || FoundBrackenInMap() || (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 14f && !((EnemyAI)this).CheckLineOfSightForPosition(((Component)base.targetPlayer).transform.position, 45f, 60, -1f, (Transform)null)))
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					DoAnimationClientRpc("startWalk");
					((EnemyAI)this).SwitchToBehaviourState(0);
					MuteStepsClientRpc(mute: false);
					MuteVoiceClientRpc(mute: true);
				}
				break;
			case 2:
				base.agent.speed = 15f;
				if ((Object)(object)flowermanTarget == (Object)null || ((EnemyAI)flowermanTarget).isEnemyDead)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					DoAnimationClientRpc("startWalk");
					((EnemyAI)this).SwitchToBehaviourState(0);
					MuteVoiceClientRpc(mute: true);
					MuteStepsClientRpc(mute: false);
				}
				else
				{
					((EnemyAI)this).SetDestinationToPosition(((Component)flowermanTarget).transform.position, false);
				}
				break;
			case 3:
			case 4:
				base.agent.speed = 2f;
				break;
			case 5:
				base.agent.speed = 15f;
				if (fleaTimer <= 0f || Vector3.Distance(((Component)this).transform.position, spawnPos) < 1.5f)
				{
					fleaTimer = 0f;
					if (carryingPlayerBody)
					{
						DropPlayerBody();
						DropPlayerBodyServerRpc();
					}
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
					DoAnimationClientRpc("startWalk");
					((EnemyAI)this).SwitchToBehaviourState(0);
					MuteVoiceClientRpc(mute: true);
					MuteStepsClientRpc(mute: false);
				}
				break;
			}
		}

		private bool FoundBrackenInMap()
		{
			//IL_0053: 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)
			flowermanTarget = null;
			float num = 2000f;
			if ((Object)(object)RoundManager.Instance == (Object)null || RoundManager.Instance.SpawnedEnemies == null)
			{
				return false;
			}
			for (int i = 0; i < RoundManager.Instance.SpawnedEnemies.Count; i++)
			{
				EnemyAI obj = RoundManager.Instance.SpawnedEnemies[i];
				FlowermanAI val = (FlowermanAI)(object)((obj is FlowermanAI) ? obj : null);
				if (val != null && !((EnemyAI)val).isEnemyDead)
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
					if (num2 < num)
					{
						num = num2;
						flowermanTarget = val;
					}
				}
			}
			return (Object)(object)flowermanTarget != (Object)null;
		}

		private bool FoundClosestPlayerInRange(float range, float senseRange)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			base.targetPlayer = null;
			float num = float.MaxValue;
			if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.allPlayerScripts == null)
			{
				return false;
			}
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
				if ((Object)(object)val == (Object)null || !val.isPlayerControlled || val.isPlayerDead)
				{
					continue;
				}
				float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
				if (num2 < range && ((EnemyAI)this).CheckLineOfSightForPosition(((Component)val.gameplayCamera).transform.position, 70f, 60, -1f, (Transform)null))
				{
					if (num2 < num)
					{
						num = num2;
						base.targetPlayer = val;
					}
				}
				else if (num2 < senseRange && num2 < num)
				{
					num = num2;
					base.targetPlayer = val;
				}
			}
			return (Object)(object)base.targetPlayer != (Object)null;
		}

		[ServerRpc(RequireOwnership = false)]
		public void DropPlayerBodyServerRpc()
		{
			DropPlayerBodyClientRpc();
		}

		[ClientRpc]
		public void DropPlayerBodyClientRpc()
		{
			DropPlayerBody();
		}

		private void DropPlayerBody()
		{
			if (carryingPlayerBody)
			{
				carryingPlayerBody = false;
				if ((Object)(object)bodyBeingCarried != (Object)null)
				{
					bodyBeingCarried.matchPositionExactly = false;
					bodyBeingCarried.attachedTo = null;
					bodyBeingCarried = null;
				}
			}
		}

		private IEnumerator FleaPlayer(bool carryingBody = true)
		{
			if (attackingPlayerCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(attackingPlayerCoroutine);
			}
			base.inSpecialAnimation = false;
			attackingPlayer = false;
			DoAnimationClientRpc("startWalk");
			MuteVoiceClientRpc(mute: true);
			MuteStepsClientRpc(mute: true);
			fleaTimer = 8f;
			if ((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				base.inSpecialAnimationWithPlayer.inSpecialInteractAnimation = false;
				base.inSpecialAnimationWithPlayer.snapToServerPosition = false;
				base.inSpecialAnimationWithPlayer.inAnimationWithEnemy = null;
				if (carryingBody && (Object)(object)base.inSpecialAnimationWithPlayer.deadBody != (Object)null)
				{
					bodyBeingCarried = base.inSpecialAnimationWithPlayer.deadBody;
					bodyBeingCarried.attachedTo = assParent;
					bodyBeingCarried.attachedLimb = base.inSpecialAnimationWithPlayer.deadBody.bodyParts[0];
					bodyBeingCarried.matchPositionExactly = true;
					carryingPlayerBody = true;
				}
			}
			if (carryingBody)
			{
				yield return (object)new WaitForSeconds(1f);
			}
			if (((NetworkBehaviour)this).IsOwner)
			{
				((Behaviour)base.agent).enabled = true;
				base.isClientCalculatingAI = true;
			}
			((EnemyAI)this).SwitchToBehaviourState(5);
			((EnemyAI)this).SetDestinationToPosition(spawnPos, false);
		}

		[ServerRpc(RequireOwnership = false)]
		private void AttackPlayerServerRpc(int playerObjectId)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (!attackingPlayer && !carryingPlayerBody)
			{
				isInterrupted = false;
				attackingPlayer = true;
				base.inSpecialAnimation = true;
				base.isClientCalculatingAI = false;
				base.inSpecialAnimationWithPlayer = StartOfRound.Instance.allPlayerScripts[playerObjectId];
				base.inSpecialAnimationWithPlayer.inAnimationWithEnemy = (EnemyAI)(object)this;
				((Component)this).transform.position = new Vector3(((Component)base.inSpecialAnimationWithPlayer).transform.position.x, ((Component)base.inSpecialAnimationWithPlayer).transform.position.y + 0.5f, ((Component)base.inSpecialAnimationWithPlayer).transform.position.z);
				AttackPlayerClientRpc(playerObjectId);
			}
		}

		[ClientRpc]
		private void AttackPlayerClientRpc(int playerObjectId)
		{
			//IL_0036: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			isInterrupted = false;
			base.inSpecialAnimationWithPlayer = StartOfRound.Instance.allPlayerScripts[playerObjectId];
			base.inSpecialAnimationWithPlayer.inAnimationWithEnemy = (EnemyAI)(object)this;
			((Component)this).transform.position = new Vector3(((Component)base.inSpecialAnimationWithPlayer).transform.position.x, ((Component)base.inSpecialAnimationWithPlayer).transform.position.y + 0.5f, ((Component)base.inSpecialAnimationWithPlayer).transform.position.z);
			((EnemyAI)this).SyncPositionToClients();
			base.inSpecialAnimationWithPlayer.SyncBodyPositionWithClients();
			base.inSpecialAnimationWithPlayer.DropAllHeldItems(true, false, false, false, default(Vector3), default(Vector3), default(Vector3), default(Vector3), default(Vector3));
			base.inSpecialAnimationWithPlayer.voiceMuffledByEnemy = true;
			attackingPlayer = true;
			base.inSpecialAnimation = true;
			((Behaviour)base.agent).enabled = false;
			base.inSpecialAnimationWithPlayer.inSpecialInteractAnimation = true;
			base.inSpecialAnimationWithPlayer.snapToServerPosition = true;
			Vector3 val = ((!((NetworkBehaviour)base.inSpecialAnimationWithPlayer).IsOwner) ? ((Component)base.inSpecialAnimationWithPlayer).transform.parent.TransformPoint(base.inSpecialAnimationWithPlayer.serverPlayerPosition) : ((Component)base.inSpecialAnimationWithPlayer).transform.position);
			Vector3 position = ((Component)this).transform.position;
			position.y = ((Component)base.inSpecialAnimationWithPlayer).transform.position.y;
			playerRay = new Ray(val, position - ((Component)base.inSpecialAnimationWithPlayer).transform.position);
			if ((Object)(object)turnCompass != (Object)null)
			{
				turnCompass.LookAt(val);
				position = ((Component)this).transform.eulerAngles;
				position.y = turnCompass.eulerAngles.y;
				((Component)this).transform.eulerAngles = position;
			}
			if (attackingPlayerCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(attackingPlayerCoroutine);
			}
			attackingPlayerCoroutine = ((MonoBehaviour)this).StartCoroutine(AttackPlayer());
		}

		private IEnumerator AttackPlayer()
		{
			Vector3 endPosition = ((Ray)(ref playerRay)).GetPoint(1f);
			if (endPosition.y < -80f)
			{
				for (int i = 0; i < 15; i++)
				{
					yield return null;
				}
				((Component)this).transform.position = endPosition;
			}
			DoAnimationClientRpc("attack");
			((EnemyAI)this).SwitchToBehaviourState(3);
			MuteStepsClientRpc(mute: true);
			MuteVoiceClientRpc(mute: true);
			yield return (object)new WaitForSeconds(0.1f);
			InterruptClientRpc(interrupt: false);
			int hitCount = 0;
			if (!((Object)(object)base.inSpecialAnimationWithPlayer != (Object)null))
			{
				yield break;
			}
			while (hitCount < 10 || (Object)(object)base.inSpecialAnimationWithPlayer.deadBody == (Object)null || !isInterrupted)
			{
				yield return (object)new WaitForSeconds(0.5f);
				base.inSpecialAnimationWithPlayer.DamagePlayer(15, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
				hitCount++;
				if (hitCount >= 10 || (Object)(object)base.inSpecialAnimationWithPlayer.deadBody != (Object)null || isInterrupted)
				{
					break;
				}
				yield return null;
			}
			if ((Object)(object)base.inSpecialAnimationWithPlayer == (Object)null || (Object)(object)base.inSpecialAnimationWithPlayer.deadBody == (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(FleaPlayer(carryingBody: false));
				yield break;
			}
			base.inSpecialAnimationWithPlayer.snapToServerPosition = false;
			base.inSpecialAnimationWithPlayer.deadBody.causeOfDeath = (CauseOfDeath)5;
			base.inSpecialAnimationWithPlayer.deadBody.bodyBleedingHeavily = true;
			((MonoBehaviour)this).StartCoroutine(FleaPlayer());
		}

		[ServerRpc(RequireOwnership = false)]
		private void AttackBrackenServerRpc(int flowermanId)
		{
			AttackBrackenClientRpc(flowermanId);
		}

		[ClientRpc]
		private void AttackBrackenClientRpc(int flowermanId)
		{
		}

		private IEnumerator AttackBracken()
		{
			((EnemyAI)this).SwitchToBehaviourClientRpc(4);
			MuteStepsClientRpc(mute: true);
			MuteVoiceClientRpc(mute: false);
			yield return (object)new WaitForSeconds(4f);
			((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			DoAnimationClientRpc("attack");
			((EnemyAI)this).SwitchToBehaviourClientRpc(0);
			MuteVoiceClientRpc(mute: true);
			MuteStepsClientRpc(mute: false);
		}

		public override void OnCollideWithEnemy(Collider other, EnemyAI collidedEnemy = null)
		{
			((EnemyAI)this).OnCollideWithEnemy(other, collidedEnemy);
			FlowermanAI componentInParent = ((Component)other).GetComponentInParent<FlowermanAI>();
			if ((Object)(object)componentInParent != (Object)null && !((EnemyAI)componentInParent).isEnemyDead)
			{
				((EnemyAI)componentInParent).KillEnemyOnOwnerClient(false);
				((MonoBehaviour)this).StartCoroutine(AttackBracken());
			}
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, attackingPlayer || carryingPlayerBody || fleaTimer > 0f, false);
			if ((Object)(object)val != (Object)null && ((NetworkBehaviour)this).IsOwner)
			{
				AttackPlayerServerRpc((int)val.playerClientId);
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			if ((Object)(object)base.creatureVoice != (Object)null)
			{
				base.creatureVoice.Stop();
			}
			if ((Object)(object)base.creatureSFX != (Object)null)
			{
				base.creatureSFX.Stop();
			}
			if ((Object)(object)stepSound != (Object)null)
			{
				stepSound.Stop();
			}
			if ((Object)(object)base.creatureAnimator != (Object)null)
			{
				base.creatureAnimator.SetLayerWeight(2, 0f);
			}
			((EnemyAI)this).KillEnemy(false);
			if (carryingPlayerBody)
			{
				carryingPlayerBody = false;
				if ((Object)(object)bodyBeingCarried != (Object)null)
				{
					bodyBeingCarried.matchPositionExactly = false;
					bodyBeingCarried.attachedTo = null;
				}
			}
			if (attackingPlayer && (Object)(object)base.inSpecialAnimationWithPlayer != (Object)null)
			{
				base.inSpecialAnimationWithPlayer.inSpecialInteractAnimation = false;
				base.inSpecialAnimationWithPlayer.snapToServerPosition = false;
				base.inSpecialAnimationWithPlayer.voiceMuffledByEnemy = false;
			}
		}

		public override void HitEnemy(int force = 1, PlayerControllerB playerWhoHit = null, bool playHitSFX = false, int hitID = -1)
		{
			((EnemyAI)this).HitEnemy(force, playerWhoHit, playHitSFX, hitID);
			if (base.isEnemyDead)
			{
				return;
			}
			if (!isInterrupted)
			{
				InterruptClientRpc(interrupt: true);
			}
			if (base.currentBehaviourStateIndex == 0 && (Object)(object)playerWhoHit != (Object)null)
			{
				base.targetPlayer = playerWhoHit;
				DoAnimationClientRpc("chasePlayer");
				((EnemyAI)this).SwitchToBehaviourClientRpc(1);
				MuteVoiceClientRpc(mute: false);
				MuteStepsClientRpc(mute: true);
			}
			base.enemyHP -= force;
			if (((NetworkBehaviour)this).IsOwner && base.enemyHP <= 0)
			{
				((MonoBehaviour)this).StopCoroutine(base.searchCoroutine);
				if (attackingPlayerCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(attackingPlayerCoroutine);
				}
				MuteVoiceClientRpc(mute: false);
				MuteStepsClientRpc(mute: true);
				((EnemyAI)this).KillEnemyOnOwnerClient(false);
			}
		}

		[ClientRpc]
		public void InterruptClientRpc(bool interrupt)
		{
			isInterrupted = interrupt;
		}

		[ServerRpc(RequireOwnership = false)]
		public void StartSearchServerRpc(Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			StartSearchClientRpc(pos);
		}

		[ClientRpc]
		public void StartSearchClientRpc(Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).StartSearch(pos, (AISearchRoutine)null);
		}

		[ServerRpc(RequireOwnership = false)]
		public void SetTargetPlayerServerRpc(int playerObjectId)
		{
			SetTargetPlayerClientRpc(playerObjectId);
		}

		[ClientRpc]
		public void SetTargetPlayerClientRpc(int playerObjectId)
		{
			base.targetPlayer = StartOfRound.Instance.allPlayerScripts[playerObjectId];
		}

		[ClientRpc]
		public void PlayDeathSoundClientRpc()
		{
			if ((Object)(object)base.creatureSFX != (Object)null && (Object)(object)base.dieSFX != (Object)null)
			{
				base.creatureSFX.PlayOneShot(base.dieSFX);
			}
		}

		[ClientRpc]
		public void MuteVoiceClientRpc(bool mute)
		{
			if ((Object)(object)base.creatureVoice != (Object)null)
			{
				base.creatureVoice.mute = mute;
			}
		}

		[ClientRpc]
		public void MuteStepsClientRpc(bool mute)
		{
			if ((Object)(object)stepSound != (Object)null)
			{
				stepSound.mute = mute;
			}
		}

		[ClientRpc]
		public void DoAnimationClientRpc(string animationName)
		{
			if ((Object)(object)base.creatureAnimator != (Object)null)
			{
				base.creatureAnimator.SetTrigger(animationName);
			}
		}
	}
	[BepInPlugin("RivalSilver97.BrolyCulo", "BrolyCulo", "1.2.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		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)this).Config);
			InitializeNetworkBehaviours();
			string path = "modassets_broly";
			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 obj = ModAssets.LoadAsset<EnemyType>("BrolyCulo");
			TerminalNode val = ModAssets.LoadAsset<TerminalNode>("BrolyCuloTN");
			TerminalKeyword val2 = ModAssets.LoadAsset<TerminalKeyword>("BrolyCuloTK");
			NetworkPrefabs.RegisterNetworkPrefab(obj.enemyPrefab);
			Enemies.RegisterEnemy(obj, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), (SpawnType)0, val, val2);
			Logger.LogInfo((object)"Plugin RivalSilver97.BrolyCulo is loaded!");
			Logger.LogInfo((object)"KAKAROOOOOOOT!");
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "RivalSilver97.BrolyCulo";

		public const string PLUGIN_NAME = "BrolyCulo";

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

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 200, "The spawn chance weight for Broly, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			ClearUnusedEntries(cfg);
		}

		private void ClearUnusedEntries(ConfigFile cfg)
		{
			PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			if (property != null)
			{
				((Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null))?.Clear();
				cfg.Save();
			}
		}
	}
}