Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of EnhancedVehicules v1.4.0
Mods/EnhancedVehicules.dll
Decompiled 2 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using EnhancedVehicules.Modules.Manager; using EnhancedVehicules.Modules.Storage; using EnhancedVehicules.Settings; using EnhancedVehicules.Settings.Vehicule; using EnhancedVehiculesMod; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne.Tools; using Il2CppScheduleOne.UI; using Il2CppScheduleOne.Vehicles; using Il2CppSystem.Collections.Generic; using Il2CppTMPro; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonColor] [assembly: MelonInfo(typeof(EnhancedVehiculesMod.EnhancedVehicules), "Enhanced Vehicules", "1.4.0", "Nebouh", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("EnhancedVehicules")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+face949a275e0248c654b41ed4bbeea13b563bca")] [assembly: AssemblyProduct("EnhancedVehicules")] [assembly: AssemblyTitle("EnhancedVehicules")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EnhancedVehicules.Modules.Manager { public static class LandVehicleManager { [CompilerGenerated] private sealed class <>c__DisplayClass1_0 { public LandVehicle vehicle; internal void <ApplyToVehicles>b__0(float price) { vehicle.vehiclePrice = price; } internal void <ApplyToVehicles>b__1(float diffGear) { vehicle.diffGearing = diffGear; } internal void <ApplyToVehicles>b__2(float topSpeed) { vehicle.TopSpeed = topSpeed; } } [CompilerGenerated] private sealed class <>c__DisplayClass1_1 { public VehicleSaleSign sign; internal void <ApplyToVehicles>b__3(float price) { ((TMP_Text)sign.PriceLabel).text = $"${price}"; } } [CompilerGenerated] private sealed class <ApplyToVehicles>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; private Enumerator<LandVehicle> <>s__1; private <>c__DisplayClass1_0 <>8__2; private IEnumerator<VehicleSaleSign> <>s__3; private <>c__DisplayClass1_1 <>8__4; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ApplyToVehicles>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__1 = null; <>8__2 = null; <>s__3 = null; <>8__4 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; vehicleManager = Object.FindObjectOfType<VehicleManager>(); if ((Object)(object)vehicleManager == (Object)null) { MelonLogger.Warning("[Enhanced Vehicules] VehicleManager not found. Cannot apply prices to vehicles."); return false; } MelonLogger.Msg("[Enhanced Vehicules] Applying vehicle prices..."); <>s__1 = vehicleManager.VehiclePrefabs.GetEnumerator(); while (<>s__1.MoveNext()) { <>8__2 = new <>c__DisplayClass1_0(); <>8__2.vehicle = <>s__1.Current; if (!((Object)(object)<>8__2.vehicle == (Object)null)) { ApplyPriceToVehicle(((Object)<>8__2.vehicle).name, delegate(float price) { <>8__2.vehicle.vehiclePrice = price; }); ApplyDiffToVehicle(((Object)<>8__2.vehicle).name, delegate(float diffGear) { <>8__2.vehicle.diffGearing = diffGear; }); ApplyTopSpeedToVehicle(((Object)<>8__2.vehicle).name, delegate(float topSpeed) { <>8__2.vehicle.TopSpeed = topSpeed; }); <>8__2 = null; } } <>s__1 = null; <>s__3 = Object.FindObjectsOfType<VehicleSaleSign>().GetEnumerator(); try { while (<>s__3.MoveNext()) { <>8__4 = new <>c__DisplayClass1_1(); <>8__4.sign = <>s__3.Current; if (!((Object)(object)<>8__4.sign == (Object)null) && !((Object)(object)<>8__4.sign.NameLabel == (Object)null) && !((Object)(object)<>8__4.sign.PriceLabel == (Object)null)) { ApplyPriceToVehicle(((TMP_Text)<>8__4.sign.NameLabel).text, delegate(float price) { ((TMP_Text)<>8__4.sign.PriceLabel).text = $"${price}"; }); <>8__4 = null; } } } finally { if (<>s__3 != null) { <>s__3.Dispose(); } } <>s__3 = 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(); } } private static VehicleManager vehicleManager; [IteratorStateMachine(typeof(<ApplyToVehicles>d__1))] public static IEnumerator ApplyToVehicles() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ApplyToVehicles>d__1(0); } private static void ApplyPriceToVehicle(string objectName, Action<float> applyAction) { foreach (VehicleData vehicle in VehicleDatabase.Vehicles) { if (objectName.Contains(vehicle.Label, StringComparison.OrdinalIgnoreCase)) { applyAction(vehicle.Price); MelonLogger.Msg($"[Enhanced Vehicules] Applied price ${vehicle.Price} to {objectName}"); break; } } } private static void ApplyDiffToVehicle(string objectName, Action<float> applyAction) { foreach (VehicleData vehicle in VehicleDatabase.Vehicles) { if (objectName.Contains(vehicle.Label, StringComparison.OrdinalIgnoreCase)) { applyAction(vehicle.DiffGear); MelonLogger.Msg($"[Enhanced Vehicules] Applied DiffGear {vehicle.DiffGear} to {objectName}"); break; } } } private static void ApplyTopSpeedToVehicle(string objectName, Action<float> applyAction) { foreach (VehicleData vehicle in VehicleDatabase.Vehicles) { if (objectName.Contains(vehicle.Label, StringComparison.OrdinalIgnoreCase)) { applyAction(vehicle.TopSpeed); MelonLogger.Msg($"[Enhanced Vehicules] Applied TopSpeed {vehicle.TopSpeed} to {objectName}"); break; } } } } } namespace EnhancedVehicules.Modules.Storage { public static class StorageEntityPatch { [HarmonyPatch(typeof(StorageMenu), "Awake")] private static class StorageMenuPatch { [HarmonyPrefix] private static void Prefix(StorageMenu __instance) { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) try { int value = SettingsManager.prefGameMaxSlots.Value; if (value <= 20) { return; } RectTransform container = __instance.Container; Transform val = ((container != null) ? ((Transform)container).Find("Slots") : null); if (!((Object)(object)val == (Object)null)) { List<ItemSlotUI> list = new List<ItemSlotUI>((IEnumerable<ItemSlotUI>)__instance.SlotsUIs); while (val.childCount < value) { GameObject gameObject = ((Component)val.GetChild(0)).gameObject; GameObject val2 = Object.Instantiate<GameObject>(gameObject, val, true); ((Object)val2).name = ((Object)val2).name.Replace("Clone", $"Extra-[{val.childCount - 1}]"); val2.SetActive(true); val2.transform.localScale = Vector3.one; ItemSlotUI item = val2.GetComponent<ItemSlotUI>() ?? val2.AddComponent<ItemSlotUI>(); list.Add(item); } __instance.SlotsUIs = Il2CppReferenceArray<ItemSlotUI>.op_Implicit(list.ToArray()); MelonLogger.Msg($"[Enhanced Vehicules] StorageMenu slots expanded to {val.childCount}."); } } catch (Exception ex) { MelonLogger.Error("[Enhanced Vehicules] StorageMenu Patch error: " + ex.Message); } } } private static Type storageEntityType; public static void Patch() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown try { storageEntityType = Type.GetType("Il2CppScheduleOne.Storage.StorageEntity, Assembly-CSharp"); if (storageEntityType == null) { MelonLogger.Error("[Enhanced Vehicules] StorageEntity type not found!"); return; } Harmony val = new Harmony("com.enhancedvehiculesmod.patch"); val.Patch((MethodBase)storageEntityType.GetMethod("Awake", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), new HarmonyMethod(typeof(StorageEntityPatch), "StorageEntityInitialize_Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.PatchAll(typeof(StorageMenuPatch)); MelonLogger.Msg("[Enhanced Vehicules] StorageEntity and StorageMenu patched successfully."); } catch (Exception ex) { MelonLogger.Error("[Enhanced Vehicules] Failed to patch: " + ex.Message); } } private static bool StorageEntityInitialize_Prefix(object __instance) { try { MonoBehaviour val = (MonoBehaviour)((__instance is MonoBehaviour) ? __instance : null); if (val == null) { return true; } foreach (VehicleData vehicle in VehicleDatabase.Vehicles) { if (!((Object)((Component)val).gameObject).name.Contains(vehicle.Label)) { continue; } int num = Mathf.Min(vehicle.Slots, SettingsManager.prefGameMaxSlots.Value); int rows = vehicle.Rows; SetFieldOrProperty(__instance, "SlotCount", num); SetFieldOrProperty(__instance, "DisplayRowCount", rows); __instance.GetType().GetMethod("SetupSlots", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(__instance, null); MelonLogger.Msg($"[Enhanced Vehicules] Patched {((Object)((Component)val).gameObject).name} (Slots: {num}, Rows: {rows})"); break; } } catch (Exception ex) { MelonLogger.Error("[Enhanced Vehicules] StorageEntity Prefix error: " + ex.Message); } return true; } private static void SetFieldOrProperty(object target, string name, object value) { Type type = storageEntityType; PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { property.SetValue(target, value); return; } FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(target, value); } } } } namespace EnhancedVehicules.Settings { public static class SettingsManager { public static MelonPreferences_Category category; public static MelonPreferences_Entry<bool> prefEnableMod; public static MelonPreferences_Entry<int> prefGameMaxSlots; public static readonly Dictionary<string, MelonPreferences_Category> RackCategories = new Dictionary<string, MelonPreferences_Category>(); public static void CreateSettings() { category = MelonPreferences.CreateCategory("EnhancedVehicules", "Enhanced Vehicules Settings"); prefEnableMod = category.CreateEntry<bool>("EnableMod", true, "Enable This Mod", (string)null, false, false, (ValueValidator)null, (string)null); prefGameMaxSlots = category.CreateEntry<int>("GameMaxSlots", 20, "Maximum Total Slots in Game", (string)null, false, false, (ValueValidator)null, (string)null); foreach (VehicleData vehicle in VehicleDatabase.Vehicles) { MelonPreferences_Category val = MelonPreferences.CreateCategory("EnhancedVehicules/" + vehicle.Key, vehicle.Label + " Settings"); RackCategories[vehicle.Key] = val; vehicle.PrefSlots = val.CreateEntry<int>("Slots", vehicle.Slots, vehicle.Label + " - Number of Slots", (string)null, false, false, (ValueValidator)null, (string)null); vehicle.PrefRows = val.CreateEntry<int>("Rows", vehicle.Rows, vehicle.Label + " - Number of Rows", (string)null, false, false, (ValueValidator)null, (string)null); vehicle.PrefPrice = val.CreateEntry<float>("Price", vehicle.Price, vehicle.Label + " - Purchase Price", (string)null, false, false, (ValueValidator)null, (string)null); vehicle.PrefDiffGear = val.CreateEntry<float>("DiffGear", vehicle.DiffGear, vehicle.Label + " - Acceleration", (string)null, false, false, (ValueValidator)null, (string)null); vehicle.PrefTopSpeed = val.CreateEntry<float>("TopSpeed", vehicle.TopSpeed, vehicle.Label + " - Top Speed", (string)null, false, false, (ValueValidator)null, (string)null); } } public static void LoadSettings() { foreach (VehicleData vehicle in VehicleDatabase.Vehicles) { if (vehicle.PrefSlots != null) { vehicle.Slots = vehicle.PrefSlots.Value; } if (vehicle.PrefRows != null) { vehicle.Rows = vehicle.PrefRows.Value; } if (vehicle.PrefPrice != null) { vehicle.Price = vehicle.PrefPrice.Value; } if (vehicle.PrefDiffGear != null) { vehicle.DiffGear = vehicle.PrefDiffGear.Value; } if (vehicle.PrefTopSpeed != null) { vehicle.TopSpeed = vehicle.PrefTopSpeed.Value; } } } } } namespace EnhancedVehicules.Settings.Vehicule { public class VehicleData { public string Key; public string Label; public int Slots; public int Rows; public float Price; public float DiffGear; public float TopSpeed; public MelonPreferences_Entry<int> PrefSlots; public MelonPreferences_Entry<int> PrefRows; public MelonPreferences_Entry<float> PrefPrice; public MelonPreferences_Entry<float> PrefDiffGear; public MelonPreferences_Entry<float> PrefTopSpeed; } public static class VehicleDatabase { public static readonly List<VehicleData> Vehicles = new List<VehicleData> { new VehicleData { Key = "Shitbox", Label = "Shitbox", Slots = 5, Rows = 1, Price = 5000f, DiffGear = 5f, TopSpeed = 35f }, new VehicleData { Key = "Veeper", Label = "Van", Slots = 16, Rows = 2, Price = 9000f, DiffGear = 5f, TopSpeed = 40f }, new VehicleData { Key = "Bruiser", Label = "SUV", Slots = 5, Rows = 1, Price = 12000f, DiffGear = 5f, TopSpeed = 40f }, new VehicleData { Key = "Dinkler", Label = "Pickup", Slots = 8, Rows = 2, Price = 15000f, DiffGear = 5f, TopSpeed = 45f }, new VehicleData { Key = "Hounddog", Label = "Sedan", Slots = 5, Rows = 1, Price = 25000f, DiffGear = 5f, TopSpeed = 50f }, new VehicleData { Key = "Cheetah", Label = "Coupe", Slots = 4, Rows = 1, Price = 40000f, DiffGear = 5f, TopSpeed = 60f } }; } } namespace EnhancedVehiculesMod { public class EnhancedVehicules : MelonMod { [CompilerGenerated] private sealed class <DelayedAfterLoad>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EnhancedVehicules <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedAfterLoad>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(2f); <>1__state = 1; return true; case 1: <>1__state = -1; 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(); } } private static bool isPatched; public override void OnInitializeMelon() { MelonLogger.Msg("[Enhanced Vehicules] Loading settings..."); SettingsManager.CreateSettings(); SettingsManager.LoadSettings(); if (!SettingsManager.prefEnableMod.Value) { MelonLogger.Msg("[Enhanced Vehicules] Mod disabled via config."); } else { SceneManager.sceneLoaded += UnityAction<Scene, LoadSceneMode>.op_Implicit((Action<Scene, LoadSceneMode>)OnSceneLoaded); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (((Scene)(ref scene)).name.Equals("Main", StringComparison.OrdinalIgnoreCase) && !isPatched) { MelonCoroutines.Start(DelayedAfterLoad()); MelonLogger.Msg("[Enhanced Vehicules] Scene loaded: " + ((Scene)(ref scene)).name + ", now patching..."); StorageEntityPatch.Patch(); MelonCoroutines.Start(LandVehicleManager.ApplyToVehicles()); isPatched = true; } } [IteratorStateMachine(typeof(<DelayedAfterLoad>d__3))] private IEnumerator DelayedAfterLoad() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedAfterLoad>d__3(0) { <>4__this = this }; } } }