Decompiled source of Barbaro v0.1.0

BepInEx/plugins/BarbaroLC/BarbaroLC.dll

Decompiled 2 hours 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 BarbaroLC.NetcodePatcher;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;

[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("BarbaroLC")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BarbaroLC")]
[assembly: AssemblyTitle("BarbaroLC")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 BarbaroLC
{
	public class BarbaroAI : EnemyAI
	{
		private enum Estado
		{
			Buscar,
			Perseguir,
			Seguir,
			Defender,
			Retirarse
		}

		[Header("Cara (se pone roja si está enfadado)")]
		[Tooltip("Renderers de la cara/cabeza del bárbaro.")]
		public Renderer[] rendersCara;

		[Tooltip("Opcional: material de la cara normal. Si los dos están puestos, se intercambian.")]
		public Material materialCaraNormal;

		[Tooltip("Opcional: material de la cara roja.")]
		public Material materialCaraEnfadada;

		[Tooltip("Piezas que solo se ven en modo agresivo (cara gritando, dientes afilados, cejas en V).")]
		public GameObject[] soloAgresivo;

		[Tooltip("Piezas que solo se ven en modo amigable (cara sonriente, dientes alineados).")]
		public GameObject[] soloAmigable;

		[Tooltip("Si no hay materiales, se tiñe la cara con este color.")]
		public Color colorEnfadado = new Color(0.68f, 0.36f, 0.3f);

		[Tooltip("Tinte para caras con textura (multiplica la textura).")]
		public Color colorEnfadadoTextura = new Color(1f, 0.68f, 0.62f);

		[Header("Sonidos (opcionales)")]
		public AudioClip[] gritos;

		public AudioClip sonidoEspadazo;

		private readonly NetworkVariable<bool> amigable = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private bool? caraAplicada;

		private Color[] coloresOriginales;

		private MaterialPropertyBlock bloque;

		private float esperaGolpe;

		private float esperaHachazo;

		private PlayerControllerB duenio;

		private EnemyAI presa;

		[Header("Vida")]
		public ScanNodeProperties nodoEscaner;

		[Tooltip("Cuerpo sólido (solo está activo cuando es agresivo, para que el amigable no te encierre).")]
		public Collider colisionSolida;

		[Tooltip("Caja de golpes (pala, espadazos). Se apaga al morir.")]
		public Collider colisionGolpes;

		private int vidaMax;

		private int vidaMostrada = -1;

		private float atacandoHasta;

		private float inicioEstado;

		private int golpesDados;

		private const float DistanciaHachazo = 2.5f;

		private const float AlcanceHachazo = 2.8f;

		private const float RetrasoHachazo = 0.42f;

		private const float DuracionHachazo = 0.9f;

		private const float AlcanceVista = 30f;

		private const float AnguloVista = 160f;

		private const float SentidoCercano = 7f;

		private static readonly RaycastHit[] impactos = (RaycastHit[])(object)new RaycastHit[16];

		public bool EsAmigable => amigable.Value;

		public string EstadoTexto
		{
			get
			{
				Estado currentBehaviourStateIndex = (Estado)base.currentBehaviourStateIndex;
				return currentBehaviourStateIndex.ToString();
			}
		}

		public override void Start()
		{
			((EnemyAI)this).Start();
			base.enemyHP = Plugin.Cfg.Vida.Value;
			vidaMax = Mathf.Max(1, base.enemyHP);
			Materiales.Convertir(((Component)this).gameObject);
			GuardarColoresCara();
			if (((NetworkBehaviour)this).IsServer)
			{
				amigable.Value = DecidirModo();
				Plugin.Log.LogInfo((object)("Ha aparecido un bárbaro " + (amigable.Value ? "AMIGABLE" : "AGRESIVO") + "."));
				((EnemyAI)this).SwitchToBehaviourClientRpc(amigable.Value ? 2 : 0);
				if (!amigable.Value)
				{
					GritarClientRpc();
				}
			}
		}

		private static bool DecidirModo()
		{
			if (Depuracion.ModoSiguiente.HasValue)
			{
				bool value = Depuracion.ModoSiguiente.Value;
				Depuracion.ModoSiguiente = null;
				return value;
			}
			string value2 = Plugin.Cfg.ForzarModo.Value;
			if (!(value2 == "Amigable"))
			{
				if (value2 == "Agresivo")
				{
					return false;
				}
				return Random.value < Plugin.Cfg.ProbAmigable.Value;
			}
			return true;
		}

		public override void Update()
		{
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			((EnemyAI)this).Update();
			if (esperaGolpe > 0f)
			{
				esperaGolpe -= Time.deltaTime;
			}
			if (esperaHachazo > 0f)
			{
				esperaHachazo -= Time.deltaTime;
			}
			if (caraAplicada != amigable.Value)
			{
				AplicarCara(!amigable.Value);
			}
			if ((Object)(object)colisionSolida != (Object)null)
			{
				bool flag = !amigable.Value && !base.isEnemyDead;
				if (colisionSolida.enabled != flag)
				{
					colisionSolida.enabled = flag;
				}
			}
			if ((Object)(object)colisionGolpes != (Object)null && colisionGolpes.enabled == base.isEnemyDead)
			{
				colisionGolpes.enabled = !base.isEnemyDead;
			}
			if ((Object)(object)nodoEscaner != (Object)null && Plugin.Cfg.MostrarVida.Value && vidaMostrada != base.enemyHP)
			{
				vidaMostrada = base.enemyHP;
				nodoEscaner.subText = (base.isEnemyDead ? "Muerto" : $"Vida: {Mathf.Max(0, base.enemyHP)}/{vidaMax}");
			}
			if ((Object)(object)base.creatureAnimator != (Object)null && (Object)(object)base.agent != (Object)null)
			{
				Animator creatureAnimator = base.creatureAnimator;
				int num;
				if (!base.isEnemyDead)
				{
					Vector3 velocity = base.agent.velocity;
					num = ((((Vector3)(ref velocity)).sqrMagnitude > 0.25f) ? 1 : 0);
				}
				else
				{
					num = 0;
				}
				creatureAnimator.SetBool("Corriendo", (byte)num != 0);
			}
			if (((NetworkBehaviour)this).IsOwner && !base.isEnemyDead && Time.time < atacandoHasta && (Object)(object)base.targetPlayer != (Object)null)
			{
				Vector3 val = ((Component)base.targetPlayer).transform.position - ((Component)this).transform.position;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
				{
					((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, Quaternion.LookRotation(val), 540f * Time.deltaTime);
				}
			}
		}

		private void CambiarEstado(Estado e)
		{
			inicioEstado = Time.time;
			if (e == Estado.Perseguir)
			{
				golpesDados = 0;
			}
			((EnemyAI)this).SwitchToBehaviourClientRpc((int)e);
		}

		public override void DoAIInterval()
		{
			((EnemyAI)this).DoAIInterval();
			if (!base.isEnemyDead && !StartOfRound.Instance.allPlayersDead)
			{
				switch ((Estado)base.currentBehaviourStateIndex)
				{
				case Estado.Buscar:
					IABuscar();
					break;
				case Estado.Perseguir:
					IAPerseguir();
					break;
				case Estado.Seguir:
					IASeguir();
					break;
				case Estado.Defender:
					IADefender();
					break;
				case Estado.Retirarse:
					IARetirarse();
					break;
				}
			}
		}

		private void IABuscar()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = Plugin.Cfg.VelocidadAgresivo.Value * 0.6f;
			base.agent.isStopped = false;
			PlayerControllerB val = VerJugador();
			if ((Object)(object)val != (Object)null)
			{
				base.targetPlayer = val;
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				CambiarEstado(Estado.Perseguir);
				GritarClientRpc();
			}
			else if (base.currentSearch == null || !base.currentSearch.inProgress)
			{
				((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
			}
		}

		private void IAPerseguir()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = Plugin.Cfg.VelocidadAgresivo.Value;
			if ((Object)(object)base.targetPlayer == (Object)null || base.targetPlayer.isPlayerDead || !base.targetPlayer.isPlayerControlled || Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) > 30f)
			{
				base.targetPlayer = VerJugador();
				if ((Object)(object)base.targetPlayer == (Object)null)
				{
					CambiarEstado(Estado.Buscar);
					return;
				}
			}
			if (Time.time < atacandoHasta)
			{
				base.agent.isStopped = true;
				return;
			}
			base.agent.isStopped = false;
			if (golpesDados >= Plugin.Cfg.GolpesAntesDeIrse.Value || Time.time - inicioEstado > Plugin.Cfg.TiempoMaxPersecucion.Value)
			{
				EmpezarRetirada();
				return;
			}
			((EnemyAI)this).SetDestinationToPosition(((Component)base.targetPlayer).transform.position, false);
			if (Vector3.Distance(((Component)this).transform.position, ((Component)base.targetPlayer).transform.position) < 2.5f)
			{
				Hachazo(base.targetPlayer);
			}
		}

		private void Hachazo(PlayerControllerB objetivo)
		{
			if (!(esperaHachazo > 0f) && !base.isEnemyDead && !amigable.Value && !((Object)(object)objetivo == (Object)null) && base.currentBehaviourStateIndex == 1)
			{
				esperaHachazo = Mathf.Max(Plugin.Cfg.EsperaEntreGolpes.Value, 0.9f);
				atacandoHasta = Time.time + 0.9f;
				base.targetPlayer = objetivo;
				base.agent.isStopped = true;
				EspadazoClientRpc();
				((MonoBehaviour)this).StartCoroutine(DanioAlBajar(objetivo));
			}
		}

		private IEnumerator DanioAlBajar(PlayerControllerB objetivo)
		{
			yield return (object)new WaitForSeconds(0.42f);
			if (!base.isEnemyDead && !((Object)(object)objetivo == (Object)null) && !objetivo.isPlayerDead && objetivo.isPlayerControlled)
			{
				Vector3 val = ((Component)objetivo).transform.position - ((Component)this).transform.position;
				val.y = 0f;
				if (((Vector3)(ref val)).magnitude < 2.8f && (((Vector3)(ref val)).magnitude < 0.9f || Vector3.Dot(((Component)this).transform.forward, ((Vector3)(ref val)).normalized) > 0.3f))
				{
					golpesDados++;
					HachazoDaClientRpc((int)objetivo.playerClientId);
				}
			}
		}

		private void EmpezarRetirada()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			atacandoHasta = 0f;
			base.agent.isStopped = false;
			Vector3 val = (((Object)(object)base.targetPlayer != (Object)null) ? ((Component)base.targetPlayer).transform.position : ((Component)this).transform.position);
			Transform val2 = ((EnemyAI)this).ChooseFarthestNodeFromPosition(val, false, 0, false, 50, -1);
			if ((Object)(object)val2 != (Object)null)
			{
				((EnemyAI)this).SetDestinationToPosition(val2.position, false);
			}
			base.targetPlayer = null;
			CambiarEstado(Estado.Retirarse);
		}

		private void IARetirarse()
		{
			base.agent.speed = Plugin.Cfg.VelocidadAgresivo.Value * 0.7f;
			base.agent.isStopped = false;
			if (Time.time - inicioEstado > Plugin.Cfg.TiempoRetirada.Value)
			{
				CambiarEstado(Estado.Buscar);
			}
		}

		private void IASeguir()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = Plugin.Cfg.VelocidadAmigable.Value;
			presa = BuscarPresa();
			if ((Object)(object)presa != (Object)null)
			{
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				((EnemyAI)this).SwitchToBehaviourClientRpc(3);
				GritarClientRpc();
				return;
			}
			if (!DuenioValido(duenio))
			{
				duenio = JugadorMasCercano();
			}
			if ((Object)(object)duenio == (Object)null)
			{
				if (base.currentSearch == null || !base.currentSearch.inProgress)
				{
					((EnemyAI)this).StartSearch(((Component)this).transform.position, (AISearchRoutine)null);
				}
				return;
			}
			((EnemyAI)this).StopSearch(base.currentSearch, true);
			float num = Vector3.Distance(((Component)this).transform.position, ((Component)duenio).transform.position);
			if (num > Plugin.Cfg.DistanciaSeguir.Value)
			{
				((EnemyAI)this).SetDestinationToPosition(((Component)duenio).transform.position, false);
			}
			else if (num < 1.6f)
			{
				Vector3 val = ((Component)this).transform.position - ((Component)duenio).transform.position;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
				{
					val = -((Component)this).transform.forward;
				}
				NavMeshHit val2 = default(NavMeshHit);
				if (NavMesh.SamplePosition(((Component)this).transform.position + ((Vector3)(ref val)).normalized * 2f, ref val2, 2f, -1))
				{
					((EnemyAI)this).SetDestinationToPosition(((NavMeshHit)(ref val2)).position, false);
				}
			}
			else
			{
				((EnemyAI)this).SetDestinationToPosition(((Component)this).transform.position, false);
			}
		}

		private void IADefender()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			base.agent.speed = Plugin.Cfg.VelocidadAmigable.Value;
			if (!PresaValida(presa))
			{
				presa = null;
				((EnemyAI)this).SwitchToBehaviourClientRpc(2);
				return;
			}
			Vector3 val = ((Component)presa).transform.position - ((Component)this).transform.position;
			((EnemyAI)this).SetDestinationToPosition(((Component)presa).transform.position, false);
			if (((Vector3)(ref val)).magnitude < 2.5f && esperaGolpe <= 0f)
			{
				esperaGolpe = Plugin.Cfg.EsperaEntreGolpes.Value;
				presa.HitEnemyOnLocalClient(Plugin.Cfg.DanioAEnemigos.Value, ((Vector3)(ref val)).normalized, (PlayerControllerB)null, false, -1);
				EspadazoClientRpc();
			}
		}

		private bool EnMiZona(PlayerControllerB p)
		{
			return p.isInsideFactory == !base.isOutside;
		}

		private bool DuenioValido(PlayerControllerB p)
		{
			if ((Object)(object)p != (Object)null && p.isPlayerControlled && !p.isPlayerDead)
			{
				return EnMiZona(p);
			}
			return false;
		}

		private PlayerControllerB VerJugador()
		{
			//IL_003d: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0091: 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_00a0: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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)
			PlayerControllerB result = null;
			float num = float.MaxValue;
			Vector3 val = (((Object)(object)base.eye != (Object)null) ? base.eye.position : (((Component)this).transform.position + Vector3.up * 1.4f));
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if (!DuenioValido(val2) || (Object)(object)val2.inAnimationWithEnemy != (Object)null)
				{
					continue;
				}
				Vector3 val3 = (((Object)(object)val2.gameplayCamera != (Object)null) ? ((Component)val2.gameplayCamera).transform.position : (((Component)val2).transform.position + Vector3.up * 1.5f));
				Vector3 val4 = val3 - val;
				float magnitude = ((Vector3)(ref val4)).magnitude;
				if (!(magnitude > 30f) && !(magnitude >= num))
				{
					Vector3 val5 = val4;
					val5.y = 0f;
					if ((!(magnitude > 7f) || !(Vector3.Angle(((Component)this).transform.forward, val5) > 80f)) && VistaLibre(val, val3))
					{
						result = val2;
						num = magnitude;
					}
				}
			}
			return result;
		}

		private static bool VistaLibre(Vector3 desde, Vector3 hasta)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = hasta - desde;
			int num = Physics.RaycastNonAlloc(desde, ((Vector3)(ref val)).normalized, impactos, ((Vector3)(ref val)).magnitude, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1);
			for (int i = 0; i < num; i++)
			{
				if ((Object)(object)((Component)((RaycastHit)(ref impactos[i])).collider).GetComponentInParent<BarbaroAI>() == (Object)null)
				{
					return false;
				}
			}
			return true;
		}

		private PlayerControllerB JugadorMasCercano()
		{
			//IL_002c: 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)
			PlayerControllerB result = null;
			float num = float.MaxValue;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (DuenioValido(val))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
					if (num2 < num)
					{
						num = num2;
						result = val;
					}
				}
			}
			return result;
		}

		private bool PresaValida(EnemyAI e)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)e != (Object)null && (Object)(object)e != (Object)(object)this && !e.isEnemyDead && (Object)(object)e.enemyType != (Object)null && e.enemyType.canDie && !(e is BarbaroAI) && e.isOutside == base.isOutside)
			{
				return Vector3.Distance(((Component)this).transform.position, ((Component)e).transform.position) < Plugin.Cfg.RadioDefensa.Value * 1.5f;
			}
			return false;
		}

		private EnemyAI BuscarPresa()
		{
			//IL_003b: 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)
			EnemyAI result = null;
			float num = Plugin.Cfg.RadioDefensa.Value;
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (PresaValida(spawnedEnemy))
				{
					float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)spawnedEnemy).transform.position);
					if (num2 < num)
					{
						num = num2;
						result = spawnedEnemy;
					}
				}
			}
			return result;
		}

		public override void OnCollideWithPlayer(Collider other)
		{
			((EnemyAI)this).OnCollideWithPlayer(other);
			if (!amigable.Value && !base.isEnemyDead && !(esperaGolpe > 0f) && base.currentBehaviourStateIndex == 1)
			{
				PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
				if (!((Object)(object)val == (Object)null))
				{
					esperaGolpe = 0.3f;
					HachazoServerRpc((int)val.playerClientId);
				}
			}
		}

		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;
			}
			base.enemyHP -= force;
			if (base.enemyHP <= 0)
			{
				if (((NetworkBehaviour)this).IsOwner)
				{
					((EnemyAI)this).KillEnemyOnOwnerClient(false);
				}
			}
			else if (((NetworkBehaviour)this).IsServer && (Object)(object)playerWhoHit != (Object)null && amigable.Value && Plugin.Cfg.SeEnfadaSiLePegas.Value)
			{
				amigable.Value = false;
				presa = null;
				base.targetPlayer = playerWhoHit;
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				CambiarEstado(Estado.Perseguir);
				GritarClientRpc();
			}
			else if (((NetworkBehaviour)this).IsServer && (Object)(object)playerWhoHit != (Object)null && !amigable.Value && base.currentBehaviourStateIndex != 1)
			{
				base.targetPlayer = playerWhoHit;
				((EnemyAI)this).StopSearch(base.currentSearch, true);
				CambiarEstado(Estado.Perseguir);
				GritarClientRpc();
			}
		}

		public override void KillEnemy(bool destroy = false)
		{
			((EnemyAI)this).KillEnemy(destroy);
			if ((Object)(object)base.creatureAnimator != (Object)null)
			{
				base.creatureAnimator.SetBool("Muerto", true);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		private void HachazoServerRpc(int jugadorId)
		{
			//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)
			{
				return;
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(713014515u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, jugadorId);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 713014515u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				if (jugadorId >= 0 && jugadorId < allPlayerScripts.Length)
				{
					Hachazo(allPlayerScripts[jugadorId]);
				}
			}
		}

		[ClientRpc]
		private void HachazoDaClientRpc(int jugadorId)
		{
			//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)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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)
			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(3957858710u, val2, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val, jugadorId);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 3957858710u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
				if (!((Object)(object)localPlayerController == (Object)null) && (int)localPlayerController.playerClientId == jugadorId && !localPlayerController.isPlayerDead)
				{
					Vector3 val3 = ((Component)localPlayerController).transform.position - ((Component)this).transform.position;
					Vector3 val4 = ((Vector3)(ref val3)).normalized * 5f;
					localPlayerController.DamagePlayer(Plugin.Cfg.DanioAJugador.Value, true, true, (CauseOfDeath)6, 0, false, val4);
				}
			}
		}

		[ClientRpc]
		private void EspadazoClientRpc()
		{
			//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(1590830325u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 1590830325u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if ((Object)(object)base.creatureAnimator != (Object)null)
				{
					base.creatureAnimator.SetTrigger("Atacar");
				}
				if ((Object)(object)sonidoEspadazo != (Object)null && (Object)(object)base.creatureSFX != (Object)null)
				{
					base.creatureSFX.PlayOneShot(sonidoEspadazo);
				}
			}
		}

		[ClientRpc]
		private void GritarClientRpc()
		{
			//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(988654224u, val2, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val, 988654224u, val2, (RpcDelivery)0);
			}
			if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				((NetworkBehaviour)this).__rpc_exec_stage = (__RpcExecStage)0;
				if (gritos != null && gritos.Length != 0 && !((Object)(object)base.creatureVoice == (Object)null))
				{
					base.creatureVoice.PlayOneShot(gritos[Random.Range(0, gritos.Length)]);
				}
			}
		}

		private void GuardarColoresCara()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			if (rendersCara != null)
			{
				bloque = new MaterialPropertyBlock();
				coloresOriginales = (Color[])(object)new Color[rendersCara.Length];
				for (int i = 0; i < rendersCara.Length; i++)
				{
					Material val = (((Object)(object)rendersCara[i] != (Object)null) ? rendersCara[i].sharedMaterial : null);
					coloresOriginales[i] = (((Object)(object)val == (Object)null) ? Color.white : (val.HasProperty("_BaseColor") ? val.GetColor("_BaseColor") : (val.HasProperty("_Color") ? val.color : Color.white)));
				}
			}
		}

		private void AplicarCara(bool enfadado)
		{
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			caraAplicada = !enfadado;
			if (soloAgresivo != null)
			{
				GameObject[] array = soloAgresivo;
				foreach (GameObject val in array)
				{
					if ((Object)(object)val != (Object)null)
					{
						val.SetActive(enfadado);
					}
				}
			}
			if (soloAmigable != null)
			{
				GameObject[] array = soloAmigable;
				foreach (GameObject val2 in array)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						val2.SetActive(!enfadado);
					}
				}
			}
			if (rendersCara == null)
			{
				return;
			}
			bool flag = (Object)(object)materialCaraNormal != (Object)null && (Object)(object)materialCaraEnfadada != (Object)null;
			for (int j = 0; j < rendersCara.Length; j++)
			{
				Renderer val3 = rendersCara[j];
				if (!((Object)(object)val3 == (Object)null))
				{
					if (flag)
					{
						val3.sharedMaterial = (enfadado ? materialCaraEnfadada : materialCaraNormal);
						continue;
					}
					Color val4 = (Materiales.TieneTextura(val3) ? colorEnfadadoTextura : colorEnfadado);
					Color val5 = (enfadado ? val4 : coloresOriginales[j]);
					val3.GetPropertyBlock(bloque);
					bloque.SetColor("_BaseColor", val5);
					bloque.SetColor("_Color", val5);
					val3.SetPropertyBlock(bloque);
				}
			}
		}

		protected override void __initializeVariables()
		{
			if (amigable == null)
			{
				throw new Exception("BarbaroAI.amigable cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)amigable).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)amigable, "amigable");
			((NetworkBehaviour)this).NetworkVariableFields.Add((NetworkVariableBase)(object)amigable);
			((EnemyAI)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(713014515u, new RpcReceiveHandler(__rpc_handler_713014515), "HachazoServerRpc");
			((NetworkBehaviour)this).__registerRpc(3957858710u, new RpcReceiveHandler(__rpc_handler_3957858710), "HachazoDaClientRpc");
			((NetworkBehaviour)this).__registerRpc(1590830325u, new RpcReceiveHandler(__rpc_handler_1590830325), "EspadazoClientRpc");
			((NetworkBehaviour)this).__registerRpc(988654224u, new RpcReceiveHandler(__rpc_handler_988654224), "GritarClientRpc");
			((EnemyAI)this).__initializeRpcs();
		}

		private static void __rpc_handler_713014515(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int jugadorId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref jugadorId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BarbaroAI)(object)target).HachazoServerRpc(jugadorId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3957858710(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int jugadorId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref jugadorId);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((BarbaroAI)(object)target).HachazoDaClientRpc(jugadorId);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1590830325(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)1;
				((BarbaroAI)(object)target).EspadazoClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_988654224(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)1;
				((BarbaroAI)(object)target).GritarClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "BarbaroAI";
		}
	}
	public class Configuracion
	{
		public ConfigEntry<float> ProbAmigable;

		public ConfigEntry<string> ForzarModo;

		public ConfigEntry<int> Rareza;

		public ConfigEntry<int> Vida;

		public ConfigEntry<int> DanioAJugador;

		public ConfigEntry<int> DanioAEnemigos;

		public ConfigEntry<float> EsperaEntreGolpes;

		public ConfigEntry<float> VelocidadAgresivo;

		public ConfigEntry<float> VelocidadAmigable;

		public ConfigEntry<float> DistanciaSeguir;

		public ConfigEntry<float> RadioDefensa;

		public ConfigEntry<bool> SeEnfadaSiLePegas;

		public ConfigEntry<bool> DepuracionActivada;

		public ConfigEntry<bool> ColisionSolida;

		public ConfigEntry<bool> MostrarVida;

		public ConfigEntry<int> GolpesAntesDeIrse;

		public ConfigEntry<float> TiempoRetirada;

		public ConfigEntry<float> TiempoMaxPersecucion;

		public Configuracion(ConfigFile cfg)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			ProbAmigable = cfg.Bind<float>("Personalidad", "ProbabilidadAmigable", 0.5f, new ConfigDescription("Probabilidad (0 a 1) de que el bárbaro salga amigable al aparecer.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ForzarModo = cfg.Bind<string>("Personalidad", "ForzarModo", "Azar", new ConfigDescription("Para probar: Azar, Agresivo o Amigable.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Azar", "Agresivo", "Amigable" }), Array.Empty<object>()));
			SeEnfadaSiLePegas = cfg.Bind<bool>("Personalidad", "SeEnfadaSiLePegas", true, "Si un jugador le pega al bárbaro amigable, se vuelve agresivo (y se le pone la cara roja).");
			Rareza = cfg.Bind<int>("Aparicion", "Rareza", 40, "Peso de aparición en todas las lunas (más alto = sale más a menudo).");
			Vida = cfg.Bind<int>("Combate", "Vida", 6, "Puntos de vida (cada golpe de pala quita 1).");
			MostrarVida = cfg.Bind<bool>("Combate", "MostrarVida", true, "Muestra la vida en el escáner (clic derecho).");
			GolpesAntesDeIrse = cfg.Bind<int>("Combate", "GolpesAntesDeIrse", 3, "Hachazos que te acierta el agresivo antes de dejarte en paz un rato.");
			TiempoRetirada = cfg.Bind<float>("Combate", "TiempoRetirada", 5f, "Segundos que se aleja y pasa de los jugadores después de atacar.");
			TiempoMaxPersecucion = cfg.Bind<float>("Combate", "TiempoMaxPersecucion", 25f, "Si en este tiempo no te ha alcanzado, se cansa y se retira.");
			ColisionSolida = cfg.Bind<bool>("Combate", "ColisionSolida", true, "El bárbaro es sólido: no se le puede atravesar andando.");
			DanioAJugador = cfg.Bind<int>("Combate", "DanioAJugador", 30, "Daño por espadazo al jugador (vida máxima 100).");
			DanioAEnemigos = cfg.Bind<int>("Combate", "DanioAEnemigos", 1, "Daño por espadazo a otros monstruos (en modo amigable).");
			EsperaEntreGolpes = cfg.Bind<float>("Combate", "EsperaEntreGolpes", 1f, "Segundos entre espadazos.");
			VelocidadAgresivo = cfg.Bind<float>("Movimiento", "VelocidadAgresivo", 5.5f, "Velocidad persiguiendo.");
			VelocidadAmigable = cfg.Bind<float>("Movimiento", "VelocidadAmigable", 6f, "Velocidad siguiendo a su jugador.");
			DistanciaSeguir = cfg.Bind<float>("Movimiento", "DistanciaSeguir", 3f, "A qué distancia se queda de su jugador.");
			DepuracionActivada = cfg.Bind<bool>("Depuracion", "Activado", false, "Teclas de prueba: F5 bárbaro agresivo, F6 amigable (solo host), F7 visión nocturna, F8 invencible, F9 panel de info, F10 matar bárbaros (solo host).");
			RadioDefensa = cfg.Bind<float>("Movimiento", "RadioDefensa", 12f, "Radio en el que ataca a monstruos cuando es amigable.");
		}
	}
	public class Depuracion : MonoBehaviour
	{
		public static Depuracion Instancia;

		public static EnemyType TipoBarbaro;

		public static bool? ModoSiguiente;

		public static bool Invencible;

		private bool vision;

		private bool panel = true;

		private Light luzVision;

		private static bool Activo => Plugin.Cfg.DepuracionActivada.Value;

		private static PlayerControllerB Yo
		{
			get
			{
				if (!((Object)(object)GameNetworkManager.Instance != (Object)null))
				{
					return null;
				}
				return GameNetworkManager.Instance.localPlayerController;
			}
		}

		private static bool EsHost
		{
			get
			{
				if ((Object)(object)RoundManager.Instance != (Object)null)
				{
					return ((NetworkBehaviour)RoundManager.Instance).IsServer;
				}
				return false;
			}
		}

		public static void Crear()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			if (!((Object)(object)Instancia != (Object)null))
			{
				GameObject val = new GameObject("BarbaroLC_Depuracion")
				{
					hideFlags = (HideFlags)61
				};
				Object.DontDestroyOnLoad((Object)val);
				Instancia = val.AddComponent<Depuracion>();
			}
		}

		private void Update()
		{
			if (!Activo || Keyboard.current == null)
			{
				return;
			}
			PlayerControllerB yo = Yo;
			if ((Object)(object)yo == (Object)null || yo.isTypingChat || yo.inTerminalMenu || ((Object)(object)yo.quickMenuManager != (Object)null && yo.quickMenuManager.isMenuOpen))
			{
				MantenerVision(yo);
				return;
			}
			Keyboard current = Keyboard.current;
			if (((ButtonControl)current.f5Key).wasPressedThisFrame)
			{
				Aparecer(yo, amigable: false);
			}
			if (((ButtonControl)current.f6Key).wasPressedThisFrame)
			{
				Aparecer(yo, amigable: true);
			}
			if (((ButtonControl)current.f7Key).wasPressedThisFrame)
			{
				vision = !vision;
				Aviso("Visión nocturna", vision ? "ACTIVADA" : "desactivada");
			}
			if (((ButtonControl)current.f8Key).wasPressedThisFrame)
			{
				Invencible = !Invencible;
				Aviso("Invencible", Invencible ? "ACTIVADO" : "desactivado");
			}
			if (((ButtonControl)current.f9Key).wasPressedThisFrame)
			{
				panel = !panel;
			}
			if (((ButtonControl)current.f10Key).wasPressedThisFrame)
			{
				MatarTodos();
			}
			MantenerVision(yo);
		}

		private void Aparecer(PlayerControllerB yo, bool amigable)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a5: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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)
			if (!EsHost)
			{
				Aviso("Bárbaro", "Solo el host puede hacer aparecer bárbaros.");
			}
			else if (!((Object)(object)TipoBarbaro == (Object)null))
			{
				NavMeshHit val = default(NavMeshHit);
				if (!NavMesh.SamplePosition(((Component)yo).transform.position + ((Component)yo).transform.forward * 4f, ref val, 8f, -1) && !NavMesh.SamplePosition(((Component)yo).transform.position, ref val, 8f, -1))
				{
					Aviso("Bárbaro", "Aquí no hay suelo navegable. Prueba en la luna o dentro del edificio.");
					return;
				}
				ModoSiguiente = amigable;
				Quaternion val2 = Quaternion.LookRotation(((Component)yo).transform.position - ((NavMeshHit)(ref val)).position);
				float y = ((Quaternion)(ref val2)).eulerAngles.y;
				RoundManager.Instance.SpawnEnemyGameObject(((NavMeshHit)(ref val)).position, y, -1, TipoBarbaro);
				Aviso("Bárbaro", amigable ? "Ha aparecido uno AMIGABLE" : "Ha aparecido uno AGRESIVO");
			}
		}

		private void MatarTodos()
		{
			if (!EsHost)
			{
				Aviso("Bárbaro", "Solo el host puede matar bárbaros.");
				return;
			}
			int num = 0;
			EnemyAI[] array = RoundManager.Instance.SpawnedEnemies.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				if (array[i] is BarbaroAI { isEnemyDead: false } barbaroAI && ((NetworkBehaviour)barbaroAI).IsOwner)
				{
					((EnemyAI)barbaroAI).KillEnemyOnOwnerClient(false);
					num++;
				}
			}
			Aviso("Bárbaro", $"Bárbaros eliminados: {num}");
		}

		private void MantenerVision(PlayerControllerB yo)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			if (!Activo || !vision || !((Object)(object)yo != (Object)null) || !((Object)(object)yo.gameplayCamera != (Object)null))
			{
				if ((Object)(object)luzVision != (Object)null)
				{
					((Behaviour)luzVision).enabled = false;
				}
				return;
			}
			if ((Object)(object)luzVision == (Object)null)
			{
				if ((Object)(object)yo.nightVision == (Object)null)
				{
					return;
				}
				GameObject val = Object.Instantiate<GameObject>(((Component)yo.nightVision).gameObject, ((Component)yo.gameplayCamera).transform);
				((Object)val).name = "BarbaroLC_Vision";
				val.transform.localPosition = Vector3.zero;
				val.transform.localRotation = Quaternion.identity;
				luzVision = val.GetComponent<Light>();
				luzVision.type = (LightType)2;
				luzVision.range = 120f;
				luzVision.intensity = Mathf.Max(luzVision.intensity, 1f) * 25f;
				luzVision.shadows = (LightShadows)0;
				luzVision.color = Color.white;
			}
			((Behaviour)luzVision).enabled = true;
		}

		private void OnGUI()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Expected O, but got Unknown
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if (!Activo || !panel || (Object)(object)RoundManager.Instance == (Object)null)
			{
				return;
			}
			PlayerControllerB yo = Yo;
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 15,
				richText = true
			};
			string text = "<b>BarbaroLC · depuración</b>\nF5 agresivo · F6 amigable · F7 visión · F8 invencible · F9 panel · F10 matar\nVisión: " + (vision ? "sí" : "no") + "   Invencible: " + (Invencible ? "sí" : "no") + "   Host: " + (EsHost ? "sí" : "no") + "\n";
			int num = 0;
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				if (spawnedEnemy is BarbaroAI barbaroAI && !((Object)(object)barbaroAI == (Object)null))
				{
					num++;
					string text2 = (barbaroAI.EsAmigable ? "<color=#7CFC00>amigable</color>" : "<color=#FF4040>agresivo</color>");
					string text3 = (((Object)(object)yo != (Object)null) ? $"{Vector3.Distance(((Component)yo).transform.position, ((Component)barbaroAI).transform.position):0} m" : "?");
					string text4 = (((Object)(object)((EnemyAI)barbaroAI).targetPlayer != (Object)null) ? ((EnemyAI)barbaroAI).targetPlayer.playerUsername : "-");
					text = text + $"#{num} {text2} · {barbaroAI.EstadoTexto} · vida {((EnemyAI)barbaroAI).enemyHP} · {text3} · " + (((EnemyAI)barbaroAI).isOutside ? "fuera" : "dentro") + " · objetivo " + text4 + (((EnemyAI)barbaroAI).isEnemyDead ? " · MUERTO" : "") + "\n";
				}
			}
			if (num == 0)
			{
				text += "No hay bárbaros en la partida.\n";
			}
			Vector2 val2 = val.CalcSize(new GUIContent(text.Replace("<b>", "").Replace("</b>", "")));
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(10f, 10f, Mathf.Max(val2.x, 300f) + 20f, val2.y + 30f + (float)(num * 2));
			GUI.color = new Color(0f, 0f, 0f, 0.6f);
			GUI.DrawTexture(val3, (Texture)(object)Texture2D.whiteTexture);
			GUI.color = Color.white;
			GUI.Label(new Rect(((Rect)(ref val3)).x + 10f, ((Rect)(ref val3)).y + 5f, ((Rect)(ref val3)).width - 20f, ((Rect)(ref val3)).height - 10f), text, val);
		}

		private static void Aviso(string titulo, string texto)
		{
			Plugin.Log.LogInfo((object)("[Depuración] " + titulo + ": " + texto));
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				HUDManager.Instance.DisplayTip(titulo, texto, false, false, "LC_Tip1");
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal static class ParcheInvencible
	{
		private static bool EsYoInvencible(PlayerControllerB p)
		{
			if (Depuracion.Invencible && Plugin.Cfg.DepuracionActivada.Value && (Object)(object)GameNetworkManager.Instance != (Object)null)
			{
				return (Object)(object)p == (Object)(object)GameNetworkManager.Instance.localPlayerController;
			}
			return false;
		}

		[HarmonyPatch("DamagePlayer")]
		[HarmonyPrefix]
		private static bool SinDanio(PlayerControllerB __instance)
		{
			return !EsYoInvencible(__instance);
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		private static bool SinMuerte(PlayerControllerB __instance)
		{
			return !EsYoInvencible(__instance);
		}
	}
	public static class Fabrica
	{
		public static EnemyType CrearEnemigo(GameObject modeloBundle)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: 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_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: 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_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: 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_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			EnemyType val = ScriptableObject.CreateInstance<EnemyType>();
			((Object)val).name = "BarbaroEnemy";
			val.enemyName = "Barbaro";
			val.probabilityCurve = AnimationCurve.Constant(0f, 1f, 1f);
			val.numberSpawnedFalloff = AnimationCurve.Constant(0f, 1f, 1f);
			val.useNumberSpawnedFalloff = false;
			val.MaxCount = 2;
			val.PowerLevel = 1f;
			val.isOutsideEnemy = false;
			val.canDie = true;
			val.destroyOnDeath = false;
			val.canBeStunned = true;
			val.stunTimeMultiplier = 1f;
			val.doorSpeedMultiplier = 1f;
			GameObject val2 = NetworkPrefabs.CreateNetworkPrefab("BarbaroLC_Enemigo");
			GameObject val3 = Object.Instantiate<GameObject>(modeloBundle, val2.transform);
			((Object)val3).name = "Modelo";
			val3.transform.localPosition = Vector3.zero;
			val3.transform.localRotation = Quaternion.identity;
			NavMeshAgent val4 = val2.AddComponent<NavMeshAgent>();
			val4.speed = 5f;
			val4.angularSpeed = 400f;
			val4.acceleration = 12f;
			val4.radius = 0.4f;
			val4.height = 1.6f;
			val4.stoppingDistance = 0.5f;
			AudioSource creatureSFX = CrearAudio(val2, "SFX");
			AudioSource creatureVoice = CrearAudio(val2, "Voz");
			Transform transform = new GameObject("Ojo").transform;
			transform.SetParent(val2.transform, false);
			transform.localPosition = new Vector3(0f, 1.36f, 0.17f);
			BarbaroAI barbaroAI = val2.AddComponent<BarbaroAI>();
			((EnemyAI)barbaroAI).enemyType = val;
			((EnemyAI)barbaroAI).agent = val4;
			((EnemyAI)barbaroAI).creatureAnimator = val3.GetComponentInChildren<Animator>();
			((EnemyAI)barbaroAI).creatureSFX = creatureSFX;
			((EnemyAI)barbaroAI).creatureVoice = creatureVoice;
			((EnemyAI)barbaroAI).eye = transform;
			((EnemyAI)barbaroAI).AIIntervalTime = 0.2f;
			((EnemyAI)barbaroAI).enemyHP = Plugin.Cfg.Vida.Value;
			((EnemyAI)barbaroAI).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[5]
			{
				Estado("Buscar"),
				Estado("Perseguir"),
				Estado("Seguir"),
				Estado("Defender"),
				Estado("Retirarse")
			};
			Transform val5 = val3.transform.Find("Cabeza");
			Transform val6 = val3.transform.Find("Cabeza_Amigable");
			if ((Object)(object)val5 != (Object)null && (Object)(object)val6 != (Object)null)
			{
				barbaroAI.rendersCara = (Renderer[])(object)new Renderer[2]
				{
					((Component)val5).GetComponent<Renderer>(),
					((Component)val6).GetComponent<Renderer>()
				};
			}
			else if ((Object)(object)val5 != (Object)null)
			{
				barbaroAI.rendersCara = (Renderer[])(object)new Renderer[1] { ((Component)val5).GetComponent<Renderer>() };
			}
			barbaroAI.soloAgresivo = Buscar(val3, ((Object)(object)val6 != (Object)null) ? "Cabeza" : null, "Gesto_Agresivo");
			barbaroAI.soloAmigable = Buscar(val3, "Cabeza_Amigable", "Gesto_Amigable");
			GameObject val7 = new GameObject("Colision");
			val7.transform.SetParent(val2.transform, false);
			val7.layer = LayerMask.NameToLayer("Enemies");
			BoxCollider val8 = val7.AddComponent<BoxCollider>();
			((Collider)val8).isTrigger = true;
			val8.center = new Vector3(0f, 0.82f, 0f);
			val8.size = new Vector3(0.8f, 1.64f, 0.8f);
			Rigidbody obj = val7.AddComponent<Rigidbody>();
			obj.isKinematic = true;
			obj.useGravity = false;
			val7.AddComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)barbaroAI;
			barbaroAI.colisionGolpes = (Collider)(object)val8;
			if (Plugin.Cfg.ColisionSolida.Value)
			{
				GameObject val9 = new GameObject("ColisionSolida");
				val9.transform.SetParent(val2.transform, false);
				int num = LayerMask.NameToLayer("Colliders");
				val9.layer = ((num >= 0) ? num : LayerMask.NameToLayer("Room"));
				CapsuleCollider val10 = val9.AddComponent<CapsuleCollider>();
				val10.center = new Vector3(0f, 0.8f, 0f);
				val10.height = 1.6f;
				val10.radius = 0.3f;
				barbaroAI.colisionSolida = (Collider)(object)val10;
			}
			GameObject val11 = new GameObject("ScanNode");
			val11.transform.SetParent(val2.transform, false);
			val11.transform.localPosition = new Vector3(0f, 1.2f, 0f);
			val11.layer = LayerMask.NameToLayer("ScanNode");
			BoxCollider obj2 = val11.AddComponent<BoxCollider>();
			((Collider)obj2).isTrigger = true;
			obj2.size = Vector3.one;
			ScanNodeProperties val12 = val11.AddComponent<ScanNodeProperties>();
			val12.headerText = "Bárbaro";
			val12.subText = "¿Amigo o enemigo?";
			val12.nodeType = 1;
			val12.minRange = 1;
			val12.maxRange = 40;
			val12.requiresLineOfSight = true;
			val12.creatureScanID = -1;
			barbaroAI.nodoEscaner = val12;
			val.enemyPrefab = val2;
			return val;
		}

		public static TerminalNode CrearNodoTerminal()
		{
			TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
			((Object)obj).name = "BarbaroTN";
			obj.creatureName = "Bárbaro";
			obj.clearPreviousText = true;
			obj.maxCharactersToType = 35;
			obj.displayText = "BÁRBARO\n\nHumanoide de bigote enorme y espada.\n\nSu humor es impredecible: si tiene la cara ROJA está furioso y atacará a cualquiera. Si tiene la cara normal, acompañará a la tripulación y peleará contra otras criaturas.\n\nSe recomienda no golpearlo nunca.\n\n";
			return obj;
		}

		public static TerminalKeyword CrearPalabraTerminal()
		{
			TerminalKeyword obj = ScriptableObject.CreateInstance<TerminalKeyword>();
			((Object)obj).name = "BarbaroTK";
			obj.word = "barbaro";
			return obj;
		}

		private static GameObject[] Buscar(GameObject modelo, params string[] nombres)
		{
			List<GameObject> list = new List<GameObject>();
			foreach (string text in nombres)
			{
				Transform val = ((text == null) ? null : modelo.transform.Find(text));
				if ((Object)(object)val != (Object)null)
				{
					list.Add(((Component)val).gameObject);
				}
			}
			return list.ToArray();
		}

		private static AudioSource CrearAudio(GameObject raiz, string nombre)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			GameObject val = new GameObject(nombre);
			val.transform.SetParent(raiz.transform, false);
			val.transform.localPosition = new Vector3(0f, 1.2f, 0f);
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.playOnAwake = false;
			obj.spatialBlend = 1f;
			obj.rolloffMode = (AudioRolloffMode)1;
			obj.minDistance = 2f;
			obj.maxDistance = 30f;
			return obj;
		}

		private static EnemyBehaviourState Estado(string nombre)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			return new EnemyBehaviourState
			{
				name = nombre,
				parameterString = "Estado",
				boolValue = false
			};
		}
	}
	public static class Materiales
	{
		private struct Datos
		{
			public Color color;

			public float metal;

			public float suavidad;

			public Datos(float r, float g, float b, float m = 0f, float s = 0.4f)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				color = new Color(r, g, b);
				metal = m;
				suavidad = s;
			}
		}

		private static readonly Dictionary<string, Datos> TABLA = new Dictionary<string, Datos>
		{
			{
				"Cara",
				new Datos(0.56f, 0.47f, 0.4f, 0f, 0.15f)
			},
			{
				"Piel",
				new Datos(0.56f, 0.47f, 0.4f, 0f, 0.15f)
			},
			{
				"Pelo",
				new Datos(0.46f, 0.38f, 0.2f, 0f, 0.1f)
			},
			{
				"Cuero",
				new Datos(0.17f, 0.12f, 0.08f, 0f, 0.15f)
			},
			{
				"Botas",
				new Datos(0.1f, 0.075f, 0.055f, 0f, 0.15f)
			},
			{
				"Metal",
				new Datos(0.42f, 0.4f, 0.37f, 0.6f, 0.35f)
			},
			{
				"Oro",
				new Datos(0.38f, 0.29f, 0.13f, 0.6f, 0.3f)
			},
			{
				"OjoBlanco",
				new Datos(0.78f, 0.75f, 0.62f, 0f, 0.6f)
			},
			{
				"Iris",
				new Datos(0.52f, 0.56f, 0.53f, 0f, 0.6f)
			},
			{
				"Pupila",
				new Datos(0.01f, 0.01f, 0.01f, 0f, 0.7f)
			},
			{
				"Boca",
				new Datos(0.09f, 0.015f, 0.015f, 0f, 0.3f)
			},
			{
				"Dientes",
				new Datos(0.7f, 0.62f, 0.42f, 0f, 0.3f)
			}
		};

		private static readonly Dictionary<string, Material> cache = new Dictionary<string, Material>();

		private static Shader lit;

		private static bool avisado;

		public static void Convertir(GameObject raiz)
		{
			if ((Object)(object)lit == (Object)null)
			{
				lit = Shader.Find("HDRP/Lit");
			}
			if ((Object)(object)lit == (Object)null)
			{
				if (!avisado)
				{
					Plugin.Log.LogWarning((object)"No encuentro el shader HDRP/Lit; el bárbaro usará los materiales del bundle.");
				}
				avisado = true;
				return;
			}
			Renderer[] componentsInChildren = raiz.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Material[] sharedMaterials = val.sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					if ((Object)(object)sharedMaterials[j] != (Object)null)
					{
						sharedMaterials[j] = (((Object)(object)sharedMaterials[j].mainTexture != (Object)null) ? ObtenerConTextura(sharedMaterials[j]) : Obtener(((Object)sharedMaterials[j]).name));
					}
				}
				val.sharedMaterials = sharedMaterials;
			}
		}

		private static Material ObtenerConTextura(Material original)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			string text = ((Object)original).name.Replace(" (Instance)", "").Trim();
			if (cache.TryGetValue("tex:" + text, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = new Material(lit)
			{
				name = "Barbaro_" + text
			};
			value.SetTexture("_BaseColorMap", original.mainTexture);
			value.SetColor("_BaseColor", Color.white);
			value.SetFloat("_Metallic", 0f);
			value.SetFloat("_Smoothness", 0.3f);
			if (original.HasProperty("_BumpMap") && (Object)(object)original.GetTexture("_BumpMap") != (Object)null)
			{
				value.SetTexture("_NormalMap", original.GetTexture("_BumpMap"));
				value.EnableKeyword("_NORMALMAP");
			}
			Validar(value);
			cache["tex:" + text] = value;
			return value;
		}

		public static bool TieneTextura(Renderer r)
		{
			if ((Object)(object)r != (Object)null && (Object)(object)r.sharedMaterial != (Object)null && r.sharedMaterial.HasProperty("_BaseColorMap"))
			{
				return (Object)(object)r.sharedMaterial.GetTexture("_BaseColorMap") != (Object)null;
			}
			return false;
		}

		private static Material Obtener(string nombreOriginal)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			string text = nombreOriginal.Replace(" (Instance)", "").Trim();
			if (cache.TryGetValue(text, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Datos value2;
			Datos datos = (TABLA.TryGetValue(text, out value2) ? value2 : new Datos(0.8f, 0.8f, 0.8f));
			value = new Material(lit)
			{
				name = "Barbaro_" + text
			};
			value.SetColor("_BaseColor", datos.color);
			value.SetFloat("_Metallic", datos.metal);
			value.SetFloat("_Smoothness", datos.suavidad);
			Validar(value);
			cache[text] = value;
			return value;
		}

		private static void Validar(Material m)
		{
			try
			{
				Type.GetType("UnityEngine.Rendering.HighDefinition.HDMaterial, Unity.RenderPipelines.HighDefinition.Runtime")?.GetMethod("ValidateMaterial", new Type[1] { typeof(Material) })?.Invoke(null, new object[1] { m });
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("ValidateMaterial: " + ex.Message));
			}
		}
	}
	[BepInPlugin("fermin.barbarolc", "BarbaroLC", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "fermin.barbarolc";

		public const string NOMBRE = "BarbaroLC";

		public const string VERSION = "0.1.0";

		private const string ARCHIVO_BUNDLE = "barbaro";

		private const string ASSET_MODELO = "BarbaroModelo";

		public static Plugin Instancia;

		public static ManualLogSource Log;

		public static Configuracion Cfg;

		private void Awake()
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			Instancia = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Cfg = new Configuracion(((BaseUnityPlugin)this).Config);
			InicializarNetcode();
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "barbaro");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)("No encuentro el AssetBundle en " + text + ". Ponlo junto a BarbaroLC.dll."));
				return;
			}
			GameObject val2 = val.LoadAsset<GameObject>("BarbaroModelo");
			if ((Object)(object)val2 == (Object)null)
			{
				Log.LogError((object)"El bundle no tiene el prefab 'BarbaroModelo'.");
				return;
			}
			EnemyType obj = Fabrica.CrearEnemigo(val2);
			TerminalNode val3 = Fabrica.CrearNodoTerminal();
			TerminalKeyword val4 = Fabrica.CrearPalabraTerminal();
			Enemies.RegisterEnemy(obj, Cfg.Rareza.Value, (LevelTypes)(-1), val3, val4);
			Depuracion.TipoBarbaro = obj;
			Depuracion.Crear();
			try
			{
				new Harmony("fermin.barbarolc").PatchAll(typeof(ParcheInvencible));
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"No pude activar el modo invencible: {arg}");
			}
			if (Cfg.DepuracionActivada.Value)
			{
				Log.LogWarning((object)"Modo depuración ACTIVADO (F5-F10).");
			}
			Log.LogInfo((object)"BarbaroLC 0.1.0 cargado: el bárbaro ya puede aparecer.");
		}

		private static void InicializarNetcode()
		{
			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);
					}
				}
			}
		}
	}
}
namespace __GEN
{
	internal class NetworkVariableSerializationHelper
	{
		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeSerialization()
		{
			NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>();
			NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>();
		}
	}
}
namespace BarbaroLC.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}