Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LOBBY WARDEN v1.3.0
LobbyWarden.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using LobbyWarden.ExtractionCommander; using LobbyWarden.ExtractionCommander.Patches; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.Localization; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Rehaan")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LobbyWarden")] [assembly: AssemblyTitle("LobbyWarden")] [assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI.")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic (Claude)")] [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 LobbyWarden { internal static class Autopilot { internal enum Job { None, ToPlayer, ToExtraction, ToTruck, OpenExtraction } private enum St { Idle, Planning, Driving, Waiting, BackingUp } private class Held { public Rigidbody Body; public Vector3 Local; public Quaternion Turn; } private const float StepsAimDistance = 0.7f; private const float CrawlPace = 0.9f; private static string _blockerDesc; private static PhysGrabCart _cart; private static Rigidbody _rb; private static PhysGrabObject _pgo; private static int _number; private static float _halfW = 0.62f; private static float _halfL = 1.13f; private static float _height = 1.05f; private static float _bottom = -0.5f; private static List<PhysGrabCart> _cartList = new List<PhysGrabCart>(); private static float _cartListAt = -99f; private static Job _job = Job.None; private static St _st = St.Idle; private static Vector3 _goal; private static Transform _follow; private static PlayerAvatar _followAvatar; private static ExtractionPoint _extraction; private static bool _extInside; private static bool _extPressed; private static readonly HashSet<int> _ignoredObj = new HashSet<int>(); private static float _arrive = 0.8f; private static float _planStart; private static float _lastPlan; private static List<Vector3> _path; private static int _seg; private static float _segT; private static float _offPath; private static float _pathHeight; private static float _rest = float.NaN; private static int _rejected; private static float _failTime; private static Vector3 _failGoal; private static Vector3 _failPos; private static float _followCheck; private static bool _facingBack; private static bool _climbing; private static float _yawCmd; private static float _cmdSpeed; private static float _load; private static float _stall; private static float _stepUp; private static float _nextProbe; private static float _blockedSince; private static float _clearSince; private static float _lastYieldMsg; private static float _reverseUntil; private static float _lastDoor; private static Vector3 _blockerPos; private static bool _blockerAtGoal; private static Vector3 _stuckRef; private static float _stuckRefTime; private static int _reverses; private static Vector3 _reverseDir; private static float _lastDiag; private static float _inLevelFrom = -1f; private static bool _prebaked; private static readonly Collider[] _hits = (Collider[])(object)new Collider[24]; private static bool _slippery; private static bool _posDrive; private static float _unresp; private static float _diagNext; private static float _tripStart; private static Vector3 _diagPos; private static string _notice = ""; private static float _noticeEnd; private static float _hudTotal; private static float _hudRemaining; private static float _hudUntil; private static int _hudMode; private static PlayerAvatar _commandAs; private static GUIStyle _hudText; private const float OpenDistance = 5f; private static float _cargoAt; private static List<Held> _held; private static bool _blockerLiving; private static Collider _blockerCol; private const int MaxPoleFixes = 8; private static int _poleFixes; private static bool _cleanRetry; private static int _movingMask = -1; private static readonly Collider[] _fixedHits = (Collider[])(object)new Collider[64]; private static readonly Collider[] _extHits = (Collider[])(object)new Collider[256]; private static bool _markLog = true; private static int _blockerMask = -1; private static float Lookahead => Cfg.ApLookahead.Value; private static float BendPace => Cfg.ApCornerSpeed.Value; private static float StepsPace => Cfg.ApStairsSpeed.Value; private static float HingePace => Cfg.ApDoorSpeed.Value; private static float BlockedReplan => Cfg.ApBlockedReplan.Value; private static float QuickReplan => Cfg.ApQuickReplan.Value; private static float ClearBeforeResume => Cfg.ApClearTime.Value; private static float BlockedAreaLife => Cfg.ApBlockedLife.Value; internal static string Status { get { if ((Object)(object)_cart == (Object)null) { return "no cart picked"; } if (_job == Job.None) { return "idle (cart " + _number + ", " + CartName(_cart) + ")"; } return JobName(_job) + " (cart " + _number + ", " + CartName(_cart) + ")"; } } internal static PhysGrabCart DrivenCart { get { if (_job == Job.None || _st != St.Driving) { return null; } return _cart; } } internal static float DrivenSpeed => _cmdSpeed; internal static bool RamsMonsters { get { if (Cfg.CartCrushImpact != null) { return Cfg.CartCrushImpact.Value; } return false; } } private static int ObstacleLayers { get { if (_blockerMask < 0) { _blockerMask = LayerMask.GetMask(new string[4] { "Player", "Enemy", "PhysGrabObject", "PhysGrabObjectCart" }); } return _blockerMask; } } internal static bool IsActive(Job j) { if (_job == j) { return _st != St.Idle; } return false; } private static string JobName(Job j) { return j switch { Job.ToPlayer => "rolling to you", Job.ToExtraction => "heading for the extraction", Job.ToTruck => "heading for the truck", Job.OpenExtraction => "opening the extraction and driving in", _ => "idle", }; } private static string CartName(PhysGrabCart c) { if ((Object)(object)c == (Object)null) { return "-"; } float num = Round.BankedFor(c); if (!(num >= 1f)) { return "empty"; } return "$" + num.ToString("N0"); } internal static List<PhysGrabCart> Carts() { try { if (Time.unscaledTime - _cartListAt > 0.5f) { _cartListAt = Time.unscaledTime; _cartList = (from c in Object.FindObjectsByType<PhysGrabCart>((FindObjectsSortMode)0) where (Object)(object)c != (Object)null && ((Component)c).gameObject.activeInHierarchy orderby ((Object)c).GetInstanceID() select c).ToList(); } } catch { } return _cartList; } internal static int SelectedNumber() { if ((Object)(object)_cart == (Object)null) { return 0; } int num = Carts().IndexOf(_cart); if (num >= 0) { return num + 1; } return 0; } internal static string Select(int number) { List<PhysGrabCart> list = Carts(); if (number < 1 || number > list.Count) { return "There is no cart " + number + "."; } if ((Object)(object)_cart != (Object)null && (Object)(object)_cart != (Object)(object)list[number - 1] && _job != Job.None) { Stop("picked another cart"); } _cart = list[number - 1]; _number = number; Plugin.Log.LogInfo((object)("[AUTO] controlling cart " + number + " (" + CartName(_cart) + ")")); return "Cart " + number + ": " + CartName(_cart); } internal static string PickNextCart() { List<PhysGrabCart> list = Carts(); if (list.Count == 0) { _cart = null; return "No cart in this level."; } string text = Select(((((Object)(object)_cart == (Object)null) ? (-1) : list.IndexOf(_cart)) + 1) % list.Count + 1); Tell(text, failure: false); return text; } private static bool Pressed(KeyCode key) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) if ((int)key != 0) { return InputCompat.GetKeyDown(key); } return false; } internal static void Keys() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_0106: Unknown result type (might be due to invalid IL or missing references) try { DrawNoticeLine(); int num; if (Cfg.AutopilotEnabled != null && Cfg.AutopilotEnabled.Value && Game.IsHost()) { num = (Game.InLevel() ? 1 : 0); if (num != 0) { goto IL_003a; } } else { num = 0; } _inLevelFrom = -1f; _prebaked = false; goto IL_003a; IL_003a: if (num != 0 || _job != Job.None) { CartNav.Tick(); } if (num == 0) { return; } if (!_prebaked) { if (_inLevelFrom < 0f) { _inLevelFrom = Time.unscaledTime; } else if (Time.unscaledTime - _inLevelFrom > 6f) { _prebaked = true; CartNav.MakeSureMapReady(_halfW); } } if (!HostMenu.IsOpen && !Game.ChatOpen()) { if (Pressed(Cfg.KeyCartToMe.Value)) { Command(Job.ToPlayer); } if (Pressed(Cfg.KeyCartToExtraction.Value)) { Command(Job.ToExtraction); } if (Pressed(Cfg.KeyCartToTruck.Value)) { Command(Job.ToTruck); } if (Pressed(Cfg.KeyCartOpenExtraction.Value)) { Command(Job.OpenExtraction); } if (Pressed(Cfg.KeyCartSelect.Value)) { PickNextCart(); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[AUTO] keys: " + ex.Message)); } } internal static string Press(Job job) { if (Cfg.AutopilotEnabled == null || !Cfg.AutopilotEnabled.Value) { return "Turn Cart runner ON (Cart options)"; } if (!Game.IsHost()) { return "Only the host can drive carts."; } if (!Game.InLevel()) { return "Start a level first."; } bool num = IsActive(job); Command(job); if (num) { return "Cart stopped."; } if (!IsActive(job)) { if (!string.IsNullOrEmpty(_notice)) { return _notice; } return "Could not start."; } return "Cart " + _number + ": " + JobName(job); } internal static void Stop(string why) { Finish(why, 0); } internal static string PressFor(Job job, PlayerAvatar who) { try { _commandAs = who; return Press(job); } finally { _commandAs = null; } } internal static string NextCartFor(PlayerAvatar who) { if (Cfg.AutopilotEnabled == null || !Cfg.AutopilotEnabled.Value) { return "Cart runner is off"; } if (!Game.IsHost() || !Game.InLevel()) { return "Start a level first."; } return PickNextCart(); } private static void Tell(string msg, bool failure) { _notice = msg; _noticeEnd = Time.time + 3f; if (failure) { Plugin.Log.LogWarning((object)("[AUTO] cart " + _number + ": " + msg)); } } private static void DrawNoticeLine() { //IL_0033: 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) try { if (!string.IsNullOrEmpty(_notice) && !(Time.time > _noticeEnd)) { SemiFunc.UIBigMessage("Runner: " + _notice, "{:O}", 20f, Color.white, new Color(1f, 0.55f, 0f, 1f)); } } catch { _noticeEnd = 0f; } } internal static void DrawHud(Action<Rect, Color, int> fill) { //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_01ae: 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_00ca: 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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Expected O, but got Unknown //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) try { if (_hudMode != 0 && (_hudMode == 1 || !(Time.time > _hudUntil)) && (_hudMode != 1 || _job != Job.None)) { float num = (float)Screen.height / 1080f; float num2 = 260f * num; float num3 = 44f * num; float num4 = 150f * num; Rect val = default(Rect); ((Rect)(ref val))..ctor((float)Screen.width * 0.5f - (num2 + num4) * 0.5f, (float)Screen.height * 0.08f, num2 + num4, num3); Color val2 = ((_hudMode == 2) ? new Color(0.3f, 0.85f, 0.4f, 1f) : ((_hudMode == 3) ? new Color(0.95f, 0.3f, 0.3f, 1f) : new Color(1f, 0.6f, 0.15f, 1f))); float num5 = ((Rect)(ref val)).x + 8f * num; float num6 = ((Rect)(ref val)).y + num3 * 0.5f; Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(num5, num6 - 2.5f * num, num2 - 20f * num, 5f * num); GUI.color = new Color(0f, 0f, 0f, 0.55f); GUI.DrawTexture(new Rect(((Rect)(ref val3)).x - 1.5f * num, ((Rect)(ref val3)).y - 1.5f * num, ((Rect)(ref val3)).width + 3f * num, ((Rect)(ref val3)).height + 3f * num), (Texture)(object)Texture2D.whiteTexture); GUI.color = new Color(1f, 1f, 1f, 0.28f); GUI.DrawTexture(val3, (Texture)(object)Texture2D.whiteTexture); float num7 = ((_hudMode == 2) ? 1f : ((_hudMode == 3) ? 0f : ((_hudTotal > 0.1f) ? Mathf.Clamp01(1f - _hudRemaining / _hudTotal) : 0f))); GUI.color = val2; GUI.DrawTexture(new Rect(((Rect)(ref val3)).x, ((Rect)(ref val3)).y, ((Rect)(ref val3)).width * num7, ((Rect)(ref val3)).height), (Texture)(object)Texture2D.whiteTexture); float num8 = 14f * num; GUI.DrawTexture(new Rect(((Rect)(ref val3)).x + ((Rect)(ref val3)).width * num7 - num8 * 0.5f, num6 - num8 * 0.5f, num8, num8), (Texture)(object)Texture2D.whiteTexture); GUI.color = Color.white; if (_hudText == null) { _hudText = new GUIStyle(GUI.skin.label) { fontStyle = (FontStyle)1, alignment = (TextAnchor)3, wordWrap = false }; } _hudText.fontSize = Mathf.RoundToInt(22f * num); string text = ((_hudMode == 2) ? "Parked" : ((_hudMode == 3) ? "No route" : (_hudRemaining.ToString("0") + " m"))); Rect val4 = default(Rect); ((Rect)(ref val4))..ctor(((Rect)(ref val)).x + num2, ((Rect)(ref val)).y, num4, num3); _hudText.normal.textColor = new Color(0f, 0f, 0f, 0.7f); GUI.Label(new Rect(((Rect)(ref val4)).x + 1.5f, ((Rect)(ref val4)).y + 1.5f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text, _hudText); _hudText.normal.textColor = (Color)((_hudMode == 1) ? new Color(0.95f, 0.95f, 1f, 1f) : val2); GUI.Label(val4, text, _hudText); } } catch { GUI.color = Color.white; } } private static void HudMode(int mode, float seconds) { _hudMode = mode; _hudUntil = Time.time + seconds; } private static PhysGrabCart Nearest(Vector3 from) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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) PhysGrabCart result = null; float num = float.MaxValue; foreach (PhysGrabCart item in Carts()) { if (!((Object)(object)item == (Object)null)) { Vector3 val = ((Component)item).transform.position - from; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } private static bool HeldByPlayer() { try { return (Object)(object)_pgo != (Object)null && _pgo.playerGrabbing != null && _pgo.playerGrabbing.Count > 0; } catch { return false; } } private static void Command(Job job) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0197: 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_01bb: 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_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: 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) Stopwatch stopwatch = Stopwatch.StartNew(); try { if (IsActive(job)) { Finish("stopped by you", 0); return; } PlayerAvatar val = (((Object)(object)_commandAs != (Object)null) ? _commandAs : Game.Me()); if ((Object)(object)_cart == (Object)null) { _cart = Nearest(((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero); } if ((Object)(object)_cart == (Object)null) { Tell("no cart in reach", failure: true); return; } _number = Math.Max(1, Carts().IndexOf(_cart) + 1); _rb = ((Component)_cart).GetComponent<Rigidbody>(); _pgo = ((Component)_cart).GetComponent<PhysGrabObject>(); if ((Object)(object)_rb == (Object)null) { Tell("that cart has no physics body", failure: true); return; } if (HeldByPlayer()) { Tell("hands on the cart, can't drive it", failure: true); return; } if (_job != Job.None) { Finish("new command", -1); } MeasureCart(); _job = job; _extraction = null; _extInside = false; _extPressed = false; _ignoredObj.Clear(); _follow = null; _followAvatar = null; _rejected = 0; _reverses = 0; _poleFixes = 0; _cleanRetry = false; CartNav.ClearBlocked(); MarkExtractionParts(); if (!FindDestination(job, val, out var why)) { _job = Job.None; _st = St.Idle; Tell(why, failure: true); HudMode(3, 2.5f); return; } Vector3 val2 = (((Object)(object)_follow != (Object)null) ? _follow.position : _goal); if (Time.time - _failTime < 3f) { Vector3 val3 = val2 - _failGoal; if (((Vector3)(ref val3)).magnitude < 1f) { val3 = ((Component)_cart).transform.position - _failPos; if (((Vector3)(ref val3)).magnitude < 0.5f) { Tell("still no route there", failure: true); HudMode(3, 2.5f); _job = Job.None; _st = St.Idle; _follow = null; _followAvatar = null; return; } } } _arrive = (((Object)(object)_follow != (Object)null) ? (_halfL + 1.2f) : 0.8f); _rest = float.NaN; _path = null; _hudTotal = 0f; _hudRemaining = 0f; SetGlide(on: true); _st = St.Planning; _planStart = Time.time; _followCheck = 2f; _yawCmd = 0f; _cmdSpeed = 0f; _facingBack = false; _stall = 0f; _stepUp = 0f; _held = null; _posDrive = false; _unresp = 0f; _tripStart = Time.time; _diagNext = 0f; _diagPos = ((Component)_cart).transform.position; _blockedSince = 0f; _clearSince = Time.time; _stuckRef = ((Component)_cart).transform.position; _stuckRefTime = Time.time; HudMode(1, 0f); Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + " (" + CartName(_cart) + ") -> " + JobName(job) + " at " + ((Vector3)(ref _goal)).ToString("0.0") + ", cart size w" + (_halfW * 2f).ToString("0.00") + " l" + (_halfL * 2f).ToString("0.00"))); CartNav.MakeSureMapReady(_halfW); MarkExtractionParts(); Plugin.Log.LogInfo((object)("[AUTO] key press handled in " + stopwatch.Elapsed.TotalMilliseconds.ToString("0.0") + " ms")); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[AUTO] command: " + ex.Message)); } } private static bool FindDestination(Job job, PlayerAvatar me, out string why) { //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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) why = ""; switch (job) { case Job.ToPlayer: if ((Object)(object)me == (Object)null) { why = "can't locate you"; return false; } _followAvatar = me; _follow = ((Component)me).transform; _goal = ((Component)me).transform.position; return true; case Job.ToTruck: { if (!Game.TruckSpot(out var pos2, out var _)) { why = "can't locate the truck"; return false; } _goal = pos2; return true; } default: { _extraction = ChooseExtraction(_job == Job.OpenExtraction); if ((Object)(object)_extraction == (Object)null) { why = "no extraction point to go to"; return false; } if (Game.ExtractionSpot(_extraction, out var pos, out var _)) { _goal = pos; } else { _goal = ((Component)_extraction).transform.position; } return true; } } } private static void LogExtractionList() { //IL_0086: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) try { StringBuilder stringBuilder = new StringBuilder("[AUTO] extraction points: "); Vector3 pos; Quaternion rot; bool flag = Game.TruckSpot(out pos, out rot); foreach (Round.Ex item in Round.Extractions()) { stringBuilder.Append("#").Append(item.Number).Append(" ") .Append(Round.StateText(item)); if (flag && (Object)(object)item.Point != (Object)null) { StringBuilder stringBuilder2 = stringBuilder.Append(" "); Vector3 val = ((Component)item.Point).transform.position - pos; stringBuilder2.Append(Mathf.RoundToInt(((Vector3)(ref val)).magnitude)).Append(" m from the truck"); } stringBuilder.Append("; "); } Plugin.Log.LogInfo((object)stringBuilder.ToString()); } catch { } } private static ExtractionPoint ChooseExtraction(bool alwaysFurthest) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) LogExtractionList(); ExtractionPoint val = Game.ActiveExtraction(); if ((Object)(object)val != (Object)null && (int)Game.StateOfExtraction(val) != 7) { return val; } List<ExtractionPoint> list = (from p in Game.ExtractionPoints() where (Object)(object)p != (Object)null && !p.isLocked && (int)Game.StateOfExtraction(p) == 1 select p).ToList(); if (list.Count == 0) { list = (from p in Game.ExtractionPoints() where (Object)(object)p != (Object)null && (int)Game.StateOfExtraction(p) == 1 select p).ToList(); if (list.Count == 0) { return null; } } Vector3 from = ((Component)_cart).transform.position; if (alwaysFurthest || (Cfg.CartExtractionFurthest != null && Cfg.CartExtractionFurthest.Value)) { if (Game.TruckSpot(out var tp, out var _)) { return list.OrderByDescending(delegate(ExtractionPoint p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) Vector3 val2 = ((Component)p).transform.position - tp; return ((Vector3)(ref val2)).sqrMagnitude; }).First(); } Plugin.Log.LogInfo((object)"[AUTO] no truck found; picking the extraction closest to the cart"); } return list.OrderBy(delegate(ExtractionPoint p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) Vector3 val2 = ((Component)p).transform.position - from; return ((Vector3)(ref val2)).sqrMagnitude; }).First(); } private static void MeasureCart() { //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_0279: 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_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: 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_01d7: 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_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: 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_0200: 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_020b: 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_021a: 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_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0236: 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_023a: 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_0241: 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_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) float halfW = 0.62f; float halfL = 1.13f; float height = 1.05f; float bottom = -0.5f; try { Transform transform = ((Component)_cart).transform; Vector3 lossyScale = transform.lossyScale; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(1E+09f, 1E+09f, 1E+09f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(-1E+09f, -1E+09f, -1E+09f); int num = 0; Collider[] componentsInChildren = ((Component)_cart).GetComponentsInChildren<Collider>(); Vector3 val7 = default(Vector3); foreach (Collider val3 in componentsInChildren) { if ((Object)(object)val3 == (Object)null || val3.isTrigger || !val3.enabled) { continue; } BoxCollider val4 = (BoxCollider)(object)((val3 is BoxCollider) ? val3 : null); CapsuleCollider val5 = (CapsuleCollider)(object)((val3 is CapsuleCollider) ? val3 : null); MeshCollider val6 = (MeshCollider)(object)((val3 is MeshCollider) ? val3 : null); Vector3 center; if ((Object)(object)val4 != (Object)null) { center = val4.center; val7 = val4.size * 0.5f; } else if ((Object)(object)val5 != (Object)null) { center = val5.center; ((Vector3)(ref val7))..ctor(val5.radius, val5.radius, val5.radius); ((Vector3)(ref val7))[val5.direction] = Mathf.Max(val5.height * 0.5f, val5.radius); } else { if (!((Object)(object)val6 != (Object)null) || !((Object)(object)val6.sharedMesh != (Object)null)) { continue; } Bounds bounds = val6.sharedMesh.bounds; center = ((Bounds)(ref bounds)).center; bounds = val6.sharedMesh.bounds; val7 = ((Bounds)(ref bounds)).extents; } for (int j = 0; j < 8; j++) { Vector3 val8 = center + new Vector3((((j & 1) == 0) ? (-1f) : 1f) * val7.x, (((j & 2) == 0) ? (-1f) : 1f) * val7.y, (((j & 4) == 0) ? (-1f) : 1f) * val7.z); Vector3 val9 = transform.InverseTransformPoint(((Component)val3).transform.TransformPoint(val8)); ((Vector3)(ref val9))..ctor(val9.x * lossyScale.x, val9.y * lossyScale.y, val9.z * lossyScale.z); val = Vector3.Min(val, val9); val2 = Vector3.Max(val2, val9); } num++; } if (num > 0) { float num2 = (val2.x - val.x) * 0.5f; float num3 = (val2.z - val.z) * 0.5f; float num4 = val2.y - val.y; if (num2 >= 0.3f && num2 <= 1.3f) { halfW = num2; } if (num3 >= 0.4f && num3 <= 2f) { halfL = num3; } if (num4 >= 0.4f && num4 <= 2.5f) { height = num4; } if (val.y >= -1.5f && val.y <= 0.2f) { bottom = val.y; } } } catch { } _halfW = halfW; _halfL = halfL; _height = height; _bottom = bottom; Plugin.Log.LogInfo((object)("[AUTO] cart '" + ((Object)_cart).name + "' measured: halfWidth=" + halfW.ToString("0.00") + " halfLength=" + halfL.ToString("0.00") + " height=" + height.ToString("0.00") + " bottomY=" + bottom.ToString("0.00"))); } private static void Finish(string why, int kind) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00f5: 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_0070: 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) try { if (_job != Job.None && kind >= 0) { Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + ": " + why)); } if (kind == 2) { _failTime = Time.time; _failGoal = (((Object)(object)_follow != (Object)null) ? _follow.position : _goal); _failPos = (((Object)(object)_cart != (Object)null) ? ((Component)_cart).transform.position : Vector3.zero); } _st = St.Idle; if (kind >= 0) { _job = Job.None; } _path = null; _follow = null; _followAvatar = null; if ((Object)(object)_rb != (Object)null && !_rb.isKinematic) { Vector3 linearVelocity = _rb.linearVelocity; _rb.linearVelocity = new Vector3(0f, linearVelocity.y, 0f); _rb.angularVelocity = Vector3.zero; } _yawCmd = 0f; _cmdSpeed = 0f; if (kind >= 0) { SetGlide(on: false); LetGoOfCargo(); } switch (kind) { case 1: HudMode(2, 2f); break; case 2: HudMode(3, 3f); break; case 0: HudMode(0, 0f); break; } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[AUTO] stop: " + ex.Message)); } } private static void SetGlide(bool on) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)_cart == (Object)null || _slippery == on) { return; } if (!on && (int)Game.Get<State>(_cart, "currentState", (State)0) != 0) { _slippery = false; return; } List<Collider> list = Game.Get<List<Collider>>(_cart, "capsuleColliders"); if (list != null) { PhysicsMaterial material = (on ? _cart.physMaterialSlippery : _cart.physMaterialNormal); foreach (Collider item in list) { if ((Object)(object)item != (Object)null) { item.material = material; } } } _slippery = on; } catch { } } private static bool NotReached(CartNav.RouteResult r, Vector3 goal) { //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) if (r.Pts == null) { return true; } if (!r.Incomplete) { return false; } return Vector3.Distance(r.Pts[r.Pts.Count - 1], goal) > 1.5f; } private static float Flat(Vector3 a, Vector3 b) { //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_0012: 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_001f: 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) Vector3 val = new Vector3(a.x - b.x, 0f, a.z - b.z); return ((Vector3)(ref val)).magnitude; } private static Vector3 F(Vector3 v) { //IL_0000: 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_0011: Unknown result type (might be due to invalid IL or missing references) return new Vector3(v.x, 0f, v.z); } private static void MakeNewRoute(bool keepIfWorse) { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0056: 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_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_0078: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00eb: 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_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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_0518: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) _lastPlan = Time.time; Vector3 goal = _goal; if ((Object)(object)_follow != (Object)null) { _goal = _follow.position; } Vector3 val = ((Component)_cart).transform.position + Vector3.up * _bottom; Stopwatch stopwatch = Stopwatch.StartNew(); CartNav.RouteResult routeResult = CartNav.Plan(val, _goal, _halfW); RaycastHit val2 = default(RaycastHit); if ((Object)(object)_follow != (Object)null && NotReached(routeResult, _goal) && Physics.Raycast(_goal + Vector3.up * 0.2f, Vector3.down, ref val2, 25f, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1) && _goal.y - ((RaycastHit)(ref val2)).point.y > 1f) { CartNav.RouteResult routeResult2 = CartNav.Plan(val, ((RaycastHit)(ref val2)).point, _halfW); if (!NotReached(routeResult2, ((RaycastHit)(ref val2)).point)) { ManualLogSource log = Plugin.Log; string text = _number.ToString(); Vector3 point = ((RaycastHit)(ref val2)).point; log.LogInfo((object)("[AUTO] cart " + text + ": target is above the cart; heading for the ground under it at " + ((Vector3)(ref point)).ToString("0.0"))); routeResult = routeResult2; _goal = ((RaycastHit)(ref val2)).point; } } stopwatch.Stop(); if (keepIfWorse && _path != null && routeResult.Pts != null && !routeResult.Incomplete) { float num = LeftToGo() + Flat(_goal, goal) + 4f; if (CartNav.Length(routeResult.Pts) > num) { _goal = goal; return; } } if (routeResult.Pts == null) { Plugin.Log.LogWarning((object)("[AUTO] cart " + _number + ": route rejected (" + routeResult.Error + ")")); bool flag = routeResult.Error != null && routeResult.Error.StartsWith("start or goal"); if (++_rejected > 2 || flag) { Tell("no route fits this cart", failure: true); Finish("no route", 2); } else { _st = St.Planning; _planStart = Time.time - 5f; } return; } if (routeResult.Mesh == "game" && CartNav.HasBlocked && !_cleanRetry) { _cleanRetry = true; Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + ": no cart-sized route with the marked areas; clearing them and planning again on the cart maps")); CartNav.ClearBlocked(); _st = St.Planning; _planStart = Time.time; return; } if (routeResult.Incomplete) { Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + ": no complete path for the cart; taking the nearest point (" + routeResult.Short.ToString("0.0") + " m short)")); if (CartNav.Length(routeResult.Pts) < 1f && Flat(_goal, ((Component)_cart).transform.position) > _arrive + 1f) { Tell("the route ends short of the target", failure: true); Finish("can't get closer", 2); return; } } if (_poleFixes < 8 && !routeResult.Incomplete && routeResult.Mesh != "game" && FixedOnRoute(routeResult.Pts, out var at, out var col)) { _poleFixes++; Bounds bounds = col.bounds; float x = ((Bounds)(ref bounds)).extents.x; bounds = col.bounds; float num2 = Mathf.Max(x, ((Bounds)(ref bounds)).extents.z); float num3 = Mathf.Min(2.5f, num2 + 0.25f); bounds = col.bounds; float num4 = Flat(((Bounds)(ref bounds)).center, _goal); if (num4 - num3 < 0.8f) { num3 = Mathf.Max(num2 + _halfW + 0.1f, num4 - 0.8f); } Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + ": fixed object on the route at " + ((Vector3)(ref at)).ToString("0.0") + " - " + DescribeDetail(col, null) + " - planning around it (" + _poleFixes + "/" + 8 + ")")); bounds = col.bounds; CartNav.AddBlocked(((Bounds)(ref bounds)).center, num3, BlockedAreaLife * 2f); _st = St.Planning; _planStart = Time.time; } else { _path = routeResult.Pts; _seg = 0; _segT = 0f; if (float.IsNaN(_rest)) { _rest = ((Component)_cart).transform.position.y - _path[0].y; } _blockedSince = 0f; _clearSince = Time.time; _st = St.Driving; _hudRemaining = LeftToGo(); if (_hudRemaining > _hudTotal) { _hudTotal = _hudRemaining; } Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + ": route of " + _path.Count + " points, " + CartNav.Length(_path).ToString("0.0") + " m on the " + routeResult.Mesh + " map" + (routeResult.Incomplete ? " (partial)" : "") + ", planned in " + stopwatch.Elapsed.TotalMilliseconds.ToString("0.0") + " ms")); } } private static void RefreshProgress() { //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_0014: 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) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_0085: 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_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_00a3: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = F(((Component)_cart).transform.position); float num = float.MaxValue; int num2 = Mathf.Min(_seg + 10, _path.Count - 1); for (int i = _seg; i < num2; i++) { Vector3 val2 = F(_path[i]); Vector3 val3 = F(_path[i + 1]) - val2; float num3 = ((((Vector3)(ref val3)).sqrMagnitude > 0f) ? Mathf.Clamp01(Vector3.Dot(val - val2, val3) / ((Vector3)(ref val3)).sqrMagnitude) : 0f); Vector3 val4 = val2 + val3 * num3 - val; float magnitude = ((Vector3)(ref val4)).magnitude; if (magnitude < num) { num = magnitude; _seg = i; _segT = num3; } } _offPath = num; int num4 = Mathf.Min(_seg, _path.Count - 2); _pathHeight = ((Component)_cart).transform.position.y - Mathf.Lerp(_path[num4].y, _path[num4 + 1].y, _segT); } private static Vector3 AimPoint(float dist) { //IL_002d: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_0094: 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_0087: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Min(_seg, _path.Count - 2); if (num < 0) { return _path[0]; } Vector3 val = Vector3.Lerp(_path[num], _path[num + 1], _segT); for (int i = num + 1; i < _path.Count; i++) { Vector3 val2 = _path[i]; Vector3 val3 = F(val2 - val); float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude >= dist && magnitude > 0f) { return Vector3.Lerp(val, val2, dist / magnitude); } dist -= magnitude; val = val2; } return _path[_path.Count - 1]; } private static float LeftToGo() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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) if (_path == null || _path.Count < 2) { return 0f; } int num = Mathf.Min(_seg, _path.Count - 2); Vector3 val = Vector3.Lerp(_path[num], _path[num + 1], _segT); float num2 = 0f; for (int i = num + 1; i < _path.Count; i++) { float num3 = num2; Vector3 val2 = F(_path[i] - val); num2 = num3 + ((Vector3)(ref val2)).magnitude; val = _path[i]; } return num2; } internal static void Drive() { try { if (_job == Job.None || _st == St.Idle) { return; } if (Cfg.AutopilotEnabled == null || !Cfg.AutopilotEnabled.Value) { Finish("autopilot switched off", 0); return; } if (!Game.IsHost() || !Game.InLevel()) { Finish("not in a level any more", 0); return; } if ((Object)(object)_cart == (Object)null || (Object)(object)_rb == (Object)null) { Finish("the cart is gone", 0); return; } if (HeldByPlayer()) { Tell("cart grabbed, handing control back", failure: false); Finish("someone else grabbed the cart", 0); return; } if (_rb.IsSleeping()) { _rb.WakeUp(); } ProtectCargo(); HoldCargo(); if (_st == St.Planning) { bool num = CartNav.MakeSureMapReady(_halfW) && !CartNav.Pending; bool flag = !CartNav.Busy && !CartNav.Ready && !string.IsNullOrEmpty(CartNav.LastProblem); if (num || flag || Time.time - _planStart > 6f) { MakeNewRoute(keepIfWorse: false); } else { Brake(); } } else if (_path == null || _path.Count < 2) { Finish("no route", 2); } else if (_st == St.BackingUp) { DriveReverse(); } else { DriveAlong(); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[AUTO] drive: " + ex.Message + " " + ex.StackTrace.Split('\n')[0])); Finish("an error stopped it", 0); } } private static void HoldCargo() { //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_021a: 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_009a: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) try { if (_held == null) { _held = new List<Held>(); List<PhysGrabObject> list = Game.Get<List<PhysGrabObject>>(_cart, "itemsInCart"); if (list != null) { foreach (PhysGrabObject item in list) { if (!((Object)(object)item == (Object)null) && !Game.IsHeld(item)) { Rigidbody component = ((Component)item).GetComponent<Rigidbody>(); if (!((Object)(object)component == (Object)null) && !component.isKinematic && !((Object)(object)component == (Object)(object)_rb)) { _held.Add(new Held { Body = component, Local = ((Component)_cart).transform.InverseTransformPoint(component.position), Turn = Quaternion.Inverse(((Component)_cart).transform.rotation) * component.rotation }); } } } } Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + ": " + _held.Count + " item(s) held in place while it drives")); return; } for (int num = _held.Count - 1; num >= 0; num--) { Held held = _held[num]; if ((Object)(object)held.Body == (Object)null) { _held.RemoveAt(num); } else { PhysGrabObject component2 = ((Component)held.Body).GetComponent<PhysGrabObject>(); if ((Object)(object)component2 != (Object)null && Game.IsHeld(component2)) { _held.RemoveAt(num); } else { held.Body.position = ((Component)_cart).transform.TransformPoint(held.Local); held.Body.rotation = ((Component)_cart).transform.rotation * held.Turn; held.Body.linearVelocity = _rb.linearVelocity; held.Body.angularVelocity = _rb.angularVelocity; } } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("[AUTO] hold cargo: " + ex.Message)); _held = null; } } private static void LetGoOfCargo() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) try { if (_held == null) { return; } foreach (Held item in _held) { if ((Object)(object)item.Body != (Object)null && (Object)(object)_rb != (Object)null) { item.Body.linearVelocity = _rb.linearVelocity; } } } catch { } _held = null; } private static void ProtectCargo() { if (Time.time - _cargoAt < 0.3f) { return; } _cargoAt = Time.time; try { List<PhysGrabObject> list = Game.Get<List<PhysGrabObject>>(_cart, "itemsInCart"); if (list == null) { return; } foreach (PhysGrabObject item in list) { if ((Object)(object)item != (Object)null) { item.OverrideIndestructible(0.8f); } } } catch { } } private static void Brake() { //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_000b: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) Vector3 linearVelocity = _rb.linearVelocity; Vector3 val = Vector3.MoveTowards(new Vector3(linearVelocity.x, 0f, linearVelocity.z), Vector3.zero, 12f * Time.fixedDeltaTime); _rb.linearVelocity = new Vector3(val.x, linearVelocity.y, val.z); _rb.angularVelocity = Vector3.zero; _cmdSpeed = 0f; } private static void DriveAlong() { //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00ae: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) RefreshProgress(); if (_offPath > 1.2f && Time.time - _lastPlan > 0.5f) { Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + ": " + _offPath.ToString("0.0") + " m off the route, planning again")); MakeNewRoute(keepIfWorse: false); return; } if ((Object)(object)_follow != (Object)null) { _followCheck -= Time.fixedDeltaTime; if (_followCheck < 0f) { _followCheck = 2f; if (Flat(_follow.position, _goal) > 3f) { MakeNewRoute(keepIfWorse: true); return; } } } float num = LeftToGo(); if ((Object)(object)_follow != (Object)null && Flat(_follow.position, ((Component)_cart).transform.position) < _arrive + 0.3f && Mathf.Abs(_follow.position.y - ((Component)_cart).transform.position.y) < 1.5f) { num = 0f; } bool flag = Flat(_path[_path.Count - 1], _goal) > 1f; _hudRemaining = num; if (num > _hudTotal) { _hudTotal = num; } if ((Object)(object)_extraction != (Object)null && !_extPressed && Flat(_goal, ((Component)_cart).transform.position) < 5f) { PressExtraction(); } if (num < (flag ? 0.5f : _arrive)) { ReachedEnd(); return; } bool flag2 = StepsNearby(1.5f); float num2 = WantedPace(num, flag2); float num3 = LoadWeight(); float num4 = Mathf.Max(0.1f, _rb.mass); _load = Mathf.Clamp01((num3 - _rb.mass) / num4 / 5f); num2 *= Mathf.Lerp(1f, 0.75f, _load); Vector3 val = AimPoint(flag2 ? 0.7f : (Mathf.Lerp(0.8f, Lookahead, num2 / Mathf.Max(0.1f, Cfg.AutopilotSpeed.Value)) * (1f + 0.6f * _load))); Vector3 dir = F(val - ((Component)_cart).transform.position); dir = ((((Vector3)(ref dir)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref dir)).normalized : F(((Component)_cart).transform.forward)); if (!WatchObstacles(dir)) { _climbing = flag2 || AimPoint(1.2f).y > AimPoint(0f).y + 0.05f; Steer(val, num2); RideHeight(); WatchProgress(dir); TripDiag(); if (Time.unscaledTime - _lastDiag > 2f) { _lastDiag = Time.unscaledTime; ManualLogSource log = Plugin.Log; string[] obj = new string[15] { "[AUTO] cart ", _number.ToString(), " ", JobName(_job), ": ", num.ToString("0.0"), " m left, speed ", null, null, null, null, null, null, null, null }; Vector3 val2 = new Vector3(_rb.linearVelocity.x, 0f, _rb.linearVelocity.z); obj[7] = ((Vector3)(ref val2)).magnitude.ToString("0.0"); obj[8] = " (wanted "; obj[9] = _cmdSpeed.ToString("0.0"); obj[10] = ") m/s, off route "; obj[11] = _offPath.ToString("0.0"); obj[12] = " m, "; obj[13] = (_facingBack ? "backwards" : "forwards"); obj[14] = (_climbing ? ", climbing" : ""); log.LogInfo((object)string.Concat(obj)); } } } private unsafe static void PressExtraction() { //IL_0011: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 _extPressed = true; string why = ""; State val = Game.StateOfExtraction(_extraction); bool flag; if ((int)val == 1) { flag = Round.Open(_extraction, out why); } else if ((int)val == 2) { flag = true; why = "already open"; } else if ((int)val == 7) { flag = false; why = "already done"; } else { try { _extraction.OnClick(); flag = true; why = "state " + ((object)(*(State*)(&val))/*cast due to .constrained prefix*/).ToString(); } catch (Exception ex) { flag = false; why = ex.Message; } } Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + " at the extraction (state " + ((object)(*(State*)(&val))/*cast due to .constrained prefix*/).ToString() + "): " + (flag ? ("pressed the button (" + why + ")") : ("could not open it (" + why + ")")))); if (flag) { Tell("extraction switched on, rolling in", failure: false); } else { Tell("extraction won't open: " + why, failure: true); } } private static void ReachedEnd() { //IL_000d: 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_008f: 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) //IL_00c5: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_extraction != (Object)null && Flat(_goal, ((Component)_cart).transform.position) > 3f) { Tell("the extraction is out of reach", failure: true); Finish("the extraction is out of the cart's reach", 2); } else if ((Object)(object)_extraction != (Object)null && !_extInside) { if (!_extPressed) { PressExtraction(); } _extInside = true; _goal = ((Component)_extraction).transform.position; _arrive = 0.5f; MakeNewRoute(keepIfWorse: false); } else if (Flat(_goal, ((Component)_cart).transform.position) > _arrive + 1f) { Tell("the route ends short of the target", failure: true); Finish("route ended " + Flat(_goal, ((Component)_cart).transform.position).ToString("0.0") + " m from the target", 2); } else { Finish("arrived", 1); } } private static float WantedPace(float remaining, bool stairs) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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) //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_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) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0.5f, Cfg.AutopilotSpeed.Value); Vector3 val = AimPoint(0f); Vector3 val2 = AimPoint(1f); Vector3 val3 = AimPoint(3f); float num2 = Vector3.Angle(F(val2 - val), F(val3 - val2)); num = Mathf.Lerp(num, Mathf.Min(num, BendPace), Mathf.Clamp01(num2 / 90f)); if (stairs) { num = Mathf.Min(num, StepsPace); } if (HingeNearby(2.5f)) { num = Mathf.Min(num, HingePace); } float num3 = Mathf.Sqrt(3.6f * Mathf.Max(0f, remaining - _arrive)) + 0.4f; num = Mathf.Min(num, num3); return Mathf.Max(num, Mathf.Min(0.9f, 0.5f)); } private static bool StepsNearby(float dist) { //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_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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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_002f: 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) Vector3 val = AimPoint(0f); Vector3 val2 = AimPoint(dist); Vector3 val3 = F(val2 - val); float magnitude = ((Vector3)(ref val3)).magnitude; if (magnitude > 0.2f) { return Mathf.Abs(val2.y - val.y) / magnitude > 0.22f; } return false; } private static float LoadWeight() { float num = _rb.mass; try { List<PhysGrabObject> list = Game.Get<List<PhysGrabObject>>(_cart, "itemsInCart"); if (list != null) { foreach (PhysGrabObject item in list) { if (!((Object)(object)item == (Object)null)) { Rigidbody component = ((Component)item).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { num += component.mass; } } } } } catch { } return num; } private static void Steer(Vector3 pursuit, float speed) { //IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0050: 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_008a: 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_008f: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = F(pursuit - ((Component)_cart).transform.position); if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { ((Vector3)(ref val)).Normalize(); Vector3 val2 = F(((Component)_cart).transform.forward); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = Vector3.Angle(normalized, val); if (_facingBack ? (num < 70f) : (num > 110f)) { _facingBack = !_facingBack; } float num2 = Vector3.SignedAngle(_facingBack ? (-normalized) : normalized, val, Vector3.up); SetTurnRate(Mathf.Clamp(num2 * (MathF.PI / 180f) * Mathf.Lerp(6f, 3f, _load), -4f, 4f)); float num3 = Mathf.Clamp01(1f - (Mathf.Abs(num2) - 25f) / 50f); _cmdSpeed = speed * num3; ApplyVelocity(val * _cmdSpeed); } } private static void SetTurnRate(float yaw) { //IL_0005: 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_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_0097: Unknown result type (might be due to invalid IL or missing references) Vector3 val = new Vector3(_rb.linearVelocity.x, 0f, _rb.linearVelocity.z); float magnitude = ((Vector3)(ref val)).magnitude; float num = Mathf.Min(1.5f / Mathf.Max(0.5f, _halfL), 3f / Mathf.Max(0.1f, magnitude)); yaw = Mathf.Clamp(yaw, 0f - num, num); _yawCmd = Mathf.MoveTowards(_yawCmd, yaw, 4f * Time.fixedDeltaTime); _rb.angularVelocity = new Vector3(0f, _yawCmd, 0f); } private static void ApplyVelocity(Vector3 want) { //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_000b: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_009f: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_01bc: 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_01c8: Unknown result type (might be due to invalid IL or missing references) Vector3 linearVelocity = _rb.linearVelocity; Vector3 val = new Vector3(linearVelocity.x, 0f, linearVelocity.z); float magnitude = ((Vector3)(ref val)).magnitude; float num = (_climbing ? 30f : Mathf.Lerp(3f, 10f, Mathf.Clamp01(magnitude / 2.5f))); Vector3 val2 = Vector3.MoveTowards(new Vector3(linearVelocity.x, 0f, linearVelocity.z), want, num * Time.fixedDeltaTime); _rb.linearVelocity = new Vector3(val2.x, linearVelocity.y, val2.z); val = new Vector3(_rb.linearVelocity.x, 0f, _rb.linearVelocity.z); _ = ((Vector3)(ref val)).magnitude; float magnitude2 = ((Vector3)(ref want)).magnitude; if (!_posDrive) { float num2 = Flat(((Component)_cart).transform.position, _diagPos); _unresp = ((magnitude2 > 1f && num2 < magnitude2 * Time.fixedDeltaTime * 0.25f) ? (_unresp + Time.fixedDeltaTime) : 0f); if (_unresp > ((Time.time - _tripStart < 1.5f) ? 0.5f : 1.2f)) { _posDrive = true; LogBodyState("body did not follow velocity"); Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + ": moving the body by position for the rest of this trip")); } } if (_posDrive && magnitude2 > 0.05f) { Vector3 val3 = want * Time.fixedDeltaTime; _rb.MovePosition(_rb.position + new Vector3(val3.x, 0f, val3.z)); } _diagPos = ((Component)_cart).transform.position; } private static void LogBodyState(string why) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: 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_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) try { StringBuilder stringBuilder = new StringBuilder("[AUTO] body state (" + why + "): "); stringBuilder.Append("kinematic=").Append(_rb.isKinematic); stringBuilder.Append(" sleeping=").Append(_rb.IsSleeping()); stringBuilder.Append(" constraints=").Append(_rb.constraints); stringBuilder.Append(" gravity=").Append(_rb.useGravity); stringBuilder.Append(" mass=").Append(_rb.mass.ToString("0.0")); stringBuilder.Append(" damp=").Append(_rb.linearDamping.ToString("0.00")).Append("/") .Append(_rb.angularDamping.ToString("0.00")); StringBuilder stringBuilder2 = stringBuilder.Append(" vel="); Vector3 linearVelocity = _rb.linearVelocity; stringBuilder2.Append(((Vector3)(ref linearVelocity)).ToString("0.00")); stringBuilder.Append(" interp=").Append(_rb.interpolation); stringBuilder.Append(" cartState=").Append(Game.Get<object>(_cart, "currentState")); if ((Object)(object)_pgo != (Object)null) { stringBuilder.Append(" grabbers=").Append((_pgo.playerGrabbing != null) ? _pgo.playerGrabbing.Count : (-1)); stringBuilder.Append(" frozenTimer=").Append(Game.Get(_pgo, "frozenTimer", -1f).ToString("0.00")); stringBuilder.Append(" overrideKinematic=").Append(Game.Get(_pgo, "overrideKinematicTimer", -1f).ToString("0.00")); stringBuilder.Append(" deactivate=").Append(Game.Get(_pgo, "timerAlterDeactivate", -1f).ToString("0.00")); stringBuilder.Append(" active=").Append(Game.Get(_pgo, "isActive", fallback: true)); } int num = Physics.OverlapBoxNonAlloc(((Component)_cart).transform.position + Vector3.up * 0.3f, new Vector3(_halfW + 0.15f, 0.4f, _halfL + 0.15f), _hits, ((Component)_cart).transform.rotation, -1, (QueryTriggerInteraction)1); List<string> list = new List<string>(); for (int i = 0; i < num; i++) { if (list.Count >= 6) { break; } Collider val = _hits[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val.attachedRigidbody == (Object)(object)_rb)) { list.Add(((Object)val).name + (((Object)(object)val.attachedRigidbody != (Object)null && !val.attachedRigidbody.isKinematic) ? "(dyn)" : "")); } } stringBuilder.Append(" touching=[").Append(string.Join(",", list.ToArray())).Append("]"); Plugin.Log.LogInfo((object)stringBuilder.ToString()); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[AUTO] state dump: " + ex.Message)); } } private static void RideHeight() { //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_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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: 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) Vector3 val = AimPoint(0f); Vector3 val2 = AimPoint(1.2f); Vector3 val3 = F(val2 - val); float magnitude = ((Vector3)(ref val3)).magnitude; float num = ((magnitude > 0.05f) ? ((val2.y - val.y) / magnitude) : 0f); float num2 = (_climbing ? (num * _cmdSpeed) : 0f); float num3 = (float.IsNaN(_rest) ? 0f : (_pathHeight - _rest)); float num4 = ((num3 > 0.15f) ? ((0f - (num3 - 0.05f)) * 3f) : ((num3 < -0.05f) ? ((0f - num3) * 4f) : 0f)); float num5 = Mathf.Clamp(num2 * 1.15f + num4, -2f, 4f); val3 = new Vector3(_rb.linearVelocity.x, 0f, _rb.linearVelocity.z); float magnitude2 = ((Vector3)(ref val3)).magnitude; _stall = ((_cmdSpeed > 0.4f && magnitude2 < 0.2f) ? (_stall + Time.fixedDeltaTime) : 0f); if (_stall > 0.5f && _stepUp <= 0f && num3 < 0.3f) { _stepUp = 0.4f; _stall = 0f; Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + " hung on a low ledge, climbing over it")); } if (_stepUp > 0f) { _stepUp -= Time.fixedDeltaTime; num5 = Mathf.Max(num5, 2f); } Vector3 linearVelocity = _rb.linearVelocity; _rb.linearVelocity = new Vector3(linearVelocity.x, Mathf.MoveTowards(linearVelocity.y, num5, 25f * Time.fixedDeltaTime), linearVelocity.z); _rb.AddForce(Vector3.up * LoadWeight() * (0f - Physics.gravity.y) * Cfg.ApStairsAssist.Value, (ForceMode)0); } private static PhysGrabHinge HingeAt(Vector3 pos, float radius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) int num = Physics.OverlapSphereNonAlloc(pos, radius, _hits, LayerMask.GetMask(new string[1] { "PhysGrabObjectHinge" }), (QueryTriggerInteraction)2); for (int i = 0; i < num; i++) { PhysGrabHinge val = (((Object)(object)_hits[i] != (Object)null) ? ((Component)_hits[i]).GetComponentInParent<PhysGrabHinge>() : null); if (!((Object)(object)val == (Object)null) && !Game.Get(val, "broken", fallback: false) && !Game.Get(val, "dead", fallback: false)) { return val; } } return null; } private static bool HingeNearby(float dist) { //IL_000b: 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) try { return (Object)(object)HingeAt(AimPoint(Mathf.Min(1f, dist)), 1.2f) != (Object)null || (Object)(object)HingeAt(AimPoint(dist), 1.2f) != (Object)null; } catch { return false; } } private static void BreakHingeAhead(Vector3 dir) { //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_003d: Unknown result type (might be due to invalid IL or missing references) if (!(Time.time - _lastDoor < 0.3f)) { _lastDoor = Time.time; PhysGrabHinge val = HingeAt(((Component)_cart).transform.position + dir * (_halfL + 0.6f), _halfW + 0.3f); if (!((Object)(object)val == (Object)null)) { Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + ": smashing door '" + ((Object)val).name + "'")); val.DestroyHinge(); } } } private static bool IsPushable(Collider c) { PhysGrabObject componentInParent = ((Component)c).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent == (Object)null) { return false; } if ((Object)(object)((Component)c).GetComponentInParent<PhysGrabCart>() != (Object)null) { return false; } if ((Object)(object)((Component)c).GetComponentInParent<PhysGrabHinge>() != (Object)null) { return false; } if ((Object)(object)((Component)c).GetComponentInParent<EnemyParent>() != (Object)null) { return false; } if ((Object)(object)((Component)c).GetComponentInParent<PlayerAvatar>() != (Object)null) { return false; } Rigidbody component = ((Component)componentInParent).GetComponent<Rigidbody>(); if (!((Object)(object)component == (Object)null)) { return component.mass <= 15f; } return true; } private static bool IsLiving(Collider c) { if (!((Object)(object)((Component)c).GetComponentInParent<PlayerAvatar>() != (Object)null) && !((Object)(object)((Component)c).GetComponentInParent<EnemyParent>() != (Object)null)) { return (Object)(object)((Component)c).GetComponentInParent<PhysGrabCart>() != (Object)null; } return true; } private static bool IgnoreCollider(Collider c) { //IL_0020: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) if (RamsMonsters && (Object)(object)((Component)c).GetComponentInParent<EnemyParent>() != (Object)null) { return true; } if (!IsLiving(c)) { Bounds bounds = c.bounds; if (CartNav.InBlocked(((Bounds)(ref bounds)).center)) { return true; } } if ((Object)(object)c.attachedRigidbody == (Object)(object)_rb || ((Component)c).transform.IsChildOf(((Component)_cart).transform)) { return true; } if (IsPushable(c)) { return true; } if ((Object)(object)((Component)c).GetComponentInParent<PhysGrabHinge>() != (Object)null) { return true; } PhysGrabObject componentInParent = ((Component)c).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent != (Object)null && _ignoredObj.Contains(((Object)componentInParent).GetInstanceID())) { return true; } if ((Object)(object)componentInParent != (Object)null) { List<PhysGrabObject> list = Game.Get<List<PhysGrabObject>>(_cart, "itemsInCart"); if (list != null && list.Contains(componentInParent)) { return true; } } PlayerAvatar componentInParent2 = ((Component)c).GetComponentInParent<PlayerAvatar>(); if ((Object)(object)componentInParent2 != (Object)null && (Object)(object)componentInParent2 == (Object)(object)_followAvatar && Flat(((Component)_cart).transform.position, ((Component)componentInParent2).transform.position) < _arrive + 3f) { return true; } return false; } private static string DescribeDetail(Collider c, PhysGrabObject po) { //IL_00ed: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) try { List<string> list = new List<string>(); Transform val = ((Component)c).transform; while ((Object)(object)val != (Object)null && list.Count < 5) { list.Add(((Object)val).name); val = val.parent; } Rigidbody val2 = (((Object)(object)po != (Object)null) ? ((Component)po).GetComponent<Rigidbody>() : null); string[] obj = new string[10] { "collider '", ((Object)c).name, "' layer ", LayerMask.LayerToName(((Component)c).gameObject.layer), " parents [", string.Join(" < ", list.ToArray()), "]", ((Object)(object)val2 != (Object)null) ? (", mass " + val2.mass.ToString("0.0") + (val2.isKinematic ? ", kinematic" : "")) : "", ", size ", null }; Bounds bounds = c.bounds; Vector3 size = ((Bounds)(ref bounds)).size; obj[9] = ((Vector3)(ref size)).ToString("0.0"); return string.Concat(obj); } catch { return "no details"; } } private static void MarkExtractionParts() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_00ff: 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_0121: 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_0142: 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_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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_021b: 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_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) try { int num = 0; foreach (ExtractionPoint item in Game.ExtractionPoints()) { if ((Object)(object)item == (Object)null) { continue; } Vector3 position = ((Component)item).transform.position; int num2 = Physics.OverlapSphereNonAlloc(position, 9f, _extHits, -1, (QueryTriggerInteraction)1); for (int i = 0; i < num2; i++) { if (num >= 60) { break; } Collider val = _extHits[i]; _extHits[i] = null; if ((Object)(object)val == (Object)null || val.isTrigger || (Object)(object)val.attachedRigidbody != (Object)null || ((Component)val).transform.IsChildOf(((Component)_cart).transform) || IsLiving(val) || (Object)(object)((Component)val).GetComponentInParent<ExtractionPoint>() == (Object)null || (Object)(object)((Component)val).GetComponentInParent<PhysGrabHinge>() != (Object)null) { continue; } Bounds bounds = val.bounds; if (!(((Bounds)(ref bounds)).max.y < position.y + 0.15f) && !(((Bounds)(ref bounds)).size.y < 0.2f) && !(Mathf.Max(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z) > 4f) && (!(Mathf.Abs(position.x - ((Bounds)(ref bounds)).center.x) < ((Bounds)(ref bounds)).extents.x) || !(Mathf.Abs(position.z - ((Bounds)(ref bounds)).center.z) < ((Bounds)(ref bounds)).extents.z))) { CartNav.AddBlockedBox(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).extents.x + 0.12f, ((Bounds)(ref bounds)).extents.z + 0.12f, 150f); if (_markLog && num < 8) { ManualLogSource log = Plugin.Log; string[] obj = new string[8] { "[AUTO] marked '", ((Object)val).name, "' (", null, null, null, null, null }; Transform parent = ((Component)val).transform.parent; obj[3] = ((parent != null) ? ((Object)parent).name : null); obj[4] = ") at "; Vector3 val2 = ((Bounds)(ref bounds)).center; obj[5] = ((Vector3)(ref val2)).ToString("0.0"); obj[6] = " size "; val2 = ((Bounds)(ref bounds)).size; obj[7] = ((Vector3)(ref val2)).ToString("0.0"); log.LogInfo((object)string.Concat(obj)); } num++; } } } if (num > 0) { Plugin.Log.LogInfo((object)("[AUTO] cart " + _number + ": " + num + " part(s) of the extraction (pillars, rails) marked as areas to stay out of")); } _markLog = false; } catch (Exception ex) { Plugin.Log.LogWarning((object)("[AUTO] extraction parts: " + ex.Message)); } } private static bool IsFixedPost(Collider col) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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) if ((Object)(object)col == (Object)null || col.isTrigger || (Object)(object)col.attachedRigidbody != (Object)null) { return false; } if (_movingMask < 0) { _movingMask = LayerMask.GetMask(new string[4] { "Player", "Enemy", "PhysGrabObject", "PhysGrabObjectCart" }); } if (((1 << ((Component)col).gameObject.layer) & _movingMask) != 0) { return false; } Bounds bounds = col.bounds; Vector3 size = ((Bounds)(ref bounds)).size; float num = Mathf.Max(size.x, size.z); float num2 = Mathf.Min(size.x, size.z); if (size.y < 0.9f || num > 1.6f || num2 > 1f) { return false; } if (((Com