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 MultiCruiser v1.0.0
BepInEx/plugins/MultiCruiser/MultiTruck.dll
Decompiled 2 years agousing System; 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 MultiTruck.Patches; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("MultiTruck")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("MultiTruck")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("c13d4b45-4d56-40ef-8f2b-402fbbd30b1f")] [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")] namespace MultiTruck { [BepInPlugin("JacobG5.MultiCruiser", "MultiCruiser", "1.0.0")] public class MultiTruckBase : BaseUnityPlugin { private const string modGUID = "JacobG5.MultiCruiser"; private const string modName = "MultiCruiser"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("JacobG5.MultiCruiser"); private static MultiTruckBase Instance; public static ManualLogSource mls; public static ConfigEntry<bool> enableCruiserCollision; public static ConfigEntry<bool> enableCruiserCollisionDamage; public static ConfigEntry<int> cruiserCollisionBaseDamage; public static ConfigEntry<int> cruiserCollisionSelfDamage; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } enableCruiserCollision = ((BaseUnityPlugin)this).Config.Bind<bool>("Main", "enableCruiserCollision", true, "Enables Cruisers to collide with each-other by 'pushing' each-other when collision detected."); enableCruiserCollisionDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Main", "enableCruiserCollisionDamage", true, "If Cruisers should Damage eachother when colliding. Requires CruiserCollision to be enabled."); cruiserCollisionBaseDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Main", "cruiserCollisionBaseDamage", 2, "Amount of damage Cruiser-on-Cruiser Collisions deal to the other Cruiser. (+2 for Medium Speed Collisions & +4 for High Speed Collisions)"); cruiserCollisionSelfDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Main", "cruiserCollisionSelfDamage", 1, "Amount of damage Cruiser-on-Cruiser Collisions deal to themselves. (+1 for Medium Speed Collisions & +2 for High Speed Collisions)"); mls = Logger.CreateLogSource("JacobG5.MultiCruiser"); mls.LogInfo((object)"Patching Terminal"); harmony.PatchAll(typeof(TerminalPatch)); harmony.PatchAll(typeof(VehicleControllerPatch)); harmony.PatchAll(typeof(VehicleCollisionTriggerPatch)); } } } namespace MultiTruck.Patches { [HarmonyPatch(typeof(Terminal))] internal class TerminalPatch { [HarmonyPatch("LoadNewNodeIfAffordable")] [HarmonyPrefix] public static bool patchPurchase(TerminalNode node, Terminal __instance, ref bool ___vehicleInDropship, ref TerminalNodesList ___terminalNodes, ref int ___totalCostOfItems, ref Item[] ___buyableItemsList, ref int[] ___itemSalesPercentages, ref int ___groupCredits, ref bool ___hasWarrantyTicket, ref int ___numberOfItemsInDropship, ref int ___orderedVehicleFromTerminal) { if (node.buyVehicleIndex == -1) { return true; } int num = ___buyableItemsList.Length + node.buyVehicleIndex; ___totalCostOfItems = (int)((float)node.itemCost * ((float)___itemSalesPercentages[num] / 100f)); if (___groupCredits < ___totalCostOfItems && !___hasWarrantyTicket) { __instance.LoadNewNode(___terminalNodes.specialNodes[2]); return false; } if (___numberOfItemsInDropship > 0) { __instance.LoadNewNode(___terminalNodes.specialNodes[27]); return false; } if (___vehicleInDropship && node.buyItemIndex != -1) { __instance.LoadNewNode(___terminalNodes.specialNodes[25]); return false; } ItemDropship val = Object.FindObjectOfType<ItemDropship>(); if (___vehicleInDropship || ((Object)(object)val != (Object)null && val.deliveringVehicle)) { __instance.LoadNewNode(___terminalNodes.specialNodes[26]); return false; } if (!node.isConfirmationNode) { if (!___hasWarrantyTicket) { ___groupCredits = Mathf.Clamp(___groupCredits - ___totalCostOfItems, 0, 10000000); } ___orderedVehicleFromTerminal = node.buyVehicleIndex; ___vehicleInDropship = true; Debug.Log((object)$"Is server?: {((NetworkBehaviour)__instance).IsServer}"); if (!((NetworkBehaviour)__instance).IsServer) { SyncBoughtVehicleWithServer(__instance, ___orderedVehicleFromTerminal); } else { ___hasWarrantyTicket = !___hasWarrantyTicket; BuyVehicleClientRpc(__instance, ___groupCredits, ___hasWarrantyTicket); } } __instance.LoadNewNode(node); return false; } [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(Terminal), "SyncBoughtVehicleWithServer")] public static void SyncBoughtVehicleWithServer(object instance, int vehicleID) { throw new NotImplementedException("It's a stub"); } [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(Terminal), "BuyVehicleClientRpc")] public static void BuyVehicleClientRpc(object instance, int newGroupCredits, bool giveWarranty) { throw new NotImplementedException("It's a stub"); } } [HarmonyPatch(typeof(VehicleCollisionTrigger))] internal class VehicleCollisionTriggerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] public static void patchStart() { if (MultiTruckBase.enableCruiserCollision.Value) { Physics.IgnoreLayerCollision(30, 13, false); } } [HarmonyPatch("OnTriggerEnter")] [HarmonyPrefix] public static void patchOnTriggerEnter(Collider other, ref VehicleController ___mainScript) { //IL_0052: 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_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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) VehicleController val = default(VehicleController); if (((Component)other).gameObject.layer != 30 || !MultiTruckBase.enableCruiserCollision.Value || !((Component)other).gameObject.TryGetComponent<VehicleController>(ref val) || !((Object)(object)val != (Object)(object)___mainScript)) { return; } val.PushTruckServerRpc(((Component)___mainScript).transform.position, ((Component)val).transform.position - ((Component)___mainScript).transform.position); if (MultiTruckBase.enableCruiserCollisionDamage.Value) { int num = 0; if (((Vector3)(ref ___mainScript.averageVelocity)).magnitude > 27f) { num += 4; } else if (((Vector3)(ref ___mainScript.averageVelocity)).magnitude > 19f) { num += 2; } if (((Vector3)(ref ___mainScript.averageVelocity)).magnitude > 11f) { VehicleControllerPatch.DealPermanentDamage(val, Math.Max(0, MultiTruckBase.cruiserCollisionBaseDamage.Value + num)); VehicleControllerPatch.DealPermanentDamage(___mainScript, Math.Max(0, MultiTruckBase.cruiserCollisionSelfDamage.Value + num / 2)); } } } } [HarmonyPatch(typeof(VehicleController))] internal class VehicleControllerPatch { [HarmonyReversePatch(/*Could not decode attribute arguments.*/)] [HarmonyPatch(typeof(VehicleController), "DealPermanentDamage")] public static void DealPermanentDamage(object instance, int damageAmount, Vector3 damagePosition = default(Vector3)) { throw new NotImplementedException("It's a stub"); } } }