Decompiled source of ConsolaCW v1.10.3

ConsolaCW.dll

Decompiled 21 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DefaultNamespace;
using HarmonyLib;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using Zorro.Core;
using Zorro.Core.CLI;

[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; private set; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace ConsolaCW
{
	internal static class G
	{
		private const BindingFlags F = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static Func<Player, Vector3> pCenter;

		private static Func<Bot, Vector3> bCenter;

		private static Action<Bot, Vector3> worldMoveTo;

		private static Action<Player> callDie;

		private static Action<Player, float, Vector3, float> takeDmgForceFall;

		private static Action<PlayerInput> resetInput;

		private static Action<Player, Vector3, Vector3> teleport;

		private static Action<PlayerRagdoll, Vector3, ForceMode> addForce;

		private static Action<PlayerRagdoll, float> callFall;

		private static Action<PlayerRagdoll, float> fall;

		private static Func<PlayerRagdoll, BodypartType, Bodypart> getBodypart;

		private static Func<PlayerRagdoll, int, Bodypart> getBodypartFromId;

		private static Func<PlayerVisor, IEnumerator> deadAnim;

		private static FieldInfo visorMaterial;

		private static FieldInfo bodypartRig;

		private static T D<T>(Type type, string name, params Type[] args) where T : class
		{
			MethodInfo methodInfo = ((args.Length > 0) ? type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, args, null) : type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic));
			if (methodInfo == null)
			{
				Plugin.Log.LogWarning((object)("No existe " + type.Name + "." + name));
				return null;
			}
			return Delegate.CreateDelegate(typeof(T), null, methodInfo) as T;
		}

		private static FieldInfo Fld(Type type, string name)
		{
			FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null)
			{
				Plugin.Log.LogWarning((object)("No existe " + type.Name + "." + name));
			}
			return field;
		}

		public static Vector3 Center(Player p)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (pCenter == null)
			{
				pCenter = D<Func<Player, Vector3>>(typeof(Player), "Center", new Type[0]);
			}
			if (pCenter == null)
			{
				return ((Component)p).transform.position;
			}
			return pCenter(p);
		}

		public static Vector3 Center(Bot b)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (bCenter == null)
			{
				bCenter = D<Func<Bot, Vector3>>(typeof(Bot), "Center", new Type[0]);
			}
			if (bCenter == null)
			{
				return ((Component)b).transform.position;
			}
			return bCenter(b);
		}

		public static void WorldMoveTo(Bot b, Vector3 pos)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (worldMoveTo == null)
			{
				worldMoveTo = D<Action<Bot, Vector3>>(typeof(Bot), "WorldMoveTo", new Type[1] { typeof(Vector3) });
			}
			if (worldMoveTo != null)
			{
				worldMoveTo(b, pos);
			}
		}

		public static void CallDie(Player p)
		{
			if (callDie == null)
			{
				callDie = D<Action<Player>>(typeof(Player), "CallDie", new Type[0]);
			}
			if (callDie != null)
			{
				callDie(p);
			}
		}

		public static void CallTakeDamageAndAddForceAndFall(Player p, float dmg, Vector3 force, float fallTime)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (takeDmgForceFall == null)
			{
				takeDmgForceFall = D<Action<Player, float, Vector3, float>>(typeof(Player), "CallTakeDamageAndAddForceAndFall", new Type[3]
				{
					typeof(float),
					typeof(Vector3),
					typeof(float)
				});
			}
			if (takeDmgForceFall != null)
			{
				takeDmgForceFall(p, dmg, force, fallTime);
			}
		}

		public static void ResetInput(PlayerInput i)
		{
			if (resetInput == null)
			{
				resetInput = D<Action<PlayerInput>>(typeof(PlayerInput), "ResetInput", new Type[0]);
			}
			if (resetInput != null)
			{
				resetInput(i);
			}
		}

		public static void Teleport(Player p, Vector3 pos, Vector3 forward)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (teleport == null)
			{
				teleport = D<Action<Player, Vector3, Vector3>>(typeof(Player), "Teleport", new Type[2]
				{
					typeof(Vector3),
					typeof(Vector3)
				});
			}
			if (teleport != null)
			{
				teleport(p, pos, forward);
			}
		}

		public static void AddForce(PlayerRagdoll r, Vector3 force, ForceMode mode)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (addForce == null)
			{
				addForce = D<Action<PlayerRagdoll, Vector3, ForceMode>>(typeof(PlayerRagdoll), "AddForce", new Type[2]
				{
					typeof(Vector3),
					typeof(ForceMode)
				});
			}
			if (addForce != null)
			{
				addForce(r, force, mode);
			}
		}

		public static void CallFall(PlayerRagdoll r, float s)
		{
			if (callFall == null)
			{
				callFall = D<Action<PlayerRagdoll, float>>(typeof(PlayerRagdoll), "CallFall", new Type[1] { typeof(float) });
			}
			if (callFall != null)
			{
				callFall(r, s);
			}
		}

		public static void Fall(PlayerRagdoll r, float s)
		{
			if (fall == null)
			{
				fall = D<Action<PlayerRagdoll, float>>(typeof(PlayerRagdoll), "Fall", new Type[1] { typeof(float) });
			}
			if (fall != null)
			{
				fall(r, s);
			}
		}

		public static Bodypart GetBodypart(PlayerRagdoll r, BodypartType t)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (getBodypart == null)
			{
				getBodypart = D<Func<PlayerRagdoll, BodypartType, Bodypart>>(typeof(PlayerRagdoll), "GetBodypart", new Type[1] { typeof(BodypartType) });
			}
			if (getBodypart == null)
			{
				return null;
			}
			return getBodypart(r, t);
		}

		public static Bodypart GetBodypartFromID(PlayerRagdoll r, int id)
		{
			if (getBodypartFromId == null)
			{
				getBodypartFromId = D<Func<PlayerRagdoll, int, Bodypart>>(typeof(PlayerRagdoll), "GetBodypartFromID", new Type[1] { typeof(int) });
			}
			if (getBodypartFromId == null)
			{
				return null;
			}
			return getBodypartFromId(r, id);
		}

		public static IEnumerator DeadAnim(PlayerVisor v)
		{
			if (deadAnim == null)
			{
				deadAnim = D<Func<PlayerVisor, IEnumerator>>(typeof(PlayerVisor), "DeadAnim", new Type[0]);
			}
			if (deadAnim == null)
			{
				return null;
			}
			return deadAnim(v);
		}

		public static Material VisorMaterial(PlayerVisor v)
		{
			if (visorMaterial == null)
			{
				visorMaterial = Fld(typeof(PlayerVisor), "m_material");
			}
			if (!(visorMaterial != null))
			{
				return null;
			}
			object? value = visorMaterial.GetValue(v);
			return (Material)((value is Material) ? value : null);
		}

		public static Rigidbody Rig(Bodypart b)
		{
			if (bodypartRig == null)
			{
				bodypartRig = Fld(typeof(Bodypart), "rig");
			}
			if (!(bodypartRig != null))
			{
				return null;
			}
			object? value = bodypartRig.GetValue(b);
			return (Rigidbody)((value is Rigidbody) ? value : null);
		}
	}
	[ContentWarningPlugin("consolacw.console", "1.10.3", false)]
	[BepInPlugin("consolacw.console", "ConsolaCW", "1.10.3")]
	public class Plugin : BaseUnityPlugin
	{
		public const string GUID = "consolacw.console";

		public const string NAME = "ConsolaCW";

		public const string VERSION = "1.10.3";

		internal static ConfigEntry<KeyCode> ToggleKey;

		internal static ConfigEntry<bool> HostOnly;

		internal static ManualLogSource Log;

		internal static Harmony HarmonyInstance;

		private void Awake()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)283, "Tecla para abrir/cerrar la consola");
			HostOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HostOnlySpawns", true, "Si es true, spawnear monstruos y dar dinero solo funciona siendo host (recomendado en lobbies públicos)");
			HarmonyInstance = new Harmony("consolacw.console");
			ApplyPatchesSafely(HarmonyInstance);
			GameObject val = new GameObject("ConsolaCW");
			((Object)val).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<ConsoleUI>();
			Log.LogInfo((object)("ConsolaCW 1.10.3 cargado. Abre la consola con " + ToggleKey.Value));
		}

		private static void ApplyPatchesSafely(Harmony harmony)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			int num2 = 0;
			MethodInfo[] methods = typeof(Patches).GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				HarmonyPatch val;
				try
				{
					val = (HarmonyPatch)Attribute.GetCustomAttribute(methodInfo, typeof(HarmonyPatch));
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Parche omitido " + methodInfo.Name + " (tipo inexistente): " + ex.Message));
					num2++;
					continue;
				}
				if (val == null || ((HarmonyAttribute)val).info == null || ((HarmonyAttribute)val).info.declaringType == null)
				{
					continue;
				}
				string text = ((HarmonyAttribute)val).info.declaringType.Name + "." + ((HarmonyAttribute)val).info.methodName;
				try
				{
					MethodInfo methodInfo2 = AccessTools.Method(((HarmonyAttribute)val).info.declaringType, ((HarmonyAttribute)val).info.methodName, (Type[])null, (Type[])null);
					if (methodInfo2 == null)
					{
						Log.LogWarning((object)("Parche omitido (no existe en esta versión): " + text));
						num2++;
						continue;
					}
					bool flag = Attribute.IsDefined(methodInfo, typeof(HarmonyPrefix));
					if (Attribute.IsDefined(methodInfo, typeof(HarmonyFinalizer)))
					{
						harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo), (HarmonyMethod)null);
					}
					else
					{
						harmony.Patch((MethodBase)methodInfo2, (!flag) ? ((HarmonyMethod)null) : new HarmonyMethod(methodInfo), flag ? ((HarmonyMethod)null) : new HarmonyMethod(methodInfo), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					}
					num++;
				}
				catch (Exception ex2)
				{
					Log.LogWarning((object)("Parche omitido " + text + ": " + ex2.Message));
					num2++;
				}
			}
			Log.LogInfo((object)("Parches aplicados: " + num + ((num2 > 0) ? (", omitidos: " + num2) : "")));
		}
	}
	internal static class Patches
	{
		public static float SnailDamage = 12f;

		public static bool MimeSmooth = true;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PlayerInput), "SampeInput")]
		private static void BlockPlayerInput(PlayerInput __instance)
		{
			if (ConsoleUI.IsOpen)
			{
				G.ResetInput(__instance);
			}
		}

		[HarmonyPatch(typeof(GlobalInputHandler), "CanTakeInput")]
		[HarmonyPostfix]
		private static void BlockGlobalInput(ref bool __result)
		{
			if (ConsoleUI.IsOpen)
			{
				__result = false;
			}
		}

		[HarmonyPatch(typeof(Player), "HasLockedInput")]
		[HarmonyPostfix]
		private static void LockInput(Player __instance, ref bool __result)
		{
			if (ConsoleUI.IsOpen && (Object)(object)__instance == (Object)(object)Player.localPlayer)
			{
				__result = true;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "TakeDamage")]
		private static bool MonsterTakeDamage(Player __instance, ref float damage)
		{
			if (GodMode.Protects(__instance))
			{
				__instance.data.health = PlayerData.maxHealth;
				return false;
			}
			damage = DamageLimiter.Filter(__instance, damage);
			return !MonsterDamage.Apply(__instance, damage);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "Die")]
		private static bool GodNoDie(Player __instance)
		{
			return !GodMode.Protects(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "CallDie")]
		private static bool GodNoCallDie(Player __instance)
		{
			return !GodMode.Protects(__instance);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "KillLocal")]
		private static bool GodNoKillLocal()
		{
			return !GodMode.Protects(Player.localPlayer);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "RPCA_PlayerDie")]
		private static bool GodNoRpcDie(Player __instance)
		{
			if (!GodMode.Protects(__instance))
			{
				return true;
			}
			GodMode.ResyncAlive(__instance);
			return false;
		}

		[HarmonyPatch(typeof(Player), "CallTakeDamage")]
		[HarmonyPrefix]
		private static void HS1(Player __instance, ref float damage)
		{
			MonsterDamage.OnHit(__instance, ref damage, null);
		}

		[HarmonyPatch(typeof(Player), "CallTakeDamageAndTase")]
		[HarmonyPrefix]
		private static void HS2(Player __instance, ref float damage)
		{
			MonsterDamage.OnHit(__instance, ref damage, null);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "CallTakeDamageAndAddForceAndFall")]
		private static void HS3(Player __instance, ref float damage)
		{
			MonsterDamage.OnHit(__instance, ref damage, null);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "CallTakeDamageAndAddForceAndFallWithFallof")]
		private static void HS4(Player __instance, ref float damage, Vector3 pos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			MonsterDamage.OnHit(__instance, ref damage, pos);
		}

		[HarmonyPatch(typeof(SnailDummy), "OnTriggerEnter")]
		[HarmonyPrefix]
		private static bool SnailHitsMonsters(SnailDummy __instance, Collider __0)
		{
			if (!Infighting.Enabled || (Object)(object)__0 == (Object)null || __0.isTrigger)
			{
				return true;
			}
			PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
			if ((Object)(object)component != (Object)null && !component.IsMine)
			{
				return true;
			}
			Player component2 = ((Component)((Component)__0).transform.root).GetComponent<Player>();
			if ((Object)(object)component2 == (Object)null || !component2.ai || component2.data == null || component2.data.dead)
			{
				return true;
			}
			if ((Object)(object)((Component)((Component)component2).transform.root).GetComponentInChildren<Attacks_SnailSpawner>(true) != (Object)null)
			{
				return true;
			}
			component2.CallTakeDamage(SnailDamage);
			__instance.RemoveSnail();
			return false;
		}

		[HarmonyPatch(typeof(BlinkRenderer), "Start")]
		[HarmonyPrefix]
		private static bool MimeNoHide()
		{
			return !MimeSmooth;
		}

		[HarmonyPatch(typeof(BlinkRenderer), "Update")]
		[HarmonyPrefix]
		private static bool MimeNoBlink(BlinkRenderer __instance)
		{
			if (!MimeSmooth)
			{
				return true;
			}
			Player componentInParent = ((Component)__instance).GetComponentInParent<Player>();
			if ((Object)(object)componentInParent != (Object)null && componentInParent.refs != null && (Object)(object)componentInParent.refs.bodyMeshRenderer != (Object)null && !((Renderer)componentInParent.refs.bodyMeshRenderer).enabled)
			{
				((Renderer)componentInParent.refs.bodyMeshRenderer).enabled = true;
			}
			if ((Object)(object)__instance.step != (Object)null)
			{
				__instance.step.step = true;
			}
			return false;
		}

		[HarmonyFinalizer]
		[HarmonyPatch(typeof(Bot_Drag), "FixedUpdate")]
		private static Exception DragNoCrash(Bot_Drag __instance, Exception __exception)
		{
			if (__exception == null)
			{
				return null;
			}
			try
			{
				Bot val = ((Component)__instance).GetComponent<Bot>() ?? ((Component)__instance).GetComponentInParent<Bot>();
				if ((Object)(object)val != (Object)null)
				{
					Infighting.Incompatible.Add(val);
					if ((Object)(object)val.targetPlayer != (Object)null && val.targetPlayer.ai)
					{
						val.targetPlayer = null;
					}
				}
			}
			catch
			{
			}
			return null;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "DelayDropItems")]
		private static bool MonsterNoDrop(Player __instance, ref IEnumerator __result)
		{
			if ((Object)(object)__instance == (Object)null || !__instance.ai)
			{
				return true;
			}
			__result = new object[0].GetEnumerator();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "DelayThenTalkToDead")]
		private static bool MonsterNoTalkToDead(Player __instance, ref IEnumerator __result)
		{
			if ((Object)(object)__instance == (Object)null || !__instance.ai)
			{
				return true;
			}
			__result = new object[0].GetEnumerator();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "RPCA_PlayerDie")]
		private static bool MonsterRpcDie(Player __instance)
		{
			if ((Object)(object)__instance == (Object)null || !__instance.ai)
			{
				return true;
			}
			__instance.data.dead = true;
			if ((Object)(object)PlayerHandler.instance != (Object)null)
			{
				PlayerHandler.instance.playersAlive.Remove(__instance);
			}
			return false;
		}

		[HarmonyPatch(typeof(Bot), "Patrol")]
		[HarmonyFinalizer]
		private static Exception PatrolNoCrash(Exception __exception, ref bool __result)
		{
			if (__exception is NullReferenceException)
			{
				__result = false;
				return null;
			}
			return __exception;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Bot), "GetTargetPlayer")]
		private static bool PassiveNoTarget(Bot __instance)
		{
			if (!PassiveWander.IsPassive(__instance))
			{
				return true;
			}
			__instance.targetPlayer = null;
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Bot), "LookForTarget")]
		private static bool PassiveNoLook(Bot __instance, ref bool __result)
		{
			if (PassiveWander.IsPassive(__instance))
			{
				__result = false;
				return false;
			}
			if (Infighting.FightingMonster(__instance))
			{
				__result = true;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(Bot), "LookForBetterTarget")]
		[HarmonyPrefix]
		private static bool FightNoBetterTarget(Bot __instance)
		{
			return !Infighting.FightingMonster(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(CursorHandler), "Update")]
		private static void FreeCursor()
		{
			if (ConsoleUI.IsOpen)
			{
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}
	}
	public class ConsoleUI : MonoBehaviour
	{
		public static bool IsOpen;

		public static ConsoleUI Instance;

		private readonly List<string> lines = new List<string>();

		private readonly List<string> history = new List<string>();

		private int historyIndex = -1;

		private string draft = "";

		private string input = "";

		private Vector2 scroll;

		private bool focusInput;

		private Rect window;

		private bool windowInit;

		private GUIStyle logStyle;

		private GUIStyle inputStyle;

		private GUIStyle boxStyle;

		private GUIStyle chipStyle;

		private GUIStyle chipFirstStyle;

		private string lastInput;

		private List<Commands.Suggestion> suggestions = new List<Commands.Suggestion>();

		private bool moveCursorToEnd;

		private bool cheatsBroken;

		private bool corpsesBroken;

		private bool fightBroken;

		private float nextCompatTry;

		private static string HistoryFile => Path.Combine(Paths.ConfigPath, "ConsolaCW_historial.txt");

		private void Awake()
		{
			Instance = this;
			Commands.Register();
			LoadHistory();
			Print("<b>ConsolaCW</b> lista. Escribe <color=#7fd>help</color> para ver los comandos.");
		}

		public static void Print(string msg)
		{
			if (!((Object)(object)Instance == (Object)null))
			{
				Instance.lines.Add(msg);
				if (Instance.lines.Count > 400)
				{
					Instance.lines.RemoveRange(0, Instance.lines.Count - 400);
				}
				Instance.scroll.y = float.MaxValue;
			}
		}

		public static void Clear()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Instance.lines.Clear();
			}
		}

		private void SetOpen(bool open)
		{
			IsOpen = open;
			focusInput = open;
			if (!open)
			{
				input = "";
			}
		}

		private void Update()
		{
			if (!Discarded.Loaded && Time.realtimeSinceStartup > 5f)
			{
				try
				{
					Discarded.Load();
					Commands.ResetMonsterCache();
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Descartados: " + ex.Message));
				}
				try
				{
					WeaponCompat.Patch(Plugin.HarmonyInstance);
				}
				catch (Exception ex2)
				{
					Plugin.Log.LogWarning((object)("Compat armas: " + ex2.Message));
				}
			}
			if (Discarded.Loaded && !SkateCompat.Done)
			{
				try
				{
					SkateCompat.Apply();
				}
				catch (Exception ex3)
				{
					SkateCompat.Done = true;
					Plugin.Log.LogWarning((object)("CW Skate compat: " + ex3.Message));
				}
			}
			if (Discarded.Loaded && !MonsterSpawnerCompat.Done && Time.realtimeSinceStartup > nextCompatTry)
			{
				nextCompatTry = Time.realtimeSinceStartup + 3f;
				try
				{
					MonsterSpawnerCompat.Apply();
				}
				catch (Exception ex4)
				{
					MonsterSpawnerCompat.Done = true;
					Plugin.Log.LogWarning((object)("Monster Spawner compat: " + ex4));
				}
			}
			if (!cheatsBroken)
			{
				try
				{
					Cheats.Tick();
				}
				catch (Exception ex5)
				{
					cheatsBroken = true;
					Plugin.Log.LogWarning((object)("Trucos desactivados en esta versión: " + ex5.Message));
				}
			}
			if (!corpsesBroken)
			{
				try
				{
					Corpses.Tick();
				}
				catch (Exception ex6)
				{
					corpsesBroken = true;
					Plugin.Log.LogWarning((object)("Cadáveres desactivados en esta versión: " + ex6.Message));
				}
			}
			if (!fightBroken)
			{
				try
				{
					Infighting.Tick();
				}
				catch (Exception ex7)
				{
					fightBroken = true;
					Plugin.Log.LogWarning((object)("Peleas/vida desactivadas: " + ex7));
				}
			}
		}

		private void LateUpdate()
		{
			if (IsOpen)
			{
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}

		private void OnGUI()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0045: Invalid comparison between Unknown and I4
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Expected O, but got Unknown
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: 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)
			Event current = Event.current;
			if ((int)current.type == 4)
			{
				if (current.keyCode == Plugin.ToggleKey.Value)
				{
					SetOpen(!IsOpen);
					current.Use();
					return;
				}
				if (IsOpen && (int)current.keyCode == 27)
				{
					SetOpen(open: false);
					current.Use();
					return;
				}
			}
			try
			{
				HealthBars.Draw();
			}
			catch (Exception ex)
			{
				HealthBars.Enabled = false;
				Plugin.Log.LogWarning((object)("Barras de vida desactivadas: " + ex.Message));
			}
			HitMarker.Draw();
			if (IsOpen)
			{
				if (logStyle == null)
				{
					logStyle = new GUIStyle(GUI.skin.label);
					logStyle.richText = true;
					logStyle.wordWrap = true;
					logStyle.fontSize = 13;
					inputStyle = new GUIStyle(GUI.skin.textField);
					inputStyle.fontSize = 15;
					inputStyle.alignment = (TextAnchor)3;
					boxStyle = new GUIStyle(GUI.skin.box);
					boxStyle.padding = new RectOffset(6, 6, 4, 4);
					boxStyle.margin = new RectOffset(2, 2, 2, 2);
					chipStyle = new GUIStyle(GUI.skin.button);
					chipStyle.richText = true;
					chipStyle.fontSize = 13;
					chipStyle.padding = new RectOffset(8, 8, 3, 3);
					chipFirstStyle = new GUIStyle(chipStyle);
					chipFirstStyle.fontStyle = (FontStyle)1;
					chipFirstStyle.normal.textColor = new Color(0.5f, 1f, 0.85f);
				}
				if (!windowInit)
				{
					float num = Mathf.Max(600f, (float)Screen.width * 0.85f);
					float num2 = Mathf.Max(320f, (float)Screen.height * 0.42f);
					window = new Rect(((float)Screen.width - num) / 2f, 30f, num, num2);
					windowInit = true;
				}
				GUI.depth = -1000;
				window = GUI.Window(49374, window, new WindowFunction(DrawWindow), string.Concat("ConsolaCW  (", Plugin.ToggleKey.Value, " / Esc para cerrar)"));
			}
		}

		private void RefreshSuggestions()
		{
			if (!(input == lastInput))
			{
				lastInput = input;
				suggestions = Commands.Suggest(input ?? "");
			}
		}

		private void ApplySuggestion(Commands.Suggestion s)
		{
			SetInput(s.Insert);
			focusInput = true;
		}

		private void SetInput(string text)
		{
			input = text ?? "";
			object stateObject = GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
			TextEditor val = (TextEditor)((stateObject is TextEditor) ? stateObject : null);
			if (val != null)
			{
				val.text = input;
				val.MoveTextEnd();
			}
			moveCursorToEnd = true;
		}

		private void LoadHistory()
		{
			try
			{
				if (File.Exists(HistoryFile))
				{
					history.AddRange(from l in File.ReadAllLines(HistoryFile)
						where l.Trim().Length > 0
						select l);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("No se pudo leer el historial: " + ex.Message));
			}
		}

		private void SaveHistory()
		{
			try
			{
				if (history.Count > 200)
				{
					history.RemoveRange(0, history.Count - 200);
				}
				File.WriteAllLines(HistoryFile, history.ToArray());
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("No se pudo guardar el historial: " + ex.Message));
			}
		}

		private void DrawWindow(int id)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Invalid comparison between Unknown and I4
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Invalid comparison between Unknown and I4
			//IL_0481: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Invalid comparison between Unknown and I4
			Event current = Event.current;
			if ((int)current.type == 4 && GUI.GetNameOfFocusedControl() == "cw_input")
			{
				if ((int)current.keyCode == 13 || (int)current.keyCode == 271)
				{
					Submit();
					current.Use();
				}
				else if ((int)current.keyCode == 9)
				{
					RefreshSuggestions();
					if (suggestions.Count > 0)
					{
						ApplySuggestion(suggestions[0]);
					}
					current.Use();
				}
				else if ((int)current.keyCode == 273)
				{
					if (history.Count > 0)
					{
						if (historyIndex < 0)
						{
							draft = input;
							historyIndex = history.Count - 1;
						}
						else if (historyIndex > 0)
						{
							historyIndex--;
						}
						SetInput(history[historyIndex]);
					}
					current.Use();
				}
				else if ((int)current.keyCode == 274)
				{
					if (historyIndex >= 0)
					{
						historyIndex++;
						if (historyIndex >= history.Count)
						{
							historyIndex = -1;
							SetInput(draft ?? "");
						}
						else
						{
							SetInput(history[historyIndex]);
						}
					}
					current.Use();
				}
				else if (current.character == '\t')
				{
					current.Use();
				}
			}
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.BeginHorizontal(boxStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("<b>></b>", logStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(14f) });
			GUI.SetNextControlName("cw_input");
			input = GUILayout.TextField(input ?? "", inputStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(26f)
			});
			if (GUILayout.Button("Enviar", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(70f),
				GUILayout.Height(26f)
			}))
			{
				Submit();
			}
			GUILayout.EndHorizontal();
			RefreshSuggestions();
			GUILayout.BeginVertical(boxStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinHeight(52f) });
			if (suggestions.Count == 0)
			{
				GUILayout.Label("<color=#888>Empieza a escribir para ver comandos parecidos. Tab completa la primera sugerencia.</color>", logStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
			else
			{
				GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
				int num = Mathf.Min(suggestions.Count, 10);
				for (int i = 0; i < num; i++)
				{
					if (GUILayout.Button(suggestions[i].Label, (i == 0) ? chipFirstStyle : chipStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
					{
						ApplySuggestion(suggestions[i]);
					}
				}
				if (suggestions.Count > num)
				{
					GUILayout.Label("<color=#888>+" + (suggestions.Count - num) + " más</color>", logStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
				}
				GUILayout.FlexibleSpace();
				GUILayout.EndHorizontal();
				GUILayout.Label(suggestions[0].Detail, logStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
			GUILayout.EndVertical();
			scroll = GUILayout.BeginScrollView(scroll, boxStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			for (int j = 0; j < lines.Count; j++)
			{
				GUILayout.Label(lines[j], logStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
			if (focusInput)
			{
				GUI.FocusControl("cw_input");
				focusInput = false;
			}
			if (moveCursorToEnd && (int)current.type == 7)
			{
				object stateObject = GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);
				TextEditor val = (TextEditor)((stateObject is TextEditor) ? stateObject : null);
				if (val != null)
				{
					val.text = input;
					val.MoveTextEnd();
				}
				moveCursorToEnd = false;
			}
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
		}

		private void Submit()
		{
			string text = (input ?? "").Trim();
			input = "";
			historyIndex = -1;
			focusInput = true;
			draft = "";
			if (text.Length != 0)
			{
				history.Remove(text);
				history.Add(text);
				SaveHistory();
				Print("<color=#aaa>> " + text + "</color>");
				Commands.Run(text);
			}
		}
	}
	internal static class SurfaceNav
	{
		private static readonly List<NavMeshDataInstance> built = new List<NavMeshDataInstance>();

		private static readonly HashSet<int> builtAgents = new HashSet<int>();

		private static bool hooked;

		private static void Hook()
		{
			if (!hooked)
			{
				hooked = true;
				SceneManager.sceneLoaded += delegate
				{
					Clear();
				};
			}
		}

		public static void Clear()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			foreach (NavMeshDataInstance item in built)
			{
				NavMeshDataInstance current = item;
				if (((NavMeshDataInstance)(ref current)).valid)
				{
					NavMesh.RemoveNavMeshData(current);
				}
			}
			built.Clear();
			builtAgents.Clear();
		}

		private static bool HasNavMesh(int agentType, Vector3 pos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			NavMeshQueryFilter val = default(NavMeshQueryFilter);
			((NavMeshQueryFilter)(ref val)).agentTypeID = agentType;
			((NavMeshQueryFilter)(ref val)).areaMask = -1;
			NavMeshHit val2 = default(NavMeshHit);
			return NavMesh.SamplePosition(pos, ref val2, 6f, val);
		}

		public static int EnsureFor(GameObject prefab, Vector3 pos, bool force)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			Hook();
			HashSet<int> hashSet = new HashSet<int>();
			if ((Object)(object)prefab != (Object)null)
			{
				NavMeshAgent[] componentsInChildren = prefab.GetComponentsInChildren<NavMeshAgent>(true);
				foreach (NavMeshAgent val in componentsInChildren)
				{
					hashSet.Add(val.agentTypeID);
				}
			}
			if (hashSet.Count == 0)
			{
				hashSet.Add(0);
			}
			int num = 0;
			foreach (int item in hashSet)
			{
				if (force || (!builtAgents.Contains(item) && !HasNavMesh(item, pos)))
				{
					Build(item, pos);
					num++;
				}
			}
			return num;
		}

		private static void Build(int agentType, Vector3 center)
		{
			//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_001a: 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_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_0058: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			NavMeshBuildSettings val = NavMesh.GetSettingsByID(agentType);
			if (((NavMeshBuildSettings)(ref val)).agentTypeID != agentType)
			{
				val = NavMesh.GetSettingsByIndex(0);
			}
			Bounds val2 = default(Bounds);
			((Bounds)(ref val2))..ctor(center, new Vector3(220f, 90f, 220f));
			List<NavMeshBuildSource> list = new List<NavMeshBuildSource>();
			int num = -1;
			int num2 = LayerMask.NameToLayer("Player");
			if (num2 >= 0)
			{
				num &= ~(1 << num2);
			}
			NavMeshBuilder.CollectSources(val2, num, (NavMeshCollectGeometry)1, 0, new List<NavMeshBuildMarkup>(), list);
			list.RemoveAll((NavMeshBuildSource s) => (Object)(object)((NavMeshBuildSource)(ref s)).component != (Object)null && (Object)(object)((NavMeshBuildSource)(ref s)).component.GetComponentInParent<Rigidbody>() != (Object)null && !((NavMeshBuildSource)(ref s)).component.GetComponentInParent<Rigidbody>().isKinematic);
			NavMeshData val3 = NavMeshBuilder.BuildNavMeshData(val, list, val2, Vector3.zero, Quaternion.identity);
			if ((Object)(object)val3 == (Object)null)
			{
				throw new Exception("No se pudo generar el NavMesh.");
			}
			NavMeshDataInstance item = NavMesh.AddNavMeshData(val3);
			built.Add(item);
			builtAgents.Add(agentType);
		}
	}
	public class PassiveWander : MonoBehaviour
	{
		private Bot bot;

		private PhotonView view;

		private Vector3 dest;

		private float nextPick;

		private Vector3 lastPos;

		private float stuckFor;

		public static bool IsPassive(Bot b)
		{
			if ((Object)(object)b != (Object)null)
			{
				return (Object)(object)((Component)((Component)b).transform.root).GetComponent<PassiveWander>() != (Object)null;
			}
			return false;
		}

		private void Start()
		{
			bot = ((Component)this).GetComponentInChildren<Bot>(true);
			view = ((Component)this).GetComponentInChildren<PhotonView>(true);
			MonoBehaviour[] componentsInChildren = ((Component)this).GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)this))
				{
					string name = ((object)val).GetType().Name;
					if ((name.StartsWith("Bot_") && name != "Bot_Nav_Navmesh" && name != "Bot_RagdollCharacter") || name.StartsWith("Attacks_"))
					{
						((Behaviour)val).enabled = false;
					}
				}
			}
			PickDestination();
		}

		private void PickDestination()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (((Object)(object)bot != (Object)null) ? G.Center(bot) : ((Component)this).transform.position);
			NavMeshHit val3 = default(NavMeshHit);
			for (int i = 0; i < 10; i++)
			{
				Vector3 val2 = val + new Vector3(Random.Range(-14f, 14f), 0f, Random.Range(-14f, 14f));
				if (NavMesh.SamplePosition(val2, ref val3, 4f, -1))
				{
					dest = ((NavMeshHit)(ref val3)).position;
					break;
				}
			}
			nextPick = Time.time + Random.Range(6f, 12f);
		}

		private void Update()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0099: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)bot == (Object)null) && (!((Object)(object)view != (Object)null) || view.IsMine))
			{
				bot.targetPlayer = null;
				bot.aggro = false;
				bot.attacking = false;
				Vector3 val = dest - G.Center(bot);
				val.y = 0f;
				if (((Vector3)(ref val)).magnitude < 1.5f || Time.time > nextPick)
				{
					PickDestination();
				}
				Vector3 val2 = G.Center(bot) - lastPos;
				if (((Vector3)(ref val2)).sqrMagnitude < 0.0004f)
				{
					stuckFor += Time.deltaTime;
				}
				else
				{
					stuckFor = 0f;
				}
				lastPos = G.Center(bot);
				if (stuckFor > 3f)
				{
					stuckFor = 0f;
					PickDestination();
				}
				G.WorldMoveTo(bot, dest);
				bot.Walk();
			}
		}
	}
	internal static class Discarded
	{
		public static readonly Dictionary<string, GameObject> Templates = new Dictionary<string, GameObject>(StringComparer.OrdinalIgnoreCase);

		private static GameObject holder;

		public static bool Loaded;

		public static string Status = "sin cargar";

		private static string folder;

		public static string Folder
		{
			get
			{
				if (folder != null)
				{
					return folder;
				}
				List<string> list = new List<string>();
				list.Add(Path.Combine(Path.GetDirectoryName(typeof(Plugin).Assembly.Location), "descartados"));
				list.Add(Path.Combine(Path.Combine(Paths.ConfigPath, "ConsolaCW"), "descartados"));
				try
				{
					string[] directories = Directory.GetDirectories(Paths.PluginPath);
					foreach (string path in directories)
					{
						list.Add(Path.Combine(path, "descartados"));
					}
				}
				catch
				{
				}
				foreach (string item in list)
				{
					if (File.Exists(Path.Combine(item, "layout.txt")))
					{
						folder = item;
						return folder;
					}
				}
				folder = list[1];
				return folder;
			}
		}

		public static void Load()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			if (Loaded)
			{
				return;
			}
			Loaded = true;
			string path = Path.Combine(Folder, "layout.txt");
			if (!File.Exists(path))
			{
				Status = "no está la carpeta 'descartados'";
				return;
			}
			GameObject val = Resources.Load<GameObject>("Toolkit_Wisk");
			if ((Object)(object)val == (Object)null)
			{
				Status = "no existe Toolkit_Wisk en esta versión";
				return;
			}
			holder = new GameObject("ConsolaCW_Descartados");
			holder.SetActive(false);
			((Object)holder).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)holder);
			string[] source = File.ReadAllLines(path);
			List<string> list = (from l in source
				where l.Trim().Length > 0
				select l.Split(' ')[1]).Distinct().ToList();
			int num = 0;
			foreach (string variant in list)
			{
				try
				{
					GameObject val2 = Build(val, variant, source.Where((string l) => l.Split(' ').Length > 1 && l.Split(' ')[1] == variant).ToArray());
					Templates[variant] = val2;
					RegisterInPhoton(variant, val2);
					num++;
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("No se pudo armar " + variant + ": " + ex));
				}
			}
			Status = num + " monstruos descartados cargados (" + string.Join(", ", Templates.Keys.ToArray()) + ")";
			Plugin.Log.LogInfo((object)Status);
		}

		private static void RegisterInPhoton(string name, GameObject template)
		{
			IPunPrefabPool prefabPool = PhotonNetwork.PrefabPool;
			DefaultPool val = (DefaultPool)(object)((prefabPool is DefaultPool) ? prefabPool : null);
			if (val != null)
			{
				val.ResourceCache[name] = template;
			}
			else
			{
				Plugin.Log.LogWarning((object)("PrefabPool no es DefaultPool: " + name + " solo se podrá spawnear sin conexión"));
			}
		}

		private static Transform FindDeep(Transform root, string name)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if (((Object)root).name == name)
			{
				return root;
			}
			foreach (Transform item in root)
			{
				Transform root2 = item;
				Transform val = FindDeep(root2, name);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		private static float[] Floats(string[] p, int from, int count)
		{
			float[] array = new float[count];
			for (int i = 0; i < count; i++)
			{
				array[i] = float.Parse(p[from + i], CultureInfo.InvariantCulture);
			}
			return array;
		}

		private static GameObject Build(GameObject wisk, string variant, string[] lines)
		{
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Expected O, but got Unknown
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(wisk, holder.transform);
			((Object)val).name = variant;
			val.SetActive(false);
			Transform val2 = val.transform.Find("Visual");
			if ((Object)(object)val2 == (Object)null)
			{
				throw new Exception("el Toolkit_Wisk no tiene 'Visual'");
			}
			Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true);
			foreach (Transform val3 in componentsInChildren)
			{
				if (((Object)val3).name == "Visp")
				{
					((Component)val3).gameObject.SetActive(false);
				}
			}
			SkinnedMeshRenderer val4 = ((IEnumerable<SkinnedMeshRenderer>)((Component)val2).GetComponentsInChildren<SkinnedMeshRenderer>(true)).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer s) => ((Object)s).name == "BasicBody"));
			if ((Object)(object)val4 == (Object)null)
			{
				throw new Exception("no encontré BasicBody");
			}
			Material sharedMaterial = ((Renderer)val4).sharedMaterial;
			foreach (string text in lines)
			{
				string[] array = text.Trim().Split(' ');
				if (array[0] == "bone")
				{
					Transform val5 = FindDeep(val2, array[2]);
					if ((Object)(object)val5 == (Object)null)
					{
						throw new Exception("hueso padre no encontrado: " + array[2]);
					}
					float[] array2 = Floats(array, 4, 10);
					Transform transform = new GameObject(array[3]).transform;
					transform.SetParent(val5, false);
					transform.localPosition = new Vector3(array2[0], array2[1], array2[2]);
					transform.localRotation = new Quaternion(array2[3], array2[4], array2[5], array2[6]);
					transform.localScale = new Vector3(array2[7], array2[8], array2[9]);
				}
			}
			foreach (string text2 in lines)
			{
				string[] array3 = text2.Trim().Split(' ');
				if (array3[0] == "skin")
				{
					Mesh sharedMesh = MeshFile.Load(Path.Combine(Folder, array3[2]));
					string[] array4 = array3[4].Split(',');
					Transform[] array5 = (Transform[])(object)new Transform[array4.Length];
					for (int num3 = 0; num3 < array4.Length; num3++)
					{
						array5[num3] = FindDeep(val2, array4[num3]);
						if ((Object)(object)array5[num3] == (Object)null)
						{
							throw new Exception("hueso no encontrado: " + array4[num3]);
						}
					}
					val4.sharedMesh = sharedMesh;
					val4.bones = array5;
					if (array3[3] != "-")
					{
						val4.rootBone = FindDeep(val2, array3[3]);
					}
					((Renderer)val4).localBounds = new Bounds(Vector3.zero, Vector3.one * 30f);
					val4.updateWhenOffscreen = true;
				}
				else if (array3[0] == "part")
				{
					Transform val6 = FindDeep(val2, array3[2]);
					if ((Object)(object)val6 == (Object)null)
					{
						throw new Exception("padre no encontrado: " + array3[2]);
					}
					float[] array6 = Floats(array3, 5, 10);
					GameObject val7 = new GameObject(array3[3]);
					val7.transform.SetParent(val6, false);
					val7.transform.localPosition = new Vector3(array6[0], array6[1], array6[2]);
					val7.transform.localRotation = new Quaternion(array6[3], array6[4], array6[5], array6[6]);
					val7.transform.localScale = new Vector3(array6[7], array6[8], array6[9]);
					val7.AddComponent<MeshFilter>().sharedMesh = MeshFile.Load(Path.Combine(Folder, array3[4]));
					((Renderer)val7.AddComponent<MeshRenderer>()).sharedMaterial = sharedMaterial;
					if (array3[3].IndexOf("Blade", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						val7.AddComponent<Spinner>();
					}
				}
			}
			if (variant.IndexOf("Fan", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				val.AddComponent<FanBlower>();
			}
			return val;
		}
	}
	public class Spinner : MonoBehaviour
	{
		public float speed = 720f;

		private void Update()
		{
			((Component)this).transform.Rotate(0f, speed * Time.deltaTime, 0f, (Space)1);
		}
	}
	public class FanBlower : MonoBehaviour
	{
		public static float BlowRange = 14f;

		public static float CloseRange = 4.5f;

		public static float PushForce = 30f;

		public static float BlastForce = 14f;

		public static float ConeAngle = 35f;

		private Bot bot;

		private Player self;

		private PhotonView view;

		private Spinner spinner;

		private Player target;

		private float nextTarget;

		private float nextScan;

		private readonly Dictionary<Player, float> blastCooldown = new Dictionary<Player, float>();

		private readonly List<Player> nearby = new List<Player>();

		private bool Dead
		{
			get
			{
				if ((Object)(object)self != (Object)null && self.data != null)
				{
					return self.data.dead;
				}
				return false;
			}
		}

		private Vector3 Center
		{
			get
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)bot != (Object)null))
				{
					return ((Component)this).transform.position;
				}
				return G.Center(bot);
			}
		}

		private void Start()
		{
			bot = ((Component)this).GetComponentInChildren<Bot>(true);
			self = ((Component)this).GetComponentInChildren<Player>(true);
			view = ((Component)this).GetComponentInChildren<PhotonView>(true);
			spinner = ((Component)this).GetComponentInChildren<Spinner>(true);
			if (!((Object)(object)view == (Object)null) && !view.IsMine)
			{
				return;
			}
			MonoBehaviour[] componentsInChildren = ((Component)this).GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)this))
				{
					string name = ((object)val).GetType().Name;
					if (name.StartsWith("Bot_") && name != "Bot_Nav_Navmesh" && name != "Bot_RagdollCharacter")
					{
						((Behaviour)val).enabled = false;
					}
				}
			}
		}

		private Player NearestPlayer()
		{
			//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)
			if ((Object)(object)PlayerHandler.instance == (Object)null)
			{
				return null;
			}
			Player result = null;
			float num = 70f;
			foreach (Player item in PlayerHandler.instance.playersAlive)
			{
				if (!((Object)(object)item == (Object)null) && !item.ai && item.data != null && !item.data.dead)
				{
					float num2 = Vector3.Distance(G.Center(item), Center);
					if (num2 < num)
					{
						num = num2;
						result = item;
					}
				}
			}
			return result;
		}

		private void Update()
		{
			//IL_0073: 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_0128: 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)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bot == (Object)null || Dead)
			{
				if ((Object)(object)spinner != (Object)null)
				{
					spinner.speed = 0f;
				}
				return;
			}
			if (Time.time > nextTarget)
			{
				target = NearestPlayer();
				nextTarget = Time.time + 0.5f;
			}
			bool flag = (Object)(object)target != (Object)null && Vector3.Distance(G.Center(target), Center) <= BlowRange;
			if ((Object)(object)spinner != (Object)null)
			{
				spinner.speed = Mathf.MoveTowards(spinner.speed, flag ? 2200f : 500f, 1500f * Time.deltaTime);
			}
			if ((Object)(object)view != (Object)null && !view.IsMine)
			{
				return;
			}
			bot.targetPlayer = null;
			bot.aggro = false;
			if ((Object)(object)target == (Object)null)
			{
				bot.StandStill();
				return;
			}
			float num = Vector3.Distance(G.Center(target), Center);
			if (num > BlowRange * 0.8f)
			{
				G.WorldMoveTo(bot, G.Center(target));
				if (num > 30f)
				{
					bot.Run();
				}
				else
				{
					bot.Walk();
				}
			}
			else
			{
				bot.StandStill();
				bot.LookAt(G.Center(target), 4f);
			}
		}

		private void FixedUpdate()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bot == (Object)null || Dead || (Object)(object)target == (Object)null)
			{
				return;
			}
			Vector3 center = Center;
			Vector3 dir = G.Center(target) - center;
			dir.y = 0f;
			if (((Vector3)(ref dir)).sqrMagnitude < 0.01f)
			{
				return;
			}
			((Vector3)(ref dir)).Normalize();
			Player localPlayer = Player.localPlayer;
			if ((Object)(object)localPlayer != (Object)null && !localPlayer.data.dead)
			{
				Blow(localPlayer, center, dir);
			}
			if (Time.time > nextScan)
			{
				nextScan = Time.time + 0.5f;
				nearby.Clear();
				Player[] array = Object.FindObjectsOfType<Player>();
				foreach (Player val in array)
				{
					if ((Object)(object)val != (Object)null && val.ai && (Object)(object)val != (Object)(object)self && val.data != null && !val.data.dead && Vector3.Distance(G.Center(val), center) < BlowRange + 2f)
					{
						nearby.Add(val);
					}
				}
			}
			foreach (Player item in nearby)
			{
				if ((Object)(object)item != (Object)null && item.refs != null && (Object)(object)item.refs.view != (Object)null && item.refs.view.IsMine && !item.data.dead)
				{
					Blow(item, center, dir);
				}
			}
		}

		private void Blow(Player p, Vector3 origin, Vector3 dir)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_00d1: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = G.Center(p) - origin;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude > BlowRange || magnitude < 0.1f)
			{
				return;
			}
			Vector3 val2 = val;
			val2.y = 0f;
			if (Vector3.Angle(dir, val2) > ConeAngle || p.refs == null || (Object)(object)p.refs.ragdoll == (Object)null)
			{
				return;
			}
			Vector3 val3 = ((Vector3)(ref val2)).normalized + Vector3.up * 0.15f;
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			if (magnitude <= CloseRange)
			{
				if (!blastCooldown.TryGetValue(p, out var value) || !(Time.time < value))
				{
					blastCooldown[p] = Time.time + 2.5f;
					G.AddForce(p.refs.ragdoll, normalized * BlastForce + Vector3.up * 4f, (ForceMode)2);
					if ((Object)(object)p == (Object)(object)Player.localPlayer || p.ai)
					{
						G.Fall(p.refs.ragdoll, 1.6f);
					}
				}
			}
			else
			{
				float num = 1f - (magnitude - CloseRange) / (BlowRange - CloseRange);
				G.AddForce(p.refs.ragdoll, normalized * PushForce * Mathf.Lerp(0.35f, 1f, num), (ForceMode)5);
			}
		}
	}
	internal static class MeshFile
	{
		private static readonly Dictionary<string, Mesh> cache = new Dictionary<string, Mesh>();

		public static Mesh Load(string file)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Expected O, but got Unknown
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			if (cache.TryGetValue(file, out var value))
			{
				return value;
			}
			using BinaryReader binaryReader = new BinaryReader(File.OpenRead(file));
			if (new string(binaryReader.ReadChars(4)) != "CWM1")
			{
				throw new Exception("formato inválido: " + file);
			}
			int num = binaryReader.ReadInt32();
			Vector3[] array = (Vector3[])(object)new Vector3[num];
			for (int i = 0; i < num; i++)
			{
				ref Vector3 reference = ref array[i];
				reference = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			int num2 = binaryReader.ReadInt32();
			Vector3[] array2 = (Vector3[])(object)new Vector3[num2];
			for (int j = 0; j < num2; j++)
			{
				ref Vector3 reference2 = ref array2[j];
				reference2 = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			int num3 = binaryReader.ReadInt32();
			Vector2[] array3 = (Vector2[])(object)new Vector2[num3];
			for (int k = 0; k < num3; k++)
			{
				ref Vector2 reference3 = ref array3[k];
				reference3 = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			int num4 = binaryReader.ReadInt32();
			int[][] array4 = new int[num4][];
			for (int l = 0; l < num4; l++)
			{
				int num5 = binaryReader.ReadInt32();
				array4[l] = new int[num5];
				for (int m = 0; m < num5; m++)
				{
					array4[l][m] = binaryReader.ReadInt32();
				}
			}
			int num6 = binaryReader.ReadInt32();
			BoneWeight[] array5 = (BoneWeight[])(object)new BoneWeight[num6];
			for (int n = 0; n < num6; n++)
			{
				BoneWeight val = default(BoneWeight);
				((BoneWeight)(ref val)).boneIndex0 = binaryReader.ReadInt32();
				((BoneWeight)(ref val)).boneIndex1 = binaryReader.ReadInt32();
				((BoneWeight)(ref val)).boneIndex2 = binaryReader.ReadInt32();
				((BoneWeight)(ref val)).boneIndex3 = binaryReader.ReadInt32();
				((BoneWeight)(ref val)).weight0 = binaryReader.ReadSingle();
				((BoneWeight)(ref val)).weight1 = binaryReader.ReadSingle();
				((BoneWeight)(ref val)).weight2 = binaryReader.ReadSingle();
				((BoneWeight)(ref val)).weight3 = binaryReader.ReadSingle();
				array5[n] = val;
			}
			int num7 = binaryReader.ReadInt32();
			Matrix4x4[] array6 = (Matrix4x4[])(object)new Matrix4x4[num7];
			for (int num8 = 0; num8 < num7; num8++)
			{
				Matrix4x4 val2 = default(Matrix4x4);
				for (int num9 = 0; num9 < 4; num9++)
				{
					for (int num10 = 0; num10 < 4; num10++)
					{
						((Matrix4x4)(ref val2))[num9, num10] = binaryReader.ReadSingle();
					}
				}
				array6[num8] = val2;
			}
			Mesh val3 = new Mesh();
			((Object)val3).name = Path.GetFileNameWithoutExtension(file);
			if (num > 65000)
			{
				val3.indexFormat = (IndexFormat)1;
			}
			val3.vertices = array;
			if (num2 == num)
			{
				val3.normals = array2;
			}
			if (num3 == num)
			{
				val3.uv = array3;
			}
			val3.subMeshCount = num4;
			for (int num11 = 0; num11 < num4; num11++)
			{
				val3.SetTriangles(array4[num11], num11);
			}
			if (num6 == num)
			{
				val3.boneWeights = array5;
			}
			if (num7 > 0)
			{
				val3.bindposes = array6;
			}
			if (num2 != num)
			{
				val3.RecalculateNormals();
			}
			val3.RecalculateBounds();
			cache[file] = val3;
			return val3;
		}
	}
	internal static class MonsterDamage
	{
		public static bool Enabled = true;

		public static float HeadshotMult = 3f;

		public static float FallbackHealth = 100f;

		public static float LastClick = -10f;

		private static readonly Dictionary<int, float> hp = new Dictionary<int, float>();

		private static Type mortalityType;

		private static MethodInfo mortalityDamage;

		private static bool searched;

		public static bool SkipHeadshotCheck;

		public static bool HasMortalEnemies
		{
			get
			{
				Find();
				return mortalityType != null;
			}
		}

		public static Type MortalityType
		{
			get
			{
				Find();
				return mortalityType;
			}
		}

		private static int HpKey(Player p)
		{
			PhotonView val = ((p.refs != null) ? p.refs.view : null);
			if (!((Object)(object)val != (Object)null))
			{
				return ((Object)p).GetInstanceID();
			}
			return val.ViewID;
		}

		public static void SetFallbackHp(Player p, float value)
		{
			hp[HpKey(p)] = value;
		}

		public static float GetFallbackHp(Player p)
		{
			if (!hp.TryGetValue(HpKey(p), out var value))
			{
				return Infighting.HpFor(p);
			}
			return value;
		}

		private static void Find()
		{
			if (searched)
			{
				return;
			}
			searched = true;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				Type type = assembly.GetType("MortalEnemies.Mortality", throwOnError: false);
				if (!(type == null))
				{
					mortalityType = type;
					mortalityDamage = type.GetMethod("Damage", new Type[1] { typeof(float) });
					break;
				}
			}
		}

		public static bool Apply(Player p, float damage)
		{
			if (!Enabled || (Object)(object)p == (Object)null || !p.ai || p.data == null || p.data.dead || damage <= 0f)
			{
				return false;
			}
			HealthBars.Hit(p);
			PhotonView val = ((p.refs != null) ? p.refs.view : null);
			int key = HpKey(p);
			if (!hp.TryGetValue(key, out var value))
			{
				value = Infighting.HpFor(p);
			}
			value -= damage;
			hp[key] = value;
			if (value <= 0f && ((Object)(object)val == (Object)null || val.IsMine))
			{
				if ((Object)(object)val != (Object)null && PhotonNetwork.InRoom)
				{
					val.RPC("RPCA_PlayerDie", (RpcTarget)0, new object[0]);
				}
				else
				{
					p.RPCA_PlayerDie();
				}
			}
			return true;
		}

		public static bool IsHeadPart(BodypartType t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			if ((int)t != 4 && (int)t != 3 && (int)t != 18 && (int)t != 19 && (int)t != 20 && (int)t != 21)
			{
				return (int)t == 22;
			}
			return true;
		}

		private static Vector3? HeadPos(Player p)
		{
			//IL_007b: 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 (p.refs != null && (Object)(object)p.refs.ragdoll != (Object)null)
			{
				Bodypart bodypart = G.GetBodypart(p.refs.ragdoll, (BodypartType)4);
				Rigidbody val = (((Object)(object)bodypart != (Object)null) ? G.Rig(bodypart) : null);
				if ((Object)(object)val != (Object)null)
				{
					return val.position;
				}
			}
			if (p.refs != null && (Object)(object)p.refs.headPos != (Object)null)
			{
				return p.refs.headPos.position;
			}
			return null;
		}

		public static bool IsHeadshot(Player target, Vector3? impactPoint)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			if (HeadshotMult <= 0f || (Object)(object)target == (Object)null || !target.ai)
			{
				return false;
			}
			Vector3? val = HeadPos(target);
			if (impactPoint.HasValue && val.HasValue && Vector3.Distance(impactPoint.Value, val.Value) < 0.6f)
			{
				return true;
			}
			if (Time.time - LastClick > 0.35f || (Object)(object)MainCamera.instance == (Object)null)
			{
				return false;
			}
			Transform transform = ((Component)MainCamera.instance).transform;
			RaycastHit[] array = Physics.RaycastAll(transform.position, transform.forward, 500f, -1, (QueryTriggerInteraction)1);
			Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
			RaycastHit[] array2 = array;
			for (int num = 0; num < array2.Length; num++)
			{
				RaycastHit val2 = array2[num];
				Player componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Player>();
				if (!((Object)(object)componentInParent == (Object)(object)Player.localPlayer))
				{
					if ((Object)(object)componentInParent != (Object)(object)target)
					{
						return false;
					}
					Bodypart componentInParent2 = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Bodypart>();
					if ((Object)(object)componentInParent2 != (Object)null && IsHeadPart(componentInParent2.bodypartType))
					{
						return true;
					}
					return val.HasValue && Vector3.Distance(((RaycastHit)(ref val2)).point, val.Value) < 0.45f;
				}
			}
			return false;
		}

		public static void OnHit(Player target, ref float damage, Vector3? impactPoint)
		{
			if (Enabled && !SkipHeadshotCheck && !((Object)(object)target == (Object)null) && target.ai && target.data != null && !target.data.dead && IsHeadshot(target, impactPoint))
			{
				damage *= HeadshotMult;
				HitMarker.Show("HEADSHOT!  x" + HeadshotMult);
			}
		}
	}
	internal static class Infighting
	{
		public static bool Enabled = true;

		public static float Range = 45f;

		public static int MinHp = 100;

		public static int MaxHp = 180;

		private static float nextTick;

		private static readonly HashSet<int> hpInitialized = new HashSet<int>();

		private static PropertyInfo mortMax;

		private static PropertyInfo mortHealth;

		public static readonly HashSet<Bot> Incompatible = new HashSet<Bot>();

		public static bool FightingMonster(Bot b)
		{
			if (!Enabled || (Object)(object)b == (Object)null || (Object)(object)b.targetPlayer == (Object)null || !b.targetPlayer.ai)
			{
				return false;
			}
			if (b.targetPlayer.data == null || b.targetPlayer.data.dead)
			{
				return false;
			}
			PhotonView componentInParent = ((Component)b).GetComponentInParent<PhotonView>();
			if (!((Object)(object)componentInParent == (Object)null))
			{
				return componentInParent.IsMine;
			}
			return true;
		}

		public static float HpFor(Player p)
		{
			int num = ((p.refs != null && (Object)(object)p.refs.view != (Object)null) ? p.refs.view.ViewID : ((Object)p).GetInstanceID());
			int num2 = Math.Max(1, MaxHp - MinHp + 1);
			uint num3 = (uint)(num * -1640531535);
			int num4 = (int)(num3 % (uint)num2);
			return MinHp + num4;
		}

		private static List<Player> Monsters()
		{
			return (from p in Object.FindObjectsOfType<Player>()
				where (Object)(object)p != (Object)null && p.ai && p.data != null && !p.data.dead
				select p).ToList();
		}

		public static void Tick()
		{
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time < nextTick)
			{
				return;
			}
			nextTick = Time.time + 0.5f;
			List<Player> list = Monsters();
			foreach (Player item in list)
			{
				InitHp(item);
			}
			if (!Enabled)
			{
				return;
			}
			foreach (Player item2 in list)
			{
				if (item2.refs == null || (Object)(object)item2.refs.view == (Object)null || !item2.refs.view.IsMine)
				{
					continue;
				}
				Transform root = ((Component)item2).transform.root;
				if ((Object)(object)((Component)root).GetComponent<PassiveWander>() != (Object)null || (Object)(object)((Component)root).GetComponent<FanBlower>() != (Object)null)
				{
					continue;
				}
				Bot componentInChildren = ((Component)root).GetComponentInChildren<Bot>();
				if ((Object)(object)componentInChildren == (Object)null || !((Behaviour)componentInChildren).enabled || Incompatible.Contains(componentInChildren))
				{
					continue;
				}
				if ((Object)(object)((Component)root).GetComponentInChildren<Bot_Drag>(true) != (Object)null)
				{
					Incompatible.Add(componentInChildren);
					continue;
				}
				Player val = null;
				float num = Range;
				foreach (Player item3 in list)
				{
					if (!((Object)(object)item3 == (Object)(object)item2) && !((Object)(object)((Component)item3).transform.root == (Object)(object)root))
					{
						float num2 = Vector3.Distance(G.Center(item3), G.Center(item2));
						if (num2 < num)
						{
							num = num2;
							val = item3;
						}
					}
				}
				if ((Object)(object)val != (Object)null && (Object)(object)componentInChildren.targetPlayer != (Object)(object)val)
				{
					componentInChildren.SetTargetPlayer(val);
					componentInChildren.aggro = true;
				}
			}
		}

		private static void InitHp(Player m)
		{
			int instanceID = ((Object)m).GetInstanceID();
			if (hpInitialized.Contains(instanceID))
			{
				return;
			}
			hpInitialized.Add(instanceID);
			float num = HpFor(m);
			MonsterDamage.SetFallbackHp(m, num);
			Type mortalityType = MonsterDamage.MortalityType;
			if (mortalityType == null)
			{
				return;
			}
			Component componentInChildren = ((Component)((Component)m).transform.root).GetComponentInChildren(mortalityType);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			if (mortMax == null)
			{
				mortMax = mortalityType.GetProperty("MaxHealth");
				mortHealth = mortalityType.GetProperty("Health");
			}
			try
			{
				if (mortMax != null && mortMax.CanWrite)
				{
					mortMax.SetValue(componentInChildren, num, null);
				}
				if (mortHealth != null && mortHealth.CanWrite)
				{
					mortHealth.SetValue(componentInChildren, num, null);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("No se pudo poner vida a " + ((Object)m).name + ": " + ex.Message));
			}
		}

		public static float CurrentHp(Player m)
		{
			return MonsterDamage.GetFallbackHp(m);
		}

		public static void ResetHp()
		{
			hpInitialized.Clear();
		}
	}
	internal static class WeaponCompat
	{
		public static float BatDamage = 30f;

		private static FieldInfo sniperDamageField;

		private static Collider lastBatCollider;

		public static float SniperKnock = 7f;

		public static float SniperFall = 1.6f;

		public static bool SolidBatUnbreakable = true;

		private static FieldInfo batBreakableField;

		public static bool InfiniteWeapons = true;

		private static readonly Dictionary<Type, FieldInfo> batteryFields = new Dictionary<Type, FieldInfo>();

		private static FieldInfo batUsesField;

		private static FieldInfo batMaxUsesField;

		public static void Patch(Harmony h)
		{
			Type type = AccessTools.TypeByName("SniperRifleItemBehaviour");
			if (type != null)
			{
				sniperDamageField = AccessTools.Field(type, "playerDamage");
				TryPatch(h, AccessTools.Method(type, "ApplyBodypartKnockback", (Type[])null, (Type[])null), "SniperBodypartPostfix");
				TryPatch(h, AccessTools.Method(type, "ApplyCulledKnockback", (Type[])null, (Type[])null), "SniperCulledPostfix");
			}
			Type type2 = AccessTools.TypeByName("SurfaceDeathPatch");
			if (type2 != null)
			{
				TryPatch(h, AccessTools.Method(type2, "PlayerDiePatch", (Type[])null, (Type[])null), "SkipUeDeathForMonsters", prefix: true);
			}
			Type type3 = AccessTools.TypeByName("BatBehaviour");
			if (type3 != null)
			{
				TryPatch(h, AccessTools.Method(type3, "ProcessHit", (Type[])null, (Type[])null), "BatProcessHitPrefix", prefix: true);
				TryPatch(h, AccessTools.Method(type3, "OnHitTarget", (Type[])null, (Type[])null), "BatOnHitPostfix");
				batBreakableField = AccessTools.Field(type3, "isBreakable");
				TryPatch(h, AccessTools.Method(type3, "BreakBat", (Type[])null, (Type[])null), "BatBreakPrefix", prefix: true);
				batUsesField = AccessTools.Field(type3, "usesEntry");
				batMaxUsesField = AccessTools.Field(type3, "maxUses");
				TryPatch(h, AccessTools.Method(type3, "ProcessHit", (Type[])null, (Type[])null), "BatInfiniteUsesPrefix", prefix: true);
			}
			string[] array = new string[3] { "SniperRifleItemBehaviour", "FlamethrowerItemBehaviour", "TranqGunItemBehaviour" };
			foreach (string text in array)
			{
				Type type4 = AccessTools.TypeByName(text);
				if (!(type4 == null))
				{
					FieldInfo fieldInfo = AccessTools.Field(type4, "m_batteryEntry");
					if (!(fieldInfo == null))
					{
						batteryFields[type4] = fieldInfo;
						TryPatch(h, AccessTools.Method(type4, "Fire", (Type[])null, (Type[])null), "RefillAfterFire");
						TryPatch(h, AccessTools.Method(type4, "ConfigItem", (Type[])null, (Type[])null), "RefillAfterFire");
					}
				}
			}
		}

		private static void TryPatch(Harmony h, MethodInfo target, string patchName, bool prefix = false)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (target == null)
			{
				return;
			}
			try
			{
				HarmonyMethod val = new HarmonyMethod(typeof(WeaponCompat).GetMethod(patchName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
				if (prefix)
				{
					h.Patch((MethodBase)target, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					h.Patch((MethodBase)target, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				Plugin.Log.LogInfo((object)("Compatibilidad armas: " + target.DeclaringType.Name + "." + target.Name));
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("No se pudo parchear " + target.Name + ": " + ex.Message));
			}
		}

		private static Player Holder(Component item)
		{
			if (!((Object)(object)item != (Object)null))
			{
				return null;
			}
			return item.GetComponentInParent<Player>();
		}

		private static float SniperDamage(object inst)
		{
			try
			{
				if (sniperDamageField != null)
				{
					return Convert.ToSingle(sniperDamageField.GetValue(inst));
				}
			}
			catch
			{
			}
			return 60f;
		}

		private static void HitMonster(Player target, float damage, bool head)
		{
			if ((Object)(object)target == (Object)null || !target.ai || target.data == null || target.data.dead)
			{
				return;
			}
			if (head && MonsterDamage.HeadshotMult > 0f)
			{
				damage *= MonsterDamage.HeadshotMult;
				HitMarker.Show("HEADSHOT!  x" + MonsterDamage.HeadshotMult);
			}
			MonsterDamage.SkipHeadshotCheck = true;
			try
			{
				target.CallTakeDamage(damage);
			}
			finally
			{
				MonsterDamage.SkipHeadshotCheck = false;
			}
		}

		private static bool IsHeadId(Player p, int bodypartId)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Bodypart bodypartFromID = G.GetBodypartFromID(p.refs.ragdoll, bodypartId);
				return (Object)(object)bodypartFromID != (Object)null && MonsterDamage.IsHeadPart(bodypartFromID.bodypartType);
			}
			catch
			{
				return false;
			}
		}

		private static void KnockPlayer(Player hitPlayer, Vector3 dir)
		{
			//IL_004b: 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_0050: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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)
			if (!((Object)(object)hitPlayer == (Object)null) && !hitPlayer.ai && !((Object)(object)hitPlayer == (Object)(object)Player.localPlayer) && hitPlayer.data != null && !hitPlayer.data.dead)
			{
				Vector3 val = ((((Vector3)(ref dir)).sqrMagnitude > 0.001f) ? ((Vector3)(ref dir)).normalized : Vector3.zero);
				G.CallTakeDamageAndAddForceAndFall(hitPlayer, 0f, val * SniperKnock + Vector3.up * 1.5f, SniperFall);
			}
		}

		private static void SniperBodypartPostfix(MonoBehaviour __instance, Player hitPlayer, int primaryBodypartId, Vector3 forceDirection)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Holder((Component)(object)__instance) != (Object)(object)Player.localPlayer))
			{
				if ((Object)(object)hitPlayer != (Object)null && !hitPlayer.ai)
				{
					KnockPlayer(hitPlayer, forceDirection);
				}
				else
				{
					HitMonster(hitPlayer, SniperDamage(__instance), IsHeadId(hitPlayer, primaryBodypartId));
				}
			}
		}

		private static void SniperCulledPostfix(MonoBehaviour __instance, Player hitPlayer, Vector3 forceDirection)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Holder((Component)(object)__instance) != (Object)(object)Player.localPlayer))
			{
				if ((Object)(object)hitPlayer != (Object)null && !hitPlayer.ai)
				{
					KnockPlayer(hitPlayer, forceDirection);
				}
				else
				{
					HitMonster(hitPlayer, SniperDamage(__instance), MonsterDamage.IsHeadshot(hitPlayer, null));
				}
			}
		}

		private static bool SkipUeDeathForMonsters(Player __instance, ref bool __result)
		{
			if ((Object)(object)__instance == (Object)null || !__instance.ai)
			{
				return true;
			}
			__instance.data.dead = true;
			if ((Object)(object)PlayerHandler.instance != (Object)null)
			{
				PlayerHandler.instance.playersAlive.Remove(__instance);
			}
			__result = false;
			return false;
		}

		private static void BatProcessHitPrefix(Collider other)
		{
			lastBatCollider = other;
		}

		private static void RefillAfterFire(MonoBehaviour __instance)
		{
			if (InfiniteWeapons && !((Object)(object)__instance == (Object)null) && batteryFields.TryGetValue(((object)__instance).GetType(), out var value))
			{
				object? value2 = value.GetValue(__instance);
				BatteryEntry val = (BatteryEntry)((value2 is BatteryEntry) ? value2 : null);
				if (val != null && !(val.m_maxCharge <= 0f) && !(val.m_charge >= val.m_maxCharge))
				{
					val.m_charge = val.m_maxCharge;
					((ItemDataEntry)val).SetDirty();
				}
			}
		}

		private static void BatInfiniteUsesPrefix(MonoBehaviour __instance)
		{
			if (!InfiniteWeapons || batUsesField == null)
			{
				return;
			}
			object? value = batUsesField.GetValue(__instance);
			IntEntry val = (IntEntry)((value is IntEntry) ? value : null);
			if (val == null)
			{
				return;
			}
			int num = 10;
			try
			{
				if (batMaxUsesField != null)
				{
					num = (int)batMaxUsesField.GetValue(__instance);
				}
			}
			catch
			{
			}
			if (val.i <= num)
			{
				val.i = num + 1;
				((ItemDataEntry)val).SetDirty();
			}
		}

		private static bool BatBreakPrefix(MonoBehaviour __instance)
		{
			if (InfiniteWeapons)
			{
				return false;
			}
			if (!SolidBatUnbreakable || batBreakableField == null)
			{
				return true;
			}
			bool flag = false;
			try
			{
				return (bool)batBreakableField.GetValue(__instance);
			}
			catch
			{
				return true;
			}
		}

		private static void BatOnHitPostfix(MonoBehaviour __instance, Player hitPlayer)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Holder((Component)(object)__instance) != (Object)(object)Player.localPlayer))
			{
				bool head = false;
				if ((Object)(object)lastBatCollider != (Object)null)
				{
					Bodypart componentInParent = ((Component)lastBatCollider).GetComponentInParent<Bodypart>();
					head = (Object)(object)componentInParent != (Object)null && MonsterDamage.IsHeadPart(componentInParent.bodypartType);
				}
				HitMonster(hitPlayer, BatDamage, head);
			}
		}
	}
	internal static class DamageLimiter
	{
		public static bool Enabled = true;

		public static float Window = 0.4f;

		public static float RepeatFactor = 0.25f;

		public static float PlayerMult = 1f;

		private static readonly Dictionary<int, float> lastHit = new Dictionary<int, float>();

		public static float Filter(Player victim, float damage)
		{
			if ((Object)(object)victim == (Object)null || damage <= 0f)
			{
				return damage;
			}
			if (!victim.ai)
			{
				damage *= PlayerMult;
			}
			if (!Enabled)
			{
				return damage;
			}
			int instanceID = ((Object)victim).GetInstanceID();
			float value;
			bool flag = lastHit.TryGetValue(instanceID, out value) && Time.time - value < Window;
			if (!flag)
			{
				lastHit[instanceID] = Time.time;
			}
			if (!flag)
			{
				return damage;
			}
			return damage * RepeatFactor;
		}
	}
	internal static class MonsterSpawnerCompat
	{
		private const BindingFlags BF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		public static bool Done;

		public static bool InOwnSpawn;

		public static void Apply()
		{
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Expected O, but got Unknown
			if (Done)
			{
				return;
			}
			Type type = AccessTools.TypeByName("MonsterSpawnerMod.Plugin");
			if (type == null)
			{
				Done = true;
				return;
			}
			Object val = Object.FindObjectOfType(type);
			if (val == (Object)null)
			{
				return;
			}
			Done = true;
			FieldInfo field = type.GetField("allMonsters", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			Type nestedType = type.GetNestedType("Monster", BindingFlags.Public | BindingFlags.NonPublic);
			if (field == null || nestedType == null)
			{
				Plugin.Log.LogWarning((object)"Monster Spawner: no reconocí su lista");
			}
			else
			{
				if (!(field.GetValue(val) is Array array))
				{
					return;
				}
				FieldInfo field2 = nestedType.GetField("id", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				FieldInfo field3 = nestedType.GetField("unused", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				int num = 0;
				bool flag = false;
				for (int i = 0; i < array.Length; i++)
				{
					object value = array.GetValue(i);
					string text = field2.GetValue(value) as string;
					if (text != null && text.IndexOf("Infiltrator", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						flag = true;
					}
					if ((bool)field3.GetValue(value) && text != null && (Discarded.Templates.ContainsKey(text) || (Object)(object)Resources.Load<GameObject>(text) != (Object)null))
					{
						field3.SetValue(value, false);
						array.SetValue(value, i);
						num++;
					}
				}
				if (!flag && (Object)(object)Resources.Load<GameObject>("Infiltrator2") != (Object)null)
				{
					try
					{
						object value2 = Activator.CreateInstance(nestedType, "Infiltrator2", "Infiltrator", "Mimic Infiltrator Impostor", 7, false);
						Array array2 = Array.CreateInstance(nestedType, array.Length + 1);
						Array.Copy(array, array2, array.Length);
						array2.SetValue(value2, array.Length);
						Array value3 = array2;
						field.SetValue(val, value3);
					}
					catch (Exception ex)
					{
						Plugin.Log.LogWarning((object)("Monster Spawner: no pude agregar el Infiltrator: " + ex.Message));
					}
				}
				try
				{
					MethodInfo method = typeof(PhotonNetwork).GetMethod("Instantiate", new Type[5]
					{
						typeof(string),
						typeof(Vector3),
						typeof(Quaternion),
						typeof(byte),
						typeof(object[])
					});
					if (method != null)
					{
						Plugin.HarmonyInstance.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(typeof(MonsterSpawnerCompat).GetMethod("AfterInstantiate", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					}
				}
				catch (Exception ex2)
				{
					Plugin.Log.LogWarning((object)("No pude enganchar Instantiate: " + ex2.Message));
				}
				MethodInfo method2 = type.GetMethod("RefreshFiltered", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (method2 != null)
				{
					try
					{
						method2.Invoke(val, null);
					}
					catch
					{
					}
				}
				Plugin.Log.LogInfo((object)("Monster Spawner: " + num + " descartados habilitados" + (flag ? "" : " + Infiltrator agregado")));
			}
		}

		private static void AfterInstantiate(GameObject __result)
		{
			if (InOwnSpawn || (Object)(object)__result == (Object)null || (Object)(object)__result.GetComponentInChildren<Bot_Infiltrator>(true) == (Object)null)
			{
				return;
			}
			try
			{
				Commands.SetupInfiltratorPublic(__result);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Infiltrator: " + ex.Message));
			}
		}
	}
	internal static class SkateCompat
	{
		public static bool Infinite = true;

		public static bool Done;

		public static void Apply()
		{
			Done = true;
			Set(Infinite);
		}

		public static string Set(bool on)
		{
			Type type = AccessTools.TypeByName("CWSkate.SkatePlugin");
			if (type == null)
			{
				return "CW Skate no está instalado";
			}
			int num = 0;
			string[] array = new string[2] { "DevInfiniteFuel", "DevNoWear" };
			foreach (string name in array)
			{
				FieldInfo field = type.GetField(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				ConfigEntryBase val = (ConfigEntryBase)((field != null) ? /*isinst with value type is only supported in some contexts*/: null);
				if (val != null)
				{
					val.BoxedValue = on;
					num++;
				}
			}
			string text = "CW Skate infinito (" + num + "/2 opciones): " + (on ? "ON" : "OFF");
			Plugin.Log.LogInfo((object)text);
			return text;
		}
	}
	internal static class HealthBars
	{
		public static bool Enabled = true;

		public static float ShowSeconds = 6f;

		private static readonly Dictionary<Player, float> shown = new Dictionary<Player, float>();

		private static Texture2D white;

		private static GUIStyle label;

		private static readonly List<Player> remove = new List<Player>();

		public static void Hit(Player p)
		{
			if ((Object)(object)p != (Object)null)
			{
				shown[p] = Time.time;
			}
		}

		private static Vector3 Top(Player p)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (p.refs != null && (Object)(object)p.refs.headPos != (Object)null)
			{
				return p.refs.headPos.position + Vector3.up * 0.9f;
			}
			return G.Center(p) + Vector3.up * 2.2f;
		}

		private static void Rect(Rect r, Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)white);
			GUI.color = color;
		}

		public static void Draw()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0044: 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_0073: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			if (!Enabled || shown.Count == 0)
			{
				return;
			}
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				return;
			}
			if ((Object)(object)white == (Object)null)
			{
				white = new Texture2D(1, 1);
				white.SetPixel(0, 0, Color.white);
				white.Apply();
			}
			if (label == null)
			{
				label = new GUIStyle(GUI.skin.label);
				label.fontSize = 12;
				label.alignment = (TextAnchor)4;
				label.fontStyle = (FontStyle)1;
				label.normal.textColor = Color.white;
			}
			remove.Clear();
			foreach (KeyValuePair<Player, float> item in shown)
			{
				Player key = item.Key;
				float num = Time.time - item.Value;
				if ((Object)(object)key == (Object)null || key.data == null || num > ShowSeconds)
				{
					remove.Add(key);
					continue;
				}
				Vector3 val = main.WorldToScreenPoint(Top(key));
				if (!(val.z <= 0f))
				{
					float z = val.z;
					if (!(z > 60f))
					{
						float num2 = Infighting.HpFor(key);
						float num3 = (key.data.dead ? 0f : Mathf.Clamp(Infighting.CurrentHp(key), 0f, num2));
						float num4 = ((num2 > 0f) ? (num3 / num2) : 0f);
						float num5 = Mathf.Clamp01((ShowSeconds - num) / 1f);
						float num6 = Mathf.Lerp(110f, 50f, z / 60f);
						float num7 = 9f;
						float num8 = val.x - num6 / 2f;
						float num9 = (float)Screen.height - val.y - num7;
						Rect(new Rect(num8 - 1f, num9 - 1f, num6 + 2f, num7 + 2f), new Color(0f, 0f, 0f, 0.75f * num5));
						Rect(new Rect(num8, num9, num6, num7), new Color(0.25f, 0.05f, 0.05f, 0.9f * num5));
						Color c = Color.Lerp(new Color(0.9f, 0.15f, 0.1f), new Color(0.2f, 0.85f, 0.25f), num4);
						c.a = num5;
						Rect(new Rect(num8, num9, num6 * num4, num7), c);
						string text = ((Object)((Component)key).transform.root).name.Replace("(Clone)", "").Trim();
						label.normal.textColor = new Color(1f, 1f, 1f, num5);
						GUI.Label(new Rect(num8 - 40f, num9 - 17f, num6 + 80f, 16f), text + "  " + (key.data.dead ? "muerto" : (Mathf.CeilToInt(num3) + "/" + Mathf.RoundToInt(num2))), label);
					}
				}
			}
			foreach (Player item2 in remove)
			{
				shown.Remove(item2);
			}
		}
	}
	internal static class HitMarker
	{
		private static string text;

		private static float until;

		private static GUIStyle style;

		public static void Show(string t)
		{
			text = t;
			until = Time.time + 1.2f;
		}

		public static void Draw()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			if (text != null && !(Time.time > until))
			{
				if (style == null)
				{
					style = new GUIStyle(GUI.skin.label);
					style.fontSize = 34;
					style.fontStyle = (FontStyle)1;
					style.alignment = (TextAnchor)4;
				}
				float num = Mathf.Clamp01((until - Time.time) / 0.4f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(0f, (float)Screen.height * 0.38f, (float)Screen.width, 60f);
				style.normal.textColor = new Color(0f, 0f, 0f, num * 0.8f);
				GUI.Label(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), text, style);
				style.normal.textColor = new Color(1f, 0.25f, 0.2f, num);
				GUI.Label(val, text, style);
			}
		}
	}
	internal static class Corpses
	{
		public static bool Enabled = true;

		private static float nextScan;

		public static void Tick()
		{
			if (!Enabled || Time.time < nextScan)
			{
				return;
			}
			nextScan = Time.time + 0.4f;
			Player[] array = Object.FindObjectsOfType<Player>();
			foreach (Player val in array)
			{
				if (!((Object)(object)val == (Object)null) && val.ai && val.data != null && val.data.dead && !((Object)(object)((Component)val).GetComponent<Corpse>() != (Object)null))
				{
					((Component)val).gameObject.AddComponent<Corpse>();
				}
			}
		}
	}
	public class Corpse : MonoBehaviour
	{
		private Player player;

		private bool visorDone;

		private void Start()
		{
			player = ((Component)this).GetComponent<Player>();
			MonoBehaviour[] componentsInChildren = ((Component)((Component)this).transform.root).GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null))
				{
					string name = ((object)val).GetType().Name;
					if ((name.StartsWith("Bot_") && name != "Bot_Nav_Navmesh") || name.StartsWith("Attacks_") || name == "Bot" || name == "PassiveWander")
					{
						((Behaviour)val).enabled = false;
					}
				}
			}
			NavMeshAgent componentInChildren = ((Component)((Component)this).transform.root).GetComponentInChildren<NavMeshAgent>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((Behaviour)componentInChildren).enabled = false;
			}
			TurnOffVisor();
		}

		private void FixedUpdate()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || player.data == null)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			if (!player.data.dead)
			{
				Object.Destroy((