Decompiled source of AutoWalkAround v1.0.2

plugins/AutoWalkAround/AutoWalkAround.dll

Decompiled 14 hours ago
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace AutoWalkAround;

public enum TurnStart
{
	WhenClose,
	Early
}
[BepInPlugin("felih.AutoWalkAround", "Auto Walk Around", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
	public const string GUID = "felih.AutoWalkAround";

	public const string NAME = "Auto Walk Around";

	public const string VERSION = "1.0.2";

	internal static ManualLogSource Log;

	internal static ConfigEntry<bool> Enabled;

	internal static ConfigEntry<KeyboardShortcut> ToggleKey;

	internal static ConfigEntry<TurnStart> StartTurning;

	internal static ConfigEntry<float> LookAhead;

	internal static ConfigEntry<float> MaxTurn;

	internal static ConfigEntry<bool> PauseWhileStrafing;

	internal static ConfigEntry<bool> AvoidCreatures;

	internal static ConfigEntry<bool> AutoJump;

	internal static ConfigEntry<bool> JumpWhenStuck;

	private static int _survives = -1;

	internal static ConfigEntry<bool> AutoSprint;

	internal static ConfigEntry<float> SprintStartPercent;

	internal static ConfigEntry<float> SprintStopPercent;

	internal static ConfigEntry<bool> DetailedLog;

	internal static bool AutoRunSurvivesJump
	{
		get
		{
			if (_survives < 0)
			{
				_survives = (Chainloader.PluginInfos.ContainsKey("Pip.ImprovedAutoRunAndJump") ? 1 : 0);
			}
			return _survives == 1;
		}
	}

	private void Awake()
	{
		//IL_0042: 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_00af: Expected O, but got Unknown
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Expected O, but got Unknown
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Expected O, but got Unknown
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Expected O, but got Unknown
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "Enabled", true, "While auto-running, steer around trees, rocks, fences and walls in your way, then carry on in the same direction.");
		ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("1 - General", "ToggleKey", new KeyboardShortcut((KeyCode)0, (KeyCode[])(object)new KeyCode[0]), "Optional key that turns the steering on and off in game. None = no key.");
		StartTurning = ((BaseUnityPlugin)this).Config.Bind<TurnStart>("2 - Steering", "StartTurning", TurnStart.WhenClose, "WhenClose: keep running until you're right at the obstacle, then go along it until the auto-run direction is clear again. Early: start turning LookAhead metres before the obstacle.");
		LookAhead = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Steering", "LookAhead", 3f, new ConfigDescription("How far ahead to look for obstacles, in metres, when StartTurning is Early.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1.5f, 8f), new object[0]));
		MaxTurn = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Steering", "MaxTurn", 90f, new ConfigDescription("The widest turn used to get around something, in degrees.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 120f), new object[0]));
		PauseWhileStrafing = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - Compatibility", "PauseWhileStrafing", true, "Stop steering while you strafe by hand (with Improved Auto-run and Jump, strafing doesn't end auto-run). Turn off if you never strafe during auto-run.");
		AvoidCreatures = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Steering", "AvoidCreatures", false, "Also steer around creatures and other players. Off by default because moving creatures make the path wobble.");
		AutoJump = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Steering", "AutoJump", false, "Jump over low obstacles (fallen logs, small rocks) instead of going around them. Keep this off unless auto-run survives a jump (Improved Auto-run and Jump does that).");
		JumpWhenStuck = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Steering", "JumpWhenStuck", true, "When you get stuck on something low (a fallen log), jump over it. Only used with Improved Auto-run and Jump installed, since a jump ends the game's own auto-run.");
		AutoSprint = ((BaseUnityPlugin)this).Config.Bind<bool>("4 - Sprint", "AutoSprint", true, "While auto-running, sprint whenever your stamina is full, stop when it runs out, wait for it to fill up again, and repeat.");
		SprintStartPercent = ((BaseUnityPlugin)this).Config.Bind<float>("4 - Sprint", "StartAtPercent", 100f, new ConfigDescription("Stamina (in % of max) needed to start sprinting again.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 100f), new object[0]));
		SprintStopPercent = ((BaseUnityPlugin)this).Config.Bind<float>("4 - Sprint", "StopAtPercent", 0f, new ConfigDescription("Stamina (in % of max) at which sprinting stops. 0 = run until it's empty.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f), new object[0]));
		DetailedLog = ((BaseUnityPlugin)this).Config.Bind<bool>("9 - Debug", "DetailedLog", false, "Writes details to the BepInEx log.");
		new Harmony("felih.AutoWalkAround").PatchAll(typeof(Plugin).Assembly);
		Log.LogInfo((object)"Auto Walk Around 1.0.2 loaded");
	}

	private void Update()
	{
		//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_000d: 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)
		KeyboardShortcut value = ToggleKey.Value;
		if ((int)((KeyboardShortcut)(ref value)).MainKey == 0)
		{
			return;
		}
		KeyboardShortcut value2 = ToggleKey.Value;
		if (((KeyboardShortcut)(ref value2)).IsDown() && (!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) && !Console.IsVisible() && !TextInput.IsVisible())
		{
			Enabled.Value = !Enabled.Value;
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				((Character)Player.m_localPlayer).Message((MessageType)1, "Auto-run steering " + (Enabled.Value ? "on" : "off"), 0, (Sprite)null, false);
			}
		}
	}

	internal static void Debug(string msg)
	{
		if (DetailedLog.Value)
		{
			Log.LogInfo((object)msg);
		}
	}
}
[HarmonyPatch(typeof(Player), "SetControls")]
internal static class SprintCycle
{
	private static bool _sprinting;

	private static bool _wasAuto;

	private static bool _heldOff;

	private static bool _keyWasDown;

	[HarmonyPriority(200)]
	[HarmonyPrefix]
	[HarmonyAfter(new string[] { "Pip.ImprovedAutoRunAndJump" })]
	private static void Prefix(Player __instance, ref bool run, bool ___m_autoRun)
	{
		if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
		{
			return;
		}
		bool flag = RunKeyDown();
		bool flag2 = flag && !_keyWasDown;
		_keyWasDown = flag;
		if (!Plugin.Enabled.Value || !Plugin.AutoSprint.Value || !___m_autoRun || ((Character)__instance).IsAttached() || ((Character)__instance).IsSwimming() || ((Character)__instance).IsDead())
		{
			if (_wasAuto)
			{
				_wasAuto = false;
				_sprinting = false;
				_heldOff = false;
			}
			return;
		}
		_wasAuto = true;
		float maxStamina = ((Character)__instance).GetMaxStamina();
		if (!(maxStamina <= 0f))
		{
			float num = __instance.GetStamina() / maxStamina * 100f;
			if (flag2)
			{
				_sprinting = !_sprinting;
				_heldOff = !_sprinting;
				Plugin.Debug(_sprinting ? "[sprint] your key: sprinting" : "[sprint] your key: stopped, waiting for you");
			}
			else if (!_sprinting && !_heldOff && num >= Plugin.SprintStartPercent.Value - 0.5f)
			{
				_sprinting = true;
				Plugin.Debug("[sprint] stamina full, sprinting");
			}
			else if (_sprinting && (num <= Plugin.SprintStopPercent.Value + 0.5f || num < 1f))
			{
				_sprinting = false;
				Plugin.Debug("[sprint] out of stamina, resting");
			}
			run = _sprinting;
		}
	}

	private static bool RunKeyDown()
	{
		if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus())
		{
			return false;
		}
		if (Console.IsVisible() || Menu.IsVisible() || TextInput.IsVisible() || InventoryGui.IsVisible())
		{
			return false;
		}
		if (!ZInput.GetButton("Run"))
		{
			return ZInput.GetButton("JoyRun");
		}
		return true;
	}
}
[HarmonyPatch(typeof(Player), "SetControls")]
internal static class Steering
{
	private const float CloseDistance = 0.7f;

	private const float WalkableNormalY = 0.6f;

	private static float _angle;

	private static int _side;

	private static float _holdUntil;

	private static float _slowSince = -1f;

	private static float _lastJump;

	private static bool _wasSteering;

	private static int _lastSide;

	private static float _lastSideUntil;

	private static int _stuckCount;

	private static float _lastStuck = -100f;

	private static int _mask;

	private static int _maskWithCreatures;

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

	private static int Mask()
	{
		if (_mask == 0)
		{
			_mask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "vehicle", "viewblock" });
			_maskWithCreatures = _mask | LayerMask.GetMask(new string[3] { "character", "character_net", "character_noenv" });
		}
		if (!Plugin.AvoidCreatures.Value)
		{
			return _mask;
		}
		return _maskWithCreatures;
	}

	[HarmonyAfter(new string[] { "Pip.ImprovedAutoRunAndJump" })]
	[HarmonyPostfix]
	[HarmonyPriority(200)]
	private static void Postfix(Player __instance, Vector3 movedir, bool ___m_autoRun, ref Vector3 ___m_moveDir)
	{
		//IL_0069: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: 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_023c: 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_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
		{
			return;
		}
		if (!Plugin.Enabled.Value || !___m_autoRun || ((Character)__instance).IsAttached() || ((Character)__instance).IsSwimming() || ((Character)__instance).IsDead() || ((Character)__instance).IsTeleporting())
		{
			Reset();
			return;
		}
		if (Plugin.PauseWhileStrafing.Value && Mathf.Abs(movedir.x) > 0.1f)
		{
			Reset();
			return;
		}
		Vector3 val = ___m_moveDir;
		val.y = 0f;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (magnitude < 0.01f)
		{
			Reset();
			return;
		}
		Vector3 val2 = val / magnitude;
		Vector3 position = ((Component)__instance).transform.position;
		float time = Time.time;
		bool flag = Plugin.StartTurning.Value == TurnStart.Early;
		float num = (flag ? Plugin.LookAhead.Value : 0.7f);
		if (Plugin.AutoJump.Value)
		{
			TryJump(__instance, position, val2, time);
		}
		if (Blocked(position, val2, num) && _angle != 0f && !Blocked(position, Turn(val2, _angle), num))
		{
			_holdUntil = time + 0.35f;
		}
		else if (Blocked(position, val2, num))
		{
			float num2 = FindOpening(position, val2, num);
			if (!_wasSteering)
			{
				Plugin.Debug("[steer] obstacle ahead, turning " + num2.ToString("0") + " degrees");
			}
			_angle = num2;
			_side = ((num2 >= 0f) ? 1 : (-1));
			_holdUntil = time + 0.35f;
			_wasSteering = true;
		}
		else if (time > _holdUntil && _angle != 0f)
		{
			float num3 = Mathf.MoveTowards(_angle, 0f, 120f * Time.fixedDeltaTime);
			if (!Blocked(position, Turn(val2, num3), flag ? (num * 0.6f) : num))
			{
				_angle = num3;
			}
			if (_angle == 0f)
			{
				if (_wasSteering)
				{
					Plugin.Debug("[steer] back on course");
				}
				if (_side != 0)
				{
					_lastSide = _side;
					_lastSideUntil = time + 3f;
				}
				_side = 0;
				_wasSteering = false;
			}
		}
		Unstick(__instance, time, position, Turn(val2, _angle));
		if (_angle != 0f)
		{
			___m_moveDir = Turn(val2, _angle) * magnitude + Vector3.up * ___m_moveDir.y;
		}
	}

	private static float FindOpening(Vector3 pos, Vector3 heading, float ahead)
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_0039: 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_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
		float value = Plugin.MaxTurn.Value;
		int num = ((_side != 0) ? _side : ((Time.time < _lastSideUntil) ? _lastSide : 0));
		for (float num2 = 15f; num2 <= value + 0.1f; num2 += 15f)
		{
			if (num != 0)
			{
				if (!Blocked(pos, Turn(heading, num2 * (float)num), ahead))
				{
					return num2 * (float)num;
				}
				continue;
			}
			bool flag = !Blocked(pos, Turn(heading, num2), ahead);
			bool flag2 = !Blocked(pos, Turn(heading, 0f - num2), ahead);
			if (flag && flag2)
			{
				return Clearer(pos, heading, num2, ahead);
			}
			if (flag)
			{
				return num2;
			}
			if (flag2)
			{
				return 0f - num2;
			}
		}
		if (num != 0)
		{
			for (float num3 = 15f; num3 <= value + 0.1f; num3 += 15f)
			{
				if (!Blocked(pos, Turn(heading, (0f - num3) * (float)num), ahead))
				{
					return (0f - num3) * (float)num;
				}
			}
		}
		return (float)((num == 0) ? 1 : num) * value;
	}

	private static float Clearer(Vector3 pos, Vector3 heading, float a, float ahead)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		float num = Room(pos, Turn(heading, a + 15f), Plugin.LookAhead.Value * 1.5f);
		float num2 = Room(pos, Turn(heading, 0f - a - 15f), Plugin.LookAhead.Value * 1.5f);
		if (!(num >= num2))
		{
			return 0f - a;
		}
		return a;
	}

	private static void Unstick(Player p, float now, Vector3 pos, Vector3 moving)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: 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)
		Rigidbody component = ((Component)p).GetComponent<Rigidbody>();
		if ((Object)(object)component == (Object)null)
		{
			return;
		}
		Vector3 linearVelocity = component.linearVelocity;
		linearVelocity.y = 0f;
		if (((Vector3)(ref linearVelocity)).magnitude > 0.6f || !((Character)p).IsOnGround())
		{
			_slowSince = -1f;
		}
		else if (_slowSince < 0f)
		{
			_slowSince = now;
		}
		else
		{
			if (now - _slowSince < 0.6f)
			{
				return;
			}
			_slowSince = -1f;
			_wasSteering = true;
			_stuckCount = ((!(now - _lastStuck < 5f)) ? 1 : (_stuckCount + 1));
			_lastStuck = now;
			if (_stuckCount == 1 && Plugin.JumpWhenStuck.Value && Plugin.AutoRunSurvivesJump && IsLow(pos, moving) && now - _lastJump > 1f)
			{
				_lastJump = now;
				((Character)p).Jump(false);
				Plugin.Debug("[steer] stuck on something low, jumping over it");
				return;
			}
			if (_side == 0)
			{
				_side = ((Room(pos, Turn(moving, 90f), 6f) >= Room(pos, Turn(moving, -90f), 6f)) ? 1 : (-1));
			}
			if (_stuckCount <= 2)
			{
				_angle = (float)_side * Mathf.Min(Plugin.MaxTurn.Value + 30f, 120f);
				_holdUntil = now + 0.8f;
				Plugin.Debug("[steer] stuck, turning harder to the " + ((_side > 0) ? "right" : "left"));
			}
			else
			{
				_side = -_side;
				_angle = (float)_side * Mathf.Min(75f, Plugin.MaxTurn.Value);
				_holdUntil = now + 1.2f;
				_stuckCount = 0;
				Plugin.Debug("[steer] still stuck, trying the " + ((_side > 0) ? "right" : "left"));
			}
		}
	}

	private static bool IsLow(Vector3 pos, Vector3 dir)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		if (Probe(pos + Vector3.up * 0.3f, dir, 1.2f))
		{
			return !Probe(pos + Vector3.up * 1.3f, dir, 1.6f);
		}
		return false;
	}

	private static void TryJump(Player p, Vector3 pos, Vector3 heading, float now)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: 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_0038: 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_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		if (!(now - _lastJump < 1f) && ((Character)p).IsOnGround())
		{
			bool flag = Probe(pos + Vector3.up * 0.3f, heading, 1.2f);
			bool flag2 = Probe(pos + Vector3.up * 1.1f, heading, 1.6f);
			if (flag && !flag2)
			{
				_lastJump = now;
				((Character)p).Jump(false);
				Plugin.Debug("[steer] jumping over a low obstacle");
			}
		}
	}

	private static bool Blocked(Vector3 pos, Vector3 dir, float dist)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		if (!Probe(pos + Vector3.up * 0.7f, dir, dist))
		{
			return Probe(pos + Vector3.up * 1.4f, dir, dist);
		}
		return true;
	}

	private static bool Probe(Vector3 from, Vector3 dir, float dist)
	{
		//IL_0000: 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_003f: Unknown result type (might be due to invalid IL or missing references)
		int num = Physics.SphereCastNonAlloc(from, 0.35f, dir, Hits, dist, Mask(), (QueryTriggerInteraction)1);
		for (int i = 0; i < num; i++)
		{
			if (!(((RaycastHit)(ref Hits[i])).distance <= 0f) && ((RaycastHit)(ref Hits[i])).normal.y < 0.6f)
			{
				return true;
			}
		}
		return false;
	}

	private static float Room(Vector3 pos, Vector3 dir, float dist)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit val = default(RaycastHit);
		if (Physics.SphereCast(pos + Vector3.up * 1f, 0.35f, dir, ref val, dist, Mask(), (QueryTriggerInteraction)1))
		{
			return ((RaycastHit)(ref val)).distance;
		}
		return dist;
	}

	private static Vector3 Turn(Vector3 dir, float degrees)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		return Quaternion.AngleAxis(degrees, Vector3.up) * dir;
	}

	private static void Reset()
	{
		if (_wasSteering)
		{
			Plugin.Debug("[steer] stopped");
		}
		_angle = 0f;
		_side = 0;
		_slowSince = -1f;
		_wasSteering = false;
	}
}