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 CartPilot v0.1.9
CartPilot.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using Unity.AI.Navigation; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [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("CartPilot")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CartPilot")] [assembly: AssemblyTitle("CartPilot")] [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 CartPilot { internal static class CartNavMesh { private class Layer { public string Name; public int AgentTypeId = -1; public float Radius; public NavMeshData Data; public NavMeshDataInstance Instance; public AsyncOperation Op; } private struct BlockedArea { public Vector3 Pos; public float Radius; public float Expires; } private struct Gap { public Vector3 A; public Vector3 B; public Vector3 Out; } internal readonly struct Scope : IDisposable { private readonly bool active; internal Scope(bool _) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: 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) active = Ready; if (!active || useDepth++ > 0) { return; } Layer[] layers = Layers; foreach (Layer obj in layers) { obj.Instance = NavMesh.AddNavMeshData(obj.Data); } if (!linksResolved) { ResolveLinks(); } foreach (NavMeshLinkData linkDatum in LinkData) { LinkInstances.Add(NavMesh.AddLink(linkDatum)); } } public void Dispose() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (!active || --useDepth > 0) { return; } foreach (NavMeshLinkInstance linkInstance in LinkInstances) { NavMeshLinkInstance current = linkInstance; ((NavMeshLinkInstance)(ref current)).Remove(); } LinkInstances.Clear(); Layer[] layers = Layers; for (int i = 0; i < layers.Length; i++) { ((NavMeshDataInstance)(ref layers[i].Instance)).Remove(); } } } private static readonly Layer Comfortable = new Layer { Name = "comfortable" }; private static readonly Layer Tight = new Layer { Name = "tight" }; private static readonly Layer Squeeze = new Layer { Name = "squeeze" }; private static readonly Layer[] Layers = new Layer[3] { Comfortable, Tight, Squeeze }; private static readonly List<BlockedArea> Blocked = new List<BlockedArea>(); private static NavMeshData bakedFromGameData; private static float bakedRadius = -1f; private static float bakedExtra = -1f; private static int useDepth; private static readonly Func<NavMeshSurface, List<NavMeshBuildSource>> CollectSources = AccessTools.MethodDelegate<Func<NavMeshSurface, List<NavMeshBuildSource>>>(AccessTools.Method(typeof(NavMeshSurface), "CollectSources", (Type[])null, (Type[])null), (object)null, true); private static readonly Func<NavMeshSurface, List<NavMeshBuildSource>, Bounds> CalculateWorldBounds = AccessTools.MethodDelegate<Func<NavMeshSurface, List<NavMeshBuildSource>, Bounds>>(AccessTools.Method(typeof(NavMeshSurface), "CalculateWorldBounds", (Type[])null, (Type[])null), (object)null, true); private static readonly List<Gap> Gaps = new List<Gap>(); private static NavMeshData gapsFromGameData; private static float gapsMax = -1f; private static readonly List<NavMeshLinkData> LinkData = new List<NavMeshLinkData>(); private static readonly List<NavMeshLinkInstance> LinkInstances = new List<NavMeshLinkInstance>(); private static readonly NavMeshPath LinkCheck = new NavMeshPath(); private static bool linksResolved; private static bool pendingRebuild; private static List<NavMeshBuildSource> baseSources; private static Bounds baseBounds; internal static bool Busy => Array.Exists(Layers, (Layer l) => IsRunning(l.Op)); internal static bool Ready { get { if (!Busy) { return Array.TrueForAll(Layers, (Layer l) => (Object)(object)l.Data != (Object)null); } return false; } } internal static NavMeshQueryFilter ComfortableFilter => Filter(Comfortable); internal static NavMeshQueryFilter TightFilter => Filter(Tight); internal static NavMeshQueryFilter SqueezeFilter => Filter(Squeeze); internal static NavMeshQueryFilter GameFilter { get { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) NavMeshSurface val = GameSurface(); NavMeshQueryFilter result = default(NavMeshQueryFilter); ((NavMeshQueryFilter)(ref result)).agentTypeID = (((Object)(object)val != (Object)null) ? val.agentTypeID : 0); ((NavMeshQueryFilter)(ref result)).areaMask = -1; return result; } } internal static float TightRadius => Tight.Radius; private static NavMeshQueryFilter Filter(Layer l) { //IL_0002: 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) NavMeshQueryFilter result = default(NavMeshQueryFilter); ((NavMeshQueryFilter)(ref result)).agentTypeID = l.AgentTypeId; ((NavMeshQueryFilter)(ref result)).areaMask = -1; return result; } private static bool IsRunning(AsyncOperation op) { if (op != null) { return !op.isDone; } return false; } internal static bool EnsureBaked(float radius, float maxGap) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Invalid comparison between Unknown and I4 //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) NavMeshSurface val = GameSurface(); if ((Object)(object)val == (Object)null || (Object)(object)val.navMeshData == (Object)null) { return false; } float value = Cfg.PreferredExtraClearance.Value; if (((Object)(object)val.navMeshData != (Object)(object)bakedFromGameData || !Mathf.Approximately(radius, bakedRadius) || !Mathf.Approximately(value, bakedExtra)) && !Busy) { if ((Object)(object)val.navMeshData != (Object)(object)bakedFromGameData) { Blocked.Clear(); } bakedFromGameData = val.navMeshData; bakedRadius = radius; bakedExtra = value; Comfortable.Radius = radius + value; Tight.Radius = radius; Squeeze.Radius = Mathf.Max(0.25f, radius * 0.5f); Layer[] layers = Layers; for (int i = 0; i < layers.Length; i++) { layers[i].Data = null; } baseSources = CollectSources(val); baseBounds = (Bounds)(((int)val.collectObjects == 1) ? new Bounds(val.center, new Vector3(Mathf.Abs(val.size.x), Mathf.Abs(val.size.y), Mathf.Abs(val.size.z))) : CalculateWorldBounds(val, baseSources)); Rebuild(val); Plugin.Log.LogInfo((object)$"Baking cart NavMesh (tight r={Tight.Radius:F2}, comfortable r={Comfortable.Radius:F2})..."); return false; } if (Ready && useDepth == 0 && ((Object)(object)gapsFromGameData != (Object)(object)bakedFromGameData || !Mathf.Approximately(maxGap, gapsMax))) { gapsFromGameData = bakedFromGameData; gapsMax = maxGap; FindGaps(maxGap); } return Ready; } private static Vector3Int Key(Vector3 p) { //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_000b: Unknown result type (might be due to invalid IL or missing references) return Vector3Int.RoundToInt(p * 50f); } private static bool FloorAt(Vector3 p, float y, out float hitY) { //IL_0007: 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_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_003d: Unknown result type (might be due to invalid IL or missing references) hitY = 0f; RaycastHit val = default(RaycastHit); if (!Physics.Raycast(new Vector3(p.x, y + 0.5f, p.z), Vector3.down, ref val, 0.8f, PathPlanner.WorldMask, (QueryTriggerInteraction)1)) { return false; } hitY = ((RaycastHit)(ref val)).point.y; return true; } private static void FindGaps(float maxGap) { //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_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_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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_01b3: 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_00f1: 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_00e6: 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_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0496: 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_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0284: 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_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) Gaps.Clear(); LinkData.Clear(); linksResolved = false; if (maxGap < 0.2f) { return; } NavMeshTriangulation val = NavMesh.CalculateTriangulation(); Vector3[] vertices = val.vertices; int[] indices = val.indices; Dictionary<(Vector3Int, Vector3Int), (int, int, int, int)> dictionary = new Dictionary<(Vector3Int, Vector3Int), (int, int, int, int)>(); for (int i = 0; i + 2 < indices.Length; i += 3) { for (int j = 0; j < 3; j++) { int num = indices[i + j]; int num2 = indices[i + (j + 1) % 3]; int item = indices[i + (j + 2) % 3]; Vector3Int val2 = Key(vertices[num]); Vector3Int val3 = Key(vertices[num2]); (Vector3Int, Vector3Int) key = ((((Vector3Int)(ref val2)).x > ((Vector3Int)(ref val3)).x || (((Vector3Int)(ref val2)).x == ((Vector3Int)(ref val3)).x && (((Vector3Int)(ref val2)).y > ((Vector3Int)(ref val3)).y || (((Vector3Int)(ref val2)).y == ((Vector3Int)(ref val3)).y && ((Vector3Int)(ref val2)).z > ((Vector3Int)(ref val3)).z)))) ? (val3, val2) : (val2, val3)); dictionary[key] = (dictionary.TryGetValue(key, out var value) ? (value.Item1, value.Item2, value.Item3, value.Item4 + 1) : (num, num2, item, 1)); } } foreach (var value2 in dictionary.Values) { var (num3, num4, num5, _) = value2; if (value2.Item4 != 1) { continue; } Vector3 val4 = vertices[num3]; Vector3 val5 = PathPlanner.Flat(vertices[num4] - val4); float magnitude = ((Vector3)(ref val5)).magnitude; if (magnitude < 0.05f) { continue; } val5 /= magnitude; Vector3 val6 = Vector3.Cross(Vector3.up, val5); if (Vector3.Dot(val6, PathPlanner.Flat(vertices[num5] - val4)) > 0f) { val6 = -val6; } for (float num6 = Mathf.Min(0.5f, magnitude * 0.5f); num6 < magnitude; num6 += 1f) { Vector3 val7 = val4 + val5 * num6; if (FloorAt(val7 + val6 * 0.7f, val7.y, out var _)) { continue; } float num7 = -1f; float num8 = -1f; for (float num9 = 0f; num9 <= 0.7f + maxGap + 0.2f; num9 += 0.1f) { float hitY2; bool flag = FloorAt(val7 + val6 * num9, val7.y, out hitY2) && Mathf.Abs(hitY2 - val7.y) < 0.2f; if (num7 < 0f) { if (!flag) { num7 = num9; } } else if (flag) { num8 = num9; break; } } if (num7 < 0f || num8 < 0f || num8 - num7 > maxGap) { continue; } Vector3 val8 = val7 + val6 * Mathf.Max(0f, num7 - 0.1f); Vector3 val9 = val7 + val6 * num8; if (!Physics.Linecast(val8 + Vector3.up * 0.4f, val9 + val6 * 0.3f + Vector3.up * 0.4f, PathPlanner.WorldMask, (QueryTriggerInteraction)1)) { Vector3 mid = (val8 + val9) * 0.5f; if (!Gaps.Exists(delegate(Gap g) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0026: Unknown result type (might be due to invalid IL or missing references) Vector3 val11 = (g.A + g.B) * 0.5f - mid; return ((Vector3)(ref val11)).sqrMagnitude < 0.64000005f; })) { Gaps.Add(new Gap { A = val8, B = val9, Out = val6 }); } } } } Plugin.Log.LogInfo((object)$"Small floor gaps the cart can roll over: {Gaps.Count}"); foreach (Gap gap in Gaps) { object arg = gap.A; object arg2 = gap.B; Vector3 val10 = PathPlanner.Flat(gap.B - gap.A); PathPlanner.Verbose($"Gap {arg} -> {arg2} ({((Vector3)(ref val10)).magnitude:F2}m)"); } } private static void ResolveLinks() { //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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_00ce: Unknown result type (might be due to invalid IL or missing references) linksResolved = true; LinkData.Clear(); Layer[] layers = Layers; NavMeshHit val2 = default(NavMeshHit); NavMeshHit val3 = default(NavMeshHit); foreach (Layer layer in layers) { NavMeshQueryFilter val = Filter(layer); foreach (Gap gap in Gaps) { if (NavMesh.SamplePosition(gap.A - gap.Out * (layer.Radius + 0.2f), ref val2, 0.5f, val) && NavMesh.SamplePosition(gap.B + gap.Out * (layer.Radius + 0.2f), ref val3, 0.5f, val) && (!NavMesh.CalculatePath(((NavMeshHit)(ref val2)).position, ((NavMeshHit)(ref val3)).position, val, LinkCheck) || (int)LinkCheck.status != 0 || !(PathPlanner.Length(new List<Vector3>(LinkCheck.corners)) < 6f))) { List<NavMeshLinkData> linkData = LinkData; NavMeshLinkData item = default(NavMeshLinkData); ((NavMeshLinkData)(ref item)).startPosition = ((NavMeshHit)(ref val2)).position; ((NavMeshLinkData)(ref item)).endPosition = ((NavMeshHit)(ref val3)).position; ((NavMeshLinkData)(ref item)).width = 0f; ((NavMeshLinkData)(ref item)).bidirectional = true; ((NavMeshLinkData)(ref item)).costModifier = -1f; ((NavMeshLinkData)(ref item)).area = 0; ((NavMeshLinkData)(ref item)).agentTypeID = layer.AgentTypeId; linkData.Add(item); } } } Plugin.Log.LogInfo((object)$"Gap links on cart meshes: {LinkData.Count}"); } internal static void AddBlockedArea(Vector3 pos, float radius) { //IL_000f: 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_0044: Unknown result type (might be due to invalid IL or missing references) Blocked.Add(new BlockedArea { Pos = pos, Radius = radius, Expires = Time.time + Cfg.BlockedAreaLifetime.Value }); Plugin.Log.LogInfo((object)$"Blocked area at {pos} r={radius:F1} for {Cfg.BlockedAreaLifetime.Value:F0}s"); pendingRebuild = true; Tick(); } internal static void Tick() { if (Blocked.RemoveAll((BlockedArea b) => b.Expires < Time.time) > 0) { pendingRebuild = true; } if (pendingRebuild && Ready) { NavMeshSurface val = GameSurface(); if (!((Object)(object)val == (Object)null)) { pendingRebuild = false; Rebuild(val); } } } internal static float RadiusOf(NavMeshQueryFilter f) { //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) if (((NavMeshQueryFilter)(ref f)).agentTypeID != Comfortable.AgentTypeId) { if (((NavMeshQueryFilter)(ref f)).agentTypeID != Squeeze.AgentTypeId) { if (((NavMeshQueryFilter)(ref f)).agentTypeID != Tight.AgentTypeId) { NavMeshBuildSettings settingsByID = NavMesh.GetSettingsByID(((NavMeshQueryFilter)(ref f)).agentTypeID); return ((NavMeshBuildSettings)(ref settingsByID)).agentRadius; } return Tight.Radius; } return Squeeze.Radius; } return Comfortable.Radius; } private static void Rebuild(NavMeshSurface surface) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown List<NavMeshBuildSource> list = new List<NavMeshBuildSource>(baseSources); foreach (BlockedArea item2 in Blocked) { NavMeshBuildSource item = default(NavMeshBuildSource); ((NavMeshBuildSource)(ref item)).shape = (NavMeshBuildSourceShape)5; ((NavMeshBuildSource)(ref item)).transform = Matrix4x4.Translate(item2.Pos); ((NavMeshBuildSource)(ref item)).size = new Vector3(item2.Radius * 2f, 4f, item2.Radius * 2f); ((NavMeshBuildSource)(ref item)).area = 1; list.Add(item); } Bounds val = baseBounds; Layer[] layers = Layers; foreach (Layer layer in layers) { if (layer.AgentTypeId < 0) { NavMeshBuildSettings val2 = NavMesh.CreateSettings(); layer.AgentTypeId = ((NavMeshBuildSettings)(ref val2)).agentTypeID; } NavMeshBuildSettings buildSettings = surface.GetBuildSettings(); ((NavMeshBuildSettings)(ref buildSettings)).agentTypeID = layer.AgentTypeId; ((NavMeshBuildSettings)(ref buildSettings)).agentRadius = layer.Radius; if ((Object)(object)layer.Data == (Object)null) { layer.Data = new NavMeshData(layer.AgentTypeId) { position = ((Component)surface).transform.position, rotation = ((Component)surface).transform.rotation }; } layer.Op = NavMeshBuilder.UpdateNavMeshDataAsync(layer.Data, buildSettings, list, val); } } private static NavMeshSurface GameSurface() { LevelGenerator instance = LevelGenerator.Instance; if (!((Object)(object)instance != (Object)null) || !instance.Generated) { return null; } return ((Component)instance).GetComponent<NavMeshSurface>(); } internal static Scope Use() { return new Scope(_: true); } } internal class CartPilotController : MonoBehaviourPun { private enum State { Idle, WaitMesh, Driving, Yielding, Reversing, Recovering } private enum HudState : byte { Hidden, Driving, Arrived, NoPath } internal static readonly List<CartPilotController> All = new List<CartPilotController>(); private PhysGrabCart cart; private Rigidbody rb; internal CartShape Shape; private float lastDrivingTime = -999f; private Player commander; private string notice; private float noticeUntil; private State state; private Vector3 goal; private Transform follow; private float arriveDistance; private int rejectedRoutes; private float failTime = -10f; private Vector3 failGoal; private Vector3 failPos; private ExtractionPoint extraction; private bool extractionInside; private bool extractionStayOutside; private List<Waypoint> path; private int seg; private float segT; private float offPath; private bool facingBack; private float lastPlanTime; private float followCheckTimer; private PathDebugDraw debug; private float yawCmd; private float hudTotal = -1f; private float hudRemaining; private float hudSendTime; private HudState hud; private float hudProgress; private float hudShown; private float hudMeters; private float hudUntil; private static readonly Color HudPanel = new Color(0.05f, 0.05f, 0.07f, 0.55f); private static readonly Color HudTrack = new Color(1f, 1f, 1f, 0.15f); private static readonly Color HudCart = new Color(1f, 0.6f, 0.15f); private static readonly Color HudOk = new Color(0.35f, 0.85f, 0.45f); private static readonly Color HudFail = new Color(0.95f, 0.3f, 0.3f); private static GUIStyle hudLabel; private static readonly int BlockerMask = LayerMask.GetMask(new string[4] { "Enemy", "Player", "PhysGrabObject", "PhysGrabObjectCart" }); private static readonly RaycastHit[] Hits = (RaycastHit[])(object)new RaycastHit[32]; private static readonly Collider[] Overlaps = (Collider[])(object)new Collider[32]; private const float ProbeLift = 0.3f; private Vector3 blockerPos; private float yieldTimer; private float clearTimer; private Vector3 reverseTarget; private float reverseTimer; private int committedChoke = -1; private float commandedSpeed; private Vector3 stuckRef; private float stuckTimer; private Vector3 lastStuckPos; private float lastStuckTime = -999f; private bool goalBlockNotified; private bool stuckRepeat; private Vector3 recoverDir; private float recoverTimer; private const float ScanInterval = 0.25f; private const float ScanRange = 15f; private float aheadScanTimer; private float aheadBlockedFor; private static readonly int FloorMask = LayerMask.GetMask(new string[3] { "Default", "NavmeshOnly", "PlayerOnlyCollision" }); private const float MaxDrop = 1f; private static readonly int DoorSearchMask = LayerMask.GetMask(new string[2] { "PhysGrabObjectHinge", "PhysGrabObject" }); private Destination lastDest; private float diagTickTimer; private static readonly int WallMask = LayerMask.GetMask(new string[1] { "Default" }); private int cargoCount; private float cargoValue; private float cargoLogCooldown; private float cargoSeen; private readonly List<PhysGrabObject> cargoBefore = new List<PhysGrabObject>(); private float hitLogCooldown; private float CartRadius => ((Cfg.CartRadius.Value > 0f) ? Cfg.CartRadius.Value : Shape.HalfWidth) + Cfg.ClearanceMargin.Value; private float MaxGap => Shape.HalfLength * 0.9f; private void Awake() { cart = ((Component)this).GetComponent<PhysGrabCart>(); rb = ((Component)this).GetComponent<Rigidbody>(); } private void Start() { Shape = CartShape.Measure(rb); Plugin.Log.LogInfo((object)$"Cart '{((Object)this).name}' measured: {Shape}"); Diag("spawn", ""); } private void OnEnable() { All.Add(this); } private void OnDisable() { All.Remove(this); } internal static bool CarryingWhileDriving(Vector3 pos) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0062: 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_0081: Unknown result type (might be due to invalid IL or missing references) foreach (CartPilotController item in All) { if (!(Time.time - item.lastDrivingTime > 2f) && !((Object)(object)item.cart.inCart == (Object)null)) { Vector3 val = item.cart.inCart.InverseTransformPoint(pos); if (Mathf.Abs(val.x) < 0.6f && Mathf.Abs(val.z) < 0.6f && val.y > -0.6f && val.y < 1.5f) { return true; } } } return false; } internal static CartPilotController Nearest(Vector3 pos) { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) CartPilotController result = null; float num = float.MaxValue; foreach (CartPilotController item in All) { Vector3 val = ((Component)item).transform.position - pos; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } return result; } internal void SendCommand(Destination dest, Vector3 playerPos) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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) if (SemiFunc.IsMasterClientOrSingleplayer()) { CartPilotGoToRPC((int)dest, playerPos); return; } ((MonoBehaviourPun)this).photonView.RPC("CartPilotGoToRPC", (RpcTarget)2, new object[2] { (int)dest, playerPos }); } [PunRPC] private void CartPilotGoToRPC(int dest, Vector3 playerPos, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_003b: 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) if (SemiFunc.IsMasterClientOrSingleplayer()) { if (!Enum.IsDefined(typeof(Destination), dest)) { Plugin.Log.LogWarning((object)$"Ignoring unknown destination {dest} from client."); return; } commander = info.Sender; GoTo((Destination)dest, playerPos); } } private void Notify(string message) { Plugin.Log.LogWarning((object)("Cart '" + ((Object)this).name + "': " + message)); Diag("FAIL", message); if (commander == null || commander.IsLocal) { CartPilotNotifyRPC(message); return; } ((MonoBehaviourPun)this).photonView.RPC("CartPilotNotifyRPC", commander, new object[1] { message }); } [PunRPC] private void CartPilotNotifyRPC(string message) { notice = "Cart: " + message; noticeUntil = Time.time + 3f; } private void Update() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (notice != null && Time.time < noticeUntil) { SemiFunc.UIBigMessage(notice, "{:O}", 20f, Color.white, new Color(1f, 0.55f, 0f)); } } private void GoTo(Destination dest, Vector3 playerPos) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) lastDest = dest; Diag("command", string.Format("{0} by {1}", dest, (commander == null) ? "host" : commander.NickName)); if (BeingHandled()) { Notify("someone is holding me"); return; } HudReset(); extraction = null; extractionInside = false; if (!ResolveDestination(dest, playerPos, out goal, out follow)) { Notify((dest == Destination.Extraction || dest == Destination.ExtractionOpen) ? "no extraction point available" : ("can't find the " + dest.ToString().ToLower())); HudSend(HudState.NoPath); return; } if (Time.time - failTime < 3f) { Vector3 val = goal - failGoal; if (((Vector3)(ref val)).magnitude < 1f) { val = ((Component)this).transform.position - failPos; if (((Vector3)(ref val)).magnitude < 0.5f) { Notify("still no way there"); HudSend(HudState.NoPath); return; } } } Plugin.Log.LogInfo((object)$"Cart '{((Object)this).name}' -> {dest} at {goal}"); arriveDistance = (((Object)(object)follow != (Object)null) ? (Shape.HalfLength + 1.2f) : 0.8f); rejectedRoutes = 0; SetState(State.WaitMesh); } private void SetState(State s) { if (s != state) { PathPlanner.Verbose($"Cart '{((Object)this).name}': {state} -> {s}"); Diag("state", $"{state}->{s}"); } if (s == State.Idle != (state == State.Idle)) { SetSlippery(s != State.Idle); } state = s; } private void SetSlippery(bool on) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!on && (int)cart.currentState != 0) { return; } foreach (Collider capsuleCollider in cart.capsuleColliders) { capsuleCollider.material = (on ? cart.physMaterialSlippery : cart.physMaterialNormal); } foreach (Collider item in cart.cartInside) { item.material = (on ? SemiFunc.PhysicMaterialPhysGrabObject() : cart.physMaterialNormal); } } private void OnDestroy() { debug?.Destroy(); } private void FixedUpdate() { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } CartNavMesh.Tick(); if (state == State.Idle) { return; } lastDrivingTime = Time.time; DiagTick(); HudTick(); if (BeingHandled()) { Plugin.Log.LogInfo((object)"Player took the cart, stopping."); Stop(HudState.Hidden); return; } switch (state) { case State.WaitMesh: if (CartNavMesh.EnsureBaked(CartRadius, MaxGap)) { Replan(); } break; case State.Driving: Drive(); break; case State.Yielding: Yield(); break; case State.Reversing: Reverse(); break; case State.Recovering: Recover(); break; } } private bool BeingHandled() { return cart.physGrabObject.playerGrabbing.Count > 0; } private void Stop(HudState result = HudState.NoPath) { //IL_0030: 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_004f: 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_0083: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) SetState(State.Idle); path = null; debug?.Clear(); rb.velocity = new Vector3(0f, rb.velocity.y, 0f); rb.angularVelocity = Vector3.zero; yawCmd = 0f; if (result == HudState.NoPath) { failTime = Time.time; failGoal = (((Object)(object)follow != (Object)null) ? follow.position : goal); failPos = ((Component)this).transform.position; } HudSend(result); } private void Replan(bool sticky = false) { //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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) lastPlanTime = Time.time; Vector3 val = goal; if ((Object)(object)follow != (Object)null) { goal = follow.position; } Vector3 val2 = ((Component)this).transform.position + Vector3.up * Shape.BottomY; Stopwatch stopwatch = Stopwatch.StartNew(); PlanResult planResult = PathPlanner.Plan(val2, goal, Shape); if ((Object)(object)follow != (Object)null && Unreached(planResult, goal) && (planResult.Path == null || planResult.Path[planResult.Path.Count - 1].Pos.y < goal.y - 1f) && PathPlanner.FloorBelow(goal, out var floor)) { PlanResult planResult2 = PathPlanner.Plan(val2, floor, Shape); if (!Unreached(planResult2, floor)) { Plugin.Log.LogInfo((object)$"Cart '{((Object)this).name}': player is up out of reach, going to the floor below at {floor}."); planResult = planResult2; goal = floor; } } Diag("plantime", $"{stopwatch.Elapsed.TotalMilliseconds:F1}ms"); Vector3 val3; if (sticky && path != null) { float num = RemainingLength(); val3 = PathPlanner.Flat(goal - val); float num2 = num + ((Vector3)(ref val3)).magnitude + 4f; if (planResult.Path == null || planResult.Partial || PathLength(planResult.Path) > num2) { PathPlanner.Verbose("Player moved; new route is longer or worse, keeping the current one."); goal = val; return; } } if (planResult.Path == null) { Plugin.Log.LogWarning((object)("Cart '" + ((Object)this).name + "': route rejected (" + planResult.Error + ").")); if (!planResult.FailPoint.HasValue) { Notify("no way through for me, stopped"); Stop(); } else if (planResult.TooNarrow) { Notify("too narrow for the cart here, stopped"); Stop(); } else if (++rejectedRoutes > 2) { Notify("no way through for me, stopped"); Stop(); } else { CartNavMesh.AddBlockedArea(planResult.FailPoint.Value, CartRadius + 0.5f); SetState(State.WaitMesh); } return; } if (planResult.Partial) { Plugin.Log.LogInfo((object)"Goal not fully reachable for the cart; driving as close as possible."); } if (planResult.Partial && PathLength(planResult.Path) < 1f) { val3 = PathPlanner.Flat(goal - ((Component)this).transform.position); if (((Vector3)(ref val3)).magnitude > arriveDistance + 1f) { Notify("can't get any closer, stopped"); Stop(); return; } } path = planResult.Path; seg = 0; segT = 0f; ResetObstacleState(); if (debug == null) { debug = new PathDebugDraw(); } debug.SetPath(path); Diag("plan", $"ok waypoints={path.Count} partial={planResult.Partial}"); SetState(State.Driving); } private static bool Unreached(PlanResult r, Vector3 target) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (r.Path != null) { if (r.Partial) { Vector3 val = r.Path[r.Path.Count - 1].Pos - target; return ((Vector3)(ref val)).magnitude > 1.5f; } return false; } return !r.FailPoint.HasValue; } private void Drive() { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0415: 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_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035d: 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_02aa: 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) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) UpdateProgress(); if (offPath > 1.2f && Time.time - lastPlanTime > 0.5f) { PathPlanner.Verbose($"Off path by {offPath:F1}m, replanning."); Replan(); return; } Vector3 val; if ((Object)(object)follow != (Object)null && (followCheckTimer -= Time.fixedDeltaTime) < 0f) { followCheckTimer = 2f; val = PathPlanner.Flat(follow.position - goal); if (((Vector3)(ref val)).magnitude > 3f) { Replan(sticky: true); return; } } float num = RemainingLength(); if ((Object)(object)follow != (Object)null) { val = PathPlanner.Flat(follow.position - ((Component)this).transform.position); if (((Vector3)(ref val)).magnitude < arriveDistance + 0.3f && Mathf.Abs(follow.position.y - ((Component)this).transform.position.y) < 1.5f) { num = 0f; } } val = PathPlanner.Flat(path[path.Count - 1].Pos - goal); bool flag = ((Vector3)(ref val)).magnitude < 1f; if (num < (flag ? arriveDistance : 0.5f)) { if ((Object)(object)extraction != (Object)null) { val = PathPlanner.Flat(goal - ((Component)this).transform.position); if (((Vector3)(ref val)).magnitude > 3f) { Notify("can't reach the extraction, stopped"); Stop(); return; } } if ((Object)(object)extraction != (Object)null && !extractionInside) { extraction.OnClick(); if (extractionStayOutside) { Plugin.Log.LogInfo((object)("Cart '" + ((Object)this).name + "' at extraction: pressed button, staying outside.")); Stop(HudState.Arrived); return; } Plugin.Log.LogInfo((object)("Cart '" + ((Object)this).name + "' at extraction: pressed button, driving inside.")); extractionInside = true; goal = ((Component)extraction).transform.position; arriveDistance = 0.5f; Replan(); return; } if ((Object)(object)follow != (Object)null && flag && Time.time - lastPlanTime > 1f) { val = PathPlanner.Flat(follow.position - ((Component)this).transform.position); if (((Vector3)(ref val)).magnitude > arriveDistance + 2f && Mathf.Abs(follow.position.y - goal.y) < 1.5f) { Replan(); return; } } val = PathPlanner.Flat(goal - ((Component)this).transform.position); if (((Vector3)(ref val)).magnitude > arriveDistance + 1f) { ManualLogSource log = Plugin.Log; string name = ((Object)this).name; val = PathPlanner.Flat(goal - ((Component)this).transform.position); log.LogInfo((object)$"Cart '{name}' route ended {((Vector3)(ref val)).magnitude:F1}m from target."); Notify("can't get any closer, stopped"); Stop(); } else { Plugin.Log.LogInfo((object)("Cart '" + ((Object)this).name + "' arrived.")); Stop(HudState.Arrived); } return; } bool flag2 = StairsNear(1.5f); float num2 = TargetSpeed(num, flag2); float dist = (flag2 ? Cfg.StairsLookahead.Value : Mathf.Lerp(0.8f, Cfg.Lookahead.Value, num2 / Mathf.Max(0.1f, Cfg.MaxSpeed.Value))); Vector3 val2 = PointAhead(dist); debug?.SetLookahead(val2); val = PathPlanner.Flat(val2 - ((Component)this).transform.position); Vector3 normalized = ((Vector3)(ref val)).normalized; if (!CheckObstacles(normalized)) { Steer(val2, num2); if (flag2) { StairsAssist(); } CheckStuck(normalized); } } private void Steer(Vector3 target, float speed) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0082: 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_00e7: 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) Vector3 val = PathPlanner.Flat(target - ((Component)this).transform.position); if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { ((Vector3)(ref val)).Normalize(); Vector3 val2 = PathPlanner.Flat(((Component)this).transform.forward); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = Vector3.Angle(normalized, val); if (facingBack ? (num < 60f) : (num > 120f)) { facingBack = !facingBack; } float num2 = Vector3.SignedAngle(facingBack ? (-normalized) : normalized, val, Vector3.up); float yawRate = Mathf.Clamp(num2 * (MathF.PI / 180f) * 6f, -4f, 4f); SetYawRate(yawRate); float num3 = Mathf.Clamp01(1f - (Mathf.Abs(num2) - 25f) / 50f); commandedSpeed = speed * num3; ApplyVelocity(val * commandedSpeed); } } private void SetYawRate(float yawRate) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) Vector3 val = PathPlanner.Flat(rb.velocity); float magnitude = ((Vector3)(ref val)).magnitude; float num = Mathf.Min(1.5f / Mathf.Max(0.5f, Shape.HalfLength), 3f / Mathf.Max(0.1f, magnitude)); yawRate = Mathf.Clamp(yawRate, 0f - num, num); yawCmd = Mathf.MoveTowards(yawCmd, yawRate, 2.5f * Time.fixedDeltaTime); rb.angularVelocity = new Vector3(0f, yawCmd, 0f); } private void ApplyVelocity(Vector3 horizontal) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_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_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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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) Vector3 velocity = rb.velocity; float num = ((state == State.Driving && StairsNear(1.5f)) ? 30f : 10f); Vector3 val = Vector3.MoveTowards(new Vector3(velocity.x, 0f, velocity.z), horizontal, num * Time.fixedDeltaTime); rb.velocity = new Vector3(val.x, velocity.y, val.z); } private float TargetSpeed(float remaining, bool stairs) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_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_003a: 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_003c: 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) float value = Cfg.MaxSpeed.Value; Vector3 val = PointAhead(0f); Vector3 val2 = PointAhead(1f); Vector3 val3 = PointAhead(3f); float num = Vector3.Angle(PathPlanner.Flat(val2 - val), PathPlanner.Flat(val3 - val2)); float num2 = Mathf.Lerp(value, Mathf.Min(value, Cfg.CornerSpeed.Value), Mathf.Clamp01(num / 90f)); num2 *= Mathf.Lerp(0.5f, 1f, Mathf.Clamp01(path[seg].Room * 0.5f)); if (stairs) { num2 = Mathf.Min(num2, Cfg.StairsSpeed.Value); } if (DoorNear(2.5f)) { num2 = Mathf.Min(num2, Cfg.DoorSpeed.Value); } num2 = Mathf.Min(num2, Mathf.Sqrt(4f * Mathf.Max(0f, remaining - arriveDistance)) + 0.3f); return Mathf.Max(num2, Mathf.Min(Cfg.MinSpeed.Value, 0.5f)); } private void StairsAssist() { //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_003c: 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_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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) Vector3 pos = path[seg].Pos; Vector3 pos2 = path[Mathf.Min(seg + 1, path.Count - 1)].Pos; Vector3 val = PathPlanner.Flat(pos2 - pos); float magnitude = ((Vector3)(ref val)).magnitude; if (pos2.y <= pos.y + 0.05f || magnitude < 0.05f) { return; } float num = commandedSpeed * (pos2.y - pos.y) / magnitude; if (rb.velocity.y < num) { rb.velocity = new Vector3(rb.velocity.x, num, rb.velocity.z); } if (Cfg.StairsUpAssist.Value <= 0f) { return; } float num2 = rb.mass; foreach (PhysGrabObject item in cart.itemsInCart) { if ((Object)(object)item != (Object)null && (Object)(object)item.rb != (Object)null) { num2 += item.rb.mass; } } rb.AddForce(Vector3.up * (Cfg.StairsUpAssist.Value * num2 * (0f - Physics.gravity.y))); } private void UpdateProgress() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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) Vector3 val = PathPlanner.Flat(((Component)this).transform.position); float num = float.MaxValue; int num2 = Mathf.Min(seg + 10, path.Count - 1); for (int i = seg; i < num2; i++) { Vector3 val2 = PathPlanner.Flat(path[i].Pos); Vector3 val3 = PathPlanner.Flat(path[i + 1].Pos) - 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; } private Vector3 PointAhead(float dist) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Lerp(path[seg].Pos, path[seg + 1].Pos, segT); for (int i = seg + 1; i < path.Count; i++) { Vector3 pos = path[i].Pos; Vector3 val2 = PathPlanner.Flat(pos - val); float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude >= dist && magnitude > 0f) { return Vector3.Lerp(val, pos, dist / magnitude); } dist -= magnitude; val = pos; } return path[path.Count - 1].Pos; } private float RemainingLength() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) Vector3 val = PathPlanner.Flat(path[seg + 1].Pos - ((Component)this).transform.position); float num = ((Vector3)(ref val)).magnitude; for (int i = seg + 1; i < path.Count - 1; i++) { float num2 = num; val = PathPlanner.Flat(path[i + 1].Pos - path[i].Pos); num = num2 + ((Vector3)(ref val)).magnitude; } return num; } private static float PathLength(List<Waypoint> p) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) float num = 0f; for (int i = 1; i < p.Count; i++) { float num2 = num; Vector3 val = PathPlanner.Flat(p[i].Pos - p[i - 1].Pos); num = num2 + ((Vector3)(ref val)).magnitude; } return num; } private bool StairsNear(float ahead) { return AnyAhead(ahead, (Waypoint w) => w.Stairs); } private bool DoorNear(float ahead) { return AnyAhead(ahead, (Waypoint w) => w.Door); } private bool AnyAhead(float ahead, Func<Waypoint, bool> pred) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0036: Unknown result type (might be due to invalid IL or missing references) Vector3 val = PathPlanner.Flat(((Component)this).transform.position); for (int i = seg; i < path.Count; i++) { Vector3 val2 = PathPlanner.Flat(path[i].Pos - val); if (((Vector3)(ref val2)).magnitude > ahead && i > seg + 1) { break; } if (pred(path[i])) { return true; } } return false; } private bool ResolveDestination(Destination dest, Vector3 playerPos, out Vector3 goal, out Transform follow) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) goal = default(Vector3); follow = null; switch (dest) { case Destination.Player: { PlayerAvatar val3 = NearestPlayer(playerPos); if ((Object)(object)val3 == (Object)null) { return false; } follow = ((Component)val3).transform; goal = follow.position; return true; } case Destination.Extraction: case Destination.ExtractionOpen: { ExtractionPoint val2 = PickExtraction(playerPos); if ((Object)(object)val2 == (Object)null) { return false; } goal = ((Component)val2).transform.position + ((Component)val2).transform.forward * 4f; extraction = val2; extractionStayOutside = dest == Destination.ExtractionOpen; return true; } case Destination.Truck: { Transform val = TruckTransform(); if ((Object)(object)val == (Object)null) { return false; } goal = val.position; return true; } default: return false; } } private static PlayerAvatar NearestPlayer(Vector3 pos) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_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) PlayerAvatar result = null; float num = float.MaxValue; foreach (PlayerAvatar item in SemiFunc.PlayerGetAll()) { if (!((Object)(object)item == (Object)null) && !item.isDisabled) { Vector3 val = ((Component)item).transform.position - pos; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } private static Transform TruckTransform() { if (!((Object)(object)TruckSafetySpawnPoint.instance != (Object)null)) { if (!((Object)(object)TruckHealer.instance != (Object)null)) { return null; } return ((Component)TruckHealer.instance).transform; } return ((Component)TruckSafetySpawnPoint.instance).transform; } private ExtractionPoint PickExtraction(Vector3 playerPos) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Invalid comparison between Unknown and I4 //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_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) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) RoundDirector instance = RoundDirector.instance; if ((Object)(object)instance == (Object)null) { return null; } Transform val = TruckTransform(); bool flag = Cfg.ExtractionFurthestFromTruck.Value && (Object)(object)val != (Object)null; Vector3 val2; Vector3 val3; if (!flag) { val2 = default(Vector3); val3 = val2; } else { val3 = val.position; } Vector3 val4 = val3; if (Cfg.ExtractionFurthestFromTruck.Value && (Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"No truck found; picking extraction by player distance."); } Vector3 val5 = (Cfg.ExtractionClosestToCart.Value ? ((Component)this).transform.position : playerPos); ExtractionPoint result = null; float num = float.MaxValue; foreach (GameObject extractionPoint in instance.extractionPointList) { if ((Object)(object)extractionPoint == (Object)null) { continue; } ExtractionPoint component = extractionPoint.GetComponent<ExtractionPoint>(); if ((Object)(object)component == (Object)null) { continue; } if ((int)component.currentState == 2) { return component; } if ((int)component.currentState == 1 && !component.isLocked) { float num2; if (!flag) { val2 = ((Component)component).transform.position - val5; num2 = ((Vector3)(ref val2)).sqrMagnitude; } else { val2 = ((Component)component).transform.position - val4; num2 = 0f - ((Vector3)(ref val2)).sqrMagnitude; } float num3 = num2; if (num3 < num) { num = num3; result = component; } } } return result; } private void HudReset() { hudTotal = -1f; hudRemaining = 0f; } private void HudSend(HudState s) { float num = ((s == HudState.Arrived) ? 1f : ((hudTotal > 0f) ? (1f - hudRemaining / hudTotal) : 0f)); float num2 = ((s == HudState.Arrived) ? 0f : hudRemaining); if (commander == null || commander.IsLocal) { CartPilotHudRPC((byte)s, num, num2); return; } ((MonoBehaviourPun)this).photonView.RPC("CartPilotHudRPC", commander, new object[3] { (byte)s, num, num2 }); } private void HudTick() { if (path != null && state == State.Driving) { hudRemaining = RemainingLength(); if (hudRemaining > hudTotal) { hudTotal = hudRemaining; } } if (!(Time.time < hudSendTime)) { hudSendTime = Time.time + 0.2f; HudSend(HudState.Driving); } } [PunRPC] private void CartPilotHudRPC(byte s, float progress, float meters) { if (hud != HudState.Driving && s == 1) { hudShown = 0f; } hud = (HudState)s; hudProgress = Mathf.Clamp01(progress); hudMeters = meters; hudUntil = Time.time + ((hud == HudState.Driving) ? 2f : 3f); } private void OnGUI() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Expected O, but got Unknown //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) if (!Cfg.HudEnabled.Value || hud == HudState.Hidden) { return; } if (Time.time > hudUntil) { hud = HudState.Hidden; } else { if ((int)Event.current.type != 7) { return; } int num = 0; foreach (CartPilotController item in All) { if ((Object)(object)item == (Object)(object)this) { break; } if (item.hud != HudState.Hidden) { num++; } } float num2 = ((hud == HudState.Arrived) ? 1f : hudProgress); hudShown = Mathf.Lerp(hudShown, num2, 1f - Mathf.Exp(-6f * Time.deltaTime)); float num3 = Cfg.HudScale.Value * (float)Screen.height / 1080f; float num4 = Mathf.Clamp01((hudUntil - Time.time) / 0.4f); Color val = ((hud == HudState.Arrived) ? HudOk : ((hud == HudState.NoPath) ? HudFail : HudCart)); float num5 = Cfg.HudLength.Value * num3; float num6 = 70f * num3; float num7 = 12f * num3; float num8 = 26f * num3; float num9 = num7 + num5 + 10f * num3 + num6; float num10 = Cfg.HudX.Value * (float)Screen.width - num9 / 2f; float num11 = Cfg.HudY.Value * (float)Screen.height + (float)num * (num8 + 6f * num3); float num12 = num11 + num8 / 2f; Round(num10, num11, num9, num8, num8 / 2f, HudPanel, num4); float num13 = num10 + num7; float num14 = 4f * num3; Round(num13, num12 - num14 / 2f, num5, num14, num14 / 2f, HudTrack, num4); Round(num13, num12 - num14 / 2f, Mathf.Max(num14, hudShown * num5), num14, num14 / 2f, val, num4); float num15 = 12f * num3; float num16 = num13 + hudShown * num5; float num17 = 2f * num3; Round(num16 - num15 / 2f, num12 - num15 / 2f, num15, num15, num15 / 2f, Color.white, num4); Round(num16 - num15 / 2f + num17, num12 - num15 / 2f + num17, num15 - 2f * num17, num15 - 2f * num17, num15 / 2f, val, num4); string text = ((hud == HudState.Arrived) ? "Arrived" : ((hud == HudState.NoPath) ? "No path" : $"{Mathf.CeilToInt(hudMeters)} m")); if (hudLabel == null) { hudLabel = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)3, fontStyle = (FontStyle)1 }; } hudLabel.fontSize = Mathf.RoundToInt(13f * num3); Color color = ((hud == HudState.Driving) ? Color.white : val); color.a = 0.9f * num4; GUI.color = color; GUI.Label(new Rect(num13 + num5 + 10f * num3, num11, num6, num8), text, hudLabel); GUI.color = Color.white; } } private static void Round(float x, float y, float w, float h, float r, Color c, float alpha) { //IL_0011: 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) c.a *= alpha; GUI.DrawTexture(new Rect(x, y, w, h), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true, 0f, c, 0f, Mathf.Min(new float[3] { r, w / 2f, h / 2f })); } private void ResetObstacleState() { //IL_000e: 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) committedChoke = -1; stuckRef = ((Component)this).transform.position; stuckTimer = 0f; aheadBlockedFor = 0f; } private bool CheckObstacles(Vector3 travel) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00ca: 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_00e0: Unknown result type (might be due to invalid IL or missing references) SmashDoorAhead(travel); if (DropAhead(travel, out var point)) { Hold(); Plugin.Log.LogWarning((object)$"Cart '{((Object)this).name}': drop ahead at {point}, not driving off it."); if (++rejectedRoutes > 2) { Notify("only route has a drop, stopped"); Stop(); return true; } CartNavMesh.AddBlockedArea(point, CartRadius); SetState(State.WaitMesh); return true; } Vector3 velocity = rb.velocity; Vector2 val = new Vector2(velocity.x, velocity.z); float magnitude = ((Vector2)(ref val)).magnitude; float num = 0.6f + magnitude * magnitude / 6f; if (Probe(travel, Shape.HalfLength + num, out var hitPos, out var what)) { EnterYield(hitPos, what); return true; } if (!ChokeAheadClear(out var farSide)) { EnterYield(farSide, "far side of chokepoint occupied"); return true; } return PathAheadBlocked(); } private bool PathAheadBlocked() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if ((aheadScanTimer -= Time.fixedDeltaTime) > 0f) { return false; } aheadScanTimer = 0.25f; if (!FindBlockerOnPath(out var at, out var what)) { aheadBlockedFor = 0f; return false; } aheadBlockedFor += 0.25f; if (aheadBlockedFor < Cfg.BlockedReplanTime.Value) { return false; } aheadBlockedFor = 0f; Vector3 val = PathPlanner.Flat(at - goal); if (((Vector3)(ref val)).magnitude < 2f) { return false; } Plugin.Log.LogInfo((object)$"Cart '{((Object)this).name}': route ahead blocked by {what} at {at}, picking a new route."); CartNavMesh.AddBlockedArea(at, CartRadius + 0.6f); SetState(State.WaitMesh); return true; } private bool FindBlockerOnPath(out Vector3 at, out string what) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_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_007d: 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) at = default(Vector3); what = null; float num = Shape.HalfWidth + 0.2f; float num2 = Mathf.Min(15f, RemainingLength()); for (float num3 = 2f; num3 <= num2; num3 += 1.5f) { Vector3 val = PointAhead(num3); int num4 = Physics.OverlapSphereNonAlloc(val + Vector3.up * (0.3f + num), num, Overlaps, BlockerMask, (QueryTriggerInteraction)1); for (int i = 0; i < num4; i++) { if (!IgnoreCollider(Overlaps[i])) { at = val; what = Describe(Overlaps[i]); return true; } } } return false; } private bool ChokeAheadClear(out Vector3 farSide) { //IL_0001: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_020a: Unknown result type (might be due to invalid IL or missing references) farSide = default(Vector3); if (path[seg].Choke) { committedChoke = Mathf.Max(committedChoke, seg); } Vector3 val = PathPlanner.Flat(((Component)this).transform.position); int num = -1; Vector3 val2; for (int i = seg + 1; i < path.Count; i++) { val2 = PathPlanner.Flat(path[i].Pos - val); if (((Vector3)(ref val2)).magnitude > 3.5f) { break; } if (path[i].Choke) { num = i; break; } } if (num < 0 || num <= committedChoke) { return true; } int j; for (j = num; j + 1 < path.Count && path[j + 1].Choke; j++) { } float num2 = Shape.HalfLength * 2f + 0.5f; int k; for (k = j; k + 1 < path.Count; k++) { if (!(num2 > 0f)) { break; } float num3 = num2; val2 = PathPlanner.Flat(path[k + 1].Pos - path[k].Pos); num2 = num3 - ((Vector3)(ref val2)).magnitude; } farSide = path[k].Pos; Vector3 dir = PathPlanner.Flat(path[k].Pos - path[j].Pos); if (((Vector3)(ref dir)).sqrMagnitude < 0.01f) { dir = PathPlanner.Flat(path[j].Pos - path[num].Pos); } if (Occupied(farSide, dir, out var what)) { PathPlanner.Verbose($"Chokepoint at {path[num].Pos}: far side has {what}."); return false; } committedChoke = j; PathPlanner.Verbose($"Chokepoint at {path[num].Pos} clear, committing."); return true; } private void CheckStuck(Vector3 travel) { //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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //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_0077: 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_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_00bc: 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_00c7: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) if (commandedSpeed < 0.4f) { stuckRef = ((Component)this).transform.position; stuckTimer = 0f; } else { if ((stuckTimer += Time.fixedDeltaTime) < Cfg.StuckTimeout.Value) { return; } Vector3 val = PathPlanner.Flat(((Component)this).transform.position - stuckRef); float magnitude = ((Vector3)(ref val)).magnitude; stuckRef = ((Component)this).transform.position; stuckTimer = 0f; if (magnitude > 0.3f) { return; } int num; if (StairsNear(2f)) { if (Time.time - lastStuckTime < 20f) { val = PathPlanner.Flat(((Component)this).transform.position - lastStuckPos); num = ((((Vector3)(ref val)).magnitude < 2f) ? 1 : 0); } else { num = 0; } } else { num = 1; } stuckRepeat = (byte)num != 0; lastStuckPos = ((Component)this).transform.position; lastStuckTime = Time.time; Plugin.Log.LogInfo((object)string.Format("Cart '{0}' stuck (moved {1:F2}m in {2:F1}s){3}, backing up.", ((Object)this).name, magnitude, Cfg.StuckTimeout.Value, stuckRepeat ? ", blocking this spot" : "")); if (stuckRepeat) { CartNavMesh.AddBlockedArea(((Component)this).transform.position + travel * (Shape.HalfLength + 0.3f), CartRadius + 0.4f); } recoverDir = -travel; recoverTimer = 0f; SetState(State.Recovering); } } private void EnterYield(Vector3 at, string why) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) blockerPos = at; yieldTimer = (clearTimer = 0f); goalBlockNotified = false; Plugin.Log.LogInfo((object)$"Cart '{((Object)this).name}' yielding: {why} at {at}."); Vector3 val = PathPlanner.Flat(at - ((Component)this).transform.position); if ((((Vector3)(ref val)).magnitude < Shape.HalfLength + 1f || path[seg].Choke) && FindLastSafe(out reverseTarget)) { reverseTimer = 0f; SetState(State.Reversing); } else { SetState(State.Yielding); } } private void Yield() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_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_0053: 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_006d: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be du