Please disclose if your mod was created primarily 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 LifetimeCruiserWarranty v1.4.0
plugins/LifetimeCruiserWarranty/LifetimeCruiserWarranty.dll
Decompiled 2 years agousing System; using System.Collections; 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 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("LifetimeCruiserWarranty")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("LifetimeCruiserWarranty")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ea55591a-2a00-4d63-9d8a-f37f0abf8888")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace LifetimeCruiserWarranty { internal class Config { public static ConfigEntry<bool> applyPenalty; public static ConfigEntry<bool> isPercentagePenalty; public static ConfigEntry<float> percentagePenaltyAmount; public static ConfigEntry<int> flatPenaltyAmount; public static void Load() { applyPenalty = Plugin.config.Bind<bool>("Apply Penalty", "ApplyPenalty", true, "Determines if leaving behind or destroying the Company Cruiser will incur a credit penalty."); isPercentagePenalty = Plugin.config.Bind<bool>("Is Penalty Percentage", "IsPercentagePenalty", true, "Determines if the credit penalty is issued as a percentage of your total credits or as a flat rate. Apply Penalty must be true for this to have any effect."); percentagePenaltyAmount = Plugin.config.Bind<float>("Percentage Penalty Amount", "PercentagePenaltyAmount", 0.2f, "The percentage penalty which will be applied. Is Penalty Percentage must be true for this to have any effect."); flatPenaltyAmount = Plugin.config.Bind<int>("Flat Penalty Amount", "FlatPenaltyAmount", 150, "The flat rate penalty which will be applied. Is Penalty Percentage must be false for this to have any effect."); } } [BepInPlugin("33mamaster.LifetimeCruiserWarranty", "Lifetime Cruiser Warranty", "1.4.0")] public class Plugin : BaseUnityPlugin { private const string modGUID = "33mamaster.LifetimeCruiserWarranty"; private const string modName = "Lifetime Cruiser Warranty"; private const string modVersion = "1.4.0"; public static ConfigFile config; internal static ManualLogSource Logger; private readonly Harmony harmony = new Harmony("33mamaster.LifetimeCruiserWarranty"); private static Plugin Instance; internal static bool isVehicleLeftBehind; internal static int due; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Mod Lifetime Cruiser Warranty is loaded!"); config = ((BaseUnityPlugin)this).Config; Config.Load(); harmony.PatchAll(); } } } namespace LifetimeCruiserWarranty.Patches { [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("PassTimeToNextDay")] [HarmonyPostfix] private static void PassTimeToNextDayPatch() { Plugin.Logger.LogInfo((object)"Display Penalty Function"); if (Plugin.isVehicleLeftBehind) { ((MonoBehaviour)HUDManager.Instance).StartCoroutine(DisplayAlert()); } } private static IEnumerator DisplayAlert() { yield return (object)new WaitForSeconds(4f); HUDManager.Instance.DisplayTip("Cruiser Lost", $"The Company Cruiser was lost.\nFINES DUE: ${Plugin.due}", true, false, "LC_Warning1"); yield return (object)new WaitForSeconds(3f); } } [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatch { [HarmonyPatch("DespawnPropsAtEndOfRound")] [HarmonyPrefix] private static void DespawnPropsAtEndOfRoundPatch() { Plugin.isVehicleLeftBehind = false; if (!Config.applyPenalty.Value) { return; } Terminal val = Object.FindObjectOfType<Terminal>(); int groupCredits = val.groupCredits; Plugin.isVehicleLeftBehind = false; Plugin.due = 0; Plugin.Logger.LogInfo((object)"Attempting Lookup of Vehicles"); try { VehicleController[] array = Object.FindObjectsByType<VehicleController>((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { if (!array[i].magnetedToShip && (Object)(object)((NetworkBehaviour)array[i]).NetworkObject != (Object)null) { Plugin.Logger.LogInfo((object)("Found Left Behind Vehicle: " + ((Object)array[i]).name)); Plugin.isVehicleLeftBehind = true; Plugin.Logger.LogInfo((object)$"Credits: {val.groupCredits}"); if (Config.isPercentagePenalty.Value) { val.groupCredits -= (int)((float)groupCredits * Config.percentagePenaltyAmount.Value); } else { val.groupCredits -= Config.flatPenaltyAmount.Value; } Plugin.Logger.LogInfo((object)$"Credits after: {val.groupCredits}"); Plugin.due = groupCredits - val.groupCredits; } } } catch (Exception arg) { Plugin.Logger.LogError((object)$"Error Searching for vehicle: {arg}"); } } } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatch { [HarmonyPatch("BuyVehicleServerRpc")] [HarmonyPostfix] private static void BuyVehicleServerRpcPatch(ref bool ___hasWarrantyTicket) { ___hasWarrantyTicket = true; } [HarmonyPatch("BuyVehicleClientRpc")] [HarmonyPostfix] private static void BuyVehicleClientRpcPatch(ref bool ___hasWarrantyTicket) { ___hasWarrantyTicket = true; } } }