Decompiled source of PlayerMonster v1.0.0

PlayerMonster.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tommy777;Dragonico")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0f4eab76deb098215fff6dc8e5e6d7c862bc5989")]
[assembly: AssemblyProduct("PlayerMonster")]
[assembly: AssemblyTitle("PlayerMonster")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace JugadorMonstruo
{
	internal static class Autoridad
	{
		private static readonly Dictionary<TipoMonstruo, Type> Cerebros = new Dictionary<TipoMonstruo, Type>
		{
			[TipoMonstruo.Animal] = typeof(EnemyAnimal),
			[TipoMonstruo.Runner] = typeof(EnemyRunner),
			[TipoMonstruo.Tumbler] = typeof(EnemyTumbler),
			[TipoMonstruo.Bowtie] = typeof(EnemyBowtie),
			[TipoMonstruo.Hunter] = typeof(EnemyHunter),
			[TipoMonstruo.Tick] = typeof(EnemyTick)
		};

		private const float CaducidadEntrada = 0.5f;

		public static EntradaMonstruo Entrada;

		private static EntradaMonstruo _entradaRecibida;

		private static float _entradaRecibidaEn = float.NegativeInfinity;

		private static TipoMonstruo? _eleccionPiloto;

		private static float _margenAparicionHasta;

		private static bool _derrotaBloqueada;

		private static bool _creadoPorNosotros;

		private static int _serie;

		private static bool _transformando;

		private static float _transformarDesde;

		private static float _transformarDuracion;

		private static int _muertes;

		private static bool _esperandoReaparicion;

		private static float _reaparecerEn;

		private static bool _protegerAlAparecer;

		private static float _proteccionHasta;

		private static Vector3 _ultimaPosicion;

		public static Enemy? Actual { get; private set; }

		public static TipoMonstruo TipoActual { get; private set; }

		public static bool Activa
		{
			get
			{
				if (!((Object)(object)Actual != (Object)null) && !_esperandoReaparicion)
				{
					return _transformando;
				}
				return true;
			}
		}

		public static int PilotoActor { get; private set; }

		public static bool PilotoEsLocal
		{
			get
			{
				if (SemiFunc.IsMultiplayer() && PhotonNetwork.LocalPlayer != null)
				{
					return PilotoActor == PhotonNetwork.LocalPlayer.ActorNumber;
				}
				return true;
			}
		}

		public static bool EstaPoseido(Enemy enemy)
		{
			if ((Object)(object)Actual != (Object)null)
			{
				return (Object)(object)Actual == (Object)(object)enemy;
			}
			return false;
		}

		public static bool Controla(Enemy enemy)
		{
			if (EstaPoseido(enemy))
			{
				return !Presencia.EnRetirada;
			}
			return false;
		}

		public static void RecibirEntrada(EntradaMonstruo entrada)
		{
			_entradaRecibida = entrada;
			_entradaRecibidaEn = Time.unscaledTime;
		}

		public static void RecibirEleccion(TipoMonstruo? tipo)
		{
			if (tipo != _eleccionPiloto)
			{
				Plugin.Log.LogInfo((object)("Selección: el piloto pide " + (tipo.HasValue ? tipo.Value.ToString() : "al azar") + "."));
			}
			_eleccionPiloto = tipo;
		}

		public static void Alternar()
		{
			if (Activa)
			{
				Soltar("tecla");
				return;
			}
			PilotoActor = ModoJuego.PilotoDeLaTecla();
			Iniciar(Plugin.MonstruoDePrueba.Value);
		}

		public static void SiguienteTipo()
		{
			if (Activa)
			{
				Plugin.Log.LogInfo((object)"Autoridad: deja de ser monstruo (tecla de posesión) antes de cambiar de tipo.");
				return;
			}
			TipoMonstruo[] array = (TipoMonstruo[])Enum.GetValues(typeof(TipoMonstruo));
			int num = (Array.IndexOf(array, Plugin.MonstruoDePrueba.Value) + 1) % array.Length;
			Plugin.MonstruoDePrueba.Value = array[num];
			Plugin.Log.LogInfo((object)$"Autoridad: monstruo de prueba = {array[num]}.");
		}

		public static void MatarDePrueba()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Actual != (Object)null && Object.op_Implicit((Object)(object)Actual) && Actual.HasHealth && Actual.EnemyParent.Spawned)
			{
				Actual.Health.Hurt(999999, Vector3.up);
			}
		}

		public static void EmpezarTransformacion(int pilotoActor, float duracion)
		{
			if (!Activa && Mensajes.SoyAutoridad && SemiFunc.RunIsLevel())
			{
				PilotoActor = pilotoActor;
				_transformando = true;
				_transformarDesde = Time.time;
				_transformarDuracion = Mathf.Max(0.1f, duracion);
				_eleccionPiloto = null;
				Plugin.Log.LogInfo((object)string.Format("Autoridad: empieza la transformación del piloto (actor {0}{1}).", pilotoActor, PilotoEsLocal ? ", local" : ", remoto"));
				PublicarEstado();
			}
		}

		public static bool Iniciar(TipoMonstruo tipo)
		{
			//IL_00dd: 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)
			if (!SemiFunc.RunIsLevel())
			{
				Plugin.Log.LogInfo((object)"Autoridad: solo disponible dentro de un nivel.");
				return false;
			}
			if (!Mensajes.SoyAutoridad)
			{
				Plugin.Log.LogInfo((object)"Autoridad: solo el anfitrión puede crear al monstruo.");
				return false;
			}
			bool esperandoReaparicion = _esperandoReaparicion;
			if (!esperandoReaparicion)
			{
				_muertes = 0;
			}
			Type cerebro = Cerebros[tipo];
			Enemy val = ((Plugin.ReutilizarExistente.Value && !esperandoReaparicion) ? BuscarCercano(cerebro) : null);
			bool flag = false;
			if ((Object)(object)val == (Object)null)
			{
				val = Crear(cerebro);
				flag = true;
			}
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)$"Autoridad: no encontré ni pude crear un {tipo}.");
				return false;
			}
			Actual = val;
			TipoActual = tipo;
			_serie++;
			_esperandoReaparicion = false;
			_protegerAlAparecer = esperandoReaparicion;
			_creadoPorNosotros = flag;
			_margenAparicionHasta = Time.time + 8f;
			_ultimaPosicion = ((Component)val).transform.position;
			_entradaRecibidaEn = float.NegativeInfinity;
			Entrada = default(EntradaMonstruo);
			ProteccionObjetos.Activar(val);
			Furia.Reiniciar();
			Presencia.Reiniciar();
			AjustarVida(val);
			Plugin.Log.LogInfo((object)("Autoridad: el piloto controla a '" + val.EnemyParent.enemyName + "' (" + (flag ? "recién creado" : "ya estaba en el nivel") + ")."));
			PublicarEstado();
			return true;
		}

		private static void AjustarVida(Enemy enemigo)
		{
			if (enemigo.HasHealth && TipoActual != TipoMonstruo.Tick)
			{
				int health = enemigo.Health.health;
				int num = Mathf.Max(1, GameDirector.instance.PlayerList.Count - 1);
				int num2 = RunManager.instance.levelsCompleted + 1;
				float num3 = Plugin.VidaBase.Value + Plugin.VidaExtraPorJugador.Value * (float)(num - 1);
				float num4 = 1f + Plugin.VidaExtraPorNivel.Value * (float)(num2 - 1);
				float num5 = Mathf.Clamp(num3 * num4, 0.3f, Plugin.VidaMultiplicadorMaximo.Value);
				num5 *= 1f + Plugin.VidaExtraPorMuerte.Value * (float)Mathf.Min(_muertes, 3);
				int num6 = Mathf.Max(1, Mathf.RoundToInt((float)health * num5));
				enemigo.Health.health = num6;
				enemigo.Health.healthCurrent = num6;
				if (_muertes >= Plugin.OrbesMaximos.Value)
				{
					enemigo.Health.spawnValuable = false;
				}
				Plugin.Log.LogInfo((object)$"Vida: {health} -> {num6} (x{num5:0.00}; humanos={num}, nivel={num2}, muertes={_muertes}).");
			}
		}

		public static void Soltar(string motivo)
		{
			Plugin.Log.LogInfo((object)("Autoridad: terminada (" + motivo + ")."));
			DejarEnemigo();
			_esperandoReaparicion = false;
			_transformando = false;
			if (_derrotaBloqueada && (Object)(object)RunManager.instance != (Object)null)
			{
				RunManager.instance.allPlayersDeadCheckDisabled = false;
				_derrotaBloqueada = false;
			}
			PublicarEstado();
		}

		private static void DejarEnemigo()
		{
			Enemy actual = Actual;
			Actual = null;
			_serie++;
			ProteccionObjetos.Desactivar();
			if (_creadoPorNosotros && Object.op_Implicit((Object)(object)actual))
			{
				Eliminar(actual.EnemyParent);
			}
			_creadoPorNosotros = false;
		}

		public static void Tick()
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			if (!Activa)
			{
				return;
			}
			if (!SemiFunc.RunIsLevel() || ((Object)(object)Actual != (Object)null && !Object.op_Implicit((Object)(object)Actual)))
			{
				Soltar("el nivel terminó o el enemigo ya no existe");
				return;
			}
			if (!PilotoPresente())
			{
				Soltar("el piloto ya no está en la sala");
				return;
			}
			if (_transformando)
			{
				if (Time.time < _transformarDesde + _transformarDuracion)
				{
					PublicarEstado();
					return;
				}
				_transformando = false;
				if (!Iniciar(Seleccion.Resolver(null)))
				{
					Soltar("no se pudo transformar");
				}
				return;
			}
			MantenerPartida();
			if (_esperandoReaparicion)
			{
				TickEsperando();
				PublicarEstado();
				return;
			}
			Enemy actual = Actual;
			EnemyParent enemyParent = actual.EnemyParent;
			if (!enemyParent.Spawned)
			{
				if (Time.time >= _margenAparicionHasta)
				{
					Morir();
					return;
				}
				enemyParent.DespawnedTimerSet(0f, false);
			}
			else
			{
				_ultimaPosicion = ((Component)actual).transform.position;
				if (_protegerAlAparecer && Time.time > _margenAparicionHasta - 7.5f)
				{
					_protegerAlAparecer = false;
					_proteccionHasta = Time.time + Plugin.ProteccionReaparicion.Value;
				}
			}
			Entrada = ((Time.unscaledTime - _entradaRecibidaEn <= 0.5f) ? _entradaRecibida : default(EntradaMonstruo));
			Furia.Filtrar(ref Entrada, TipoActual);
			enemyParent.SpawnedTimerPause(1f);
			if ((_protegerAlAparecer || Time.time < _proteccionHasta) && actual.HasHealth)
			{
				actual.Health.OverrideDamageResistance(1f, 0.2f);
			}
			ProteccionObjetos.Tick(actual);
			if (enemyParent.Spawned)
			{
				Presencia.Tick(actual, TipoActual);
			}
			PublicarEstado();
		}

		private static void MantenerPartida()
		{
			if (Plugin.EvitarDerrotaEnSolitario.Value && GameDirector.instance.PlayerList.Count == 1)
			{
				RunManager.instance.allPlayersDeadCheckDisabled = true;
				_derrotaBloqueada = true;
			}
		}

		private static void Morir()
		{
			_muertes++;
			Seleccion.Bloquear(TipoActual);
			DejarEnemigo();
			_esperandoReaparicion = true;
			_eleccionPiloto = null;
			_reaparecerEn = Time.time + Mathf.Max(1f, Plugin.TiempoReaparicion.Value);
			Plugin.Log.LogInfo((object)$"Autoridad: el monstruo ha muerto ({_muertes} en este nivel). Reaparece en {Plugin.TiempoReaparicion.Value:0.#} s.");
			PublicarEstado();
		}

		private static void TickEsperando()
		{
			if (!(Time.time < _reaparecerEn))
			{
				TipoMonstruo tipo = Seleccion.Resolver(_eleccionPiloto);
				Plugin.Log.LogInfo((object)("Selección: reaparece como " + tipo.ToString() + " (el piloto pidió " + (_eleccionPiloto.HasValue ? _eleccionPiloto.Value.ToString() : "al azar") + ")."));
				if (!Iniciar(tipo))
				{
					Soltar("no se pudo reaparecer");
				}
			}
		}

		private static void PublicarEstado()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			EstadoMonstruo estado = new EstadoMonstruo
			{
				Fase = (Activa ? (_transformando ? FaseMonstruo.Transformando : (_esperandoReaparicion ? FaseMonstruo.Esperando : FaseMonstruo.Vivo)) : FaseMonstruo.Ninguna),
				Tipo = TipoActual,
				Serie = _serie,
				Furia = Furia.Nivel,
				Agotado = Furia.Agotado,
				Presencia = Presencia.Nivel,
				Retirada = ((Object)(object)Actual != (Object)null && Presencia.EnRetirada),
				UltimaPosicion = _ultimaPosicion
			};
			Enemy actual = Actual;
			if ((Object)(object)actual != (Object)null && Object.op_Implicit((Object)(object)actual))
			{
				estado.EnemigoViewId = (Object.op_Implicit((Object)(object)actual.PhotonView) ? actual.PhotonView.ViewID : 0);
				if (actual.HasHealth)
				{
					estado.Vida = actual.Health.healthCurrent;
					estado.VidaMaxima = actual.Health.health;
				}
			}
			if (_esperandoReaparicion)
			{
				estado.SegundosParaReaparecer = Mathf.Max(0f, _reaparecerEn - Time.time);
			}
			if (_transformando)
			{
				estado.Progreso = Mathf.Clamp01((Time.time - _transformarDesde) / _transformarDuracion);
			}
			if (_transformando || _esperandoReaparicion)
			{
				estado.Opciones = Seleccion.Disponibilidad();
			}
			Mensajes.EnviarEstado(estado);
		}

		public static void RuidoEnElNivel(Vector3 posicion, float radio)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (Mensajes.SoyAutoridad && !((Object)(object)Actual == (Object)null) && Object.op_Implicit((Object)(object)Actual) && TipoActual == TipoMonstruo.Hunter)
			{
				Mensajes.EnviarRuido(posicion, radio);
			}
		}

		private static bool PilotoPresente()
		{
			if (!PilotoEsLocal)
			{
				if (PhotonNetwork.CurrentRoom != null)
				{
					return PhotonNetwork.CurrentRoom.GetPlayer(PilotoActor, false) != null;
				}
				return false;
			}
			return true;
		}

		private static PlayerAvatar AvatarDelPiloto()
		{
			if (!PilotoEsLocal && Object.op_Implicit((Object)(object)GameDirector.instance))
			{
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if (Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)player.photonView) && player.photonView.Owner != null && player.photonView.Owner.ActorNumber == PilotoActor)
					{
						return player;
					}
				}
			}
			return PlayerAvatar.instance;
		}

		private static void Eliminar(EnemyParent padre)
		{
			if (Object.op_Implicit((Object)(object)padre))
			{
				EnemyDirector.instance.enemiesSpawned.Remove(padre);
				if (SemiFunc.IsMultiplayer())
				{
					PhotonNetwork.Destroy(((Component)padre).gameObject);
				}
				else
				{
					Object.Destroy((Object)(object)((Component)padre).gameObject);
				}
			}
		}

		private static Enemy? BuscarCercano(Type cerebro)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 yo = ((Component)AvatarDelPiloto()).transform.position;
			return (from p in EnemyDirector.instance.enemiesSpawned
				where Object.op_Implicit((Object)(object)p) && p.Spawned && Object.op_Implicit((Object)(object)p.Enemy) && Object.op_Implicit((Object)(object)((Component)p.Enemy).GetComponent(cerebro))
				select p.Enemy into e
				orderby Vector3.Distance(((Component)e).transform.position, yo)
				select e).FirstOrDefault();
		}

		private static Enemy? Crear(Type cerebro)
		{
			//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)
			EnemySetup val = SetupDe(cerebro);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			return Enemies.SpawnEnemy(val, PuntoDeAparicion(), Quaternion.identity, false)?.Select((EnemyParent p) => ((Component)p).GetComponentInChildren<Enemy>(true)).FirstOrDefault((Func<Enemy, bool>)((Enemy e) => (Object)(object)e != (Object)null));
		}

		private static EnemySetup? SetupDe(Type cerebro)
		{
			return ((IEnumerable<EnemySetup>)Enemies.AllEnemies).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup s) => (Object)(object)s != (Object)null && s.spawnObjects.Any((PrefabRef o) => o != null && (Object)(object)((PrefabRef<GameObject>)(object)o).Prefab != (Object)null && (Object)(object)((PrefabRef<GameObject>)(object)o).Prefab.GetComponentInChildren(cerebro, true) != (Object)null)));
		}

		public static EnemySetup? SetupDe(TipoMonstruo tipo)
		{
			return SetupDe(Cerebros[tipo]);
		}

		private static Vector3 PuntoDeAparicion()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: 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)
			Transform transform = ((Component)AvatarDelPiloto()).transform;
			if (!Plugin.CrearLejos.Value)
			{
				return transform.position + transform.forward * 2.5f;
			}
			List<Vector3> list = new List<Vector3>();
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (Object.op_Implicit((Object)(object)player) && !player.isDisabled)
				{
					list.Add(((Component)player).transform.position);
				}
			}
			if (list.Count == 0)
			{
				list.Add(transform.position);
			}
			foreach (LevelPoint levelPathPoint in LevelGenerator.Instance.LevelPathPoints)
			{
				if (Object.op_Implicit((Object)(object)levelPathPoint) && (levelPathPoint.Truck || (Object.op_Implicit((Object)(object)levelPathPoint.Room) && levelPathPoint.Room.Truck)))
				{
					list.Add(((Component)levelPathPoint).transform.position);
				}
			}
			LevelPoint val = null;
			float num = -1f;
			foreach (LevelPoint levelPathPoint2 in LevelGenerator.Instance.LevelPathPoints)
			{
				if (!Object.op_Implicit((Object)(object)levelPathPoint2) || levelPathPoint2.Truck || (Object.op_Implicit((Object)(object)levelPathPoint2.Room) && levelPathPoint2.Room.Truck))
				{
					continue;
				}
				float num2 = float.MaxValue;
				foreach (Vector3 item in list)
				{
					num2 = Mathf.Min(num2, Vector3.Distance(((Component)levelPathPoint2).transform.position, item));
				}
				if (num2 > num)
				{
					num = num2;
					val = levelPathPoint2;
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				return transform.position + transform.forward * 2.5f;
			}
			return ((Component)val).transform.position;
		}
	}
	internal static class Aviso
	{
		private static GameObject? _raiz;

		private static TextMeshProUGUI? _texto;

		private static string _ultimo = "";

		private static float _visibleHasta;

		private static float _golpe;

		public static void Mostrar(string mensaje, float tamano, Color color)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			Crear();
			if (!((Object)(object)_texto == (Object)null))
			{
				if (mensaje != _ultimo)
				{
					_ultimo = mensaje;
					((TMP_Text)_texto).text = mensaje;
					_golpe = 1f;
				}
				((TMP_Text)_texto).fontSize = tamano;
				((Graphic)_texto).color = color;
				_visibleHasta = Time.unscaledTime + 0.15f;
			}
		}

		public static void Tick()
		{
			//IL_0077: 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_00a7: 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)
			if ((Object)(object)_raiz == (Object)null || (Object)(object)_texto == (Object)null)
			{
				return;
			}
			bool flag = Time.unscaledTime < _visibleHasta;
			if (_raiz.activeSelf != flag)
			{
				_raiz.SetActive(flag);
			}
			if (!flag)
			{
				_ultimo = "";
				return;
			}
			_golpe = Mathf.MoveTowards(_golpe, 0f, Time.unscaledDeltaTime * 3f);
			((Transform)((TMP_Text)_texto).rectTransform).localScale = Vector3.one * (1f + 0.5f * _golpe * _golpe);
			((TMP_Text)_texto).rectTransform.anchoredPosition = Random.insideUnitCircle * (2f + 10f * _golpe);
			if (Object.op_Implicit((Object)(object)BigMessageUI.instance) && Object.op_Implicit((Object)(object)BigMessageUI.instance.Text) && (Object)(object)((TMP_Text)_texto).font != (Object)(object)((TMP_Text)BigMessageUI.instance.Text).font)
			{
				((TMP_Text)_texto).font = ((TMP_Text)BigMessageUI.instance.Text).font;
			}
		}

		private static void Crear()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_raiz != (Object)null))
			{
				_raiz = new GameObject("PlayerMonster Aviso");
				Object.DontDestroyOnLoad((Object)(object)_raiz);
				((Object)_raiz).hideFlags = (HideFlags)61;
				Canvas obj = _raiz.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 30000;
				CanvasScaler obj2 = _raiz.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 0.5f;
				GameObject val = new GameObject("Texto");
				val.transform.SetParent(_raiz.transform, false);
				_texto = val.AddComponent<TextMeshProUGUI>();
				((TMP_Text)_texto).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_texto).textWrappingMode = (TextWrappingModes)0;
				((Graphic)_texto).raycastTarget = false;
				((TMP_Text)_texto).fontStyle = (FontStyles)1;
				RectTransform rectTransform = ((TMP_Text)_texto).rectTransform;
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(0.5f, 0.62f);
				rectTransform.anchorMax = val2;
				Vector2 anchorMin = val2;
				rectTransform.anchorMin = anchorMin;
				rectTransform.sizeDelta = new Vector2(1800f, 300f);
				_raiz.SetActive(false);
			}
		}
	}
	internal static class Camara
	{
		private static readonly List<Renderer> Ocultos = new List<Renderer>();

		private static Enemy? _enemigoOculto;

		public static void Seguir(Enemy enemy)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_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_0090: 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)
			Camera main = Camera.main;
			if (!((Object)(object)main == (Object)null) && !((Object)(object)CameraPosition.instance == (Object)null))
			{
				if (Plugin.PrimeraPersona.Value)
				{
					OcultarModelo(enemy);
					Vector3 val = ((!enemy.HasVision || !Object.op_Implicit((Object)(object)enemy.Vision.VisionTransform)) ? (Object.op_Implicit((Object)(object)enemy.CenterTransform) ? enemy.CenterTransform.position : (((Component)enemy).transform.position + Vector3.up)) : enemy.Vision.VisionTransform.position);
					CameraPosition.instance.OverridePosition(val, 0.1f);
				}
				else
				{
					MostrarModelo();
					Vector3 centro = (Object.op_Implicit((Object)(object)enemy.CenterTransform) ? enemy.CenterTransform.position : (((Component)enemy).transform.position + Vector3.up));
					EnTerceraPersona(main, centro);
				}
			}
		}

		public static void Mirar(Vector3 centro)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if (!((Object)(object)main == (Object)null) && !((Object)(object)CameraPosition.instance == (Object)null))
			{
				MostrarModelo();
				EnTerceraPersona(main, centro);
			}
		}

		private static void EnTerceraPersona(Camera camara, Vector3 centro)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_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)
			Vector3 val = centro + Vector3.up * 0.6f;
			Vector3 val2 = -((Component)camara).transform.forward;
			float num = Plugin.DistanciaCamara.Value;
			RaycastHit val3 = default(RaycastHit);
			if (Physics.SphereCast(val, 0.3f, val2, ref val3, num, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1))
			{
				num = Mathf.Max(0.2f, ((RaycastHit)(ref val3)).distance);
			}
			CameraPosition.instance.OverridePosition(val + val2 * num, 0.1f);
		}

		private static void OcultarModelo(Enemy enemy)
		{
			if ((Object)(object)_enemigoOculto == (Object)(object)enemy)
			{
				return;
			}
			MostrarModelo();
			_enemigoOculto = enemy;
			Renderer[] componentsInChildren = ((Component)enemy.EnemyParent).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!(val is ParticleSystemRenderer) && !(val is LineRenderer) && !val.forceRenderingOff)
				{
					val.forceRenderingOff = true;
					Ocultos.Add(val);
				}
			}
		}

		public static void MostrarModelo()
		{
			foreach (Renderer oculto in Ocultos)
			{
				if (Object.op_Implicit((Object)(object)oculto))
				{
					oculto.forceRenderingOff = false;
				}
			}
			Ocultos.Clear();
			_enemigoOculto = null;
		}

		public static void Alternar()
		{
			Plugin.PrimeraPersona.Value = !Plugin.PrimeraPersona.Value;
			Plugin.Log.LogInfo((object)("Cámara: " + (Plugin.PrimeraPersona.Value ? "primera" : "tercera") + " persona."));
		}
	}
	internal static class Camion
	{
		private static float _acampado;

		private static int _avatar;

		private static bool _avisado;

		public static bool Protegido
		{
			get
			{
				PlayerAvatar instance = PlayerAvatar.instance;
				if (Plugin.ReglaCamion.Value && Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.RoomVolumeCheck) && instance.RoomVolumeCheck.inTruck)
				{
					return _acampado < Plugin.CamionSegundos.Value;
				}
				return false;
			}
		}

		public static void Tick()
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar instance = PlayerAvatar.instance;
			if (!Object.op_Implicit((Object)(object)instance) || !SemiFunc.RunIsLevel())
			{
				_acampado = 0f;
				return;
			}
			if (((Object)instance).GetInstanceID() != _avatar)
			{
				_avatar = ((Object)instance).GetInstanceID();
				_acampado = 0f;
				_avisado = false;
			}
			bool flag = !instance.isDisabled && Object.op_Implicit((Object)(object)instance.RoomVolumeCheck) && instance.RoomVolumeCheck.inTruck;
			if (flag && (Object)(object)RedMonstruo.MonstruoEnElNivel() != (Object)null)
			{
				_acampado += Time.deltaTime;
			}
			else
			{
				_acampado = Mathf.Max(0f, _acampado - Time.deltaTime * 2f);
			}
			float value = Plugin.CamionSegundos.Value;
			if (Plugin.ReglaCamion.Value && flag && _acampado >= value && !_avisado)
			{
				_avisado = true;
				SemiFunc.UIFocusText(Idioma.T("El camión ya no te protege", "The truck no longer protects you"), Color.red, Color.white, 4f);
			}
			if (_acampado < value * 0.5f)
			{
				_avisado = false;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerHealth), "Hurt")]
	internal static class DanoDelMonstruoPatch
	{
		private static bool Prefix(PlayerHealth __instance, int damage, int enemyIndex)
		{
			if (enemyIndex < 0 || damage <= 0 || !Object.op_Implicit((Object)(object)__instance.playerAvatar) || !__instance.playerAvatar.isLocal)
			{
				return true;
			}
			Enemy val = RedMonstruo.MonstruoEnElNivel();
			if ((Object)(object)val == (Object)null || (Object)(object)SemiFunc.EnemyGetFromIndex(enemyIndex) != (Object)(object)val)
			{
				return true;
			}
			if (Camion.Protegido)
			{
				return false;
			}
			Mensajes.EnviarGolpe();
			return true;
		}
	}
	internal static class Cercania
	{
		private static readonly Color Rojo = new Color(0.6f, 0f, 0f);

		private static AudioSource? _fuente;

		private static AudioClip? _latido;

		private static float _siguienteLatido;

		private static float _pulso;

		public static void Tick()
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			_pulso = Mathf.MoveTowards(_pulso, 0f, Time.deltaTime * 2.5f);
			PlayerAvatar instance = PlayerAvatar.instance;
			if (!Plugin.AvisoCercania.Value || !SemiFunc.RunIsLevel() || !Object.op_Implicit((Object)(object)instance) || instance.isDisabled || Piloto.Activo)
			{
				return;
			}
			Enemy val = RedMonstruo.MonstruoEnElNivel();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Vector3 val2 = (Object.op_Implicit((Object)(object)val.CenterTransform) ? val.CenterTransform.position : ((Component)val).transform.position);
			float num = Vector3.Distance(((Component)instance).transform.position, val2);
			float value = Plugin.CercaniaLejos.Value;
			float value2 = Plugin.CercaniaCerca.Value;
			if (!(num > value))
			{
				float num2 = Mathf.InverseLerp(value, 3f, num);
				if (Time.time >= _siguienteLatido)
				{
					_siguienteLatido = Time.time + Mathf.Lerp(1.3f, 0.45f, num2);
					_pulso = 1f;
					Latir(Mathf.Lerp(0.25f, 1f, num2) * Plugin.CercaniaVolumen.Value);
				}
				if (num <= value2 && Object.op_Implicit((Object)(object)PostProcessing.Instance))
				{
					float num3 = Mathf.Lerp(0.2f, 0.45f, num2) + 0.2f * _pulso;
					PostProcessing.Instance.VignetteOverride(Rojo, num3, 1f, 8f, 3f, 0.2f, ((Component)Plugin.Instancia).gameObject, 999);
				}
			}
		}

		private static void Latir(float volumen)
		{
			//IL_0012: 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_001d: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_fuente == (Object)null)
			{
				GameObject val = new GameObject("PlayerMonster Latido");
				Object.DontDestroyOnLoad((Object)val);
				((Object)val).hideFlags = (HideFlags)61;
				_fuente = val.AddComponent<AudioSource>();
				_fuente.spatialBlend = 0f;
				_fuente.playOnAwake = false;
				_latido = CrearLatido();
			}
			_fuente.PlayOneShot(_latido, Mathf.Clamp01(volumen));
		}

		private static AudioClip CrearLatido()
		{
			int num = 22050;
			float[] array = new float[num];
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i / 44100f;
				array[i] = Golpe(num2, 1f) + Golpe(num2 - 0.17f, 0.7f);
			}
			AudioClip obj = AudioClip.Create("PlayerMonster latido", num, 1, 44100, false);
			obj.SetData(array, 0);
			return obj;
		}

		private static float Golpe(float t, float fuerza)
		{
			if (t < 0f)
			{
				return 0f;
			}
			float num = Mathf.Exp((0f - t) * 28f);
			return (Mathf.Sin(MathF.PI * 120f * t) + 0.5f * Mathf.Sin(MathF.PI * 240f * t)) * num * fuerza * 0.6f;
		}
	}
	internal static class CuerpoJugador
	{
		private static bool _oculto;

		public static void Ocultar()
		{
			PlayerAvatar instance = PlayerAvatar.instance;
			if (!_oculto && !((Object)(object)instance == (Object)null) && Object.op_Implicit((Object)(object)PlayerController.instance))
			{
				instance.physGrabber.ReleaseObject(-1, 0.1f);
				instance.SetDisabled();
				((Component)instance.playerAvatarVisuals).gameObject.SetActive(false);
				((Component)instance).gameObject.SetActive(false);
				PlayerController.instance.col.enabled = false;
				_oculto = true;
				RedMonstruo.Anunciar(soyMonstruo: true);
			}
		}

		public static void Tick()
		{
			if (_oculto)
			{
				PlayerController.instance.Kinematic(0.2f);
				PlayerController.instance.InputDisable(0.1f);
				SemiFunc.UIHideHealth();
				SemiFunc.UIHideOvercharge();
				SemiFunc.UIHideEnergy();
				SemiFunc.UIHideInventory();
				SemiFunc.UIHideAim();
			}
		}

		public static void Restaurar()
		{
			PlayerAvatar instance = PlayerAvatar.instance;
			if (!_oculto || (Object)(object)instance == (Object)null)
			{
				if (_oculto)
				{
					RedMonstruo.Anunciar(soyMonstruo: false);
				}
				_oculto = false;
				return;
			}
			instance.isDisabled = false;
			((Component)instance).gameObject.SetActive(true);
			((Component)instance.playerAvatarVisuals).gameObject.SetActive(true);
			if (Object.op_Implicit((Object)(object)PlayerController.instance))
			{
				PlayerController.instance.col.enabled = true;
			}
			_oculto = false;
			RedMonstruo.Anunciar(soyMonstruo: false);
		}

		public static void Olvidar()
		{
			_oculto = false;
		}
	}
	internal struct EntradaMonstruo
	{
		public Vector3 Direccion;

		public bool Correr;

		public bool Atacar;

		public Vector3 Mirada;

		public Vector3 PuntoMira;

		private const float AlcanceMira = 40f;

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

		public readonly Vector3 MiradaPlana
		{
			get
			{
				//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_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = Vector3.ProjectOnPlane(Mirada, Vector3.up);
				if (!(((Vector3)(ref val)).sqrMagnitude > 0.001f))
				{
					return Vector3.forward;
				}
				return ((Vector3)(ref val)).normalized;
			}
		}

		public static EntradaMonstruo LeerLocal(Enemy? propio = null)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0049: 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_004c: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			EntradaMonstruo result = default(EntradaMonstruo);
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return result;
			}
			Vector2 val = SemiFunc.InputMovement();
			Vector3 val2 = Vector3.ProjectOnPlane(((Component)main).transform.forward, Vector3.up);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			Vector3 val3 = Vector3.Cross(Vector3.up, normalized);
			Vector3 val4 = normalized * val.y + val3 * val.x;
			result.Direccion = ((((Vector3)(ref val4)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val4)).normalized : Vector3.zero);
			result.Correr = SemiFunc.InputHold((InputKey)15);
			result.Atacar = SemiFunc.InputHold((InputKey)10);
			result.Mirada = ((Component)main).transform.forward;
			result.PuntoMira = CalcularPuntoMira(main, propio);
			return result;
		}

		private static Vector3 CalcularPuntoMira(Camera camara, Enemy? propio)
		{
			//IL_0006: 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)
			//IL_0012: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)camara).transform.position;
			Vector3 forward = ((Component)camara).transform.forward;
			int num = LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()) | LayerMask.GetMask(new string[2] { "Player", "PhysGrabObject" });
			int num2 = Physics.RaycastNonAlloc(position, forward, Impactos, 40f, num, (QueryTriggerInteraction)1);
			float num3 = 40f;
			EnemyParent val = (((Object)(object)propio != (Object)null && Object.op_Implicit((Object)(object)propio)) ? propio.EnemyParent : null);
			for (int i = 0; i < num2; i++)
			{
				RaycastHit val2 = Impactos[i];
				if ((!((Object)(object)val != (Object)null) || !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<EnemyParent>() == (Object)(object)val)) && ((RaycastHit)(ref val2)).distance < num3)
				{
					num3 = ((RaycastHit)(ref val2)).distance;
				}
			}
			return position + forward * num3;
		}
	}
	internal struct EstadoMonstruo
	{
		public FaseMonstruo Fase;

		public TipoMonstruo Tipo;

		public int Serie;

		public int EnemigoViewId;

		public float Furia;

		public bool Agotado;

		public int Vida;

		public int VidaMaxima;

		public float SegundosParaReaparecer;

		public Vector3 UltimaPosicion;

		public float Progreso;

		public float[]? Opciones;

		public float Presencia;

		public bool Retirada;
	}
	internal enum FaseMonstruo
	{
		Ninguna,
		Transformando,
		Vivo,
		Esperando
	}
	internal static class Final
	{
		private const float Duracion = 8f;

		private const float EsperaMaxima = 60f;

		private static bool _pendiente;

		private static int _nivelAlAnunciar;

		private static float _caducaEn;

		private static float _hasta;

		private static string _nombre = "";

		private static bool _eraYo;

		private static float _todosMuertosDesde = -1f;

		public static void VigilarDerrota()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			if (!Mensajes.SoyAutoridad || !SemiFunc.IsMultiplayer() || !Autoridad.Activa || !SemiFunc.RunIsLevel() || !Object.op_Implicit((Object)(object)RunManager.instance) || RunManager.instance.restarting || RunManager.instance.allPlayersDeadCheckDisabled || !Object.op_Implicit((Object)(object)GameDirector.instance) || (int)GameDirector.instance.currentState != 2 || GameDirector.instance.PlayerList.Count == 0)
			{
				_todosMuertosDesde = -1f;
				return;
			}
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (Object.op_Implicit((Object)(object)player) && !player.isDisabled)
				{
					_todosMuertosDesde = -1f;
					return;
				}
			}
			if (Object.op_Implicit((Object)(object)SpectateCamera.instance))
			{
				_todosMuertosDesde = -1f;
				return;
			}
			if (_todosMuertosDesde < 0f)
			{
				_todosMuertosDesde = Time.time;
			}
			if (Time.time - _todosMuertosDesde >= 5f)
			{
				_todosMuertosDesde = -1f;
				Plugin.Log.LogInfo((object)"Final: no queda ningún humano vivo y el anfitrión es el monstruo; se pasa a la arena.");
				RunManager.instance.ChangeLevel(false, true, (ChangeLevelType)0);
			}
		}

		public static void Anunciar()
		{
			string text = "";
			int num = 0;
			if (SemiFunc.IsMultiplayer() && PhotonNetwork.CurrentRoom != null)
			{
				num = Autoridad.PilotoActor;
				Player player = PhotonNetwork.CurrentRoom.GetPlayer(num, false);
				text = ((player != null) ? player.NickName : "");
			}
			Plugin.Log.LogInfo((object)("Final: el equipo ha caído, gana el monstruo ('" + text + "')."));
			Mensajes.EnviarVictoria(num, text);
		}

		public static void Mostrar(int actorDelMonstruo, string nombre)
		{
			_nombre = nombre ?? "";
			_eraYo = !SemiFunc.IsMultiplayer() || (PhotonNetwork.LocalPlayer != null && PhotonNetwork.LocalPlayer.ActorNumber == actorDelMonstruo);
			_pendiente = true;
			_nivelAlAnunciar = (Object.op_Implicit((Object)(object)LevelGenerator.Instance) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0);
			_caducaEn = Time.unscaledTime + 60f;
		}

		private static bool SiguienteNivelListo()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			LevelGenerator instance = LevelGenerator.Instance;
			if (Object.op_Implicit((Object)(object)instance) && ((Object)instance).GetInstanceID() != _nivelAlAnunciar && instance.Generated && Object.op_Implicit((Object)(object)GameDirector.instance))
			{
				return (int)GameDirector.instance.currentState == 2;
			}
			return false;
		}

		public static void Tick()
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if (_pendiente)
			{
				if (SiguienteNivelListo())
				{
					_pendiente = false;
					_hasta = Time.unscaledTime + 8f;
				}
				else if (Time.unscaledTime >= _caducaEn)
				{
					_pendiente = false;
				}
			}
			if (!(Time.unscaledTime >= _hasta))
			{
				string obj = (_eraYo ? Idioma.T("HAS GANADO", "YOU WIN") : Idioma.T("EL MONSTRUO GANA", "THE MONSTER WINS"));
				string text = (_eraYo ? Idioma.T("Nadie cumplió la cuota", "Nobody met the quota") : ((_nombre.Length <= 0) ? Idioma.T("Nadie cumplió la cuota", "Nobody met the quota") : (_nombre + Idioma.T(" era el monstruo", " was the monster"))));
				Aviso.Mostrar(obj + "\n<size=40%><color=#FFFFFF><noparse>" + text + "</noparse></color></size>", 120f, Color.red);
			}
		}
	}
	[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
	internal static class NivelPerdidoPatch
	{
		private static void Prefix(bool _levelFailed)
		{
			if (_levelFailed && Mensajes.SoyAutoridad)
			{
				if (Autoridad.Activa && SemiFunc.RunIsLevel())
				{
					Final.Anunciar();
				}
				Rotacion.Reiniciar("el equipo perdió el nivel");
			}
		}
	}
	public enum ForzarPiloto
	{
		None,
		Host,
		FirstClient
	}
	internal static class Furia
	{
		private readonly struct Ajuste
		{
			public readonly bool Continuo;

			public readonly float SegundosDeAtaque;

			public readonly float SegundosDeRecarga;

			public readonly float SegundosAgotado;

			public Ajuste(bool continuo, float ataque, float recarga, float agotado)
			{
				Continuo = continuo;
				SegundosDeAtaque = ataque;
				SegundosDeRecarga = recarga;
				SegundosAgotado = agotado;
			}
		}

		private static float _agotadoHasta;

		private static float _pausaHasta;

		public static float Nivel { get; private set; } = 1f;

		public static bool Agotado => Time.time < _agotadoHasta;

		public static bool PuedeAtacar => Nivel >= 1f;

		private static Ajuste Para(TipoMonstruo tipo)
		{
			return tipo switch
			{
				TipoMonstruo.Runner => new Ajuste(continuo: true, 3f, 5f, 2.5f), 
				TipoMonstruo.Animal => new Ajuste(continuo: true, 5f, 5f, 2f), 
				TipoMonstruo.Tumbler => new Ajuste(continuo: false, 0f, 4f, 0f), 
				TipoMonstruo.Bowtie => new Ajuste(continuo: false, 0f, 6f, 0f), 
				TipoMonstruo.Hunter => new Ajuste(continuo: false, 0f, 2f, 0f), 
				TipoMonstruo.Tick => new Ajuste(continuo: false, 0f, 30f, 0f), 
				_ => new Ajuste(continuo: true, 3f, 5f, 2.5f), 
			};
		}

		public static void Reiniciar()
		{
			Nivel = 1f;
			_agotadoHasta = 0f;
			_pausaHasta = 0f;
		}

		public static void GolpeAcertado()
		{
			_pausaHasta = Time.time + Mathf.Max(0f, Plugin.PausaTrasGolpe.Value);
		}

		public static void FinDeSecuencia()
		{
			Nivel = 0f;
		}

		public static void Filtrar(ref EntradaMonstruo entrada, TipoMonstruo tipo)
		{
			if (!Plugin.UsarFuria.Value)
			{
				Nivel = 1f;
				return;
			}
			Ajuste ajuste = Para(tipo);
			float deltaTime = Time.deltaTime;
			if (ajuste.Continuo && Time.time < _pausaHasta)
			{
				entrada.Atacar = false;
			}
			if (!ajuste.Continuo)
			{
				Nivel = Mathf.MoveTowards(Nivel, 1f, deltaTime / ajuste.SegundosDeRecarga);
			}
			else if (Agotado)
			{
				entrada.Atacar = false;
				entrada.Correr = false;
			}
			else if (entrada.Atacar)
			{
				Nivel = Mathf.MoveTowards(Nivel, 0f, deltaTime / ajuste.SegundosDeAtaque);
				if (Nivel <= 0f)
				{
					_agotadoHasta = Time.time + ajuste.SegundosAgotado;
					entrada.Atacar = false;
					entrada.Correr = false;
				}
			}
			else
			{
				Nivel = Mathf.MoveTowards(Nivel, 1f, deltaTime / ajuste.SegundosDeRecarga);
			}
		}
	}
	internal static class Hud
	{
		private static GameObject? _raiz;

		private static RectTransform? _relleno;

		private static Image? _rellenoImagen;

		private static TextMeshProUGUI? _vida;

		private static RectTransform? _presencia;

		private static Image? _presenciaImagen;

		private static readonly Color ColorPresencia = new Color(0.9f, 0.7f, 0.15f);

		private static readonly Color ColorPresenciaAlta = new Color(1f, 0.35f, 0.1f);

		private static readonly Color ColorFuria = new Color(0.85f, 0.1f, 0.1f);

		private static readonly Color ColorRecargando = new Color(0.55f, 0.35f, 0.1f);

		private static readonly Color ColorAgotado = new Color(0.35f, 0.35f, 0.35f);

		public static void Tick()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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)
			Enemy enemigo = Piloto.Enemigo;
			if (!((Object)(object)enemigo != (Object)null) || !Object.op_Implicit((Object)(object)enemigo) || !enemigo.EnemyParent.Spawned)
			{
				if ((Object)(object)_raiz != (Object)null && _raiz.activeSelf)
				{
					_raiz.SetActive(false);
				}
				return;
			}
			Crear();
			if (!_raiz.activeSelf)
			{
				_raiz.SetActive(true);
			}
			EstadoMonstruo estado = Piloto.Estado;
			_relleno.anchorMax = new Vector2(estado.Furia, 1f);
			Image? rellenoImagen = _rellenoImagen;
			Color color = ((!estado.Agotado) ? ((estado.Furia >= 1f) ? ColorFuria : ColorRecargando) : ColorAgotado);
			((Graphic)rellenoImagen).color = color;
			_presencia.anchorMax = new Vector2(Mathf.Clamp01(estado.Presencia), 1f);
			bool flag = estado.Presencia >= 0.75f || estado.Retirada;
			((Graphic)_presenciaImagen).color = (flag ? ColorPresenciaAlta : ColorPresencia);
			string text = (estado.Retirada ? ("   <color=#FF6030>" + Idioma.T("RETIRADA", "RETREAT") + "</color>") : (flag ? ("   <color=#FF6030>" + Idioma.T("¡MUÉVETE!", "MOVE ON!") + "</color>") : ""));
			if (estado.VidaMaxima > 0)
			{
				((TMP_Text)_vida).text = string.Format("{0} {1} / {2}{3}", Idioma.T("VIDA", "HP"), estado.Vida, estado.VidaMaxima, text);
			}
			if (Object.op_Implicit((Object)(object)BigMessageUI.instance) && Object.op_Implicit((Object)(object)BigMessageUI.instance.Text) && (Object)(object)((TMP_Text)_vida).font != (Object)(object)((TMP_Text)BigMessageUI.instance.Text).font)
			{
				((TMP_Text)_vida).font = ((TMP_Text)BigMessageUI.instance.Text).font;
			}
		}

		private static void Crear()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_raiz != (Object)null))
			{
				_raiz = new GameObject("PlayerMonster HUD");
				Object.DontDestroyOnLoad((Object)(object)_raiz);
				((Object)_raiz).hideFlags = (HideFlags)61;
				Canvas obj = _raiz.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 29990;
				CanvasScaler obj2 = _raiz.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 0.5f;
				RectTransform val = Rectangulo("Fondo", _raiz.transform, new Color(0f, 0f, 0f, 0.6f));
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(0.5f, 0f);
				val.anchorMax = val2;
				Vector2 anchorMin = val2;
				val.anchorMin = anchorMin;
				val.pivot = new Vector2(0.5f, 0f);
				val.anchoredPosition = new Vector2(0f, 60f);
				val.sizeDelta = new Vector2(420f, 18f);
				_relleno = Rectangulo("Relleno", (Transform)(object)val, ColorFuria);
				_relleno.anchorMin = Vector2.zero;
				_relleno.anchorMax = Vector2.one;
				_relleno.offsetMin = new Vector2(2f, 2f);
				_relleno.offsetMax = new Vector2(-2f, -2f);
				_rellenoImagen = ((Component)_relleno).GetComponent<Image>();
				RectTransform val3 = Rectangulo("Fondo presencia", _raiz.transform, new Color(0f, 0f, 0f, 0.6f));
				((Vector2)(ref val2))..ctor(0.5f, 0f);
				val3.anchorMax = val2;
				val3.anchorMin = val2;
				val3.pivot = new Vector2(0.5f, 0f);
				val3.anchoredPosition = new Vector2(0f, 46f);
				val3.sizeDelta = new Vector2(420f, 10f);
				_presencia = Rectangulo("Presencia", (Transform)(object)val3, ColorPresencia);
				_presencia.anchorMin = Vector2.zero;
				_presencia.anchorMax = new Vector2(0f, 1f);
				_presencia.offsetMin = new Vector2(2f, 2f);
				_presencia.offsetMax = new Vector2(-2f, -2f);
				_presenciaImagen = ((Component)_presencia).GetComponent<Image>();
				GameObject val4 = new GameObject("Vida");
				val4.transform.SetParent(_raiz.transform, false);
				_vida = val4.AddComponent<TextMeshProUGUI>();
				((TMP_Text)_vida).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_vida).fontSize = 30f;
				((Graphic)_vida).color = Color.white;
				((Graphic)_vida).raycastTarget = false;
				((TMP_Text)_vida).richText = true;
				((TMP_Text)_vida).textWrappingMode = (TextWrappingModes)0;
				RectTransform rectTransform = ((TMP_Text)_vida).rectTransform;
				((Vector2)(ref val2))..ctor(0.5f, 0f);
				rectTransform.anchorMax = val2;
				anchorMin = val2;
				rectTransform.anchorMin = anchorMin;
				rectTransform.pivot = new Vector2(0.5f, 0f);
				rectTransform.anchoredPosition = new Vector2(0f, 84f);
				rectTransform.sizeDelta = new Vector2(600f, 40f);
			}
		}

		private static RectTransform Rectangulo(string nombre, Transform padre, Color color)
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(nombre);
			val.transform.SetParent(padre, false);
			Image obj = val.AddComponent<Image>();
			((Graphic)obj).color = color;
			((Graphic)obj).raycastTarget = false;
			return ((Graphic)obj).rectTransform;
		}
	}
	public enum IdiomaMod
	{
		Auto,
		Spanish,
		English
	}
	internal static class Idioma
	{
		public static bool EnEspanol => Plugin.IdiomaTextos.Value switch
		{
			IdiomaMod.Spanish => true, 
			IdiomaMod.English => false, 
			_ => (int)Application.systemLanguage == 34, 
		};

		public static string T(string es, string en)
		{
			if (!EnEspanol)
			{
				return en;
			}
			return es;
		}
	}
	internal static class Mensajes
	{
		private const float IntervaloEntrada = 0.04f;

		private const float IntervaloEstado = 0.1f;

		private const float IntervaloRuido = 1f / 15f;

		private static NetworkedEvent? _evEntrada;

		private static NetworkedEvent? _evEleccion;

		private static NetworkedEvent? _evEstado;

		private static NetworkedEvent? _evMareo;

		private static NetworkedEvent? _evRuido;

		private static NetworkedEvent? _evGolpe;

		private static NetworkedEvent? _evVictoria;

		private static float _siguienteGolpe;

		private static EntradaMonstruo _entradaEnviada;

		private static float _siguienteEntrada;

		private static EstadoMonstruo _estadoEnviado;

		private static int _estadoEnviadoA = -1;

		private static float _siguienteEstado;

		private static float _siguienteRuido;

		public static bool SoyAutoridad => SemiFunc.IsMasterClientOrSingleplayer();

		public static void Registrar()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			_evEntrada = new NetworkedEvent("PlayerMonster Entrada", (Action<EventData>)AlRecibirEntrada);
			_evEleccion = new NetworkedEvent("PlayerMonster Eleccion", (Action<EventData>)AlRecibirEleccion);
			_evEstado = new NetworkedEvent("PlayerMonster Estado", (Action<EventData>)AlRecibirEstado);
			_evMareo = new NetworkedEvent("PlayerMonster Mareo", (Action<EventData>)AlRecibirMareo);
			_evRuido = new NetworkedEvent("PlayerMonster Ruido", (Action<EventData>)AlRecibirRuido);
			_evGolpe = new NetworkedEvent("PlayerMonster Golpe", (Action<EventData>)AlRecibirGolpe);
			_evVictoria = new NetworkedEvent("PlayerMonster Victoria", (Action<EventData>)AlRecibirVictoria);
		}

		public static void EnviarEntrada(EntradaMonstruo entrada)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			if (SoyAutoridad)
			{
				if (Autoridad.PilotoEsLocal)
				{
					Autoridad.RecibirEntrada(entrada);
				}
			}
			else if (entrada.Correr != _entradaEnviada.Correr || entrada.Atacar != _entradaEnviada.Atacar || !(Time.unscaledTime < _siguienteEntrada))
			{
				_siguienteEntrada = Time.unscaledTime + 0.04f;
				_entradaEnviada = entrada;
				byte b = (byte)((entrada.Correr ? 1u : 0u) | (uint)(entrada.Atacar ? 2 : 0));
				NetworkedEvent? evEntrada = _evEntrada;
				if (evEntrada != null)
				{
					evEntrada.RaiseEvent((object)new object[5]
					{
						entrada.Direccion.x,
						entrada.Direccion.z,
						b,
						entrada.Mirada,
						entrada.PuntoMira
					}, NetworkingEvents.RaiseMasterClient, SendOptions.SendUnreliable);
				}
			}
		}

		private static void AlRecibirEntrada(EventData evento)
		{
			//IL_009d: 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)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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_019a: Unknown result type (might be due to invalid IL or missing references)
			if (SoyAutoridad && !Autoridad.PilotoEsLocal && evento.Sender == Autoridad.PilotoActor && evento.CustomData is object[] array && array.Length == 5 && array[0] is float num && array[1] is float num2 && array[2] is byte b && array[3] is Vector3 val && array[4] is Vector3 val2 && !float.IsNaN(num) && !float.IsNaN(num2))
			{
				Vector3 direccion = default(Vector3);
				((Vector3)(ref direccion))..ctor(num, 0f, num2);
				direccion = ((((Vector3)(ref direccion)).sqrMagnitude > 0.01f) ? ((Vector3)(ref direccion)).normalized : Vector3.zero);
				Autoridad.RecibirEntrada(new EntradaMonstruo
				{
					Direccion = direccion,
					Correr = ((b & 1) != 0),
					Atacar = ((b & 2) != 0),
					Mirada = ((((Vector3)(ref val)).sqrMagnitude > 0.01f && !float.IsNaN(val.x + val.y + val.z)) ? ((Vector3)(ref val)).normalized : Vector3.forward),
					PuntoMira = ((float.IsNaN(val2.x + val2.y + val2.z) || float.IsInfinity(((Vector3)(ref val2)).sqrMagnitude)) ? Vector3.zero : val2)
				});
			}
		}

		public static void EnviarEleccion(TipoMonstruo? tipo)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (SoyAutoridad)
			{
				if (Autoridad.PilotoEsLocal)
				{
					Autoridad.RecibirEleccion(tipo);
				}
				return;
			}
			NetworkedEvent? evEleccion = _evEleccion;
			if (evEleccion != null)
			{
				evEleccion.RaiseEvent((object)(int)(tipo.HasValue ? tipo.Value : ((TipoMonstruo)(-1))), NetworkingEvents.RaiseMasterClient, SendOptions.SendReliable);
			}
		}

		private static void AlRecibirEleccion(EventData evento)
		{
			if (SoyAutoridad && !Autoridad.PilotoEsLocal && evento.Sender == Autoridad.PilotoActor && evento.CustomData is int num)
			{
				Autoridad.RecibirEleccion(Enum.IsDefined(typeof(TipoMonstruo), num) ? new TipoMonstruo?((TipoMonstruo)num) : ((TipoMonstruo?)null));
			}
		}

		public static void EnviarEstado(EstadoMonstruo estado)
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			if (Autoridad.PilotoEsLocal)
			{
				Piloto.RecibirEstado(estado);
				return;
			}
			int pilotoActor = Autoridad.PilotoActor;
			if (pilotoActor != _estadoEnviadoA || estado.Fase != _estadoEnviado.Fase || estado.Serie != _estadoEnviado.Serie || estado.Tipo != _estadoEnviado.Tipo || !(Time.unscaledTime < _siguienteEstado))
			{
				_siguienteEstado = Time.unscaledTime + 0.1f;
				_estadoEnviado = estado;
				_estadoEnviadoA = pilotoActor;
				object[] array = new object[14]
				{
					(byte)estado.Fase,
					(byte)estado.Tipo,
					estado.Serie,
					estado.EnemigoViewId,
					estado.Furia,
					estado.Agotado,
					estado.Vida,
					estado.VidaMaxima,
					estado.SegundosParaReaparecer,
					estado.UltimaPosicion,
					estado.Progreso,
					estado.Opciones ?? Array.Empty<float>(),
					estado.Presencia,
					estado.Retirada
				};
				NetworkedEvent? evEstado = _evEstado;
				if (evEstado != null)
				{
					evEstado.RaiseEvent((object)array, Solo(pilotoActor), SendOptions.SendReliable);
				}
			}
		}

		private static void AlRecibirEstado(EventData evento)
		{
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			if (!SoyAutoridad && VieneDelAnfitrion(evento) && evento.CustomData is object[] array && array.Length == 14 && array[0] is byte fase && array[1] is byte tipo && array[2] is int serie && array[3] is int enemigoViewId && array[4] is float furia && array[5] is bool agotado && array[6] is int vida && array[7] is int vidaMaxima && array[8] is float segundosParaReaparecer && array[9] is Vector3 ultimaPosicion && array[10] is float progreso && array[11] is float[] array2 && array[12] is float presencia && array[13] is bool retirada)
			{
				Piloto.RecibirEstado(new EstadoMonstruo
				{
					Fase = (FaseMonstruo)fase,
					Tipo = (TipoMonstruo)tipo,
					Serie = serie,
					EnemigoViewId = enemigoViewId,
					Furia = furia,
					Agotado = agotado,
					Vida = vida,
					VidaMaxima = vidaMaxima,
					SegundosParaReaparecer = segundosParaReaparecer,
					UltimaPosicion = ultimaPosicion,
					Progreso = progreso,
					Opciones = ((array2.Length != 0) ? array2 : null),
					Presencia = presencia,
					Retirada = retirada
				});
			}
		}

		public static void EnviarMareo(float segundos)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (Autoridad.PilotoEsLocal)
			{
				Piloto.RecibirMareo(segundos);
				return;
			}
			NetworkedEvent? evMareo = _evMareo;
			if (evMareo != null)
			{
				evMareo.RaiseEvent((object)segundos, Solo(Autoridad.PilotoActor), SendOptions.SendReliable);
			}
		}

		private static void AlRecibirMareo(EventData evento)
		{
			if (!SoyAutoridad && VieneDelAnfitrion(evento) && evento.CustomData is float num)
			{
				Piloto.RecibirMareo(Mathf.Clamp(num, 0f, 10f));
			}
		}

		public static void EnviarRuido(Vector3 posicion, float radio)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (Autoridad.PilotoEsLocal)
			{
				Piloto.RecibirRuido(posicion, radio);
			}
			else if (!(Time.unscaledTime < _siguienteRuido))
			{
				_siguienteRuido = Time.unscaledTime + 1f / 15f;
				NetworkedEvent? evRuido = _evRuido;
				if (evRuido != null)
				{
					evRuido.RaiseEvent((object)new object[2] { posicion, radio }, Solo(Autoridad.PilotoActor), SendOptions.SendUnreliable);
				}
			}
		}

		private static void AlRecibirRuido(EventData evento)
		{
			//IL_0031: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			if (!SoyAutoridad && VieneDelAnfitrion(evento) && evento.CustomData is object[] array && array.Length == 2 && array[0] is Vector3 posicion && array[1] is float radio)
			{
				Piloto.RecibirRuido(posicion, radio);
			}
		}

		private static bool VieneDelAnfitrion(EventData evento)
		{
			if (PhotonNetwork.MasterClient != null)
			{
				return evento.Sender == PhotonNetwork.MasterClient.ActorNumber;
			}
			return false;
		}

		public static void EnviarGolpe()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (SoyAutoridad)
			{
				Furia.GolpeAcertado();
			}
			else if (!(Time.unscaledTime < _siguienteGolpe))
			{
				_siguienteGolpe = Time.unscaledTime + 0.3f;
				NetworkedEvent? evGolpe = _evGolpe;
				if (evGolpe != null)
				{
					evGolpe.RaiseEvent((object)(byte)1, NetworkingEvents.RaiseMasterClient, SendOptions.SendReliable);
				}
			}
		}

		private static void AlRecibirGolpe(EventData evento)
		{
			if (SoyAutoridad && (Object)(object)Autoridad.Actual != (Object)null && evento.Sender != Autoridad.PilotoActor)
			{
				Furia.GolpeAcertado();
			}
		}

		public static void EnviarVictoria(int actorDelMonstruo, string nombre)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Final.Mostrar(actorDelMonstruo, nombre);
			if (SemiFunc.IsMultiplayer())
			{
				NetworkedEvent? evVictoria = _evVictoria;
				if (evVictoria != null)
				{
					evVictoria.RaiseEvent((object)new object[2] { actorDelMonstruo, nombre }, NetworkingEvents.RaiseOthers, SendOptions.SendReliable);
				}
			}
		}

		private static void AlRecibirVictoria(EventData evento)
		{
			if (VieneDelAnfitrion(evento) && evento.CustomData is object[] array && array.Length == 2 && array[0] is int actorDelMonstruo && array[1] is string text)
			{
				Final.Mostrar(actorDelMonstruo, (text.Length > 32) ? text.Substring(0, 32) : text);
			}
		}

		private static RaiseEventOptions Solo(int actor)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			RaiseEventOptions val = new RaiseEventOptions();
			val.TargetActors = new int[1] { actor };
			return val;
		}
	}
	internal static class Mira
	{
		private static GameObject? _raiz;

		private static readonly Image[] Piezas = (Image[])(object)new Image[5];

		private static float _pedidaEn = -1f;

		public static void Mostrar(bool apuntando)
		{
			//IL_0037: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			Crear();
			Color color = (apuntando ? new Color(1f, 0.2f, 0.15f, 0.95f) : new Color(1f, 1f, 1f, 0.75f));
			Image[] piezas = Piezas;
			for (int i = 0; i < piezas.Length; i++)
			{
				((Graphic)piezas[i]).color = color;
			}
			float num = (apuntando ? 10f : 16f);
			((Graphic)Piezas[0]).rectTransform.anchoredPosition = new Vector2(0f, num);
			((Graphic)Piezas[1]).rectTransform.anchoredPosition = new Vector2(0f, 0f - num);
			((Graphic)Piezas[2]).rectTransform.anchoredPosition = new Vector2(0f - num, 0f);
			((Graphic)Piezas[3]).rectTransform.anchoredPosition = new Vector2(num, 0f);
			_pedidaEn = Time.unscaledTime;
		}

		public static void Mantener()
		{
			if ((Object)(object)_raiz != (Object)null)
			{
				bool flag = Time.unscaledTime - _pedidaEn < 0.1f;
				if (_raiz.activeSelf != flag)
				{
					_raiz.SetActive(flag);
				}
			}
		}

		private static void Crear()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_006a: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_raiz != (Object)null))
			{
				_raiz = new GameObject("PlayerMonster Mira");
				Object.DontDestroyOnLoad((Object)(object)_raiz);
				((Object)_raiz).hideFlags = (HideFlags)61;
				Canvas obj = _raiz.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 29500;
				CanvasScaler obj2 = _raiz.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 0.5f;
				Vector2 tamano = default(Vector2);
				((Vector2)(ref tamano))..ctor(3f, 14f);
				Vector2 tamano2 = default(Vector2);
				((Vector2)(ref tamano2))..ctor(14f, 3f);
				Piezas[0] = Pieza(tamano);
				Piezas[1] = Pieza(tamano);
				Piezas[2] = Pieza(tamano2);
				Piezas[3] = Pieza(tamano2);
				Piezas[4] = Pieza(new Vector2(4f, 4f));
				_raiz.SetActive(false);
			}
		}

		private static Image Pieza(Vector2 tamano)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_004b: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Pieza");
			val.transform.SetParent(_raiz.transform, false);
			Image obj = val.AddComponent<Image>();
			((Graphic)obj).raycastTarget = false;
			RectTransform rectTransform = ((Graphic)obj).rectTransform;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			rectTransform.anchorMax = val2;
			rectTransform.anchorMin = val2;
			rectTransform.sizeDelta = tamano;
			rectTransform.anchoredPosition = Vector2.zero;
			return obj;
		}
	}
	internal static class ModoJuego
	{
		private static int _nivelProcesado;

		private static int _nivelDecidido;

		private static bool _hayMonstruo;

		public static bool HayMonstruoEnEsteNivel()
		{
			LevelGenerator instance = LevelGenerator.Instance;
			if (!Plugin.ModoAutomatico.Value || !Object.op_Implicit((Object)(object)instance) || !Mensajes.SoyAutoridad)
			{
				return false;
			}
			int instanceID = ((Object)instance).GetInstanceID();
			if (instanceID != _nivelDecidido)
			{
				_nivelDecidido = instanceID;
				_hayMonstruo = Random.Range(0f, 100f) < Plugin.Probabilidad.Value;
				Plugin.Log.LogInfo((object)(_hayMonstruo ? "Modo: en este nivel hay jugador-monstruo." : "Modo: en este nivel no hay jugador-monstruo (probabilidad)."));
			}
			return _hayMonstruo;
		}

		public static int PilotoDeLaTecla()
		{
			if (!SemiFunc.IsMultiplayer() || PhotonNetwork.LocalPlayer == null)
			{
				return 0;
			}
			if (Plugin.PilotoForzado.Value == ForzarPiloto.FirstClient && PhotonNetwork.PlayerListOthers.Length != 0)
			{
				int num = int.MaxValue;
				Player[] playerListOthers = PhotonNetwork.PlayerListOthers;
				foreach (Player val in playerListOthers)
				{
					num = Mathf.Min(num, val.ActorNumber);
				}
				return num;
			}
			return PhotonNetwork.LocalPlayer.ActorNumber;
		}

		public static void Tick()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			if (!Plugin.ModoAutomatico.Value || !Mensajes.SoyAutoridad)
			{
				return;
			}
			LevelGenerator instance = LevelGenerator.Instance;
			if (!Object.op_Implicit((Object)(object)instance) || !instance.Generated || !SemiFunc.RunIsLevel() || !Object.op_Implicit((Object)(object)PlayerAvatar.instance) || !Object.op_Implicit((Object)(object)GameDirector.instance) || (int)GameDirector.instance.currentState != 2)
			{
				return;
			}
			int instanceID = ((Object)instance).GetInstanceID();
			if (instanceID != _nivelProcesado)
			{
				_nivelProcesado = instanceID;
				if (HayMonstruoEnEsteNivel())
				{
					Autoridad.EmpezarTransformacion(Rotacion.PilotoParaEsteNivel(), Mathf.Max(1f, Plugin.RetrasoTransformacion.Value));
				}
			}
		}
	}
	internal static class Olfato
	{
		private const float RadioContacto = 15f;

		private const float CadaSegundos = 12f;

		private const float DuracionMarca = 4f;

		private static float _ultimoContacto;

		private static float _siguienteRastro;

		private static float _marcaHasta;

		private static float _pedidoEn = -1f;

		private static GameObject? _raiz;

		private static Image? _marca;

		public static void Reiniciar()
		{
			_ultimoContacto = Time.time;
			_marcaHasta = 0f;
		}

		public static void Tick(Enemy enemigo)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.UsarOlfato.Value || !Object.op_Implicit((Object)(object)GameDirector.instance))
			{
				return;
			}
			Vector3 val = (Object.op_Implicit((Object)(object)enemigo.CenterTransform) ? enemigo.CenterTransform.position : ((Component)enemigo).transform.position);
			PlayerAvatar val2 = null;
			float num = float.MaxValue;
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (Object.op_Implicit((Object)(object)player) && !player.isLocal && !player.isDisabled)
				{
					float num2 = Vector3.Distance(val, ((Component)player).transform.position);
					if (num2 < num)
					{
						num = num2;
						val2 = player;
					}
				}
			}
			if ((Object)(object)val2 == (Object)null || num <= 15f)
			{
				_ultimoContacto = Time.time;
			}
			else if (!(Time.time - _ultimoContacto < Plugin.OlfatoSegundos.Value))
			{
				if (Time.time >= _siguienteRastro)
				{
					_siguienteRastro = Time.time + 12f;
					_marcaHasta = Time.time + 4f;
				}
				if (Time.time < _marcaHasta)
				{
					Dibujar(((Component)val2).transform.position + Vector3.up);
				}
			}
		}

		public static void Mantener()
		{
			if ((Object)(object)_raiz != (Object)null)
			{
				bool flag = Time.unscaledTime - _pedidoEn < 0.1f;
				if (_raiz.activeSelf != flag)
				{
					_raiz.SetActive(flag);
				}
			}
		}

		private static void Dibujar(Vector3 objetivo)
		{
			//IL_0016: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00d2: 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_003d: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			Camera main = Camera.main;
			if (!((Object)(object)main == (Object)null))
			{
				Crear();
				Vector3 val = main.WorldToViewportPoint(objetivo);
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(val.x, val.y);
				Vector2 val4;
				if (val.z < 0f)
				{
					val2 = Vector2.one - val2;
					Vector2 val3 = new Vector2(0.5f, 0.5f);
					val4 = val2 - new Vector2(0.5f, 0.5f);
					val2 = val3 + ((Vector2)(ref val4)).normalized * 2f;
				}
				val2.x = Mathf.Clamp(val2.x, 0.06f, 0.94f);
				val2.y = Mathf.Clamp(val2.y, 0.1f, 0.9f);
				RectTransform rectTransform = ((Graphic)_marca).rectTransform;
				val4 = (rectTransform.anchorMin = (rectTransform.anchorMax = val2));
				float num = 0.55f + 0.45f * Mathf.Sin(Time.time * 9f);
				((Graphic)_marca).color = new Color(1f, 0.1f, 0.1f, num);
				_pedidoEn = Time.unscaledTime;
			}
		}

		private static void Crear()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_raiz != (Object)null))
			{
				_raiz = new GameObject("PlayerMonster Olfato");
				Object.DontDestroyOnLoad((Object)(object)_raiz);
				((Object)_raiz).hideFlags = (HideFlags)61;
				Canvas obj = _raiz.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 29980;
				CanvasScaler obj2 = _raiz.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 0.5f;
				GameObject val = new GameObject("Marca");
				val.transform.SetParent(_raiz.transform, false);
				_marca = val.AddComponent<Image>();
				((Graphic)_marca).raycastTarget = false;
				RectTransform rectTransform = ((Graphic)_marca).rectTransform;
				rectTransform.sizeDelta = new Vector2(34f, 34f);
				rectTransform.anchoredPosition = Vector2.zero;
				((Transform)rectTransform).localRotation = Quaternion.Euler(0f, 0f, 45f);
				_raiz.SetActive(false);
			}
		}
	}
	[HarmonyPatch(typeof(RunManager), "ResetProgress")]
	internal static class PartidaNuevaPatch
	{
		private static void Prefix()
		{
			Rotacion.Reiniciar("partida nueva");
		}
	}
	internal static class Piloto
	{
		private static EntradaMonstruo _entrada;

		private static Enemy? _enemigoRemoto;

		private static TipoMonstruo? _eleccionEnviada;

		private static bool _eleccionPendiente;

		private static int _pasoSecuencia = -1;

		private static float _mensajeFinalHasta;

		private const int PasosDeFallo = 3;

		private static readonly Color RojoOscuro = new Color(0.5f, 0f, 0f);

		private static float _siguienteEleccion;

		private static float _ultimoEstadoEn;

		public static EstadoMonstruo Estado { get; private set; }

		public static bool Activo => Estado.Fase != FaseMonstruo.Ninguna;

		public static Enemy? Enemigo
		{
			get
			{
				if (Estado.Fase != FaseMonstruo.Vivo)
				{
					return null;
				}
				if (Mensajes.SoyAutoridad)
				{
					Enemy actual = Autoridad.Actual;
					if (!((Object)(object)actual != (Object)null) || !Object.op_Implicit((Object)(object)actual))
					{
						return null;
					}
					return actual;
				}
				if (((Object)(object)_enemigoRemoto == (Object)null || !Object.op_Implicit((Object)(object)_enemigoRemoto)) && Estado.EnemigoViewId != 0)
				{
					PhotonView val = PhotonView.Find(Estado.EnemigoViewId);
					_enemigoRemoto = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<Enemy>() : null);
				}
				if (!((Object)(object)_enemigoRemoto != (Object)null) || !Object.op_Implicit((Object)(object)_enemigoRemoto))
				{
					return null;
				}
				return _enemigoRemoto;
			}
		}

		private static string MensajeDeFallo(int paso)
		{
			return paso switch
			{
				0 => Idioma.T("ERROR DE SISTEMA", "SYSTEM ERROR"), 
				1 => Idioma.T("CIRCUITOS COMPROMETIDOS", "CIRCUITS COMPROMISED"), 
				_ => Idioma.T("PERDIENDO EL CONTROL", "LOSING CONTROL"), 
			};
		}

		private static bool EsMonstruo(FaseMonstruo fase)
		{
			if (fase != FaseMonstruo.Vivo)
			{
				return fase == FaseMonstruo.Esperando;
			}
			return true;
		}

		public static void RecibirEstado(EstadoMonstruo nuevo)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			EstadoMonstruo estado = Estado;
			Estado = nuevo;
			_ultimoEstadoEn = Time.unscaledTime;
			if (nuevo.Fase == FaseMonstruo.Transformando && estado.Fase != FaseMonstruo.Transformando)
			{
				_pasoSecuencia = -1;
			}
			if (!EsMonstruo(estado.Fase) && EsMonstruo(nuevo.Fase) && Plugin.OcultarCuerpo.Value)
			{
				CuerpoJugador.Ocultar();
			}
			if (nuevo.Serie != estado.Serie)
			{
				_enemigoRemoto = null;
				_entrada = default(EntradaMonstruo);
				Camara.MostrarModelo();
				Sentidos.Ocultar();
				Olfato.Reiniciar();
			}
			if (estado.Fase == FaseMonstruo.Transformando && nuevo.Fase == FaseMonstruo.Vivo)
			{
				Sacudida(5f, 1f, 0.3f);
				_mensajeFinalHasta = Time.time + 4f;
				SemiFunc.UIFocusText(Idioma.T("Impide que el equipo cumpla la cuota", "Stop the team from meeting the quota"), Color.red, Color.white, 8f);
			}
			if (estado.Fase == FaseMonstruo.Vivo && nuevo.Fase == FaseMonstruo.Esperando)
			{
				Seleccion.Empezar(nuevo.Opciones);
				_eleccionPendiente = true;
				Sacudida(4f, 0.8f, 0f);
			}
			if (EsMonstruo(estado.Fase) && nuevo.Fase == FaseMonstruo.Ninguna)
			{
				CuerpoJugador.Restaurar();
			}
		}

		private static void Sacudida(float fuerza, float duracion, float duracionImpacto)
		{
			if (Object.op_Implicit((Object)(object)CameraGlitch.Instance))
			{
				CameraGlitch.Instance.PlayLong();
			}
			if (Object.op_Implicit((Object)(object)GameDirector.instance))
			{
				GameDirector.instance.CameraShake.Shake(fuerza, duracion);
				if (duracionImpacto > 0f)
				{
					GameDirector.instance.CameraImpact.Shake(fuerza, duracionImpacto);
				}
			}
		}

		public static void RecibirMareo(float segundos)
		{
			Sentidos.Marear(segundos);
		}

		public static void RecibirRuido(Vector3 posicion, float radio)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			Sentidos.RegistrarRuido(posicion, radio);
		}

		public static void EnviarEntrada()
		{
			if (Estado.Fase == FaseMonstruo.Vivo)
			{
				_entrada = EntradaMonstruo.LeerLocal(Enemigo);
				Mensajes.EnviarEntrada(_entrada);
			}
		}

		public static void Tick()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: 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_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time < _mensajeFinalHasta)
			{
				Aviso.Mostrar(Idioma.T("ERES EL MONSTRUO", "YOU ARE THE MONSTER"), 130f, Color.red);
			}
			if (Activo && !Autoridad.Activa && Time.unscaledTime - _ultimoEstadoEn > 3f)
			{
				Plugin.Log.LogWarning((object)"Piloto: hace 3 s que no llega el estado del anfitrión; vuelvo a ser robot.");
				RecibirEstado(default(EstadoMonstruo));
			}
			if (Activo && !Autoridad.Activa && !SemiFunc.RunIsLevel())
			{
				RecibirEstado(default(EstadoMonstruo));
			}
			if (Estado.Fase != FaseMonstruo.Vivo)
			{
				Sentidos.Ocultar();
				Camara.MostrarModelo();
			}
			RedMonstruo.AnunciarEnemigo(Enemigo);
			if (!Activo || !SemiFunc.RunIsLevel() || !Object.op_Implicit((Object)(object)PlayerController.instance) || !Object.op_Implicit((Object)(object)GameDirector.instance))
			{
				return;
			}
			if (Estado.Fase == FaseMonstruo.Transformando)
			{
				SecuenciaDeFallo(Estado.Progreso);
				return;
			}
			if (Plugin.OcultarCuerpo.Value)
			{
				CuerpoJugador.Ocultar();
			}
			PlayerController.instance.InputDisable(0.1f);
			CuerpoJugador.Tick();
			if (Estado.Fase == FaseMonstruo.Esperando)
			{
				if (Estado.SegundosParaReaparecer > 0f)
				{
					Aviso.Mostrar(Idioma.T("REAPARECES EN ", "RESPAWNING IN ") + Mathf.CeilToInt(Estado.SegundosParaReaparecer), 90f, Color.red);
				}
				Seleccion.Mostrar(Estado.Opciones);
				EnviarEleccion();
				Camara.Mirar(Estado.UltimaPosicion + Vector3.up);
				return;
			}
			if (Estado.Retirada)
			{
				Aviso.Mostrar(Idioma.T("RETIRADA", "RETREAT"), 70f, new Color(1f, 0.45f, 0.1f));
			}
			Enemy enemigo = Enemigo;
			if (!((Object)(object)enemigo == (Object)null))
			{
				EntradaMonstruo entrada = _entrada;
				if (Estado.Agotado)
				{
					entrada.Atacar = false;
					entrada.Correr = false;
				}
				Sentidos.Tick(Estado.Tipo, enemigo, entrada);
				Olfato.Tick(enemigo);
				if (Estado.Tipo == TipoMonstruo.Hunter)
				{
					Mira.Mostrar(entrada.Atacar);
				}
				Camara.Seguir(enemigo);
			}
		}

		private static void SecuenciaDeFallo(float progreso)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)Plugin.Instancia).gameObject;
			if (Object.op_Implicit((Object)(object)PostProcessing.Instance))
			{
				PostProcessing.Instance.VignetteOverride(RojoOscuro, Mathf.Lerp(0.15f, 0.6f, progreso), 1f, 3f, 1f, 0.2f, gameObject, 999);
				PostProcessing.Instance.SaturationOverride(Mathf.Lerp(-10f, -70f, progreso), 3f, 1f, 0.2f, gameObject, 999);
				PostProcessing.Instance.ContrastOverride(Mathf.Lerp(0f, 15f, progreso), 3f, 1f, 0.2f, gameObject, 999);
			}
			int num = Mathf.Min((int)(progreso * 3f), 2);
			if (num != _pasoSecuencia)
			{
				_pasoSecuencia = num;
				float num2 = 1f + (float)num;
				if (num == 0)
				{
					CameraGlitch.Instance.PlayTiny();
				}
				else
				{
					CameraGlitch.Instance.PlayShort();
				}
				GameDirector.instance.CameraShake.Shake(num2, 0.6f);
				GameDirector.instance.CameraImpact.Shake(num2, 0.15f);
			}
			Aviso.Mostrar(MensajeDeFallo(num), 80f + (float)num * 15f, Color.red);
		}

		private static void EnviarEleccion()
		{
			TipoMonstruo? cursor = Seleccion.Cursor;
			if (_eleccionPendiente || cursor != _eleccionEnviada || Time.unscaledTime >= _siguienteEleccion)
			{
				_eleccionPendiente = false;
				_eleccionEnviada = cursor;
				_siguienteEleccion = Time.unscaledTime + 0.5f;
				Mensajes.EnviarEleccion(cursor);
			}
		}
	}
	[BepInPlugin("tommy777.playermonster", "PlayerMonster", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "tommy777.playermonster";

		public const string Nombre = "PlayerMonster";

		public const string Version = "1.0.0";

		internal static Plugin Instancia;

		internal static ManualLogSource Log;

		internal static ConfigEntry<Key> TeclaPosesion;

		internal static ConfigEntry<Key> TeclaCambiarTipo;

		internal static ConfigEntry<Key> TeclaMatar;

		internal static ConfigEntry<Key> TeclaCamara;

		internal static ConfigEntry<bool> PrimeraPersona;

		internal static ConfigEntry<Key> TeclaRuido;

		internal static ConfigEntry<float> DistanciaCamara;

		internal static ConfigEntry<bool> ModoAutomatico;

		internal static ConfigEntry<float> Probabilidad;

		internal static ConfigEntry<float> RetrasoTransformacion;

		internal static ConfigEntry<bool> MonstruoAleatorio;

		internal static ConfigEntry<bool> SoloJugadorMonstruo;

		internal static ConfigEntry<bool> ProtegerObjetos;

		internal static ConfigEntry<bool> ElegirMonstruo;

		internal static ConfigEntry<float> BloqueoDificultad1;

		internal static ConfigEntry<float> BloqueoDificultad2;

		internal static ConfigEntry<float> BloqueoDificultad3;

		internal static ConfigEntry<bool> VozCorrupta;

		internal static ConfigEntry<float> VozTono;

		internal static ConfigEntry<bool> UsarFuria;

		internal static ConfigEntry<float> VidaBase;

		internal static ConfigEntry<float> VidaExtraPorJugador;

		internal static ConfigEntry<float> VidaExtraPorNivel;

		internal static ConfigEntry<float> VidaMultiplicadorMaximo;

		internal static ConfigEntry<float> VidaExtraPorMuerte;

		internal static ConfigEntry<bool> UsarPresencia;

		internal static ConfigEntry<bool> AvisoCercania;

		internal static ConfigEntry<float> CercaniaLejos;

		internal static ConfigEntry<float> CercaniaCerca;

		internal static ConfigEntry<float> CercaniaVolumen;

		internal static ConfigEntry<bool> ReglaCamion;

		internal static ConfigEntry<float> CamionSegundos;

		internal static ConfigEntry<float> PausaTrasGolpe;

		internal static ConfigEntry<bool> UsarOlfato;

		internal static ConfigEntry<float> OlfatoSegundos;

		internal static ConfigEntry<float> PresenciaSegundos;

		internal static ConfigEntry<float> PresenciaRetirada;

		internal static ConfigEntry<float> PresenciaRadio;

		internal static ConfigEntry<bool> TeclasDePrueba;

		internal static ConfigEntry<IdiomaMod> IdiomaTextos;

		internal static ConfigEntry<bool> UsarSentidos;

		internal static ConfigEntry<float> CegueraHunter;

		internal static ConfigEntry<float> TiempoReaparicion;

		internal static ConfigEntry<float> ProteccionReaparicion;

		internal static ConfigEntry<int> OrbesMaximos;

		internal static ConfigEntry<bool> CrearLejos;

		internal static ConfigEntry<bool> OcultarCuerpo;

		internal static ConfigEntry<bool> ReutilizarExistente;

		internal static ConfigEntry<bool> EvitarDerrotaEnSolitario;

		internal static ConfigEntry<TipoMonstruo> MonstruoDePrueba;

		internal static ConfigEntry<ForzarPiloto> PilotoForzado;

		internal static ConfigEntry<int> RondasPorMonstruo;

		private readonly Harmony _harmony = new Harmony("tommy777.playermonster");

		private const string GuidAntiguo = "tomas.jugadormonstruo";

		internal static bool Conflicto;

		private bool _conflictoComprobado;

		private float _avisoConflictoHasta;

		private void Awake()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Expected O, but got Unknown
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Expected O, but got Unknown
			Instancia = this;
			Log = ((BaseUnityPlugin)this).Logger;
			((Component)this).transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (