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 SelfMovingCart v1.3.4
SelfMovingCart.dll
Decompiled 10 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Photon.Pun; using SelfMovingCart.Patches; using TMPro; using UnityEngine; using UnityEngine.AI; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("SelfMovingCart")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SelfMovingCart")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("63e461c3-71af-4546-991a-f4d7968cf96f")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace SelfMovingCart { [BepInPlugin("Syntaxe.SelfMovingCart", "Self Moving Cart", "1.3.3")] public class SelfMovingCartBase : BaseUnityPlugin { private const string modGUID = "Syntaxe.SelfMovingCart"; private const string modName = "Self Moving Cart"; private const string modVersion = "1.3.3"; private readonly Harmony harmony = new Harmony("Syntaxe.SelfMovingCart"); private static SelfMovingCartBase Instance; public static ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("Syntaxe.SelfMovingCart"); ConfigManager.Initialize(((BaseUnityPlugin)this).Config); mls.LogInfo((object)"Syntaxe.SelfMovingCart is now awake!"); harmony.PatchAll(typeof(SelfMovingCartBase)); harmony.PatchAll(typeof(ExtractionPointPatch)); harmony.PatchAll(typeof(PhysGrabCartPatch)); harmony.PatchAll(typeof(PlayerControllerPatch)); harmony.PatchAll(typeof(RoundDirectorPatch)); harmony.PatchAll(typeof(TruckHealerPatch)); harmony.PatchAll(typeof(PhysGrabHingePatch)); harmony.PatchAll(typeof(ChatManagerPatch)); harmony.PatchAll(typeof(InputManagerPatch)); if (ConfigManager.alwaysShowCartModeText.Value) { harmony.PatchAll(typeof(CartModeUI)); } } } } namespace SelfMovingCart.Patches { [HarmonyPatch(typeof(RoundDirector))] public static class CartModeUI { private static GameObject cartModeTextInstance; private static TextMeshProUGUI cartModeText; private static void SetCoordinates(RectTransform component) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0064: Unknown result type (might be due to invalid IL or missing references) component.pivot = new Vector2(1f, 1f); component.anchoredPosition = new Vector2(20f, 100f); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(0f, 0f); component.sizeDelta = new Vector2(0f, 0f); } [HarmonyPatch("Update")] [HarmonyPostfix] public static void UpdateCartModeUI() { //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.RunIsLevel()) { if ((Object)(object)cartModeTextInstance != (Object)null) { cartModeTextInstance.SetActive(false); } return; } if ((Object)(object)cartModeTextInstance == (Object)null) { GameObject val = GameObject.Find("Game Hud"); GameObject val2 = GameObject.Find("Tax Haul"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return; } TMP_FontAsset font = val2.GetComponent<TMP_Text>().font; cartModeTextInstance = new GameObject("Cart Mode HUD"); cartModeTextInstance.SetActive(false); cartModeTextInstance.AddComponent<TextMeshProUGUI>(); cartModeText = cartModeTextInstance.GetComponent<TextMeshProUGUI>(); ((TMP_Text)cartModeText).font = font; ((Graphic)cartModeText).color = new Color(1f, 0.95f, 0.5f, 1f); ((TMP_Text)cartModeText).fontSize = 22f; ((TMP_Text)cartModeText).enableWordWrapping = false; ((TMP_Text)cartModeText).alignment = (TextAlignmentOptions)257; ((TMP_Text)cartModeText).horizontalAlignment = (HorizontalAlignmentOptions)1; ((TMP_Text)cartModeText).verticalAlignment = (VerticalAlignmentOptions)256; cartModeTextInstance.transform.SetParent(val.transform, false); RectTransform component = cartModeTextInstance.GetComponent<RectTransform>(); SetCoordinates(component); } string text; if (PhysGrabCartPatch.controlledCart == -1) { text = "Cart Mode: Nearest Cart"; } else { CartSelfMovementManager cartSelfMovementManager = PhysGrabCartPatch.carts[PhysGrabCartPatch.controlledCart]; int privateField = ReflectionHelper.GetPrivateField<int>(((Component)cartSelfMovementManager).GetComponent<PhysGrabCart>(), "haulCurrent"); int num = Mathf.RoundToInt(Vector3.Distance(((Component)PlayerController.instance).transform.position, ((Component)cartSelfMovementManager).transform.position)); text = $"Cart Mode: Cart #{PhysGrabCartPatch.controlledCart + 1} (Val: {privateField}, Dist: {num}m)"; } ((TMP_Text)cartModeText).SetText(text, true); cartModeTextInstance.SetActive(true); } } internal class CartSelfMovementManager : MonoBehaviour { private Rigidbody rb; public CartTargetSync cartTargetSync; private Transform inCart; private float totalCartMass = 0f; private float calculateObjectsEvery = 1f; private int cornerInd = 0; private NavMeshPath cartNavMeshPath; private List<Vector3> pathCorners = new List<Vector3>(); private bool isCartFollowingPath = false; private float cornerMinDistance = 1f; private float cartSpeed = 15f; private float cartRotationSpeed = 2f; private float cartDriveRotationSpeed = 7f; private int extractionPointInd = -1; private bool isExtracting = false; public bool isCartBeingPulled = false; private Vector3 lastCartPosition = Vector3.zero; public bool remoteControlForward = false; public bool remoteControlBack = false; public bool remoteControlRight = false; public bool remoteControlLeft = false; private float pathRecalculationTimer = 5f; private float checkDistanceFromPathTimer = 0.5f; private Vector3 finalDestination; private List<GameObject> cornerSpheres; private GameObject cartHeightGuide; private bool cartGuideForward = true; private bool toVisualize = false; private List<PhysGrabHinge> collidedUnbrokenDoors = new List<PhysGrabHinge>(); private List<float> doorsCollisionTime = new List<float>(); private float destroyDoorAfter = 2f; private void Start() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_008f: 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_00c0: Unknown result type (might be due to invalid IL or missing references) rb = ((Component)this).GetComponent<Rigidbody>(); cartTargetSync = ((Component)this).gameObject.AddComponent<CartTargetSync>(); inCart = ((Component)this).transform.Find("In Cart"); cartNavMeshPath = new NavMeshPath(); isCartFollowingPath = false; isCartBeingPulled = false; remoteControlForward = false; remoteControlBack = false; remoteControlRight = false; remoteControlLeft = false; cornerSpheres = new List<GameObject>(); cartHeightGuide = new GameObject("CartHeightGuide"); cartHeightGuide.transform.localScale = Vector3.one / 4f; cartGuideForward = true; if (toVisualize) { MiscHelper.AddSphereToGameObject(cartHeightGuide, 0.1f, Color.yellow); } } private void FixedUpdate() { GetNextCartStepHeight(); HandleCollidedDoors(); calculateObjectsEvery -= Time.fixedDeltaTime; if (calculateObjectsEvery < 0f) { CalculateCartObjectsMass(); calculateObjectsEvery = 0.5f; } if ((remoteControlForward || remoteControlBack || remoteControlRight || remoteControlLeft) && !isCartBeingPulled) { StopPathfinding(); ApplyUpwardsForceToCart(); if (remoteControlForward || remoteControlBack) { HandleCartSpeed(); } if (remoteControlForward) { MoveCartForward(); } if (remoteControlBack) { MoveCartBackward(); } if (remoteControlRight) { TurnCartRight(); } if (remoteControlLeft) { TurnCartLeft(); } } if (isCartBeingPulled && isCartFollowingPath) { StopPathfinding(); } if (isCartFollowingPath) { ApplyUpwardsForceToCart(); HandleCartSpeed(); FollowPath(); HandlePathRecalculation(); } } private void HandlePathRecalculation() { //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_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_0098: 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) checkDistanceFromPathTimer -= Time.fixedDeltaTime; pathRecalculationTimer -= Time.fixedDeltaTime; if (checkDistanceFromPathTimer < 0f) { Vector3 closestPointOnPath = GetClosestPointOnPath(); float num = Vector3.Distance(((Component)this).transform.position, closestPointOnPath); if (num > 0.5f) { CalculatePath(finalDestination); checkDistanceFromPathTimer = 0.5f; pathRecalculationTimer = 5f; } } if (pathRecalculationTimer < 0f) { CalculatePath(finalDestination); checkDistanceFromPathTimer = 0.5f; pathRecalculationTimer = 5f; } } private void CalculateCartObjectsMass() { //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_0028: 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) List<PhysGrabObject> list = new List<PhysGrabObject>(); float num = 0f; Collider[] array = Physics.OverlapBox(inCart.position, inCart.localScale / 2f, inCart.rotation); Collider[] array2 = array; foreach (Collider val in array2) { bool flag = ((Component)val).gameObject.layer == LayerMask.NameToLayer("PhysGrabObject"); bool flag2 = ((Component)val).gameObject.layer == LayerMask.NameToLayer("Player"); if (!flag && !flag2) { continue; } Rigidbody componentInParent = ((Component)val).gameObject.GetComponentInParent<Rigidbody>(); if ((Object)(object)componentInParent == (Object)null) { continue; } if (flag) { PhysGrabObject componentInParent2 = ((Component)val).GetComponentInParent<PhysGrabObject>(); if (!list.Contains(componentInParent2)) { list.Add(componentInParent2); num += componentInParent.mass; } } else { num += componentInParent.mass; } } totalCartMass = num; } private void MoveCartForward() { //IL_001b: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_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_007b: 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_008c: Unknown result type (might be due to invalid IL or missing references) if (!cartGuideForward) { cartGuideForward = true; } Vector3 val = new Vector3(((Component)this).transform.forward.x, 0f, ((Component)this).transform.forward.z); Vector3 normalized = ((Vector3)(ref val)).normalized; float y = rb.velocity.y; Vector3 val2 = normalized * cartSpeed; val2.y = y; rb.velocity = Vector3.Lerp(rb.velocity, val2, Time.fixedDeltaTime * 2f); } private void MoveCartBackward() { //IL_0018: 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_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_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_004a: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (cartGuideForward) { cartGuideForward = false; } Vector3 val = new Vector3(((Component)this).transform.forward.x, 0f, ((Component)this).transform.forward.z); Vector3 val2 = -((Vector3)(ref val)).normalized; float y = rb.velocity.y; Vector3 val3 = val2 * (cartSpeed * 0.7f); val3.y = y; rb.velocity = Vector3.Lerp(rb.velocity, val3, Time.fixedDeltaTime * 2f); } private void TurnCartLeft() { //IL_0007: 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_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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_011c: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) Vector3 val = new Vector3(rb.velocity.x, 0f, rb.velocity.z); float magnitude = ((Vector3)(ref val)).magnitude; float num = Mathf.Clamp01(1f - magnitude / (cartSpeed * 1.2f)); float num2 = cartDriveRotationSpeed * Mathf.Lerp(0.5f, 1f, num); float num3 = -90f * Time.fixedDeltaTime * num2; float num4 = Mathf.Clamp(Mathf.Abs(num3) / 180f, 0.2f, 1f) * 15f; num4 = Mathf.Clamp(num4, 0f, 4f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, Mathf.Sign(num3) * num4, 0f); rb.angularVelocity = Vector3.MoveTowards(rb.angularVelocity, val2, num4); rb.angularVelocity = Vector3.ClampMagnitude(rb.angularVelocity, 4f); Vector3 val3 = Vector3.Project(rb.velocity, ((Component)this).transform.right); Rigidbody obj = rb; obj.velocity -= val3 * 0.1f * Time.fixedDeltaTime; } private void TurnCartRight() { //IL_0007: 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_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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_011c: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) Vector3 val = new Vector3(rb.velocity.x, 0f, rb.velocity.z); float magnitude = ((Vector3)(ref val)).magnitude; float num = Mathf.Clamp01(1f - magnitude / (cartSpeed * 1.2f)); float num2 = cartDriveRotationSpeed * Mathf.Lerp(0.5f, 1f, num); float num3 = 90f * Time.fixedDeltaTime * num2; float num4 = Mathf.Clamp(Mathf.Abs(num3) / 180f, 0.2f, 1f) * 15f; num4 = Mathf.Clamp(num4, 0f, 4f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, Mathf.Sign(num3) * num4, 0f); rb.angularVelocity = Vector3.MoveTowards(rb.angularVelocity, val2, num4); rb.angularVelocity = Vector3.ClampMagnitude(rb.angularVelocity, 4f); Vector3 val3 = Vector3.Project(rb.velocity, ((Component)this).transform.right); Rigidbody obj = rb; obj.velocity -= val3 * 0.1f * Time.fixedDeltaTime; } private void ApplyUpwardsForceToCart() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0031: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.up * (totalCartMass + GetNextCartStepHeight()); Vector3 gravity = Physics.gravity; Vector3 val2 = val * ((Vector3)(ref gravity)).magnitude; rb.AddForce(val2); } private float GetNextCartStepHeight() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) float num = 1.5f; Vector3 origin = ((Component)this).transform.position + ((Component)this).transform.forward * num; if (!cartGuideForward) { origin = ((Component)this).transform.position + ((Component)this).transform.forward * (0f - num); } if (isCartFollowingPath) { origin = MiscHelper.GetPointTowardTarget(((Component)this).transform.position, pathCorners[cornerInd], num); } origin = GetNearestNavMeshPosition(origin); cartHeightGuide.transform.position = origin; float num2 = origin.y - ((Component)this).transform.position.y; num2 += 0.5f; if (num2 > 0.3f) { return 2.1f; } if (num2 < -0.3f) { return -2f; } return 0f; } private void HandleCartSpeed() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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) float distanceWithoutY = GetDistanceWithoutY(((Component)this).transform.position, lastCartPosition); if (distanceWithoutY < 0.075f && cartSpeed < 30f) { cartSpeed *= 1.003f; } else if (distanceWithoutY > 0.08f) { cartSpeed /= 1.01f; } lastCartPosition = ((Component)this).transform.position; } private void FollowPath() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_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_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_0065: 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_0084: 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_008d: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024c: 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_0262: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Invalid comparison between Unknown and I4 //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0582: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pathCorners[cornerInd]; Vector3 nearestNavMeshPosition = GetNearestNavMeshPosition(((Component)this).transform.position); Vector3 val2 = val - nearestNavMeshPosition; Vector3 normalized = ((Vector3)(ref val2)).normalized; float distanceWithoutY = GetDistanceWithoutY(nearestNavMeshPosition, val); val2 = new Vector3(normalized.x, 0f, normalized.z); Vector3 normalized2 = ((Vector3)(ref val2)).normalized; val2 = new Vector3(((Component)this).transform.forward.x, 0f, ((Component)this).transform.forward.z); Vector3 normalized3 = ((Vector3)(ref val2)).normalized; float num = Vector3.Angle(normalized3, normalized2); Vector3 val3 = ((Component)this).transform.forward * -1f; val2 = new Vector3(val3.x, 0f, val3.z); Vector3 normalized4 = ((Vector3)(ref val2)).normalized; float num2 = Vector3.Angle(normalized4, normalized2); float num3; if (num <= num2) { num3 = num; cartGuideForward = true; } else { num3 = num2; cartGuideForward = false; } bool flag = false; float num4 = 3f; float num5 = 45f; if (cornerInd < pathCorners.Count - 1 && distanceWithoutY < num4) { val2 = pathCorners[cornerInd + 1] - val; Vector3 normalized5 = ((Vector3)(ref val2)).normalized; float num6 = Vector3.Angle(normalized, normalized5); if (num6 > num5) { flag = true; float num7 = 1f - distanceWithoutY / num4; float num8 = Mathf.Clamp01(num6 / 90f); } } if (distanceWithoutY > cornerMinDistance) { float num9 = Mathf.Lerp(0.3f, 1f, Mathf.Clamp01(1f - num3 / 90f)); float num10 = 1f; if (flag) { float num11 = 1f - distanceWithoutY / num4; val2 = pathCorners[cornerInd + 1] - val; float num12 = Mathf.Clamp01(Vector3.Angle(normalized, ((Vector3)(ref val2)).normalized) / 90f); num10 = Mathf.Lerp(0.8f, 0.4f, num11 * num12); } float num13 = num9 * num10; Vector3 val4 = normalized * cartSpeed * num13; val4.y = rb.velocity.y; rb.velocity = Vector3.Lerp(rb.velocity, val4, Time.fixedDeltaTime * 2f); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(rb.velocity.x, 0f, rb.velocity.z); if (((Vector3)(ref val5)).magnitude > 0.1f) { Quaternion val6 = Quaternion.LookRotation(val5, Vector3.up); Quaternion val7 = ((Component)this).transform.rotation; float num14 = ((Quaternion)(ref val7)).eulerAngles.y; if (!cartGuideForward) { val7 = ((Component)this).transform.rotation; num14 = (((Quaternion)(ref val7)).eulerAngles.y + 180f) % 360f; } Quaternion val8 = Quaternion.Euler(0f, num14, 0f); val7 = val6 * Quaternion.Inverse(val8); float num15 = default(float); Vector3 val9 = default(Vector3); ((Quaternion)(ref val7)).ToAngleAxis(ref num15, ref val9); if (num15 > 180f) { num15 -= 360f; } float num16 = 12f; float num17 = num16 * cartRotationSpeed; float num18 = Mathf.Clamp(Mathf.Abs(num15) / 180f, 0.2f, 1f) * num17; num18 = Mathf.Clamp(num18, 2f, 3f * cartRotationSpeed); num18 *= 1f - Mathf.Clamp01(num3 / 180f) * 0.7f; Vector3 val10 = (float)Math.PI / 180f * num15 * ((Vector3)(ref val9)).normalized * num18; val10 = Vector3.ClampMagnitude(val10, 4f * cartRotationSpeed); rb.angularVelocity = Vector3.MoveTowards(rb.angularVelocity, val10, num18); rb.angularVelocity = Vector3.ClampMagnitude(rb.angularVelocity, 4f * cartRotationSpeed); } } else if (cornerInd == pathCorners.Count - 1) { if (extractionPointInd != -1 && (int)ExtractionPointPatch.extractionStates[extractionPointInd] == 1) { ((Component)ExtractionPointPatch.extractionPoints[extractionPointInd]).GetComponent<ExtractionPoint>().OnClick(); } if (isExtracting) { SetPathfindingTarget(ExtractionPointPatch.extractionPoints[extractionPointInd].position, -1, _isExtracting: false); cornerMinDistance = 0.4f; return; } rb.velocity = Vector3.Lerp(rb.velocity, new Vector3(0f, 0f, 0f), Time.fixedDeltaTime * 3f); rb.angularVelocity = Vector3.Lerp(rb.angularVelocity, Vector3.zero, Time.fixedDeltaTime * 5f); val2 = rb.velocity; if (((Vector3)(ref val2)).magnitude < 0.1f) { rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; StopPathfinding(); SelfMovingCartBase.mls.LogInfo((object)"Ending cart navigation."); } } else { ChangeCornerInd(cornerInd + 1); } } private void StopPathfinding() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown isCartFollowingPath = false; cartNavMeshPath = new NavMeshPath(); pathCorners.Clear(); cartSpeed = 15f; cornerMinDistance = 1f; extractionPointInd = -1; isExtracting = false; } public void SetPathfindingTarget(Vector3 target, int _extractionPointInd, bool _isExtracting) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) StopPathfinding(); finalDestination = target; extractionPointInd = _extractionPointInd; isExtracting = _isExtracting; CalculatePath(target); cartSpeed = 15f; isCartFollowingPath = true; checkDistanceFromPathTimer = 0.5f; pathRecalculationTimer = 5f; } private void CalculatePath(Vector3 target) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_0082: Unknown result type (might be due to invalid IL or missing references) Vector3 nearestNavMeshPosition = GetNearestNavMeshPosition(((Component)this).transform.position); Vector3 nearestNavMeshPosition2 = GetNearestNavMeshPosition(target); if (!NavMesh.CalculatePath(nearestNavMeshPosition, nearestNavMeshPosition2, 1, cartNavMeshPath)) { SelfMovingCartBase.mls.LogError((object)$"Could not find path from {nearestNavMeshPosition} to {nearestNavMeshPosition2}."); return; } pathCorners.Clear(); Vector3[] corners = cartNavMeshPath.corners; foreach (Vector3 item in corners) { pathCorners.Add(item); } ChangeCornerInd(0); VisualizeCorners(); } private void VisualizeCorners() { //IL_0057: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0071: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) foreach (GameObject cornerSphere in cornerSpheres) { Object.Destroy((Object)(object)cornerSphere); } cornerSpheres = new List<GameObject>(); foreach (Vector3 pathCorner in pathCorners) { GameObject val = new GameObject("CornerSphere"); val.transform.position = pathCorner; val.transform.localScale = Vector3.one / 4f; if (toVisualize) { MiscHelper.AddSphereToGameObject(val, 0.1f, Color.red); } cornerSpheres.Add(val); } } public Vector3 GetNearestNavMeshPosition(Vector3 origin) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) float num = 0.5f; float num2 = 32f; NavMeshHit val = default(NavMeshHit); while (num < num2 && !NavMesh.SamplePosition(origin, ref val, num, 1)) { num *= 2f; } if (num >= num2) { return default(Vector3); } return ((NavMeshHit)(ref val)).position; } private static float GetDistanceWithoutY(Vector3 pos1, Vector3 pos2) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(pos1.x, 0f, pos1.z); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(pos2.x, 0f, pos2.z); return Vector3.Distance(val, val2); } public float GetDistanceFrom(Vector3 position) { //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) return GetDistanceWithoutY(((Component)this).transform.position, position); } private Vector3 GetClosestPointOnPath() { //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_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0040: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00d8: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) Vector3 result = ((Component)this).transform.position; float num = float.MaxValue; for (int i = 0; i < pathCorners.Count - 1; i++) { Vector3 val = pathCorners[i]; Vector3 val2 = pathCorners[i + 1]; Vector3 val3 = val2 - val; float magnitude = ((Vector3)(ref val3)).magnitude; ((Vector3)(ref val3)).Normalize(); Vector3 val4 = ((Component)this).transform.position - val; float num2 = Vector3.Dot(val4, val3); num2 = Mathf.Clamp(num2, 0f, magnitude); Vector3 val5 = val + val3 * num2; float num3 = Vector3.Distance(((Component)this).transform.position, val5); if (num3 < num) { num = num3; result = val5; } } return result; } private void ChangeCornerInd(int newVal) { cornerInd = newVal; } private void HandleCollidedDoors() { if (!isCartFollowingPath && !remoteControlForward && !remoteControlBack && !remoteControlRight && !remoteControlLeft) { if (collidedUnbrokenDoors.Count > 0) { collidedUnbrokenDoors.Clear(); doorsCollisionTime.Clear(); } return; } for (int i = 0; i < collidedUnbrokenDoors.Count; i++) { doorsCollisionTime[i] += Time.deltaTime; if (doorsCollisionTime[i] > destroyDoorAfter) { if ((Object)(object)collidedUnbrokenDoors[i] != (Object)null) { collidedUnbrokenDoors[i].DestroyHinge(); } collidedUnbrokenDoors.RemoveAt(i); doorsCollisionTime.RemoveAt(i); } } } private void AddCollidedDoor(GameObject doorObject) { PhysGrabHinge component = doorObject.GetComponent<PhysGrabHinge>(); if ((Object)(object)component == (Object)null) { return; } DoorTracker component2 = doorObject.GetComponent<DoorTracker>(); if (!component2.isDestroyed) { if (component2.isBroken) { component.DestroyHinge(); } else if (!collidedUnbrokenDoors.Contains(component)) { collidedUnbrokenDoors.Add(component); doorsCollisionTime.Add(0f); } } } private void RemoveCollidedDoor(GameObject doorObject) { PhysGrabHinge component = doorObject.GetComponent<PhysGrabHinge>(); if (!((Object)(object)component == (Object)null)) { int num = collidedUnbrokenDoors.IndexOf(component); if (num != -1) { collidedUnbrokenDoors.RemoveAt(num); doorsCollisionTime.RemoveAt(num); } } } private void OnCollisionEnter(Collision collision) { if (isCartFollowingPath || remoteControlForward || remoteControlBack || remoteControlRight || remoteControlLeft) { AddCollidedDoor(collision.gameObject); } } private void OnCollisionStay(Collision collision) { if (isCartFollowingPath || remoteControlForward || remoteControlBack || remoteControlRight || remoteControlLeft) { AddCollidedDoor(collision.gameObject); } } private void OnCollisionExit(Collision collision) { RemoveCollidedDoor(collision.gameObject); } } internal class CartTargetSync : MonoBehaviourPun { private CartSelfMovementManager cart; private void Start() { cart = ((Component)this).GetComponent<CartSelfMovementManager>(); } public void GoToTarget(int type, Vector3 playerPosition) { //IL_0032: 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) if (SemiFunc.IsMasterClientOrSingleplayer()) { GoToTargetRPC(type, playerPosition); return; } ((MonoBehaviourPun)this).photonView.RPC("GoToTargetRPC", (RpcTarget)2, new object[2] { type, playerPosition }); } [PunRPC] private void GoToTargetRPC(int type, Vector3 playerPosition) { //IL_000f: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Invalid comparison between Unknown and I4 //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Invalid comparison between Unknown and I4 //IL_00ae: 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) //IL_00bf: 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_0146: 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_0157: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) switch (type) { case 0: cart.SetPathfindingTarget(playerPosition, -1, _isExtracting: false); return; case 1: cart.SetPathfindingTarget(TruckHealerPatch.truckPosition, -1, _isExtracting: false); return; } Vector3 val = default(Vector3); int num = 0; float num2 = float.PositiveInfinity; bool flag = false; for (int i = 0; i < ExtractionPointPatch.extractionPoints.Count; i++) { Transform val2 = ExtractionPointPatch.extractionPoints[i]; State val3 = ExtractionPointPatch.extractionStates[i]; SelfMovingCartBase.mls.LogInfo((object)$"Extraction state: {val3}, rotation: {val2.rotation}"); if ((int)val3 == 2) { val = GetExtractionFrontPosition(val2.position, val2.rotation); cart.SetPathfindingTarget(val, i, type == 3); return; } if ((int)val3 != 7) { float num3 = Vector3.Distance(val2.position, playerPosition); if (num3 < num2) { num = i; num2 = num3; flag = true; } } } if (flag) { Transform val4 = ExtractionPointPatch.extractionPoints[num]; val = GetExtractionFrontPosition(val4.position, val4.rotation); cart.SetPathfindingTarget(val, num, type == 3); } } private Vector3 GetExtractionFrontPosition(Vector3 position, Quaternion rotation) { //IL_0003: 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_000f: 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_002c: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(position.x, position.y, position.z); Vector3 zero = Vector3.zero; float num = 0.1f; float num2 = 4f; if (Mathf.Abs(rotation.y - 0.7071f) < num) { if (Mathf.Abs(rotation.w - 0.7071f) < num) { ((Vector3)(ref zero))..ctor(num2, 0f, 0f); } else { ((Vector3)(ref zero))..ctor(0f - num2, 0f, 0f); } } else if (Mathf.Abs(rotation.y + 0.7071f) < num) { if (Mathf.Abs(rotation.w - 0.7071f) < num) { ((Vector3)(ref zero))..ctor(0f - num2, 0f, 0f); } else { ((Vector3)(ref zero))..ctor(num2, 0f, 0f); } } else if (Mathf.Abs(rotation.y - 1f) < num || Mathf.Abs(rotation.y + 1f) < num) { ((Vector3)(ref zero))..ctor(0f, 0f, 0f - num2); } else if (Mathf.Abs(rotation.y) < num) { ((Vector3)(ref zero))..ctor(0f, 0f, num2); } return val + zero; } public void MoveCart(bool moveForward, bool moveBack, bool turnRight, bool turnLeft) { if (SemiFunc.IsMasterClientOrSingleplayer()) { MoveCartRPC(moveForward, moveBack, turnRight, turnLeft); return; } ((MonoBehaviourPun)this).photonView.RPC("MoveCartRPC", (RpcTarget)2, new object[4] { moveForward, moveBack, turnRight, turnLeft }); } [PunRPC] private void MoveCartRPC(bool moveForward, bool moveBack, bool turnRight, bool turnLeft) { cart.remoteControlForward = moveForward; cart.remoteControlBack = moveBack; cart.remoteControlRight = turnRight; cart.remoteControlLeft = turnLeft; } } [HarmonyPatch(typeof(ChatManager))] internal class ChatManagerPatch { public static ChatState chatState; [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePatch(ref ChatState ___chatState) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) chatState = ___chatState; } } internal class ConfigManager { public static ConfigEntry<string> cartSwitchKey; public static ConfigEntry<string> goToPlayerKey; public static ConfigEntry<string> goToShipKey; public static ConfigEntry<string> goToExtractionKey; public static ConfigEntry<string> extractKey; public static ConfigEntry<string> cartRemoteControlModeKey; public static ConfigEntry<string> goForwardKey; public static ConfigEntry<string> goBackwardsKey; public static ConfigEntry<string> turnRightKey; public static ConfigEntry<string> turnLeftKey; public static ConfigEntry<bool> alwaysShowCartModeText; public static void Initialize(ConfigFile cfg) { cartSwitchKey = cfg.Bind<string>("Controls", "CartSwitchKey", "r", "The key used to select whether your orders will be excuted by the nearest cart, or a particular cart."); goToPlayerKey = cfg.Bind<string>("Controls", "GoToPlayerKey", "f", "The key used to order the cart to come to the player."); goToShipKey = cfg.Bind<string>("Controls", "GoToShipKey", "g", "The key used to order the cart to go to the ship."); goToExtractionKey = cfg.Bind<string>("Controls", "GoToExtractionKey", "v", "The key used to order the cart to go to the extraction (Stands outside extraction)."); extractKey = cfg.Bind<string>("Controls", "ExtractKey", "b", "The key used to order the cart to go to go inside extraction."); cartRemoteControlModeKey = cfg.Bind<string>("Controls", "CartRemoteControlModeKey", "capsLock", "If you hold this key, WASD keys will stop controlling the player movement and will control the cart instead (A more practical alternative to using the arrow keys)."); goForwardKey = cfg.Bind<string>("Controls", "GoForwardKey", "upArrow", "The key used to order the cart to go forward."); goBackwardsKey = cfg.Bind<string>("Controls", "GoBackwardsKey", "downArrow", "The key used to order the cart to go backwards."); turnRightKey = cfg.Bind<string>("Controls", "TurnRightKey", "rightArrow", "The key used to order the cart to turn right"); turnLeftKey = cfg.Bind<string>("Controls", "TurnLeftKey", "leftArrow", "The key used to order the cart to turn left"); alwaysShowCartModeText = cfg.Bind<bool>("UI", "AlwaysShowCartModeText", false, "Determines whether the cart mode ui will always be shown or if it will only be shown when the player switches the mode and then disappears again."); UpdateDeprecatedKeys(); cfg.Save(); } private static void UpdateDeprecatedKeys() { Dictionary<string, string> dictionary = new Dictionary<string, string> { { "up", "upArrow" }, { "down", "downArrow" }, { "left", "leftArrow" }, { "right", "rightArrow" } }; if (dictionary.ContainsKey(goForwardKey.Value)) { goForwardKey.Value = dictionary[goForwardKey.Value]; } if (dictionary.ContainsKey(goBackwardsKey.Value)) { goBackwardsKey.Value = dictionary[goBackwardsKey.Value]; } if (dictionary.ContainsKey(turnRightKey.Value)) { turnRightKey.Value = dictionary[turnRightKey.Value]; } if (dictionary.ContainsKey(turnLeftKey.Value)) { turnLeftKey.Value = dictionary[turnLeftKey.Value]; } } } [HarmonyPatch(typeof(ExtractionPoint))] internal class ExtractionPointPatch { public static List<Transform> extractionPoints = new List<Transform>(); public static List<State> extractionStates = new List<State>(); [HarmonyPatch("Start")] [HarmonyPostfix] private static void ExtractionPointStartPatch(ExtractionPoint __instance, ref State ___currentState) { //IL_002f: 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) extractionPoints.Add(((Component)__instance).transform); extractionStates.Add(___currentState); SelfMovingCartBase.mls.LogInfo((object)$"Extraction position: {((Component)__instance).transform.position}, rotation: {((Component)__instance).transform.rotation}"); } [HarmonyPatch("Update")] [HarmonyPostfix] private static void ExtractionPointUpdatePatch(ExtractionPoint __instance, ref State ___currentState) { int index = extractionPoints.IndexOf(((Component)__instance).transform); extractionStates[index] = ___currentState; } } [HarmonyPatch(typeof(InputManager))] internal class InputManagerPatch { [HarmonyPatch("GetMovement")] [HarmonyPrefix] private static bool GetMovementPatch(ref Vector2 __result) { //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) if (PlayerControllerPatch.cartControlMode) { __result = Vector2.zero; return false; } return true; } [HarmonyPatch("GetMovementX")] [HarmonyPrefix] private static bool GetMovementXPatch(ref float __result) { if (PlayerControllerPatch.cartControlMode) { __result = 0f; return false; } return true; } [HarmonyPatch("GetMovementY")] [HarmonyPrefix] private static bool GetMovementYPatch(ref float __result) { if (PlayerControllerPatch.cartControlMode) { __result = 0f; return false; } return true; } public static float GetMovementX() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) Dictionary<InputKey, InputAction> privateField = ReflectionHelper.GetPrivateField<Dictionary<InputKey, InputAction>>(InputManager.instance, "inputActions"); if (privateField.TryGetValue((InputKey)0, out var value)) { return value.ReadValue<Vector2>().x; } return 0f; } public static float GetMovementY() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) Dictionary<InputKey, InputAction> privateField = ReflectionHelper.GetPrivateField<Dictionary<InputKey, InputAction>>(InputManager.instance, "inputActions"); if (privateField.TryGetValue((InputKey)0, out var value)) { return value.ReadValue<Vector2>().y; } return 0f; } } [HarmonyPatch(typeof(PhysGrabCart))] internal class PhysGrabCartPatch { [CompilerGenerated] private sealed class <FadeOutSwitchCartText>d__10 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; private Color <color>5__1; private float <fadeSpeed>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FadeOutSwitchCartText>d__10(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; <color>5__1 = ((Graphic)switchCartTMP).color; <fadeSpeed>5__2 = 2f; break; case 2: <>1__state = -1; break; } if (<color>5__1.a > 0f) { <color>5__1.a -= <fadeSpeed>5__2 * Time.deltaTime; <color>5__1.a = Mathf.Max(0f, <color>5__1.a); ((Graphic)switchCartTMP).color = <color>5__1; <>2__current = null; <>1__state = 2; return true; } <color>5__1.a = 0f; ((Graphic)switchCartTMP).color = <color>5__1; switchCartTextCoroutine = null; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static List<CartSelfMovementManager> carts = new List<CartSelfMovementManager>(); public static int controlledCart = -1; private static TextMeshProUGUI switchCartTMP; private static Coroutine switchCartTextCoroutine; [HarmonyPatch("Start")] [HarmonyPostfix] private static void CartStartPatch(PhysGrabCart __instance) { if (!__instance.isSmallCart) { CartSelfMovementManager item = ((Component)__instance).gameObject.AddComponent<CartSelfMovementManager>(); carts.Add(item); } } [HarmonyPatch("FixedUpdate")] [HarmonyPostfix] private static void CartFixedUpdatePatch(PhysGrabCart __instance, ref bool ___cartBeingPulled) { if (!__instance.isSmallCart) { CartSelfMovementManager component = ((Component)__instance).gameObject.GetComponent<CartSelfMovementManager>(); if ((Object)(object)component == (Object)null) { carts.Remove(component); } else { component.isCartBeingPulled = ___cartBeingPulled; } } } public static CartSelfMovementManager GetCartToOrder(Vector3 position) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (controlledCart > -1) { return carts[controlledCart]; } CartSelfMovementManager result = null; float num = float.PositiveInfinity; foreach (CartSelfMovementManager cart in carts) { if (!((Object)(object)cart == (Object)null) && !cart.isCartBeingPulled) { float distanceFrom = cart.GetDistanceFrom(position); if (distanceFrom < num) { result = cart; num = distanceFrom; } } } return result; } public static void OrderCart(int orderType, Vector3 playerPosition) { //IL_0001: 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) CartSelfMovementManager cartToOrder = GetCartToOrder(playerPosition); if (!((Object)(object)cartToOrder == (Object)null)) { cartToOrder.cartTargetSync.GoToTarget(orderType, playerPosition); } } public static void SwitchCarts() { if (controlledCart + 1 < carts.Count) { controlledCart++; } else { controlledCart = -1; } if (!ConfigManager.alwaysShowCartModeText.Value) { SwitchCartUI(); } } private static void SwitchCartUI() { //IL_0103: 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_006c: 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_009a: 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_0154: 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) if (switchCartTextCoroutine != null) { ((MonoBehaviour)PlayerController.instance).StopCoroutine(switchCartTextCoroutine); } if ((Object)(object)switchCartTMP == (Object)null) { Transform val = CreateUIElement(); RectTransform component = ((Component)val).GetComponent<RectTransform>(); switchCartTMP = ((Component)val).GetComponent<TextMeshProUGUI>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.sizeDelta = new Vector2(400f, 50f); component.anchoredPosition = new Vector2(0f, -20f); ((TMP_Text)switchCartTMP).alignment = (TextAlignmentOptions)514; ((TMP_Text)switchCartTMP).fontSize = 22f; ((Component)val).gameObject.SetActive(true); } ((Graphic)switchCartTMP).color = new Color(1f, 0.95f, 0.5f, 1f); string text = "Cart Mode: Nearest Cart"; if (controlledCart != -1) { CartSelfMovementManager cartSelfMovementManager = carts[controlledCart]; int privateField = ReflectionHelper.GetPrivateField<int>(((Component)cartSelfMovementManager).GetComponent<PhysGrabCart>(), "haulCurrent"); int num = Mathf.RoundToInt(Vector3.Distance(((Component)PlayerController.instance).transform.position, ((Component)cartSelfMovementManager).transform.position)); text = $"Cart Mode: Cart #{controlledCart + 1} (Val: {privateField}, Dist: {num}m)"; } ((TMP_Text)switchCartTMP).text = text; switchCartTextCoroutine = ((MonoBehaviour)PlayerController.instance).StartCoroutine(FadeOutSwitchCartText()); } [IteratorStateMachine(typeof(<FadeOutSwitchCartText>d__10))] private static IEnumerator FadeOutSwitchCartText() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FadeOutSwitchCartText>d__10(0); } private static Transform CreateUIElement() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0071: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0122: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("Game Hud"); GameObject val2 = GameObject.Find("Tax Haul"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return null; } TMP_FontAsset font = val2.GetComponent<TMP_Text>().font; GameObject val3 = new GameObject("Cart Mode HUD"); val3.SetActive(false); val3.AddComponent<TextMeshProUGUI>(); TextMeshProUGUI component = val3.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).font = font; ((Graphic)component).color = Color.white; ((TMP_Text)component).fontSize = 22f; ((TMP_Text)component).enableWordWrapping = false; ((TMP_Text)component).alignment = (TextAlignmentOptions)514; val3.transform.SetParent(val.transform, false); RectTransform component2 = val3.GetComponent<RectTransform>(); component2.pivot = new Vector2(0.5f, 0.5f); component2.anchoredPosition = new Vector2(0f, -20f); component2.anchorMin = new Vector2(0.5f, 0.5f); component2.anchorMax = new Vector2(0.5f, 0.5f); component2.sizeDelta = new Vector2(400f, 50f); return val3.transform; } } [HarmonyPatch(typeof(PhysGrabHinge))] internal class PhysGrabHingePatch { [HarmonyPatch("Awake")] [HarmonyPostfix] private static void AwakePatch(PhysGrabHinge __instance) { ((Component)__instance).gameObject.AddComponent<DoorTracker>(); } [HarmonyPatch("HingeBreakImpulse")] [HarmonyPostfix] private static void HingeBreakImpulsePatch(PhysGrabHinge __instance) { ((Component)__instance).GetComponent<DoorTracker>().isBroken = true; } [HarmonyPatch("DestroyHinge")] [HarmonyPostfix] private static void DestroyHingePatch(PhysGrabHinge __instance) { ((Component)__instance).GetComponent<DoorTracker>().isDestroyed = true; } } internal class DoorTracker : MonoBehaviour { public bool isBroken = false; public bool isDestroyed = false; private void Start() { isBroken = false; isDestroyed = false; } } [HarmonyPatch(typeof(PlayerController))] internal class PlayerControllerPatch { private static bool lastFrameHadMovement = false; private static CartSelfMovementManager closestCart = null; public static bool cartControlMode = false; private static List<string> mouseBtns = new List<string> { "leftButton", "rightButton", "middleButton", "forwardButton", "backButton" }; [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePatch(PlayerController __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0050: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if ((int)ChatManagerPatch.chatState != 1) { if (WasButtonPressedThisFrame(ConfigManager.cartSwitchKey.Value)) { PhysGrabCartPatch.SwitchCarts(); } if (WasButtonPressedThisFrame(ConfigManager.goToPlayerKey.Value)) { PhysGrabCartPatch.OrderCart(0, ((Component)__instance).transform.position); } if (WasButtonPressedThisFrame(ConfigManager.goToShipKey.Value)) { PhysGrabCartPatch.OrderCart(1, ((Component)__instance).transform.position); } if (WasButtonPressedThisFrame(ConfigManager.goToExtractionKey.Value)) { PhysGrabCartPatch.OrderCart(2, ((Component)__instance).transform.position); } if (WasButtonPressedThisFrame(ConfigManager.extractKey.Value)) { PhysGrabCartPatch.OrderCart(3, ((Component)__instance).transform.position); } } bool flag = IsButtonPressed(ConfigManager.goForwardKey.Value); bool flag2 = IsButtonPressed(ConfigManager.goBackwardsKey.Value); bool flag3 = IsButtonPressed(ConfigManager.turnLeftKey.Value); bool flag4 = IsButtonPressed(ConfigManager.turnRightKey.Value); cartControlMode = IsButtonPressed(ConfigManager.cartRemoteControlModeKey.Value); if (cartControlMode) { flag = flag || InputManagerPatch.GetMovementY() > 0f; flag2 = flag2 || InputManagerPatch.GetMovementY() < 0f; flag3 = flag3 || InputManagerPatch.GetMovementX() < 0f; flag4 = flag4 || InputManagerPatch.GetMovementX() > 0f; } bool flag5 = flag || flag2 || flag4 || flag3; if (flag5 || lastFrameHadMovement) { CartSelfMovementManager cartToOrder = PhysGrabCartPatch.GetCartToOrder(((Component)__instance).transform.position); if ((Object)(object)cartToOrder != (Object)null) { if ((Object)(object)cartToOrder != (Object)(object)closestCart && (Object)(object)closestCart != (Object)null) { closestCart.cartTargetSync.MoveCart(moveForward: false, moveBack: false, turnRight: false, turnLeft: false); } closestCart = cartToOrder; closestCart.cartTargetSync.MoveCart(flag, flag2, flag4, flag3); if (!flag5) { lastFrameHadMovement = false; } else { lastFrameHadMovement = true; } } else { closestCart = null; } } else { closestCart = null; } } private static bool WasButtonPressedThisFrame(string btn) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) InputControl val = ((!mouseBtns.Contains(btn)) ? ((InputControl)Keyboard.current)[btn] : ((InputControl)Mouse.current)[btn]); return ((ButtonControl)val).wasPressedThisFrame; } private static bool IsButtonPressed(string btn) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) InputControl val = ((!mouseBtns.Contains(btn)) ? ((InputControl)Keyboard.current)[btn] : ((InputControl)Mouse.current)[btn]); return ((ButtonControl)val).isPressed; } } public static class MiscHelper { private static Dictionary<PrimitiveType, Mesh> primitiveMeshes = new Dictionary<PrimitiveType, Mesh>(); public static void AddSphereToGameObject(GameObject gameObject, float radius, Color color) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) SphereCollider val = gameObject.AddComponent<SphereCollider>(); val.radius = radius; ((Collider)val).isTrigger = true; MeshFilter val2 = gameObject.AddComponent<MeshFilter>(); val2.mesh = GetPrimitiveMesh((PrimitiveType)0); MeshRenderer val3 = gameObject.AddComponent<MeshRenderer>(); ((Renderer)val3).material = new Material(Shader.Find("Standard")); ((Renderer)val3).material.color = color; } public static void AddCubeToGameObject(GameObject gameObject, float width, float height, Color color) { //IL_0019: 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_0054: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) BoxCollider val = gameObject.AddComponent<BoxCollider>(); ((Collider)val).isTrigger = true; gameObject.transform.localScale = new Vector3(width, height, width); MeshFilter val2 = gameObject.AddComponent<MeshFilter>(); val2.mesh = GetPrimitiveMesh((PrimitiveType)3); MeshRenderer val3 = gameObject.AddComponent<MeshRenderer>(); ((Renderer)val3).material = new Material(Shader.Find("Standard")); ((Renderer)val3).material.color = color; } public static Mesh GetPrimitiveMesh(PrimitiveType type) { //IL_0006: 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_0014: 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 (!primitiveMeshes.ContainsKey(type)) { GameObject val = GameObject.CreatePrimitive(type); Mesh sharedMesh = val.GetComponent<MeshFilter>().sharedMesh; Object.Destroy((Object)(object)val); primitiveMeshes[type] = sharedMesh; } return primitiveMeshes[type]; } public static Vector3 GetPointTowardTarget(Vector3 originPosition, Vector3 targetPosition, float distance) { //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_0003: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0025: 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_003c: Unknown result type (might be due to invalid IL or missing references) Vector3 val = targetPosition - originPosition; float magnitude = ((Vector3)(ref val)).magnitude; Vector3 normalized = ((Vector3)(ref val)).normalized; if (magnitude <= distance) { return targetPosition; } return originPosition + normalized * distance; } } public static class ReflectionHelper { public static object InvokePrivateMethod(object instance, string methodName, params object[] parameters) { if (instance == null) { throw new ArgumentNullException("instance"); } Type type = instance.GetType(); MethodInfo methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null); if (methodInfo == null) { throw new MissingMethodException("Method '" + methodName + "' not found on type '" + type.FullName + "'"); } return methodInfo.Invoke(instance, parameters); } public static object InvokePrivateStaticMethod(Type type, string methodName, params object[] parameters) { if (type == null) { throw new ArgumentNullException("type"); } MethodInfo methodInfo = AccessTools.Method(type, methodName, (Type[])null, (Type[])null); if (methodInfo == null) { throw new MissingMethodException("Static method '" + methodName + "' not found on type '" + type.FullName + "'"); } return methodInfo.Invoke(null, parameters); } public static T GetPrivateField<T>(object instance, string fieldName) { if (instance == null) { throw new ArgumentNullException("instance"); } Type type = instance.GetType(); FieldInfo fieldInfo = AccessTools.Field(type, fieldName); if (fieldInfo == null) { throw new MissingFieldException("Field '" + fieldName + "' not found on type '" + type.FullName + "'"); } return (T)fieldInfo.GetValue(instance); } public static T GetPrivateStaticField<T>(Type type, string fieldName) { if (type == null) { throw new ArgumentNullException("type"); } FieldInfo fieldInfo = AccessTools.Field(type, fieldName); if (fieldInfo == null) { throw new MissingFieldException("Static field '" + fieldName + "' not found on type '" + type.FullName + "'"); } return (T)fieldInfo.GetValue(null); } public static void SetPrivateField(object instance, string fieldName, object value) { if (instance == null) { throw new ArgumentNullException("instance"); } Type type = instance.GetType(); FieldInfo fieldInfo = AccessTools.Field(type, fieldName); if (fieldInfo == null) { throw new MissingFieldException("Field '" + fieldName + "' not found on type '" + type.FullName + "'"); } fieldInfo.SetValue(instance, value); } public static void SetPrivateStaticField(Type type, string fieldName, object value) { if (type == null) { throw new ArgumentNullException("type"); } FieldInfo fieldInfo = AccessTools.Field(type, fieldName); if (fieldInfo == null) { throw new MissingFieldException("Static field '" + fieldName + "' not found on type '" + type.FullName + "'"); } fieldInfo.SetValue(null, value); } public static T GetPrivateProperty<T>(object instance, string propertyName) { if (instance == null) { throw new ArgumentNullException("instance"); } Type type = instance.GetType(); PropertyInfo propertyInfo = AccessTools.Property(type, propertyName); if (propertyInfo == null) { throw new MissingMemberException("Property '" + propertyName + "' not found on type '" + type.FullName + "'"); } return (T)propertyInfo.GetValue(instance); } public static object GetPrivateEnumValue(Type containingType, string enumTypeName, string enumValueName) { Type type = AccessTools.Inner(containingType, enumTypeName); if (type == null) { throw new MissingMemberException("Enum type '" + enumTypeName + "' not found in '" + containingType.FullName + "'"); } return Enum.Parse(type, enumValueName); } } [HarmonyPatch(typeof(RoundDirector))] internal class RoundDirectorPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch() { PhysGrabCartPatch.carts.Clear(); ExtractionPointPatch.extractionPoints.Clear(); ExtractionPointPatch.extractionStates.Clear(); } } [HarmonyPatch(typeof(TruckHealer))] internal class TruckHealerPatch { public static Vector3 truckPosition; [HarmonyPatch("Start")] [HarmonyPostfix] private static void TruckHealerStartPatch(TruckHealer __instance) { //IL_0007: 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_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) truckPosition = new Vector3(((Component)__instance).transform.position.x, 0f, ((Component)__instance).transform.position.z); } } }