From 8666318e79bde10b6d5aa5e3ed61409fd268ac37 Mon Sep 17 00:00:00 2001 From: user Date: Tue, 7 Jan 2025 17:14:54 +0300 Subject: [PATCH] Quick fix for overencumbered shyuttles launch --- Source/1.5/HarmonyPatches.cs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Source/1.5/HarmonyPatches.cs b/Source/1.5/HarmonyPatches.cs index b5534fad..44fa1c26 100644 --- a/Source/1.5/HarmonyPatches.cs +++ b/Source/1.5/HarmonyPatches.cs @@ -4517,9 +4517,24 @@ public static class VFShuttleBayLaunch { public static void Postfix(ref string disableReason, CompVehicleLauncher __instance, ref bool __result) { - if (disableReason != Translator.Translate("CommandLaunchGroupFailUnderRoof")) return; + //Temporary fix clarifying the message on shuttle unable to launch because of rotated + if (disableReason == "VF_CannotLaunchImmobile".Translate(__instance.Vehicle.LabelShort) && __instance.Vehicle.Angle != 0) + { + disableReason = "VF_Fix_CannotLaunchRotated".Translate(__instance.Vehicle.LabelShort); + } + + // Somwehow, was allowed to launch overloaded. + VehiclePawn vehiclePawn = (VehiclePawn)__instance.parent; + float vehicleCapacity = vehiclePawn.GetStatValue(VehicleStatDefOf.CargoCapacity); + if (MassUtility.InventoryMass(vehiclePawn) > vehicleCapacity) + { + disableReason = "VF_CannotLaunchOverEncumbered".Translate(vehiclePawn.LabelShort); + __result = false; + return; + } + + if (disableReason != Translator.Translate("CommandLaunchGroupFailUnderRoof")) return; - VehiclePawn vehiclePawn = (VehiclePawn) __instance.parent; Map map = vehiclePawn.Map; IntVec3 cell = vehiclePawn.Position; @@ -4800,21 +4815,8 @@ public static bool Prefix() //__result.AddRange(aerialVehicle.vehicle.AllPawnsAboard); } return false; - } - } - - [HarmonyPatch(typeof(CompVehicleLauncher), "CanLaunchWithCargoCapacity")] - public static class RotatedLaunchWarningFix - { - //Temporary fix clarifying the message on shuttle unable to launch - public static void Postfix(CompVehicleLauncher __instance, ref string disableReason) - { - if( disableReason == "VF_CannotLaunchImmobile".Translate(__instance.Vehicle.LabelShort) && __instance.Vehicle.Angle != 0) - { - disableReason = "VF_Fix_CannotLaunchRotated".Translate(__instance.Vehicle.LabelShort); - } - } - } + } + } [HarmonyPatch(typeof(CompUpgradeTree), "ValidateListers")] public static class DisableValidateListersOffMap