Decompiled source of Burrow Wolf v1.0.0

BurrowWolf.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BurrowWolf
{
	internal static class L
	{
		internal const bool EN = true;

		internal const bool BLIND = false;

		private static readonly Dictionary<string, string> Sections = new Dictionary<string, string>
		{
			{ "Prueba", "Testing" },
			{ "Aspecto", "Looks" },
			{ "Aparicion", "Spawning" },
			{ "Caza", "Hunting" },
			{ "Estres", "Stress" },
			{ "Depuracion", "Debug" },
			{ "Sonido", "Sound" }
		};

		private static readonly Dictionary<string, string> Keys = new Dictionary<string, string>
		{
			{ "ModoPrueba", "TestMode" },
			{ "DistanciaPrueba", "TestDistance" },
			{ "ForzarVariante", "ForceVariant" },
			{ "Tamano", "Size" },
			{ "LunasDesierto", "DesertMoons" },
			{ "Probabilidad", "Chance" },
			{ "Sistema", "SpawnSystem" },
			{ "Rareza", "Rarity" },
			{ "MaximoLobos", "MaxWolves" },
			{ "Lunas", "Moons" },
			{ "RadioTerritorio", "TerritoryRadius" },
			{ "RadioPeriferia", "PeripheryRadius" },
			{ "DistanciaNave", "ShipDistance" },
			{ "VelocidadSubterranea", "UndergroundSpeed" },
			{ "AlcanceSalto", "LeapRange" },
			{ "PreparacionSalto", "LeapWindup" },
			{ "Dano", "Damage" },
			{ "Vida", "Health" },
			{ "SegundosRetirada", "RetreatSeconds" },
			{ "RecuperacionMin", "RecoverMin" },
			{ "RecuperacionMax", "RecoverMax" },
			{ "RadioPercepcion", "PerceptionRadius" },
			{ "EscanerEnterrado", "ScanWhileBuried" },
			{ "Multiplicador", "Multiplier" },
			{ "Recuperacion", "Recovery" },
			{ "Lineas", "Lines" },
			{ "Volumen", "Volume" },
			{ "DistanciaAullido", "HowlDistance" }
		};

		internal static string T(string es, string en)
		{
			return en;
		}

		internal static ConfigEntry<T> Bind<T>(ConfigFile c, string section, string key, T def, string descEs, string descEn)
		{
			if (Sections.TryGetValue(section, out var value))
			{
				section = value;
			}
			if (Keys.TryGetValue(key, out var value2))
			{
				key = value2;
			}
			return c.Bind<T>(section, key, def, descEn);
		}
	}
	internal static class Patches
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		private static class StartPatch
		{
			[HarmonyPostfix]
			private static void Postfix(StartOfRound __instance)
			{
				WolfNet.Register();
				if ((Object)(object)((Component)__instance).GetComponent<WolfDirector>() == (Object)null)
				{
					((Component)__instance).gameObject.AddComponent<WolfDirector>();
				}
			}
		}
	}
	internal class WolfDirector : MonoBehaviour
	{
		private bool landedHandled;

		private float landedAt;

		private readonly List<Vector3> pending = new List<Vector3>();

		private float spawnAt;

		private void Update()
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			if (instance.inShipPhase || !instance.shipHasLanded)
			{
				landedHandled = false;
				pending.Clear();
				return;
			}
			if (!landedHandled)
			{
				landedHandled = true;
				landedAt = Time.time;
				try
				{
					WolfTerrain.LogMoonCensus();
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("[BurrowWolf] Censo de suelos: " + ex.Message));
				}
				NetworkManager singleton = NetworkManager.Singleton;
				if ((Object)(object)singleton != (Object)null && singleton.IsServer)
				{
					try
					{
						Decide();
					}
					catch (Exception arg)
					{
						Plugin.Log.LogError((object)$"[BurrowWolf] Error decidiendo territorios: {arg}");
					}
				}
			}
			if (pending.Count <= 0 || !(Time.time >= spawnAt))
			{
				return;
			}
			foreach (Vector3 item in pending)
			{
				RoundManager.Instance.SpawnEnemyGameObject(item, Random.Range(0f, 360f), -1, WolfEnemy.Type);
			}
			Plugin.Log.LogInfo((object)$"[BurrowWolf] {pending.Count} lobo(s) en sus territorios");
			pending.Clear();
		}

		internal static bool MainEntrance(out Vector3 pos)
		{
			//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_0039: 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)
			pos = Vector3.zero;
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
			foreach (EntranceTeleport val in array)
			{
				if ((Object)(object)val != (Object)null && val.isEntranceToBuilding && val.entranceId == 0)
				{
					pos = ((Component)val).transform.position;
					return true;
				}
			}
			return false;
		}

		internal static float RouteDistance(Vector3 p)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_005e: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance?.elevatorTransform == (Object)null || !MainEntrance(out var pos))
			{
				return 999f;
			}
			Vector3 position = instance.elevatorTransform.position;
			Vector3 val = pos - position;
			val.y = 0f;
			Vector3 val2 = p - position;
			val2.y = 0f;
			float num = Mathf.Clamp01(Vector3.Dot(val2, val) / Mathf.Max(0.01f, ((Vector3)(ref val)).sqrMagnitude));
			Vector3 val3 = position + val * num;
			val3.y = p.y;
			Vector3 val4 = p - val3;
			val4.y = 0f;
			return ((Vector3)(ref val4)).magnitude;
		}

		internal static bool RoutePoint(out Vector3 p)
		{
			//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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			p = Vector3.zero;
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance?.elevatorTransform == (Object)null || !MainEntrance(out var pos))
			{
				return false;
			}
			p = Vector3.Lerp(instance.elevatorTransform.position, pos, Random.Range(0.45f, 0.8f));
			return true;
		}

		private static bool MoonAllowed(SelectableLevel lvl)
		{
			if ((Object)(object)lvl == (Object)null || !lvl.planetHasTime || !lvl.spawnEnemiesAndScrap)
			{
				return false;
			}
			string text = Plugin.Moons.Value.Trim();
			if (text.Length == 0)
			{
				return true;
			}
			string text2 = lvl.PlanetName + " " + lvl.sceneName;
			string[] array = text.Split(',');
			for (int i = 0; i < array.Length; i++)
			{
				string text3 = array[i].Trim();
				if (text3.Length > 0 && text2.IndexOf(text3, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}

		private void Decide()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if (!MoonAllowed(instance.currentLevel))
			{
				return;
			}
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if (Plugin.TestMode.Value && (Object)(object)val != (Object)null)
			{
				Vector3 forward = ((Component)val).transform.forward;
				forward.y = 0f;
				((Vector3)(ref forward)).Normalize();
				Vector3 val2 = ((Component)val).transform.position + forward * Mathf.Max(8f, Plugin.TestDistance.Value);
				Vector3 ground = val2;
				for (int i = 0; i < 40 && !WolfTerrain.CanBurrow(val2 + new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)) * (0.6f * (float)i), out ground); i++)
				{
				}
				pending.Add(ground);
				spawnAt = Time.time + 3f;
				Plugin.Log.LogInfo((object)$"[BurrowWolf] Prueba: territorio en {ground}");
			}
			else
			{
				if (Plugin.UseGameSpawns)
				{
					return;
				}
				if (Random.value > Mathf.Clamp01(Plugin.Chance.Value))
				{
					Plugin.Log.LogInfo((object)"[BurrowWolf] Hoy no hay lobos en esta luna");
					return;
				}
				GameObject[] array = RoundManager.Instance?.outsideAINodes;
				if (array == null || array.Length == 0)
				{
					return;
				}
				int num = ((array.Length > 60) ? 3 : ((array.Length <= 30) ? 1 : 2));
				int num2 = Mathf.Clamp(Random.Range(1, num + 1), 1, Mathf.Max(1, Plugin.MaxWolves.Value));
				Vector3 val3 = (((Object)(object)instance.elevatorTransform != (Object)null) ? instance.elevatorTransform.position : Vector3.zero);
				List<(Vector3, float)> list = new List<(Vector3, float)>();
				GameObject[] array2 = array;
				foreach (GameObject val4 in array2)
				{
					if ((Object)(object)val4 == (Object)null)
					{
						continue;
					}
					Vector3 position = val4.transform.position;
					if (Vector3.Distance(position, val3) < Plugin.ShipDistance.Value || !WolfTerrain.CanBurrow(position, out var ground2))
					{
						continue;
					}
					position = ground2;
					Dictionary<string, int> dictionary = WolfTerrain.Census(position, 15f, 5);
					int num3 = 0;
					int num4 = 0;
					int num5 = 0;
					foreach (KeyValuePair<string, int> item4 in dictionary)
					{
						num3 += item4.Value;
						if (WolfTerrain.Diggable(item4.Key))
						{
							num4 += item4.Value;
						}
						if (item4.Key == "Grass")
						{
							num5 += item4.Value;
						}
					}
					if (num3 != 0)
					{
						float num6 = (float)num4 / (float)num3;
						if (!(num6 < 0.6f))
						{
							float num7 = RouteDistance(position);
							list.Add((position, num6 + 0.3f * (float)num5 / (float)num3 + 0.8f * (1f - Mathf.Clamp01(num7 / 45f))));
						}
					}
				}
				if (list.Count == 0)
				{
					Plugin.Log.LogInfo((object)"[BurrowWolf] Sin terreno excavable para un territorio");
					return;
				}
				float num8 = Plugin.TerritoryRadius.Value * 2f;
				for (int k = 0; k < num2; k++)
				{
					Vector3 item = Vector3.zero;
					float num9 = float.MinValue;
					foreach (var item5 in list)
					{
						Vector3 item2 = item5.Item1;
						float item3 = item5.Item2;
						float num10 = float.MaxValue;
						foreach (Vector3 item6 in pending)
						{
							num10 = Mathf.Min(num10, Vector3.Distance(item2, item6));
						}
						float num11 = item3 * Random.Range(0.75f, 1.25f) - ((num10 < num8) ? ((num8 - num10) / num8 * 1.5f) : 0f);
						if (num11 > num9)
						{
							num9 = num11;
							item = item2;
						}
					}
					pending.Add(item);
				}
				spawnAt = Time.time + Random.Range(10f, 40f);
				Plugin.Log.LogInfo((object)string.Format("[BurrowWolf] Hoy hay {0} lobo(s). Territorios: {1}", num2, string.Join(", ", pending)));
			}
		}
	}
	[BepInPlugin("trepidrock.burrowwolf", "Burrow Wolf", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static Plugin Instance;

		internal static ManualLogSource Log;

		internal static string Folder;

		private readonly Harmony harmony = new Harmony("trepidrock.burrowwolf");

		internal static ConfigEntry<bool> TestMode;

		internal static ConfigEntry<float> TestDistance;

		internal static ConfigEntry<string> ForceVariant;

		internal static ConfigEntry<float> Size;

		internal static ConfigEntry<string> DesertMoons;

		internal static ConfigEntry<float> Chance;

		internal static ConfigEntry<float> TerritoryRadius;

		internal static ConfigEntry<float> PeripheryRadius;

		internal static ConfigEntry<float> ShipDistance;

		internal static ConfigEntry<int> MaxWolves;

		internal static ConfigEntry<int> Rarity;

		internal static ConfigEntry<string> SpawnSystem;

		internal static ConfigEntry<string> Moons;

		internal static ConfigEntry<float> UndergroundSpeed;

		internal static ConfigEntry<float> LeapRange;

		internal static ConfigEntry<float> CommitTime;

		internal static ConfigEntry<float> RetreatSeconds;

		internal static ConfigEntry<float> RecoverMin;

		internal static ConfigEntry<float> RecoverMax;

		internal static ConfigEntry<float> PerceptionRadius;

		internal static ConfigEntry<int> Damage;

		internal static ConfigEntry<int> Health;

		internal static ConfigEntry<bool> ScanWhileBuried;

		internal static ConfigEntry<float> StressRate;

		internal static ConfigEntry<float> StressDecay;

		internal static ConfigEntry<bool> DebugLines;

		internal static ConfigEntry<float> Volume;

		internal static ConfigEntry<float> HowlDistance;

		internal static readonly Dictionary<string, List<AudioClip>> Sounds = new Dictionary<string, List<AudioClip>>();

		internal static bool UseGameSpawns
		{
			get
			{
				if (!string.Equals(SpawnSystem.Value.Trim(), "propio", StringComparison.OrdinalIgnoreCase))
				{
					return !string.Equals(SpawnSystem.Value.Trim(), "own", StringComparison.OrdinalIgnoreCase);
				}
				return false;
			}
		}

		private void Awake()
		{
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			ConfigFile config = ((BaseUnityPlugin)this).Config;
			TestMode = L.Bind(config, "Prueba", "ModoPrueba", def: false, "Para probar: al aterrizar aparece un lobo cerca del jugador y recorre sus animaciones y poses de melena. Se apaga solo cada vez que inicias el juego.", "For testing: after landing a wolf appears near the player and cycles through its animations and mane poses. Turns itself off every time you start the game.");
			if (TestMode.Value)
			{
				TestMode.Value = false;
				Log.LogInfo((object)"[BurrowWolf] ModoPrueba estaba activo en la config: se apago al iniciar");
			}
			TestDistance = L.Bind(config, "Prueba", "DistanciaPrueba", 7f, "Distancia (metros) delante del jugador a la que aparece el lobo de prueba.", "Distance (meters) in front of the player where the test wolf appears.");
			ForceVariant = L.Bind(config, "Prueba", "ForzarVariante", "", "Vacio = automatica segun el suelo. Si no: tierra, pasto, nieve, roca o desierto.", "Empty = automatic from the ground. Otherwise: tierra (dirt), pasto (grass), nieve (snow), roca (rock) or desierto (desert).");
			Size = L.Bind(config, "Aspecto", "Tamano", 1.25f, "Escala del lobo (1 = unos 2 m de largo).", "Wolf scale (1 = about 2 m long).");
			if (Mathf.Approximately(Size.Value, 1f))
			{
				Size.Value = 1.25f;
			}
			DesertMoons = L.Bind(config, "Aspecto", "LunasDesierto", "Assurance,Offense", "Lunas desérticas (separadas por coma). Muchas usan el mismo suelo que las rocosas, asi que aqui se indica cuales llevan la variante desierto.", "Desert moons (comma separated). Many share the same ground tag as rocky moons, so this list says which ones use the desert variant.");
			SpawnSystem = L.Bind(config, "Aparicion", "Sistema", "juego", "juego = aparece con el sistema normal de enemigos de exterior (poder 2, usa Rareza). propio = spawner del mod con territorios (usa Probabilidad y MaximoLobos). Requiere reiniciar el juego.", "juego (game) = spawns through the normal outdoor enemy system (power 2, uses Rarity). propio (own) = the mod's own spawner with territories (uses Chance and MaxWolves). Requires a game restart.");
			Rarity = L.Bind(config, "Aparicion", "Rareza", 20, "Peso de aparicion en el sistema del juego (como los demas enemigos de exterior). 0 = nunca. Requiere reiniciar el juego.", "Spawn weight in the game system (like other outdoor enemies). 0 = never. Requires a game restart.");
			Chance = L.Bind(config, "Aparicion", "Probabilidad", 0.35f, "Probabilidad (0 a 1) de que aparezcan lobos cada dia en una luna con exterior.", "Chance (0 to 1) that wolves appear each day on an outdoor moon.");
			MaxWolves = L.Bind(config, "Aparicion", "MaximoLobos", 3, "Maximo de lobos por dia (las lunas grandes pueden tener mas de uno).", "Maximum wolves per day (big moons can have more than one).");
			Moons = L.Bind(config, "Aparicion", "Lunas", "", "Lunas donde puede aparecer, separadas por coma. Vacio = todas las lunas con exterior.", "Moons where it can appear, comma separated. Empty = every outdoor moon.");
			TerritoryRadius = L.Bind(config, "Aparicion", "RadioTerritorio", 25f, "Radio (m) de la zona principal de caza.", "Radius (m) of the main hunting zone.");
			PeripheryRadius = L.Bind(config, "Aparicion", "RadioPeriferia", 45f, "Radio (m) de la zona periferica.", "Radius (m) of the peripheral zone.");
			ShipDistance = L.Bind(config, "Aparicion", "DistanciaNave", 35f, "Distancia minima (m) entre la nave y el centro de un territorio. Tampoco embosca a menos de 14 m de la nave.", "Minimum distance (m) between the ship and a territory center. It also never ambushes within 14 m of the ship.");
			UndergroundSpeed = L.Bind(config, "Caza", "VelocidadSubterranea", 8f, "Velocidad bajo tierra (m/s). Sube un poco con cada impacto.", "Underground speed (m/s). Rises a bit with each hit.");
			LeapRange = L.Bind(config, "Caza", "AlcanceSalto", 8.5f, "Distancia maxima del salto (m).", "Maximum leap distance (m).");
			CommitTime = L.Bind(config, "Caza", "PreparacionSalto", 0.6f, "Segundos con el hocico afuera antes de saltar (baja con el impulso, minimo 0.45).", "Seconds with the snout out before leaping (drops with momentum, minimum 0.45).");
			Damage = L.Bind(config, "Caza", "Dano", 30, "Dano de cada mordida al acertar el salto.", "Damage of each bite when the leap lands.");
			Health = L.Bind(config, "Caza", "Vida", 3, "Golpes de pala para matarlo (solo es vulnerable mientras huye tras fallar).", "Shovel hits to kill it (it is only vulnerable while fleeing after a miss).");
			RetreatSeconds = L.Bind(config, "Caza", "SegundosRetirada", 3f, "Segundos que huye por la superficie tras fallar (vulnerable).", "Seconds it flees on the surface after a miss (vulnerable).");
			RecoverMin = L.Bind(config, "Caza", "RecuperacionMin", 8f, "Recuperacion minima tras fallar (s).", "Minimum recovery after a miss (s).");
			RecoverMax = L.Bind(config, "Caza", "RecuperacionMax", 14f, "Recuperacion maxima tras fallar (s).", "Maximum recovery after a miss (s).");
			PerceptionRadius = L.Bind(config, "Caza", "RadioPercepcion", 40f, "Distancia (m) a la que siente las vibraciones de los pasos.", "Distance (m) at which it feels footstep vibrations.");
			if (Mathf.Approximately(CommitTime.Value, 0.8f))
			{
				CommitTime.Value = 0.6f;
			}
			if (MaxWolves.Value == 2)
			{
				MaxWolves.Value = 3;
			}
			if (Mathf.Approximately(RecoverMin.Value, 12f))
			{
				RecoverMin.Value = 8f;
			}
			if (Mathf.Approximately(RecoverMax.Value, 20f))
			{
				RecoverMax.Value = 14f;
			}
			if (Mathf.Approximately(PerceptionRadius.Value, 32f))
			{
				PerceptionRadius.Value = 40f;
			}
			ScanWhileBuried = L.Bind(config, "Caza", "EscanerEnterrado", def: false, "Si el escaner lo detecta mientras esta enterrado. Apagado = hay que reconocer la cresta a simple vista.", "Whether the scanner detects it while buried. Off = you must recognize the crest by eye.");
			StressRate = L.Bind(config, "Estres", "Multiplicador", 1f, "Multiplica lo rapido que se estresa al ser observado (1 observador = 5/s, maximo 100).", "Multiplies how fast it gets stressed while watched (1 watcher = 5/s, max 100).");
			StressDecay = L.Bind(config, "Estres", "Recuperacion", 1.5f, "Estres que pierde por segundo cuando nadie lo mira.", "Stress lost per second when nobody watches it.");
			DebugLines = L.Bind(config, "Depuracion", "Lineas", def: false, "Dibuja el territorio, la prediccion y el salto (solo en el host). Para probar.", "Draws the territory, prediction and leap (host only). For testing.");
			Volume = L.Bind(config, "Sonido", "Volumen", 1f, "Volumen general del lobo (0 a 1).", "Overall wolf volume (0 to 1).");
			HowlDistance = L.Bind(config, "Sonido", "DistanciaAullido", 50f, "El lobo solo aulla si no hay ningun jugador a menos de esta distancia (m). El aullido se oye de muy lejos.", "The wolf only howls if no player is within this distance (m). The howl can be heard from very far.");
			LoadSounds();
			WolfAssets.Init();
			WolfEnemy.Register();
			harmony.PatchAll();
			Log.LogInfo((object)"[BurrowWolf] v1.0.0 cargado");
		}

		private static void LoadSounds()
		{
			List<string> list = new List<string>(Directory.GetFiles(Folder, "*.ogg", SearchOption.AllDirectories));
			list.Sort();
			foreach (string item in list)
			{
				string text = Path.GetFileNameWithoutExtension(item).ToLowerInvariant();
				int num = text.LastIndexOf('_');
				int result;
				string key = ((num > 0 && int.TryParse(text.Substring(num + 1), out result)) ? text.Substring(0, num) : text);
				AudioClip val = LoadClip(item);
				if (!((Object)(object)val == (Object)null))
				{
					if (!Sounds.TryGetValue(key, out var value))
					{
						value = (Sounds[key] = new List<AudioClip>());
					}
					value.Add(val);
				}
			}
			StringBuilder stringBuilder = new StringBuilder();
			foreach (KeyValuePair<string, List<AudioClip>> sound in Sounds)
			{
				stringBuilder.Append($"{sound.Key}={sound.Value.Count} ");
			}
			Log.LogInfo((object)$"[BurrowWolf] Sonidos: {stringBuilder}");
		}

		internal static AudioClip Sound(string key)
		{
			if (!Sounds.TryGetValue(key, out var value) || value.Count <= 0)
			{
				return null;
			}
			return value[Random.Range(0, value.Count)];
		}

		private static AudioClip LoadClip(string path)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Invalid comparison between Unknown and I4
			try
			{
				UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file:///" + path.Replace('\\', '/'), (AudioType)14);
				try
				{
					((DownloadHandlerAudioClip)audioClip.downloadHandler).streamAudio = false;
					UnityWebRequestAsyncOperation val = audioClip.SendWebRequest();
					Stopwatch stopwatch = Stopwatch.StartNew();
					while (!((AsyncOperation)val).isDone && stopwatch.ElapsedMilliseconds < 10000)
					{
						Thread.Sleep(2);
					}
					if ((int)audioClip.result != 1)
					{
						Log.LogError((object)("[BurrowWolf] Error cargando " + path + ": " + audioClip.error));
						return null;
					}
					AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
					((Object)content).name = Path.GetFileNameWithoutExtension(path);
					return content;
				}
				finally
				{
					((IDisposable)audioClip)?.Dispose();
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("[BurrowWolf] Error cargando " + path + ": " + ex.Message));
				return null;
			}
		}

		internal static string FindFile(string name, bool optional = false)
		{
			string text = Path.Combine(Folder, name);
			if (File.Exists(text))
			{
				return text;
			}
			string[] files = Directory.GetFiles(Folder, name, SearchOption.AllDirectories);
			int num = 0;
			if (num < files.Length)
			{
				return files[num];
			}
			if (!optional)
			{
				Log.LogError((object)("[BurrowWolf] No se encontro el archivo " + name));
			}
			return null;
		}
	}
	internal static class WolfAssets
	{
		internal class Clip
		{
			internal string Name;

			internal float Fps;

			internal bool Loop;

			internal int Frames;

			internal Vector3[] Pos;

			internal Quaternion[] Rot;

			internal Vector3[] Scl;

			internal float Length => (float)Frames / Fps;
		}

		internal static Mesh Mesh;

		internal static string[] BoneNames;

		internal static Vector3[] RestPos;

		internal static Quaternion[] RestRot;

		internal static readonly Dictionary<string, Clip> Clips = new Dictionary<string, Clip>();

		internal static readonly string[] Variants = new string[5] { "tierra", "pasto", "nieve", "roca", "desierto" };

		private static readonly Dictionary<string, Material[]> mats = new Dictionary<string, Material[]>();

		private static Texture2D emit;

		internal static readonly Color EyeColor = new Color(0.62f, 0.86f, 1f);

		internal static bool Loaded => (Object)(object)Mesh != (Object)null;

		internal static void Init()
		{
			try
			{
				Load("BurrowWolf.tsk");
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"[BurrowWolf] Error cargando el modelo: {arg}");
			}
		}

		internal static int BoneIndex(string name)
		{
			for (int i = 0; i < BoneNames.Length; i++)
			{
				if (BoneNames[i] == name)
				{
					return i;
				}
			}
			return -1;
		}

		private static string ReadStr(BinaryReader br)
		{
			return Encoding.UTF8.GetString(br.ReadBytes(br.ReadInt32()));
		}

		private static Vector3 V3(BinaryReader br)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
		}

		private static Quaternion Q(BinaryReader br)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new Quaternion(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
		}

		private static void Load(string file)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: 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_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Expected O, but got Unknown
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			string text = Plugin.FindFile(file);
			if (text == null)
			{
				return;
			}
			using BinaryReader binaryReader = new BinaryReader(File.OpenRead(text));
			if (new string(binaryReader.ReadChars(4)) != "TSK1")
			{
				Plugin.Log.LogError((object)("[BurrowWolf] " + file + " no es un modelo valido"));
				return;
			}
			int num = binaryReader.ReadInt32();
			Vector3[] array = (Vector3[])(object)new Vector3[num];
			Vector3[] array2 = (Vector3[])(object)new Vector3[num];
			Vector2[] array3 = (Vector2[])(object)new Vector2[num];
			BoneWeight[] array4 = (BoneWeight[])(object)new BoneWeight[num];
			for (int i = 0; i < num; i++)
			{
				array[i] = V3(binaryReader);
				array2[i] = V3(binaryReader);
				array3[i] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
				byte boneIndex = binaryReader.ReadByte();
				byte boneIndex2 = binaryReader.ReadByte();
				byte boneIndex3 = binaryReader.ReadByte();
				byte boneIndex4 = binaryReader.ReadByte();
				int num2 = i;
				BoneWeight val = default(BoneWeight);
				((BoneWeight)(ref val)).boneIndex0 = boneIndex;
				((BoneWeight)(ref val)).boneIndex1 = boneIndex2;
				((BoneWeight)(ref val)).boneIndex2 = boneIndex3;
				((BoneWeight)(ref val)).boneIndex3 = boneIndex4;
				((BoneWeight)(ref val)).weight0 = binaryReader.ReadSingle();
				((BoneWeight)(ref val)).weight1 = binaryReader.ReadSingle();
				((BoneWeight)(ref val)).weight2 = binaryReader.ReadSingle();
				((BoneWeight)(ref val)).weight3 = binaryReader.ReadSingle();
				array4[num2] = val;
			}
			int num3 = binaryReader.ReadInt32();
			int[][] array5 = new int[num3][];
			for (int j = 0; j < num3; j++)
			{
				int num4 = binaryReader.ReadInt32();
				array5[j] = new int[num4];
				for (int k = 0; k < num4; k++)
				{
					array5[j][k] = binaryReader.ReadInt32();
				}
			}
			int num5 = binaryReader.ReadInt32();
			BoneNames = new string[num5];
			RestPos = (Vector3[])(object)new Vector3[num5];
			RestRot = (Quaternion[])(object)new Quaternion[num5];
			Matrix4x4[] array6 = (Matrix4x4[])(object)new Matrix4x4[num5];
			for (int l = 0; l < num5; l++)
			{
				BoneNames[l] = ReadStr(binaryReader);
				RestPos[l] = V3(binaryReader);
				RestRot[l] = Q(binaryReader);
				int num6 = l;
				Matrix4x4 val2 = Matrix4x4.TRS(RestPos[l], RestRot[l], Vector3.one);
				array6[num6] = ((Matrix4x4)(ref val2)).inverse;
			}
			Mesh val3 = new Mesh
			{
				name = "BurrowWolf"
			};
			if (num > 65000)
			{
				val3.indexFormat = (IndexFormat)1;
			}
			val3.vertices = array;
			val3.normals = array2;
			val3.uv = array3;
			val3.subMeshCount = num3;
			for (int m = 0; m < num3; m++)
			{
				val3.SetTriangles(array5[m], m);
			}
			val3.boneWeights = array4;
			val3.bindposes = array6;
			int num7 = binaryReader.ReadInt32();
			for (int n = 0; n < num7; n++)
			{
				string text2 = ReadStr(binaryReader);
				Vector3[] array7 = (Vector3[])(object)new Vector3[num];
				Vector3[] array8 = (Vector3[])(object)new Vector3[num];
				for (int num8 = 0; num8 < num; num8++)
				{
					array7[num8] = V3(binaryReader);
					array8[num8] = V3(binaryReader);
				}
				val3.AddBlendShapeFrame(text2, 100f, array7, array8, (Vector3[])null);
			}
			val3.RecalculateBounds();
			Mesh = val3;
			int num9 = binaryReader.ReadInt32();
			for (int num10 = 0; num10 < num9; num10++)
			{
				Clip clip = new Clip
				{
					Name = ReadStr(binaryReader),
					Fps = binaryReader.ReadSingle(),
					Loop = (binaryReader.ReadInt32() != 0),
					Frames = binaryReader.ReadInt32()
				};
				int num11 = clip.Frames * num5;
				clip.Pos = (Vector3[])(object)new Vector3[num11];
				clip.Rot = (Quaternion[])(object)new Quaternion[num11];
				clip.Scl = (Vector3[])(object)new Vector3[num11];
				for (int num12 = 0; num12 < num11; num12++)
				{
					clip.Pos[num12] = V3(binaryReader);
					clip.Rot[num12] = Q(binaryReader);
					clip.Scl[num12] = V3(binaryReader);
				}
				Clips[clip.Name] = clip;
			}
			Plugin.Log.LogInfo((object)string.Format("[BurrowWolf] Modelo cargado: {0} vertices, {1} huesos, {2} blend shapes, animaciones: {3}", num, num5, num7, string.Join(", ", Clips.Keys)));
		}

		internal static Material[] Materials(string variant)
		{
			//IL_00b4: 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)
			if (Array.IndexOf(Variants, variant) < 0)
			{
				variant = "tierra";
			}
			if (mats.TryGetValue(variant, out var value))
			{
				return value;
			}
			if ((Object)(object)emit == (Object)null)
			{
				emit = LoadTexture("wolf_emit.png");
			}
			Material val = NewLit("WolfBody_" + variant);
			val.SetTexture("_BaseColorMap", (Texture)(object)LoadTexture("wolf_base_" + variant + ".png"));
			val.SetFloat("_Smoothness", 0.12f);
			val.SetTexture("_EmissiveColorMap", (Texture)(object)emit);
			val.EnableKeyword("_EMISSIVE_COLOR_MAP");
			val.SetFloat("_UseEmissiveIntensity", 0f);
			val.SetColor("_EmissiveColor", Color.white * 1.6f);
			val.SetFloat("_EmissiveExposureWeight", 0.6f);
			Validate(val);
			Material val2 = NewLit("WolfMane_" + variant);
			val2.SetTexture("_BaseColorMap", (Texture)(object)LoadTexture("wolf_mane_" + variant + ".png"));
			val2.SetFloat("_Smoothness", 0.08f);
			val2.SetFloat("_DoubleSidedEnable", 1f);
			val2.SetFloat("_DoubleSidedNormalMode", 0f);
			val2.SetFloat("_CullMode", 0f);
			val2.SetFloat("_CullModeForward", 0f);
			Validate(val2);
			value = (Material[])(object)new Material[2] { val, val2 };
			mats[variant] = value;
			return value;
		}

		private static Material NewLit(string name)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Material val = new Material(Shader.Find("HDRP/Lit"))
			{
				name = name
			};
			val.SetColor("_BaseColor", Color.white);
			return val;
		}

		private static void Validate(Material m)
		{
			try
			{
				HDMaterial.ValidateMaterial(m);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[BurrowWolf] ValidateMaterial fallo en " + ((Object)m).name + ": " + ex.Message));
			}
		}

		private static Texture2D LoadTexture(string file)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, false)
			{
				name = Path.GetFileNameWithoutExtension(file)
			};
			string text = Plugin.FindFile(file);
			if (text != null)
			{
				ImageConversion.LoadImage(val, File.ReadAllBytes(text));
			}
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			val.Apply(true, true);
			return val;
		}
	}
	public class WolfAudio : MonoBehaviour
	{
		private AudioSource sfx;

		private AudioSource ambient;

		private AudioSource stressSrc;

		private AudioSource howl;

		private float ambientTarget;

		private float stressLevel;

		private bool stressExposed = true;

		private string ambientKey;

		private static float Vol => Mathf.Clamp01(Plugin.Volume.Value);

		private AudioSource NewSource(float min, float max, bool loop)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("WolfAudio");
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.localPosition = Vector3.up * 0.4f;
			AudioSource obj = val.AddComponent<AudioSource>();
			obj.playOnAwake = false;
			obj.loop = loop;
			obj.spatialBlend = 1f;
			obj.dopplerLevel = 0f;
			obj.spatialize = false;
			obj.spatializePostEffects = false;
			obj.rolloffMode = (AudioRolloffMode)1;
			obj.minDistance = min;
			obj.maxDistance = max;
			return obj;
		}

		private void Awake()
		{
			sfx = NewSource(2f, 35f, loop: false);
			ambient = NewSource(1f, 9f, loop: true);
			stressSrc = NewSource(1.5f, 18f, loop: true);
			howl = NewSource(25f, 260f, loop: false);
			howl.spread = 60f;
		}

		internal void OneShot(string key, float volume = 1f, float maxDist = 35f)
		{
			AudioClip val = Plugin.Sound(key);
			if (!((Object)(object)val == (Object)null))
			{
				sfx.maxDistance = maxDist;
				sfx.pitch = Random.Range(0.94f, 1.06f);
				sfx.PlayOneShot(val, volume * Vol);
			}
		}

		internal void Ambient(string key, float volume = 0.6f, float maxDist = 9f)
		{
			if (key != ambientKey)
			{
				ambientKey = key;
				AudioClip val = ((key != null) ? Plugin.Sound(key) : null);
				if ((Object)(object)val != (Object)null)
				{
					ambient.clip = val;
					ambient.time = Random.Range(0f, val.length * 0.9f);
					ambient.volume = 0f;
					ambient.Play();
				}
				else
				{
					ambientTarget = 0f;
				}
			}
			if (key != null)
			{
				ambientTarget = volume;
				ambient.maxDistance = maxDist;
			}
		}

		internal void Stress(float s01, bool exposed)
		{
			stressLevel = s01;
			stressExposed = exposed;
		}

		internal void Howl()
		{
			AudioClip val = Plugin.Sound("aullido");
			if (!((Object)(object)val == (Object)null))
			{
				howl.pitch = Random.Range(0.95f, 1.03f);
				howl.PlayOneShot(val, Vol);
			}
		}

		private void Update()
		{
			float deltaTime = Time.deltaTime;
			ambient.volume = Mathf.MoveTowards(ambient.volume, ambientTarget * Vol, deltaTime * 1.5f);
			if (ambient.isPlaying && ambient.volume <= 0.001f && ambientTarget <= 0f)
			{
				ambient.Stop();
			}
			float num = Mathf.Clamp01((stressLevel - 0.3f) / 0.7f);
			if (num > 0.01f && !stressSrc.isPlaying)
			{
				AudioClip val = Plugin.Sound("estres");
				if ((Object)(object)val != (Object)null)
				{
					stressSrc.clip = val;
					stressSrc.Play();
				}
			}
			float num2 = (stressExposed ? (num * 0.9f * Vol) : 0f);
			stressSrc.volume = Mathf.MoveTowards(stressSrc.volume, num2, deltaTime * (stressExposed ? 0.8f : 3f));
			stressSrc.pitch = 0.95f + 0.12f * num;
			if (stressSrc.isPlaying && stressSrc.volume <= 0.001f && num <= 0.01f)
			{
				stressSrc.Stop();
			}
		}

		internal void StopAll()
		{
			ambientTarget = 0f;
			stressLevel = 0f;
		}
	}
	public class WolfEnemy : EnemyAI
	{
		internal enum S
		{
			Burrowed,
			Underground,
			Ambush,
			Commit,
			Leap,
			DigDown,
			Retreat,
			Dead,
			Maul
		}

		private class Track
		{
			internal readonly List<(Vector3 p, float t)> Obs = new List<(Vector3, float)>();

			internal Vector3 LastSample;

			internal float LastSampleTime;

			internal float Speed;

			internal float LastObs
			{
				get
				{
					if (Obs.Count <= 0)
					{
						return -999f;
					}
					return Obs[Obs.Count - 1].t;
				}
			}

			internal Vector3 LastPos
			{
				get
				{
					//IL_002c: Unknown result type (might be due to invalid IL or missing references)
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					if (Obs.Count <= 0)
					{
						return Vector3.zero;
					}
					return Obs[Obs.Count - 1].p;
				}
			}
		}

		internal static EnemyType Type;

		internal static GameObject Prefab;

		internal static readonly List<WolfEnemy> All = new List<WolfEnemy>();

		internal const float BuryDepth = 0.68f;

		internal const float SnoutDepth = 0.4f;

		internal S state;

		internal WolfVisual Visual;

		internal WolfAudio Audio;

		internal Vector3 TerritoryCenter;

		private float stateTime;

		private Vector3 netPos;

		private float netYaw;

		private bool hasNetPos;

		private Vector3 leapFrom;

		private Vector3 leapTo;

		private float leapDur;

		private float leapT0;

		private bool hitThisLeap;

		private bool leapLandedFx;

		private bool localWatching;

		private float nextWatchSend;

		private BoxCollider body;

		private GameObject scanGo;

		private readonly Dictionary<int, Track> tracks = new Dictionary<int, Track>();

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

		private int targetIdx = -1;

		private int fixation = -1;

		private int momentum;

		private float stress;

		private float nextPlan;

		private float ambushPatience;

		private float nextHowl;

		private float nextReplan;

		private float lastOpportunity;

		private float nextDrift;

		private Vector3 lastSeenAny;

		private bool hasSeenAny;

		private int relocateFrom = -1;

		private bool relocatePending;

		private bool retreatFixing;

		private bool rushing;

		private bool digMomentum;

		private bool leapKilled;

		private DeadBodyInfo maulBody;

		private float nextMaulGrowl;

		private Vector3 retreatFrom;

		private Vector3 lastStuckPos;

		private float nextStuckCheck;

		private int stuckChecks;

		private float relocateMin = 6f;

		private float relocateMax = 11f;

		private float nextThink;

		private float nextAttack;

		private float nextPosSync;

		private float nextStressSync;

		private float lastStressSent = -1f;

		private float nextWander;

		private Vector3 dest;

		private bool destIsAmbush;

		private float ambushLimit;

		private float lastTargetDist = 999f;

		private float approachTimer;

		private bool leapHit;

		private int leapVictim = -1;

		private bool impulsive;

		private float hp;

		private float nextNoSpotLog;

		private readonly List<Vector3> route = new List<Vector3>();

		private int routeIdx;

		private float runSpeed;

		private Vector3 skidDir;

		private bool agentRouted;

		private bool inRecoilPlan;

		private const float RecoilTime = 0.4f;

		private float stressNet;

		private Vector3 lastVisPos;

		private float lastVisYaw;

		private float visSpeed;

		private float visYawRate;

		private float nextGlance;

		private float glanceUntil;

		private LineRenderer dbgTerritory;

		private LineRenderer dbgPeriph;

		private LineRenderer dbgPlan;

		private float Scale => Mathf.Max(0.2f, Plugin.Size.Value);

		private float UgSpeed => Plugin.UndergroundSpeed.Value * (1f + 0.12f * (float)momentum) * (rushing ? 1.5f : 1f);

		private float CommitDur => Mathf.Max(0.45f, Plugin.CommitTime.Value - 0.1f * (float)momentum);

		private float PredError => Mathf.Max(0.5f, 1.6f - 0.4f * (float)momentum);

		private float CommitRange => Mathf.Min(Plugin.LeapRange.Value, 6.5f) * Scale;

		private float MaxRunSpeed => 9.5f * Mathf.Sqrt(Scale);

		internal static void Register()
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			Prefab = NetworkPrefabs.CreateNetworkPrefab("BurrowWolf");
			WolfEnemy wolfEnemy = Prefab.AddComponent<WolfEnemy>();
			NavMeshAgent val = Prefab.AddComponent<NavMeshAgent>();
			((Behaviour)val).enabled = false;
			val.speed = 9f;
			val.acceleration = 30f;
			val.angularSpeed = 720f;
			val.radius = 0.6f;
			val.height = 1.2f;
			((EnemyAI)wolfEnemy).agent = val;
			AudioSource val2 = Prefab.AddComponent<AudioSource>();
			val2.playOnAwake = false;
			val2.spatialBlend = 1f;
			((EnemyAI)wolfEnemy).creatureVoice = val2;
			((EnemyAI)wolfEnemy).creatureSFX = val2;
			Transform transform = new GameObject("Eye").transform;
			transform.SetParent(Prefab.transform, false);
			transform.localPosition = new Vector3(0f, 0.6f, 0.9f);
			((EnemyAI)wolfEnemy).eye = transform;
			GameObject val3 = new GameObject("ScanNode")
			{
				layer = 22
			};
			val3.transform.SetParent(Prefab.transform, false);
			val3.transform.localPosition = new Vector3(0f, 0.7f, 0.2f);
			BoxCollider obj = val3.AddComponent<BoxCollider>();
			((Collider)obj).isTrigger = true;
			obj.size = new Vector3(1f, 1f, 2f);
			ScanNodeProperties obj2 = val3.AddComponent<ScanNodeProperties>();
			obj2.headerText = L.T("Lobo Excavador", "Burrow Wolf");
			obj2.subText = "";
			obj2.nodeType = 1;
			obj2.minRange = 1;
			obj2.maxRange = 60;
			obj2.requiresLineOfSight = true;
			obj2.creatureScanID = -1;
			Type = ScriptableObject.CreateInstance<EnemyType>();
			((Object)Type).name = "BurrowWolfType";
			Type.enemyName = L.T("Lobo Excavador", "Burrow Wolf");
			Type.enemyPrefab = Prefab;
			Type.PowerLevel = 2f;
			Type.MaxCount = 3;
			Type.isOutsideEnemy = true;
			Type.isDaytimeEnemy = false;
			Type.canDie = true;
			Type.canBeStunned = false;
			Type.canBeDestroyed = true;
			Type.destroyOnDeath = false;
			Type.canSeeThroughFog = false;
			Type.stunTimeMultiplier = 1f;
			Type.doorSpeedMultiplier = 1f;
			Type.loudnessMultiplier = 1f;
			Type.normalizedTimeInDayToLeave = 1f;
			Type.spawnInGroupsOf = 1;
			Type.probabilityCurve = AnimationCurve.Constant(0f, 1f, 1f);
			Type.numberSpawnedFalloff = AnimationCurve.Constant(0f, 1f, 1f);
			Type.audioClips = (AudioClip[])(object)new AudioClip[0];
			Type.miscAnimations = (MiscAnimation[])(object)new MiscAnimation[0];
			((EnemyAI)wolfEnemy).enemyType = Type;
			((EnemyAI)wolfEnemy).enemyHP = 3;
			((EnemyAI)wolfEnemy).AIIntervalTime = 0.2f;
			((EnemyAI)wolfEnemy).enemyBehaviourStates = (EnemyBehaviourState[])(object)new EnemyBehaviourState[0];
			((EnemyAI)wolfEnemy).skinnedMeshRenderers = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[0];
			((EnemyAI)wolfEnemy).meshRenderers = (MeshRenderer[])(object)new MeshRenderer[0];
			TerminalNode val4 = ScriptableObject.CreateInstance<TerminalNode>();
			val4.clearPreviousText = true;
			val4.maxCharactersToType = 35;
			val4.creatureName = Type.enemyName;
			val4.displayText = L.T("BURROW WOLF\n\nNivel de peligro según Sigurd: 65%*\n\nNombre científico: Lupus fossor\n\nLos lobos excavadores son mamíferos carnívoros que presentan adaptaciones inusuales para la vida subterránea. Sus extremidades delanteras poseen una musculatura desarrollada y largas garras curvas, capaces de remover grandes cantidades de tierra en poco tiempo. Su característica más distintiva es una gruesa cresta de pelaje irregular que sobresale del suelo cuando permanecen enterrados, confundiéndose fácilmente con la vegetación circundante.\n\nA diferencia de otros cánidos, los lobos excavadores son animales solitarios y altamente territoriales. Pasan gran parte de su vida ocultos bajo tierra, desplazándose entre diferentes puntos de su territorio. Se cree que son capaces de anticipar los movimientos de sus presas, ya que se han registrado ataques en lugares considerablemente alejados de donde fueron detectados por última vez. Rara vez persiguen a sus víctimas por la superficie, prefiriendo realizar saltos repentinos desde el suelo y desaparecer inmediatamente después.\n\nResulta curioso que estos animales parezcan evitar atacar cuando son observados directamente. Sin embargo, la exposición prolongada a la mirada de otros individuos parece provocarles una respuesta de agitación extrema. También se ha observado que, después de herir a una presa, sus ataques posteriores ocurren con intervalos cada vez más cortos. Se desconoce si esto se debe a un aumento de agresividad o a una mayor familiaridad con los movimientos de la víctima.\n\nSi encuentra una formación de pelaje sobresaliendo del suelo, evite acercarse innecesariamente. Golpearla parece obligar al animal a cambiar de posición, aunque no se han observado lesiones durante estos encuentros. Los ejemplares que fallan sus ataques suelen huir por la superficie antes de volver a enterrarse.\n\n", "BURROW WOLF\n\nSigurd's danger level: 65%*\n\nScientific name: Lupus fossor\n\nBurrow wolves are carnivorous mammals with unusual adaptations for life underground. Their forelimbs have well-developed muscles and long curved claws, able to move large amounts of earth in a short time. Their most distinctive feature is a thick crest of irregular fur that sticks out of the ground while they are buried, easily blending in with the surrounding vegetation.\n\nUnlike other canids, burrow wolves are solitary and highly territorial animals. They spend much of their lives hidden underground, moving between different points of their territory. They are believed to be able to anticipate the movements of their prey, since attacks have been recorded in places considerably far from where they were last detected. They rarely chase their victims on the surface, preferring sudden leaps from the ground before disappearing right after.\n\nCuriously, these animals seem to avoid attacking while being watched directly. However, prolonged exposure to the gaze of other individuals appears to trigger an extreme agitation response. It has also been observed that, after wounding a prey, their following attacks happen at ever shorter intervals. It is unknown whether this is due to increased aggression or greater familiarity with the victim's movements.\n\nIf you find a formation of fur sticking out of the ground, avoid getting close unnecessarily. Hitting it seems to force the animal to change position, although no injuries have been observed during these encounters. Specimens that miss their attacks usually flee on the surface before burrowing again.\n\n");
			TerminalKeyword val5 = ScriptableObject.CreateInstance<TerminalKeyword>();
			val5.word = L.T("lobo", "wolf");
			val5.isVerb = false;
			int num = (Plugin.UseGameSpawns ? Mathf.Max(0, Plugin.Rarity.Value) : 0);
			Enemies.RegisterEnemy(Type, num, (LevelTypes)(-1), (SpawnType)2, val4, val5);
			Plugin.Log.LogInfo((object)("[BurrowWolf] Enemigo registrado (aparicion: " + (Plugin.UseGameSpawns ? $"sistema del juego, rareza {num}, poder {Type.PowerLevel}" : "spawner propio") + ")"));
		}

		internal static WolfEnemy Find(ulong id)
		{
			foreach (WolfEnemy item in All)
			{
				if ((Object)(object)item != (Object)null && ((NetworkBehaviour)item).NetworkObjectId == id)
				{
					return item;
				}
			}
			return null;
		}

		public override void Start()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				((EnemyAI)this).Start();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("[BurrowWolf] EnemyAI.Start: " + ex.Message));
			}
			All.Add(this);
			if ((Object)(object)base.agent != (Object)null)
			{
				((Behaviour)base.agent).enabled = false;
			}
			Vector3 val = ((Component)this).transform.position;
			if (WolfTerrain.GroundAt(val, out var hit, 3f, 10f))
			{
				val = ((RaycastHit)(ref hit)).point;
			}
			((Component)this).transform.position = val;
			TerritoryCenter = val;
			netPos = val;
			netYaw = ((Component)this).transform.eulerAngles.y;
			string text = WolfTerrain.PickVariant(TerritoryCenter);
			Visual = WolfVisual.Create(((Component)this).transform, text);
			Audio = ((Component)this).gameObject.AddComponent<WolfAudio>();
			Transform obj = ((Component)this).transform.Find("ScanNode");
			scanGo = ((obj != null) ? ((Component)obj).gameObject : null);
			BuildCollider();
			hp = Mathf.Max(1, Plugin.Health.Value);
			base.enemyHP = (int)hp;
			ApplyVisual(S.Burrowed, instant: true);
			if (((NetworkBehaviour)this).IsServer && !WolfTerrain.CanBurrow(((Component)this).transform.position, out var ground) && FindDiggable(((Component)this).transform.position, out var point))
			{
				ground = Flat(point - ((Component)this).transform.position);
				if (((Vector3)(ref ground)).magnitude < 15f)
				{
					((Component)this).transform.position = point;
					TerritoryCenter = point;
					netPos = point;
				}
			}
			if (((NetworkBehaviour)this).IsServer)
			{
				nextAttack = Time.time + 6f;
				nextWander = Time.time + Random.Range(30f, 70f);
				nextHowl = Time.time + Random.Range(40f, 120f);
				lastOpportunity = Time.time;
				SetState(S.Burrowed);
			}
			Plugin.Log.LogInfo((object)$"[BurrowWolf] Lobo aparecio en {((Component)this).transform.position} (host={((NetworkBehaviour)this).IsServer}, variante {text}, territorio {Plugin.TerritoryRadius.Value:0}/{Plugin.PeripheryRadius.Value:0} m)");
		}

		private void BuildCollider()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Visual == (Object)null))
			{
				GameObject val = new GameObject("WolfBody");
				val.layer = 19;
				val.transform.SetParent(Visual.Rig, false);
				body = val.AddComponent<BoxCollider>();
				((Collider)body).isTrigger = true;
				body.center = new Vector3(0f, 0.6f, 0.1f);
				body.size = new Vector3(0.9f, 0.9f, 1.9f);
				Rigidbody obj = val.AddComponent<Rigidbody>();
				obj.isKinematic = true;
				obj.useGravity = false;
				val.AddComponent<EnemyAICollisionDetect>().mainScript = (EnemyAI)(object)this;
			}
		}

		public override void OnDestroy()
		{
			ReleaseBody();
			All.Remove(this);
			ClearDebug();
			try
			{
				((EnemyAI)this).OnDestroy();
			}
			catch
			{
			}
		}

		public override void DoAIInterval()
		{
		}

		public override void Update()
		{
			if (!((Object)(object)Visual == (Object)null))
			{
				stateTime += Time.deltaTime;
				if (((NetworkBehaviour)this).IsServer)
				{
					ServerUpdate();
				}
				else
				{
					ClientMove();
				}
				LocalWatch();
				if (state == S.Leap)
				{
					UpdateLeapPose();
				}
				if (state == S.Retreat)
				{
					RetreatVisuals();
					return;
				}
				if (state == S.Maul)
				{
					MaulVisuals();
					return;
				}
				Visual.RollTarget = 0f;
				Visual.LookYawTarget = 0f;
				Visual.LookSpeed = 160f;
			}
		}

		private void SetState(S s, int target = -1)
		{
			//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)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			WolfNet.Broadcast(new WolfNet.Packet
			{
				Type = WolfNet.M.State,
				Id = ((NetworkBehaviour)this).NetworkObjectId,
				A = (int)s,
				B = target,
				V = ((Component)this).transform.position,
				F = ((Component)this).transform.eulerAngles.y
			});
		}

		private void ServerUpdate()
		{
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			if (state == S.Dead)
			{
				return;
			}
			float time = Time.time;
			int num = CountWatchers();
			bool flag = state == S.Burrowed || state == S.Ambush;
			if (num > 0 && flag)
			{
				stress += num switch
				{
					2 => 6f, 
					1 => 5f, 
					_ => 7f, 
				} * Plugin.StressRate.Value * Time.deltaTime;
			}
			else
			{
				stress -= Plugin.StressDecay.Value * Time.deltaTime;
			}
			stress = Mathf.Clamp(stress, 0f, 100f);
			if (time > nextStressSync && Mathf.Abs(stress - lastStressSent) > 2f)
			{
				nextStressSync = time + 0.4f;
				lastStressSent = stress;
				WolfNet.Broadcast(new WolfNet.Packet
				{
					Type = WolfNet.M.Stress,
					Id = ((NetworkBehaviour)this).NetworkObjectId,
					F = stress
				}, unreliable: true);
			}
			if (time > nextThink)
			{
				nextThink = time + 0.2f;
				Perceive();
			}
			if (fixation >= 0)
			{
				PlayerControllerB val = WolfNet.Player(fixation);
				if ((Object)(object)val == (Object)null || val.isPlayerDead || !val.isPlayerControlled)
				{
					Plugin.Log.LogInfo((object)"[BurrowWolf] Fijacion terminada (presa muerta o desconectada). Impulso perdido.");
					fixation = -1;
					momentum = 0;
				}
			}
			if (time > nextHowl)
			{
				nextHowl = time + Random.Range(70f, 160f);
				if (state == S.Burrowed && fixation < 0 && HourOfDay() >= 20f && !PlayerNear(Plugin.HowlDistance.Value))
				{
					WolfNet.Broadcast(new WolfNet.Packet
					{
						Type = WolfNet.M.Howl,
						Id = ((NetworkBehaviour)this).NetworkObjectId
					});
					Plugin.Log.LogInfo((object)"[BurrowWolf] Aullido");
				}
			}
			if (stress >= 100f && (state == S.Burrowed || state == S.Ambush) && stateTime > 0.3f)
			{
				ImpulsiveAttack();
				return;
			}
			switch (state)
			{
			case S.Burrowed:
				ThinkBurrowed();
				break;
			case S.Underground:
				MoveUnderground();
				break;
			case S.Ambush:
				ThinkAmbush();
				break;
			case S.Commit:
				if (stateTime >= CommitDur)
				{
					StartLeap();
				}
				break;
			case S.Leap:
				if (stateTime >= leapDur)
				{
					EndLeap();
				}
				break;
			case S.DigDown:
				if (digMomentum && stateTime < 0.5f)
				{
					float num2 = 1f - stateTime / 0.5f;
					Vector3 val2 = ((Component)this).transform.position + skidDir * (6f * Scale * num2 * num2) * Time.deltaTime;
					if (WolfTerrain.GroundAt(val2, out var hit))
					{
						val2.y = ((RaycastHit)(ref hit)).point.y;
					}
					((Component)this).transform.position = val2;
					SyncPos();
				}
				if (stateTime > 1.6f)
				{
					digMomentum = false;
					Vector3 ground;
					Vector3 point;
					if (relocatePending && BlindSpot(relocateFrom, out var spot))
					{
						relocatePending = false;
						GoUnderground(spot, ambush: false);
					}
					else if (!WolfTerrain.CanBurrow(((Component)this).transform.position, out ground) && FindDiggable(((Component)this).transform.position, out point))
					{
						relocatePending = false;
						GoUnderground(point, ambush: false);
					}
					else
					{
						relocatePending = false;
						SetState(S.Burrowed);
					}
				}
				break;
			case S.Retreat:
				UpdateRetreat();
				break;
			case S.Maul:
				if (stateTime > 2.4f)
				{
					SetState(S.DigDown);
				}
				break;
			}
			DrawDebug();
		}

		private void Perceive()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			float time = Time.time;
			float value = Plugin.PerceptionRadius.Value;
			for (int i = 0; i < instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = instance.allPlayerScripts[i];
				if (!Targetable(val))
				{
					tracks.Remove(i);
					continue;
				}
				if (!tracks.TryGetValue(i, out var value2))
				{
					value2 = new Track
					{
						LastSample = ((Component)val).transform.position,
						LastSampleTime = time
					};
					tracks[i] = value2;
				}
				Vector3 position = ((Component)val).transform.position;
				float num = Mathf.Max(0.05f, time - value2.LastSampleTime);
				Vector3 val2 = position - value2.LastSample;
				val2.y = 0f;
				value2.Speed = Mathf.Lerp(value2.Speed, ((Vector3)(ref val2)).magnitude / num, 0.5f);
				value2.LastSample = position;
				value2.LastSampleTime = time;
				Vector3 val3 = Flat(position - ((Component)this).transform.position);
				float magnitude = ((Vector3)(ref val3)).magnitude;
				float num2 = 0f;
				if (magnitude < value)
				{
					float num3 = value2.Speed / 3.5f * (val.isCrouching ? 0.4f : 1f);
					if (value2.Speed > 0.5f)
					{
						num3 += Mathf.Max(0f, val.carryWeight - 1f) * 0.6f;
					}
					num2 = num3 * (1f - magnitude / value);
				}
				if (magnitude < 7f && value2.Obs.Count > 0 && time - value2.LastObs < 20f)
				{
					num2 = Mathf.Max(num2, 0.5f);
				}
				if (num2 > 0.15f)
				{
					lastSeenAny = position;
					hasSeenAny = true;
					if (ZoneWeight(position, fixedPrey: false) >= 0.5f)
					{
						lastOpportunity = time;
					}
					value2.Obs.Add((position, time));
					if (value2.Obs.Count > 10)
					{
						value2.Obs.RemoveAt(0);
					}
				}
			}
		}

		public override void DetectNoise(Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_00cb: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer || state == S.Dead)
			{
				return;
			}
			Vector3 val = Flat(noisePosition - ((Component)this).transform.position);
			if (((Vector3)(ref val)).magnitude > Plugin.PerceptionRadius.Value * 1.3f)
			{
				return;
			}
			StartOfRound instance = StartOfRound.Instance;
			for (int i = 0; i < instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val2 = instance.allPlayerScripts[i];
				if (Targetable(val2) && !(Vector3.Distance(((Component)val2).transform.position, noisePosition) > 5f))
				{
					if (!tracks.TryGetValue(i, out var value))
					{
						value = new Track
						{
							LastSample = ((Component)val2).transform.position,
							LastSampleTime = Time.time
						};
						tracks[i] = value;
					}
					value.Obs.Add((((Component)val2).transform.position, Time.time));
					if (value.Obs.Count > 10)
					{
						value.Obs.RemoveAt(0);
					}
				}
			}
		}

		private bool BlindSpot(int refPlayer, out Vector3 spot)
		{
			//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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			spot = ((Component)this).transform.position;
			PlayerControllerB val = WolfNet.Player(refPlayer);
			Vector3 val2 = (((Object)(object)val != (Object)null && Targetable(val)) ? ((Component)val).transform.position : ((Component)this).transform.position);
			StartOfRound instance = StartOfRound.Instance;
			float num = float.MinValue;
			bool flag = false;
			Vector3 val6;
			for (int i = 0; i < 28; i++)
			{
				float num2 = Random.Range(0f, 360f);
				float num3 = Random.Range(relocateMin, relocateMax);
				Vector3 p = val2 + Quaternion.Euler(0f, num2, 0f) * Vector3.forward * num3;
				p.y = val2.y;
				if (ZoneWeight(p, fixation >= 0) <= 0f || NearShip(p) || (!WolfTerrain.CanBurrow(p, out var ground) && !WolfTerrain.CanBurrow(p, out ground, relaxed: true)))
				{
					continue;
				}
				float num4 = 180f;
				PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
				foreach (PlayerControllerB val3 in allPlayerScripts)
				{
					if (Targetable(val3))
					{
						Transform val4 = (((Object)(object)val3.gameplayCamera != (Object)null) ? ((Component)val3.gameplayCamera).transform : ((Component)val3).transform);
						Vector3 val5 = Flat(ground - val4.position);
						if (!(((Vector3)(ref val5)).magnitude > 40f))
						{
							num4 = Mathf.Min(num4, Vector3.Angle(Flat(val4.forward), val5));
						}
					}
				}
				float num5 = num4 / 180f * 2f + ZoneWeight(ground, fixedPrey: true) * 0.3f;
				val6 = Flat(ground - ((Component)this).transform.position);
				float num6 = num5 - ((Vector3)(ref val6)).magnitude / 60f;
				if (num6 > num)
				{
					num = num6;
					spot = ground;
					flag = true;
				}
			}
			if (flag)
			{
				ManualLogSource log = Plugin.Log;
				val6 = Flat(spot - val2);
				log.LogInfo((object)$"[BurrowWolf] Punto ciego a {((Vector3)(ref val6)).magnitude:0} m de {Name(refPlayer)}");
			}
			return flag;
		}

		private int NearestPlayer()
		{
			//IL_002d: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			int result = -1;
			float num = float.MaxValue;
			for (int i = 0; i < instance.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = instance.allPlayerScripts[i];
				if (Targetable(val))
				{
					Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						result = i;
					}
				}
			}
			return result;
		}

		private static float HourOfDay()
		{
			TimeOfDay instance = TimeOfDay.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				return 6f + instance.normalizedTimeOfDay * (float)instance.numberOfHours;
			}
			return 0f;
		}

		private bool PlayerNear(float dist)
		{
			//IL_003f: 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)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return false;
			}
			PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead && Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position) < dist)
				{
					return true;
				}
			}
			return false;
		}

		private bool Targetable(PlayerControllerB pl)
		{
			if ((Object)(object)pl != (Object)null && pl.isPlayerControlled && !pl.isPlayerDead && !pl.isInsideFactory && !pl.isInHangarShipRoom)
			{
				return !pl.isInElevator;
			}
			return false;
		}

		private Vector3 Velocity(Track tr)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			if (tr.Obs.Count < 2)
			{
				return Vector3.zero;
			}
			(Vector3, float) tuple = tr.Obs[tr.Obs.Count - 1];
			for (int num = tr.Obs.Count - 2; num >= 0; num--)
			{
				(Vector3, float) tuple2 = tr.Obs[num];
				if (tuple.Item2 - tuple2.Item2 >= 0.4f)
				{
					Vector3 val = (tuple.Item1 - tuple2.Item1) / (tuple.Item2 - tuple2.Item2);
					val.y = 0f;
					if (!(tuple.Item2 - tuple2.Item2 > 2f))
					{
						return val;
					}
					return val * 0.5f;
				}
			}
			return Vector3.zero;
		}

		private Vector3 Predict(Track tr, float ahead)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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)
			return tr.LastPos + Velocity(tr) * (ahead + Time.time - tr.LastObs);
		}

		private float ZoneWeight(Vector3 p, bool fixedPrey)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Flat(p - TerritoryCenter);
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude <= Plugin.TerritoryRadius.Value)
			{
				return 1f;
			}
			if (magnitude <= Plugin.PeripheryRadius.Value)
			{
				if (!fixedPrey)
				{
					return 0.5f;
				}
				return 0.8f;
			}
			if (!fixedPrey)
			{
				return 0.15f;
			}
			return 0.25f;
		}

		private bool NearShip(Vector3 p)
		{
			//IL_001f: 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_0030: 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)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.elevatorTransform == (Object)null)
			{
				return false;
			}
			Vector3 val = Flat(p - instance.elevatorTransform.position);
			return ((Vector3)(ref val)).magnitude < 14f;
		}

		private void ThinkBurrowed()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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)
			if (stateTime < 0.5f || Time.time < nextPlan)
			{
				return;
			}
			nextPlan = Time.time + 0.25f;
			float time = Time.time;
			if (time >= nextAttack && CountWatchers() == 0 && OpportunisticStrike())
			{
				return;
			}
			if (time >= nextAttack && Plan(out var spot))
			{
				GoUnderground(spot, ambush: true);
				return;
			}
			if (fixation < 0 && time - lastOpportunity > 90f && time > nextDrift)
			{
				nextDrift = time + 60f;
				DriftTerritory();
			}
			if (fixation < 0 && time > nextWander)
			{
				nextWander = time + Random.Range(20f, 45f);
				if (FindDiggable(TerritoryCenter + Flat(Random.insideUnitSphere) * Plugin.TerritoryRadius.Value * 0.8f, out var point))
				{
					GoUnderground(point, ambush: false);
				}
			}
		}

		private bool Plan(out Vector3 spot, bool quiet = false)
		{
			//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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			spot = Vector3.zero;
			float time = Time.time;
			int num = -1;
			float num2 = 0f;
			Vector3 val;
			foreach (KeyValuePair<int, Track> track2 in tracks)
			{
				if (fixation >= 0 && track2.Key != fixation)
				{
					continue;
				}
				Track value = track2.Value;
				if (value.Obs.Count == 0 || time - value.LastObs > ((fixation >= 0) ? 6f : 2.5f))
				{
					continue;
				}
				float num3 = ZoneWeight(value.LastPos, fixation >= 0);
				if (!(num3 <= 0f))
				{
					val = Velocity(value);
					float num4 = ((((Vector3)(ref val)).magnitude < 1.5f) ? 1.3f : 1f);
					val = Flat(value.LastPos - ((Component)this).transform.position);
					float num5 = 1f - Mathf.Clamp01(((Vector3)(ref val)).magnitude / (Plugin.PerceptionRadius.Value * 1.5f));
					float num6 = num3 * num4 * (0.3f + num5);
					if (num6 > num2)
					{
						num2 = num6;
						num = track2.Key;
					}
				}
			}
			if (num < 0)
			{
				return false;
			}
			Track track = tracks[num];
			Vector3 val2 = Velocity(track);
			bool flag = fixation >= 0;
			if (((Vector3)(ref val2)).magnitude > 1.2f)
			{
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				Vector3 val3 = Vector3.Cross(Vector3.up, normalized);
				if (Vector3.Dot(val3, ((Component)this).transform.position - track.LastPos) < 0f)
				{
					val3 = -val3;
				}
				for (float num7 = 1.2f; num7 <= 6f; num7 += 0.4f)
				{
					Vector3 val4 = Predict(track, num7) + val3 * Random.Range(2.5f, 4.5f) + Flat(Random.insideUnitSphere) * PredError;
					val = Flat(val4 - ((Component)this).transform.position);
					float num8 = ((Vector3)(ref val)).magnitude / UgSpeed;
					if (!(num8 + 0.7f > num7) && !(ZoneWeight(val4, flag) <= 0f) && !NearShip(val4) && FindDiggable(val4, out spot))
					{
						targetIdx = num;
						if (!quiet)
						{
							Plugin.Log.LogInfo((object)string.Format("[BurrowWolf] Plan: interceptar a {0} (v={1:0.0} m/s) en {2:0.0}s, viaje {3:0.0}s, error {4:0.0} m{5}", Name(num), ((Vector3)(ref val2)).magnitude, num7, num8, PredError, flag ? ", fijada" : ""));
						}
						return true;
					}
				}
				NoSpotWarning(num);
				return false;
			}
			Vector3 lastPos = track.LastPos;
			val = Flat(Random.insideUnitSphere);
			Vector3 val5 = lastPos + ((Vector3)(ref val)).normalized * Random.Range(2.8f, 4.2f);
			if (ZoneWeight(val5, flag) <= 0f || NearShip(val5) || !FindDiggable(val5, out spot))
			{
				NoSpotWarning(num);
				return false;
			}
			targetIdx = num;
			Plugin.Log.LogInfo((object)("[BurrowWolf] Plan: emboscada directa a " + Name(num) + " (lenta o quieta)" + (flag ? ", fijada" : "")));
			return true;
		}

		private void DriftTerritory()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			Vector3 p;
			if (hasSeenAny)
			{
				p = lastSeenAny;
			}
			else if (!WolfDirector.RoutePoint(out p))
			{
				return;
			}
			Vector3 val = Vector3.Lerp(TerritoryCenter, p, 0.5f);
			Vector3 val2 = Flat(val - TerritoryCenter);
			if (!(((Vector3)(ref val2)).magnitude < 6f) && FindDiggable(val, out var point))
			{
				ManualLogSource log = Plugin.Log;
				val2 = Flat(point - TerritoryCenter);
				log.LogInfo((object)string.Format("[BurrowWolf] Sin presas en mucho tiempo: el territorio se desplaza {0:0} m hacia {1}", ((Vector3)(ref val2)).magnitude, hasSeenAny ? "el ultimo rastro" : "el camino de la nave"));
				TerritoryCenter = point;
				lastOpportunity = Time.time;
				GoUnderground(point, ambush: false);
			}
		}

		private bool OpportunisticStrike()
		{
			//IL_0065: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			foreach (KeyValuePair<int, Track> track in tracks)
			{
				if (fixation >= 0 && track.Key != fixation)
				{
					continue;
				}
				Track value = track.Value;
				if (value.Obs.Count == 0 || time - value.LastObs > 0.5f)
				{
					continue;
				}
				Vector3 val = Flat(value.LastPos - ((Component)this).transform.position);
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (!(magnitude > CommitRange * 1.4f))
				{
					Vector3 val2 = Predict(value, CommitDur + 0.28f + Mathf.Min(magnitude, CommitRange) / 27f);
					val = Flat(val2 - ((Component)this).transform.position);
					float magnitude2 = ((Vector3)(ref val)).magnitude;
					if (!(magnitude2 < 1.2f) && !(magnitude2 > CommitRange))
					{
						targetIdx = track.Key;
						impulsive = false;
						Plugin.Log.LogInfo((object)("[BurrowWolf] Oportunidad: " + Name(track.Key) + " pasa cerca, salta desde su escondite"));
						Commit(val2 + Flat(Random.insideUnitSphere) * (PredError * 0.3f));
						return true;
					}
				}
			}
			return false;
		}

		private void NoSpotWarning(int prey)
		{
			if (!(Time.time < nextNoSpotLog))
			{
				nextNoSpotLog = Time.time + 20f;
				Plugin.Log.LogInfo((object)("[BurrowWolf] Detecta a " + Name(prey) + " pero no encuentra un escondite valido cerca de su camino. Rechazos: " + WolfTerrain.RejectSummary()));
			}
		}

		private bool FindDiggable(Vector3 around, out Vector3 point)
		{
			//IL_0089: 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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 2; i++)
			{
				for (int j = 0; j < 14; j++)
				{
					Vector3 p = around + ((j == 0) ? Vector3.zero : (Flat(Random.insideUnitSphere) * (((i == 0) ? 0.8f : 1f) * (float)j)));
					p.y = around.y;
					if (WolfTerrain.CanBurrow(p, out point, i == 1))
					{
						if (!NearShip(point))
						{
							return true;
						}
						WolfTerrain.Rejects[6]++;
					}
				}
			}
			point = around;
			return false;
		}

		private void GoUnderground(Vector3 to, bool ambush)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			dest = to;
			destIsAmbush = ambush;
			if ((Object)(object)base.agent != (Object)null)
			{
				((Behaviour)base.agent).enabled = false;
			}
			SetState(S.Underground, ambush ? targetIdx : (-1));
		}

		private void MoveUnderground()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result