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 CruiserStatus v1.0.0
CruiserStatus.dll
Decompiled a day agousing System; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.SceneManagement; 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("CruiserStatus")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CruiserStatus")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("56b3cdf1-e536-4054-867e-4ce2f28d87a4")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("azumi.cruiserstatus", "CruiserStatus", "1.0.0")] public class CruiserStatusPlugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigFile ConfigFile; private Harmony harmony; private void Awake() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ConfigFile = ((BaseUnityPlugin)this).Config; Log.LogInfo((object)"CruiserStatus loaded."); CruiserStatusConfig.Init(((BaseUnityPlugin)this).Config); harmony = new Harmony("azumi.cruiserstatus"); harmony.PatchAll(); CruiserStatusHost.Create(); } } public static class CruiserStatusConfig { public static ConfigEntry<Key> DashboardKey; public static ConfigEntry<Key> ResetPositionKey; public static ConfigEntry<float> PositionX; public static ConfigEntry<float> PositionY; public static ConfigEntry<float> DashboardScale; public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> UseMph; public static readonly Vector2 DefaultPosition = new Vector2(700f, 0f); public static void Init(ConfigFile config) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown Enabled = config.Bind<bool>("General", "Enabled", true, "Enable or disable CruiserStatus entirely."); DashboardKey = config.Bind<Key>("Controls", "Dashboard Key", (Key)98, "Key used to toggle the Cruiser Status Dashboard."); ResetPositionKey = config.Bind<Key>("Controls", "Reset Position Key", (Key)99, "Key used to reset the dashboard position."); PositionX = config.Bind<float>("Position", "Position X", 700f, new ConfigDescription("Dashboard anchored X position.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-850f, 850f), Array.Empty<object>())); PositionY = config.Bind<float>("Position", "Position Y", 0f, new ConfigDescription("Dashboard anchored Y position.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-448f, 448f), Array.Empty<object>())); DashboardScale = config.Bind<float>("General", "Dashboard Scale", 1f, new ConfigDescription("Overall dashboard UI scale.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())); UseMph = config.Bind<bool>("General", "Use MPH", false, "Display speed in miles per hour instead of km/h."); } public static Vector2 GetPosition() { //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_001d: Unknown result type (might be due to invalid IL or missing references) return new Vector2(PositionX.Value, PositionY.Value); } public static void SetPosition(Vector2 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) PositionX.Value = position.x; PositionY.Value = position.y; Save(); } public static void ResetPosition() { PositionX.Value = DefaultPosition.x; PositionY.Value = DefaultPosition.y; Save(); } public static void Save() { if (CruiserStatusPlugin.ConfigFile == null) { return; } try { CruiserStatusPlugin.ConfigFile.Save(); } catch (Exception ex) { ManualLogSource log = CruiserStatusPlugin.Log; if (log != null) { log.LogError((object)("[Config] ConfigFile.Save() failed: " + ex)); } } } } public static class CruiserStatusState { public static bool DashboardEnabled = true; public static bool IsOnCruiser; public static bool IsVisible; public static void ToggleDashboard() { DashboardEnabled = !DashboardEnabled; UpdateVisibility(); } public static void SetCruiserState(bool onCruiser) { IsOnCruiser = onCruiser; UpdateVisibility(); } public static void UpdateVisibility() { bool flag = DashboardEnabled && IsOnCruiser; if (IsVisible != flag) { IsVisible = flag; } } public static void Hide() { IsVisible = false; } } public class CruiserStatusHost : MonoBehaviour { public static CruiserStatusHost Instance; private DashboardGUI dashboardGUI; public static void Create() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("CruiserStatus_Host"); Object.DontDestroyOnLoad((Object)(object)val); Instance = val.AddComponent<CruiserStatusHost>(); } } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { ManualLogSource log = CruiserStatusPlugin.Log; if (log != null) { log.LogWarning((object)"Duplicate CruiserStatus Host detected. Destroying duplicate."); } Object.Destroy((Object)(object)((Component)this).gameObject); } else { Instance = this; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); SceneManager.sceneLoaded += OnSceneLoaded; CreateDashboardGUI(); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { CruiserStatusState.Hide(); DashboardDragController.CancelDrag(); } private void CreateDashboardGUI() { if (!((Object)(object)dashboardGUI != (Object)null)) { dashboardGUI = ((Component)this).gameObject.AddComponent<DashboardGUI>(); } } public static void EnsureExists() { if ((Object)(object)Instance == (Object)null) { ManualLogSource log = CruiserStatusPlugin.Log; if (log != null) { log.LogWarning((object)"CruiserStatus Host missing. Recreating."); } Create(); } else if ((Object)(object)Instance.dashboardGUI == (Object)null) { ManualLogSource log2 = CruiserStatusPlugin.Log; if (log2 != null) { log2.LogWarning((object)"DashboardGUI missing. Recreating."); } Instance.CreateDashboardGUI(); } } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; DashboardDragController.CancelDrag(); CruiserStatusState.Hide(); if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public static class CruiserInfoSystem { private static float speedValue; private static Terminal terminal; private static bool warrantyTicketObserved; private static readonly FieldInfo TurboBoostsField = typeof(VehicleController).GetField("turboBoosts", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); public static VehicleController CurrentVehicle { get; private set; } public static float DisplayedSpeed { get; private set; } public static string SpeedUnit { get; private set; } = "km/h"; public static void Update(PlayerControllerB localPlayer) { VehicleController val = FindCurrentCruiser(localPlayer); if ((Object)(object)val != (Object)(object)CurrentVehicle) { CurrentVehicle = val; speedValue = 0f; } if ((Object)(object)CurrentVehicle == (Object)null) { DisplayedSpeed = 0f; return; } UpdateSpeed(CurrentVehicle); bool flag = CruiserStatusConfig.UseMph != null && CruiserStatusConfig.UseMph.Value; DisplayedSpeed = speedValue * (flag ? 0.6213712f : 1f); SpeedUnit = (flag ? "mph" : "km/h"); if ((Object)(object)terminal == (Object)null) { terminal = Object.FindObjectOfType<Terminal>(); } if ((Object)(object)terminal != (Object)null && terminal.hasWarrantyTicket) { warrantyTicketObserved = true; } } private static VehicleController FindCurrentCruiser(PlayerControllerB player) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null) { return null; } VehicleController[] array = Object.FindObjectsOfType<VehicleController>(); if (array == null || array.Length == 0) { return null; } foreach (VehicleController val in array) { if (!((Object)(object)val == (Object)null) && !val.carDestroyed && (val.localPlayerInControl || val.localPlayerInPassengerSeat || (Object)(object)val.currentDriver == (Object)(object)player || (Object)(object)val.currentPassenger == (Object)(object)player)) { return val; } } Vector3 val2 = ((Component)player).transform.position + Vector3.up * 0.25f; RaycastHit[] array2 = Physics.RaycastAll(val2, Vector3.down, 3f, -5, (QueryTriggerInteraction)1); if (array2 == null) { return null; } for (int j = 0; j < array2.Length; j++) { Collider collider = ((RaycastHit)(ref array2[j])).collider; if ((Object)(object)collider == (Object)null || (Object)(object)((Component)collider).GetComponentInParent<PlayerControllerB>() == (Object)(object)player) { continue; } VehicleController componentInParent = ((Component)collider).GetComponentInParent<VehicleController>(); if ((Object)(object)componentInParent == (Object)null || componentInParent.carDestroyed) { continue; } for (int k = 0; k < array.Length; k++) { if ((Object)(object)array[k] == (Object)(object)componentInParent) { return componentInParent; } } } return null; } private static void UpdateSpeed(VehicleController vehicle) { //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 ((Object)(object)vehicle == (Object)null || vehicle.carDestroyed || vehicle.magnetedToShip || (Object)(object)vehicle.mainRigidbody == (Object)null) { speedValue = 0f; return; } Vector3 velocity = vehicle.mainRigidbody.velocity; float num = ((Vector3)(ref velocity)).magnitude * 2f; if (float.IsNaN(num) || float.IsInfinity(num) || num < 0f) { num = 0f; } speedValue = Mathf.Lerp(speedValue, num, 0.35f); } public static string GetIgnition() { return ((Object)(object)CurrentVehicle != (Object)null && CurrentVehicle.ignitionStarted) ? "ON" : "OFF"; } public static string GetAttached() { return ((Object)(object)CurrentVehicle != (Object)null && CurrentVehicle.magnetedToShip) ? "YES" : "NO"; } public static string GetHealth() { if ((Object)(object)CurrentVehicle == (Object)null) { return "0 / 0"; } return Mathf.Max(0, CurrentVehicle.carHP) + " / " + Mathf.Max(0, CurrentVehicle.baseCarHP); } public static string GetTurbo() { return Mathf.Clamp(ReadTurboBoosts(CurrentVehicle), 0, 5) + " / 5"; } public static string GetGear() { //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_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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected I4, but got Unknown if ((Object)(object)CurrentVehicle == (Object)null) { return "UNKNOWN"; } CarGearShift gear = CurrentVehicle.gear; CarGearShift val = gear; return (val - 1) switch { 2 => "P", 1 => "R", 0 => "D", _ => "UNKNOWN", }; } public static string GetSeat() { if ((Object)(object)CurrentVehicle == (Object)null) { return "NO DRIVER / NO PASSENGER"; } PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); string text = (IsOccupied(CurrentVehicle.currentDriver) ? SafePlayerName(CurrentVehicle.currentDriver, "DRIVER") : ((CurrentVehicle.localPlayerInControl && (Object)(object)val != (Object)null) ? SafePlayerName(val, "DRIVER") : "NO DRIVER")); string text2 = (IsOccupied(CurrentVehicle.currentPassenger) ? SafePlayerName(CurrentVehicle.currentPassenger, "PASSENGER") : ((CurrentVehicle.localPlayerInPassengerSeat && (Object)(object)val != (Object)null) ? SafePlayerName(val, "PASSENGER") : "NO PASSENGER")); return text + " / " + text2; } public static string GetCargo() { return HasCargoRider(CurrentVehicle, StartOfRound.Instance) ? "OCCUPIED" : "NO RIDER"; } public static string GetRear() { return ((Object)(object)CurrentVehicle != (Object)null && CurrentVehicle.backDoorOpen) ? "OPEN" : "CLOSED"; } public static string GetWarranty() { if ((Object)(object)terminal != (Object)null && terminal.hasWarrantyTicket) { warrantyTicketObserved = true; return "ACTIVE"; } return warrantyTicketObserved ? "USED" : "NONE"; } private static int ReadTurboBoosts(VehicleController vehicle) { if ((Object)(object)vehicle == (Object)null || TurboBoostsField == null) { return 0; } try { if (TurboBoostsField.GetValue(vehicle) is int result) { return result; } } catch { } return 0; } private static bool IsOccupied(PlayerControllerB player) { return (Object)(object)player != (Object)null && player.isPlayerControlled && !player.isPlayerDead; } private static string SafePlayerName(PlayerControllerB player, string fallback) { if ((Object)(object)player == (Object)null || string.IsNullOrEmpty(player.playerUsername)) { return fallback; } return player.playerUsername; } private static bool HasCargoRider(VehicleController vehicle, StartOfRound round) { if ((Object)(object)vehicle == (Object)null || (Object)(object)round == (Object)null || round.allPlayerScripts == null) { return false; } PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null); PlayerControllerB[] allPlayerScripts = round.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if (IsOccupied(val2)) { bool flag = (Object)(object)val2 == (Object)(object)vehicle.currentDriver || ((Object)(object)val2 == (Object)(object)val && vehicle.localPlayerInControl); bool flag2 = (Object)(object)val2 == (Object)(object)vehicle.currentPassenger || ((Object)(object)val2 == (Object)(object)val && vehicle.localPlayerInPassengerSeat); if (!(flag || flag2) && StandingOn(val2, vehicle)) { return true; } } } return false; } private static bool StandingOn(PlayerControllerB player, VehicleController vehicle) { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_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_0049: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || (Object)(object)vehicle == (Object)null || vehicle.carDestroyed) { return false; } Vector3 val = ((Component)player).transform.position + Vector3.up * 0.25f; RaycastHit[] array = Physics.RaycastAll(val, Vector3.down, 3f, -5, (QueryTriggerInteraction)1); if (array == null) { return false; } for (int i = 0; i < array.Length; i++) { Collider collider = ((RaycastHit)(ref array[i])).collider; if (!((Object)(object)collider == (Object)null) && !((Object)(object)((Component)collider).GetComponentInParent<PlayerControllerB>() == (Object)(object)player)) { VehicleController componentInParent = ((Component)collider).GetComponentInParent<VehicleController>(); if ((Object)(object)componentInParent == (Object)(object)vehicle) { return true; } } } return false; } } [HarmonyPatch(typeof(HUDManager), "Update")] public static class CruiserStatusHUDUpdatePatch { private static void Postfix() { if (CruiserStatusConfig.Enabled != null && !CruiserStatusConfig.Enabled.Value) { CruiserStatusState.Hide(); return; } ProcessDashboardKey(); ProcessResetPositionKey(); if ((Object)(object)GameNetworkManager.Instance == (Object)null) { CruiserStatusState.Hide(); return; } PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null) { CruiserStatusState.Hide(); return; } CruiserInfoSystem.Update(localPlayerController); bool cruiserState = (Object)(object)CruiserInfoSystem.CurrentVehicle != (Object)null; CruiserStatusState.SetCruiserState(cruiserState); CruiserStatusHost.EnsureExists(); } private static void ProcessDashboardKey() { //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (Keyboard.current == null) { return; } Key value = CruiserStatusConfig.DashboardKey.Value; if ((int)value == 0) { return; } ButtonControl val; try { val = (ButtonControl)(object)Keyboard.current[value]; } catch { return; } if (val != null && val.wasPressedThisFrame) { CruiserStatusHost.EnsureExists(); CruiserStatusState.ToggleDashboard(); if (CruiserStatusState.DashboardEnabled) { ShowTip("Cruiser", "Dashboard ON."); } else { ShowTip("Cruiser", "Dashboard OFF."); } } } private static void ProcessResetPositionKey() { //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_001d: Invalid comparison between Unknown and I4 //IL_002d: Unknown result type (might be due to invalid IL or missing references) if (Keyboard.current == null) { return; } Key value = CruiserStatusConfig.ResetPositionKey.Value; if ((int)value != 0) { ButtonControl val; try { val = (ButtonControl)(object)Keyboard.current[value]; } catch { return; } if (val != null && val.wasPressedThisFrame) { CruiserStatusConfig.ResetPosition(); ShowTip("Cruiser", "Dashboard position reset."); } } } private static void ShowTip(string title, string message) { if (!((Object)(object)HUDManager.Instance == (Object)null)) { HUDManager.Instance.DisplayTip(title, message, false, false, "LC_Tip1"); } } } [HarmonyPatch(typeof(HUDManager), "Start")] public static class CruiserStatusHUDStartPatch { private static void Postfix() { CruiserStatusState.Hide(); CruiserStatusHost.EnsureExists(); } } public class DashboardGUI : MonoBehaviour { private Canvas canvas; private GameObject canvasObject; private GameObject dashboardObject; private RectTransform dashboardRect; private TextMeshProUGUI titleText; private TextMeshProUGUI ignitionText; private TextMeshProUGUI attachedText; private TextMeshProUGUI healthText; private TextMeshProUGUI turboText; private TextMeshProUGUI gearText; private TextMeshProUGUI speedText; private TextMeshProUGUI seatText; private TextMeshProUGUI cargoText; private TextMeshProUGUI rearText; private TextMeshProUGUI warrantyText; private Image backgroundImage; private Image topBorderImage; private Image bottomBorderImage; private Image leftBorderImage; private Image rightBorderImage; private Image dividerImage; private static readonly Color DashboardBlack = new Color(0f, 0f, 0f, 0.72f); private static readonly Color DashboardOrange = new Color(1f, 0.32f, 0.04f, 1f); private static readonly Color DashboardWhite = new Color(1f, 1f, 1f, 1f); private bool initialized; private float lastScale = -1f; private void Awake() { } private void Update() { if (CruiserStatusConfig.Enabled != null && !CruiserStatusConfig.Enabled.Value) { if ((Object)(object)canvasObject != (Object)null && canvasObject.activeSelf) { canvasObject.SetActive(false); } DashboardDragController.CancelDrag(); return; } if (!CruiserStatusState.IsVisible) { if ((Object)(object)canvasObject != (Object)null && canvasObject.activeSelf) { canvasObject.SetActive(false); } DashboardDragController.CancelDrag(); return; } if (!initialized) { CreateUI(); return; } if ((Object)(object)canvasObject != (Object)null && !canvasObject.activeSelf) { canvasObject.SetActive(true); } RefreshStatusTexts(); float value = CruiserStatusConfig.DashboardScale.Value; if (!Mathf.Approximately(value, lastScale)) { UpdateDashboardPosition(); lastScale = value; } ApplyConfigPosition(); DashboardDragController.ProcessDrag(dashboardRect, canvas); } private void CreateUI() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0189: Unknown result type (might be due to invalid IL or missing references) if (!initialized && !((Object)(object)HUDManager.Instance == (Object)null)) { CreateCanvas(); if (!((Object)(object)canvas == (Object)null)) { dashboardObject = new GameObject("CruiserStatus_Dashboard"); dashboardObject.transform.SetParent(((Component)canvas).transform, false); dashboardRect = dashboardObject.AddComponent<RectTransform>(); dashboardRect.anchorMin = new Vector2(0.5f, 0.5f); dashboardRect.anchorMax = new Vector2(0.5f, 0.5f); dashboardRect.pivot = new Vector2(0.5f, 0.5f); backgroundImage = CreateImage("Background", dashboardObject.transform, DashboardBlack); topBorderImage = CreateImage("TopBorder", dashboardObject.transform, DashboardOrange); bottomBorderImage = CreateImage("BottomBorder", dashboardObject.transform, DashboardOrange); leftBorderImage = CreateImage("LeftBorder", dashboardObject.transform, DashboardOrange); rightBorderImage = CreateImage("RightBorder", dashboardObject.transform, DashboardOrange); dividerImage = CreateImage("TitleDivider", dashboardObject.transform, DashboardOrange); CreateTexts(); initialized = true; UpdateDashboardPosition(); lastScale = CruiserStatusConfig.DashboardScale.Value; } } } private void CreateCanvas() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) canvasObject = new GameObject("CruiserStatus_Canvas"); canvasObject.transform.SetParent(((Component)this).transform, false); canvas = canvasObject.AddComponent<Canvas>(); canvas.renderMode = (RenderMode)0; canvas.sortingOrder = 5000; CanvasScaler val = canvasObject.AddComponent<CanvasScaler>(); val.uiScaleMode = (ScaleMode)1; val.referenceResolution = new Vector2(1920f, 1080f); val.screenMatchMode = (ScreenMatchMode)0; val.matchWidthOrHeight = 0.5f; canvasObject.AddComponent<GraphicRaycaster>(); } private void CreateTexts() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI template = null; if ((Object)(object)HUDManager.Instance != (Object)null && (Object)(object)HUDManager.Instance.weightCounter != (Object)null) { template = HUDManager.Instance.weightCounter; } titleText = CreateTMPText("Title", template); ((TMP_Text)titleText).text = "CRUISER STATUS"; ((TMP_Text)titleText).fontSize = 24f; ((TMP_Text)titleText).alignment = (TextAlignmentOptions)514; ((Graphic)titleText).color = DashboardOrange; ignitionText = CreateTMPText("Ignition", template); ((TMP_Text)ignitionText).text = "IGNITION: ON"; attachedText = CreateTMPText("Attached", template); ((TMP_Text)attachedText).text = "ATTACHED: NO"; healthText = CreateTMPText("Health", template); ((TMP_Text)healthText).text = "HEALTH: 30 / 30"; turboText = CreateTMPText("Turbo", template); ((TMP_Text)turboText).text = "TURBO: 5 / 5"; gearText = CreateTMPText("Gear", template); ((TMP_Text)gearText).text = "GEAR: D"; speedText = CreateTMPText("Speed", template); ((TMP_Text)speedText).text = "SPEED: 0 km/h"; seatText = CreateTMPText("Seat", template); ((TMP_Text)seatText).text = "SEAT: DRIVER"; cargoText = CreateTMPText("Cargo", template); ((TMP_Text)cargoText).text = "CARGO: NO RIDER"; rearText = CreateTMPText("Rear", template); ((TMP_Text)rearText).text = "REAR: CLOSED"; warrantyText = CreateTMPText("Warranty", template); ((TMP_Text)warrantyText).text = "WARRANTY: NONE"; } private void RefreshStatusTexts() { VehicleController currentVehicle = CruiserInfoSystem.CurrentVehicle; if (!((Object)(object)currentVehicle == (Object)null)) { ((TMP_Text)ignitionText).text = "IGNITION: " + CruiserInfoSystem.GetIgnition(); ((TMP_Text)attachedText).text = "ATTACHED: " + CruiserInfoSystem.GetAttached(); ((TMP_Text)healthText).text = "HEALTH: " + CruiserInfoSystem.GetHealth(); ((TMP_Text)turboText).text = "TURBO: " + CruiserInfoSystem.GetTurbo(); ((TMP_Text)gearText).text = "GEAR: " + CruiserInfoSystem.GetGear(); ((TMP_Text)speedText).text = "SPEED: " + CruiserInfoSystem.DisplayedSpeed.ToString("0.0", CultureInfo.InvariantCulture) + " " + CruiserInfoSystem.SpeedUnit; ((TMP_Text)seatText).text = "SEAT: " + CruiserInfoSystem.GetSeat(); ((TMP_Text)cargoText).text = "CARGO: " + CruiserInfoSystem.GetCargo(); ((TMP_Text)rearText).text = "REAR: " + CruiserInfoSystem.GetRear(); ((TMP_Text)warrantyText).text = "WARRANTY: " + CruiserInfoSystem.GetWarranty(); } } private TextMeshProUGUI CreateTMPText(string objectName, TextMeshProUGUI template) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(objectName); val.transform.SetParent(dashboardObject.transform, false); TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>(); if ((Object)(object)template != (Object)null) { ((TMP_Text)val2).font = ((TMP_Text)template).font; ((TMP_Text)val2).fontSharedMaterial = ((TMP_Text)template).fontSharedMaterial; ((TMP_Text)val2).characterSpacing = ((TMP_Text)template).characterSpacing; ((TMP_Text)val2).wordSpacing = ((TMP_Text)template).wordSpacing; ((TMP_Text)val2).lineSpacing = 0f; } ((TMP_Text)val2).fontSize = 28f; ((TMP_Text)val2).fontStyle = (FontStyles)0; ((Graphic)val2).color = DashboardWhite; ((TMP_Text)val2).enableAutoSizing = false; ((TMP_Text)val2).enableWordWrapping = false; ((TMP_Text)val2).overflowMode = (TextOverflowModes)0; ((TMP_Text)val2).alignment = (TextAlignmentOptions)4097; ((Graphic)val2).raycastTarget = false; RectTransform rectTransform = ((TMP_Text)val2).rectTransform; ((Transform)rectTransform).localScale = Vector3.one; ((Transform)rectTransform).localRotation = Quaternion.identity; return val2; } private Image CreateImage(string objectName, Transform parent, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(objectName); val.transform.SetParent(parent, false); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = color; ((Graphic)val2).raycastTarget = false; return val2; } private void UpdateDashboardPosition() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)dashboardRect == (Object)null) { return; } float num = Mathf.Min((float)Screen.width / 1920f, (float)Screen.height / 1080f); num = Mathf.Clamp(num, 0.7f, 1.4f); float num2 = Mathf.Clamp(CruiserStatusConfig.DashboardScale.Value, 0.5f, 2f); float num3 = num * num2; float num4 = 440f * num3; float num5 = 368f * num3; dashboardRect.sizeDelta = new Vector2(num4, num5); dashboardRect.anchoredPosition = CruiserStatusConfig.GetPosition(); float num6 = Mathf.Max(1f, 1f * num3); SetRect(((Graphic)backgroundImage).rectTransform, 0f, 0f, num4, num5); SetRect(((Graphic)topBorderImage).rectTransform, 0f, num5 - num6, num4, num6); SetRect(((Graphic)bottomBorderImage).rectTransform, 0f, 0f, num4, num6); SetRect(((Graphic)leftBorderImage).rectTransform, 0f, 0f, num6, num5); SetRect(((Graphic)rightBorderImage).rectTransform, num4 - num6, 0f, num6, num5); float num7 = 16f * num3; SetRect(((Graphic)dividerImage).rectTransform, num7, num5 - 57f * num3, num4 - num7 * 2f, num6); SetRect(((TMP_Text)titleText).rectTransform, num7, num5 - 53f * num3, num4 - num7 * 2f, 45f * num3); ((TMP_Text)titleText).fontSize = 40f * num3; ((TMP_Text)titleText).alignment = (TextAlignmentOptions)514; ((TMP_Text)titleText).enableWordWrapping = false; ((TMP_Text)titleText).overflowMode = (TextOverflowModes)1; float num8 = 22f * num3; float num9 = 14f * num3; float width = num4 - num8 - num9; float num10 = 29f * num3; float num11 = num5 - 95f * num3; TextMeshProUGUI[] array = (TextMeshProUGUI[])(object)new TextMeshProUGUI[10] { speedText, ignitionText, attachedText, healthText, turboText, gearText, seatText, cargoText, rearText, warrantyText }; for (int i = 0; i < array.Length; i++) { TextMeshProUGUI val = array[i]; if (!((Object)(object)val == (Object)null)) { float y = num11 - num10 * (float)i; SetRect(((TMP_Text)val).rectTransform, num8, y, width, num10); ((TMP_Text)val).fontSize = 28f * num3; ((TMP_Text)val).alignment = (TextAlignmentOptions)4097; ((TMP_Text)val).enableWordWrapping = false; ((TMP_Text)val).overflowMode = (TextOverflowModes)1; ((TMP_Text)val).margin = Vector4.zero; } } } private void ApplyConfigPosition() { //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_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_003d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)dashboardRect == (Object)null)) { Vector2 position = CruiserStatusConfig.GetPosition(); if (Vector2.Distance(dashboardRect.anchoredPosition, position) > 0.01f) { dashboardRect.anchoredPosition = position; } } } private void SetRect(RectTransform rect, float x, float y, float width, float height) { //IL_001a: 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_0046: 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_0064: 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_007c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)rect == (Object)null)) { rect.anchorMin = new Vector2(0f, 0f); rect.anchorMax = new Vector2(0f, 0f); rect.pivot = new Vector2(0f, 0f); rect.anchoredPosition = new Vector2(x, y); rect.sizeDelta = new Vector2(width, height); ((Transform)rect).localScale = Vector3.one; ((Transform)rect).localRotation = Quaternion.identity; } } private void OnDestroy() { DashboardDragController.CancelDrag(); if ((Object)(object)canvasObject != (Object)null) { Object.Destroy((Object)(object)canvasObject); canvasObject = null; } canvas = null; dashboardObject = null; dashboardRect = null; initialized = false; } } public static class DashboardDragController { private static bool dragging; private static Vector2 dragOffset; public static void ProcessDrag(RectTransform dashboardRect, Canvas canvas) { //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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)dashboardRect == (Object)null || !CruiserStatusState.IsVisible) { dragging = false; return; } Mouse current = Mouse.current; if (current == null) { return; } Camera canvasCamera = GetCanvasCamera(canvas); Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current).position).ReadValue(); Transform parent = ((Transform)dashboardRect).parent; RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null); if (!((Object)(object)val2 == (Object)null)) { Vector2 val3 = default(Vector2); if (!dragging && current.leftButton.wasPressedThisFrame && RectTransformUtility.RectangleContainsScreenPoint(dashboardRect, val, canvasCamera) && RectTransformUtility.ScreenPointToLocalPointInRectangle(val2, val, canvasCamera, ref val3)) { dragOffset = dashboardRect.anchoredPosition - val3; dragging = true; } Vector2 val4 = default(Vector2); if (dragging && RectTransformUtility.ScreenPointToLocalPointInRectangle(val2, val, canvasCamera, ref val4)) { Vector2 anchoredPosition = val4 + dragOffset; dashboardRect.anchoredPosition = anchoredPosition; } if (dragging && current.leftButton.wasReleasedThisFrame) { dragging = false; Vector2 anchoredPosition2 = dashboardRect.anchoredPosition; CruiserStatusConfig.SetPosition(anchoredPosition2); } } } public static void CancelDrag() { dragging = false; } private static Camera GetCanvasCamera(Canvas canvas) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if ((Object)(object)canvas == (Object)null) { return null; } if ((int)canvas.renderMode == 0) { return null; } return canvas.worldCamera; } }