Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of Grand Theft Automobile v1.0.0
Mods/WoodStudios.GrandTheftAutomobile.dll
Decompiled 22 minutes agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using HarmonyLib; using Il2CppFishNet.Object; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppScheduleOne.DevUtilities; using Il2CppScheduleOne.Interaction; using Il2CppScheduleOne.Law; using Il2CppScheduleOne.Lighting; using Il2CppScheduleOne.NPCs; using Il2CppScheduleOne.PlayerScripts; using Il2CppScheduleOne.Police; using Il2CppScheduleOne.Vehicles; using Il2CppScheduleOne.Vehicles.AI; using Il2CppSystem.Collections.Generic; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; using WoodStudios.GTA; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Main), "Grand Theft Automobile", "1.0.0", "Wood Studios", null)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace WoodStudios.GTA { public class Main : MelonMod { internal static Instance Log; internal static MelonPreferences_Entry<float> CopSightRange; internal static MelonPreferences_Entry<bool> CopCarsWanted; private float _nextScan; public override void OnInitializeMelon() { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown Log = ((MelonBase)this).LoggerInstance; MelonPreferences_Category obj = MelonPreferences.CreateCategory("GrandTheftAutomobile", "Grand Theft Automobile"); CopSightRange = obj.CreateEntry<float>("CopSightRange", 40f, "How far away (metres) a cop can see you steal a car", (string)null, false, false, (ValueValidator)null, (string)null); CopCarsWanted = obj.CreateEntry<bool>("CopCarsWanted", true, "Stealing a police car always makes you wanted", (string)null, false, false, (ValueValidator)null, (string)null); try { ((MelonBase)this).HarmonyInstance.Patch((MethodBase)AccessTools.Method(typeof(LandVehicle), "Hovered", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Main), "HoverPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((MelonBase)this).HarmonyInstance.Patch((MethodBase)AccessTools.Method(typeof(LandVehicle), "Interacted", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Main), "InteractPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.Msg("Grand Theft Automobile loaded: walk up to any car and press your interact key to steal it."); } catch (Exception ex) { Log.Error("Couldn't hook the cars: " + ex.Message); } } public override void OnUpdate() { //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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) if (Time.unscaledTime < _nextScan) { return; } _nextScan = Time.unscaledTime + 0.5f; try { Player local = Player.Local; VehicleManager instance = NetworkSingleton<VehicleManager>.Instance; if ((Object)(object)local == (Object)null || (Object)(object)instance == (Object)null || instance.AllVehicles == null || local.IsInVehicle) { return; } Vector3 position = ((Component)local).transform.position; for (int i = 0; i < instance.AllVehicles.Count; i++) { LandVehicle val = instance.AllVehicles[i]; if ((Object)(object)val == (Object)null || val.IsPlayerOwned || (Object)(object)val.intObj == (Object)null) { continue; } Vector3 val2 = ((Component)val).transform.position - position; if (((Vector3)(ref val2)).sqrMagnitude < 100f) { if (!((Behaviour)val.intObj).enabled) { ((Behaviour)val.intObj).enabled = true; } if (!((Component)val.intObj).gameObject.activeSelf) { ((Component)val.intObj).gameObject.SetActive(true); } } } } catch { } } private static bool Stealable(LandVehicle v) { if ((Object)(object)v == (Object)null || v.IsPlayerOwned) { return false; } try { if ((Object)(object)v.DriverPlayer != (Object)null) { return false; } if (((Object)((Component)v).gameObject).name.StartsWith("rc_", StringComparison.OrdinalIgnoreCase)) { return false; } } catch { } return true; } internal static bool IsCopCar(LandVehicle v) { try { if ((Object)(object)((Component)v).GetComponentInChildren<PoliceLight>(true) != (Object)null) { return true; } string text = v.VehicleName + " " + v.vehicleCode + " " + ((Object)((Component)v).gameObject).name; if (text.IndexOf("police", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("cop", StringComparison.OrdinalIgnoreCase) >= 0) { return true; } Il2CppReferenceArray<NPC> occupantNPCs = v.OccupantNPCs; int num = 0; while (occupantNPCs != null && num < ((Il2CppArrayBase<NPC>)(object)occupantNPCs).Length) { if ((Object)(object)((Il2CppArrayBase<NPC>)(object)occupantNPCs)[num] != (Object)null && (Object)(object)((Il2CppObjectBase)((Il2CppArrayBase<NPC>)(object)occupantNPCs)[num]).TryCast<PoliceOfficer>() != (Object)null) { return true; } num++; } } catch { } return false; } private static bool HoverPrefix(LandVehicle __instance) { if (!Stealable(__instance)) { return true; } try { InteractableObject intObj = __instance.intObj; intObj.SetMessage(IsCopCar(__instance) ? "Steal police car" : (HasDriver(__instance) ? "Carjack" : "Steal car")); intObj.SetInteractableState((EInteractableState)0); } catch { } return false; } private static bool InteractPrefix(LandVehicle __instance) { if (!Stealable(__instance)) { return true; } if (!Steals.Busy) { MelonCoroutines.Start(Steals.Steal(__instance)); } return false; } internal static bool HasDriver(LandVehicle v) { try { Il2CppReferenceArray<NPC> occupantNPCs = v.OccupantNPCs; int num = 0; while (occupantNPCs != null && num < ((Il2CppArrayBase<NPC>)(object)occupantNPCs).Length) { if ((Object)(object)((Il2CppArrayBase<NPC>)(object)occupantNPCs)[num] != (Object)null) { return true; } num++; } } catch { } return false; } } internal static class Steals { internal static bool Busy; internal static IEnumerator Steal(LandVehicle v) { Busy = true; Player me = Player.Local; bool copCar = Main.IsCopCar(v); List<NPC> pulled = new List<NPC>(); try { Il2CppReferenceArray<NPC> occupantNPCs = v.OccupantNPCs; int num = 0; while (occupantNPCs != null && num < ((Il2CppArrayBase<NPC>)(object)occupantNPCs).Length) { if ((Object)(object)((Il2CppArrayBase<NPC>)(object)occupantNPCs)[num] != (Object)null) { pulled.Add(((Il2CppArrayBase<NPC>)(object)occupantNPCs)[num]); } num++; } foreach (NPC item in pulled) { item.ExitVehicle(); } VehicleAgent agent = v.Agent; if (agent != null) { agent.StopNavigating(); } } catch (Exception ex) { Main.Log.Warning("Couldn't pull the driver out: " + ex.Message); } if (pulled.Count > 0) { yield return (object)new WaitForSeconds(0.7f); } PoliceOfficer witness = Witness(me); try { v.EnterVehicle(); } catch (Exception ex2) { Main.Log.Warning("Couldn't get into the car: " + ex2.Message); Busy = false; yield break; } yield return (object)new WaitForSeconds(0.4f); try { foreach (NPC item2 in pulled) { PoliceOfficer val = ((Il2CppObjectBase)item2).TryCast<PoliceOfficer>(); if ((Object)(object)val != (Object)null) { witness = witness ?? val; } else { item2.SetPanicked_Server(); } } if ((copCar && Main.CopCarsWanted.Value) || (Object)(object)witness != (Object)null) { Wanted(me, v, witness, copCar); } } catch (Exception ex3) { Main.Log.Warning("Wanted check: " + ex3.Message); } Busy = false; } private static PoliceOfficer Witness(Player me) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_008b: 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_00c5: 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_00b2: 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) try { Vector3 val = ((Component)me).transform.position + Vector3.up * 1.5f; float value = Main.CopSightRange.Value; List<PoliceOfficer> officers = PoliceOfficer.Officers; int num = 0; RaycastHit val5 = default(RaycastHit); while (officers != null && num < officers.Count) { PoliceOfficer val2 = officers[num]; if (!((Object)(object)val2 == (Object)null) && ((NPC)val2).IsConscious && ((Component)val2).gameObject.activeInHierarchy) { Vector3 val3 = ((Component)val2).transform.position + Vector3.up * 1.6f; Vector3 val4 = val - val3; float magnitude = ((Vector3)(ref val4)).magnitude; if (!(magnitude > value) && (!(magnitude > 6f) || !(Vector3.Angle(((Component)val2).transform.forward, val4) > 80f)) && !Physics.Raycast(val3, ((Vector3)(ref val4)).normalized, ref val5, magnitude - 1f, 1, (QueryTriggerInteraction)1)) { return val2; } } num++; } } catch { } return null; } private static void Wanted(Player me, LandVehicle v, PoliceOfficer cop, bool copCar) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) PlayerCrimeData crimeData = me.CrimeData; crimeData.AddCrime((Crime)new Theft(), 1); if ((int)crimeData.CurrentPursuitLevel < 2) { crimeData.SetPursuitLevel((EPursuitLevel)2); } crimeData.RecordLastKnownPosition(true); PoliceOfficer val = cop; if ((Object)(object)val == (Object)null) { float num = default(float); val = PoliceOfficer.GetNearestOfficer(((Component)me).transform.position, ref num, true); } if (val != null) { val.BeginVehiclePursuit_Networked(me.PlayerCode, ((NetworkBehaviour)v).NetworkObject, true); } Main.Log.Msg(copCar ? "Stole a police car: you're wanted." : "A cop saw you steal that car: you're wanted."); } } }