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 CruiserRadioSelector v1.4.1
BepInEx/Plugins/CruiserRadioSelector/CruiserRadioSelector.dll
Decompiled 3 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CruiserRadioSelector")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+dad30d75055ba3563f2db477c96fec6b8017aac5")] [assembly: AssemblyProduct("CruiserRadioSelector")] [assembly: AssemblyTitle("CruiserRadioSelector")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace CruiserRadioSelector { [BepInPlugin("Potatoh.CruiserRadioSelector", "Cruiser Radio Selector", "1.4.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(VehicleController), "Awake")] public static class VehicleControllerAwakePatch { public static void Postfix(VehicleController __instance) { if (!((Object)(object)__instance == (Object)null) && __instance.vehicleID == 0) { SetCachedCar(__instance); } } } internal static ManualLogSource Log; private const int TracksPerPage = 10; private int currentPage = 0; private static VehicleController? cachedCar; private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Cruiser Radio Selector loaded!"); new Harmony("Potatoh.CruiserRadioSelector").PatchAll(); } internal static void SetCachedCar(VehicleController car) { cachedCar = car; Log.LogInfo((object)"Cached vanilla VehicleController."); } private static VehicleController? GetCar() { if ((Object)(object)cachedCar == (Object)null || (Object)(object)((Component)cachedCar).gameObject == (Object)null) { return null; } if (cachedCar.vehicleID != 0) { return null; } return cachedCar; } private void Update() { if (!Application.isPlaying) { return; } Keyboard current = Keyboard.current; if (current == null) { return; } if (((ButtonControl)current.vKey).wasPressedThisFrame) { NextPage(); } else if (((ButtonControl)current.cKey).isPressed) { if (((ButtonControl)current.digit1Key).wasPressedThisFrame) { TrySetTrack(currentPage * 10); } if (((ButtonControl)current.digit2Key).wasPressedThisFrame) { TrySetTrack(currentPage * 10 + 1); } if (((ButtonControl)current.digit3Key).wasPressedThisFrame) { TrySetTrack(currentPage * 10 + 2); } if (((ButtonControl)current.digit4Key).wasPressedThisFrame) { TrySetTrack(currentPage * 10 + 3); } if (((ButtonControl)current.digit5Key).wasPressedThisFrame) { TrySetTrack(currentPage * 10 + 4); } if (((ButtonControl)current.digit6Key).wasPressedThisFrame) { TrySetTrack(currentPage * 10 + 5); } if (((ButtonControl)current.digit7Key).wasPressedThisFrame) { TrySetTrack(currentPage * 10 + 6); } if (((ButtonControl)current.digit8Key).wasPressedThisFrame) { TrySetTrack(currentPage * 10 + 7); } if (((ButtonControl)current.digit9Key).wasPressedThisFrame) { TrySetTrack(currentPage * 10 + 8); } if (((ButtonControl)current.digit0Key).wasPressedThisFrame) { TrySetTrack(currentPage * 10 + 9); } } } private void NextPage() { VehicleController car = GetCar(); if (!((Object)(object)car == (Object)null) && car.radioClips != null && car.radioClips.Length != 0) { int num = Mathf.CeilToInt((float)car.radioClips.Length / 10f); currentPage++; if (currentPage >= num) { currentPage = 0; } Log.LogInfo((object)$"Cruiser Radio Selector page: {currentPage + 1}/{num}"); } } private static void TrySetTrack(int index) { VehicleController car = GetCar(); if ((Object)(object)car == (Object)null) { Log.LogWarning((object)"Vanilla VehicleController not found."); return; } if (car.radioClips == null || car.radioClips.Length == 0) { Log.LogWarning((object)"No radio clips found on cruiser."); return; } if (index < 0 || index >= car.radioClips.Length) { Log.LogWarning((object)$"Track index {index} is out of range. Tracks count: {car.radioClips.Length}"); return; } Log.LogInfo((object)$"Setting cruiser radio track: {index + 1}/{car.radioClips.Length}"); car.SetRadioStationServerRpc(index, 3); } private void OnGUI() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) Keyboard current = Keyboard.current; if (current == null || !((ButtonControl)current.cKey).isPressed) { return; } VehicleController car = GetCar(); if ((Object)(object)car == (Object)null || car.radioClips == null || car.radioClips.Length == 0) { return; } int num = Mathf.CeilToInt((float)car.radioClips.Length / 10f); currentPage = Mathf.Clamp(currentPage, 0, Mathf.Max(0, num - 1)); GUI.Box(new Rect(20f, 80f, 460f, 350f), ""); GUI.Label(new Rect(35f, 95f, 420f, 25f), $"Cruiser Radio Selector | Page {currentPage + 1}/{num}"); GUI.Label(new Rect(35f, 120f, 420f, 25f), "Hold C + 1-9/0 - select track | V - next page"); for (int i = 0; i < 10; i++) { int num2 = currentPage * 10 + i; if (num2 >= car.radioClips.Length) { break; } string arg = ((i == 9) ? "0" : (i + 1).ToString()); string arg2 = (((Object)(object)car.radioClips[num2] != (Object)null) ? ((Object)car.radioClips[num2]).name : "Unknown"); GUI.Label(new Rect(35f, (float)(155 + i * 25), 420f, 25f), $"C + {arg} | {num2 + 1}. {arg2}"); } } } }