Package megameklab.util
Class FrankenMekDonorUtil
java.lang.Object
megameklab.util.FrankenMekDonorUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetDonorLocationInvalidReason(megamek.common.units.Mek target, int location, int donorTonnage) Validates whether the donor location tonnage can be installed in the target FrankenMek location.static intgetDonorLocationTonnage(megamek.common.units.Mek donor, int location) Gets the tonnage that should be used for a donated location.static StringgetDonorSourceDisplayName(megamek.common.units.Mek donor) Gets the donor chassis display name stored for a FrankenMek location.static StringgetDonorSourceType(megamek.common.units.Mek donor, int location) Gets the type of the donor.static voidimportLocation(megamek.common.units.Mek target, megamek.common.units.Mek donor, int location) Imports one FrankenMek donor location into the target, including structure data, armor, equipment, and any location-specific systems that are copied with that body section.static voidreplaceLocationEquipment(megamek.common.units.Mek target, megamek.common.units.Mek donor, int location) Replaces the target location's donor-owned equipment with copies from the donor location while preserving system criticals that belong to the target unit.
-
Method Details
-
importLocation
public static void importLocation(megamek.common.units.Mek target, megamek.common.units.Mek donor, int location) throws megamek.common.exceptions.LocationFullException, megamek.common.loaders.EntityLoadingException Imports one FrankenMek donor location into the target, including structure data, armor, equipment, and any location-specific systems that are copied with that body section.- Parameters:
target- The FrankenMek being modifieddonor- The unit donating the body sectionlocation- The location index to import- Throws:
megamek.common.exceptions.LocationFullException- If copied equipment cannot be added to the targetmegamek.common.loaders.EntityLoadingException- If post-load initialization fails after the import
-
replaceLocationEquipment
public static void replaceLocationEquipment(megamek.common.units.Mek target, megamek.common.units.Mek donor, int location) throws megamek.common.exceptions.LocationFullException Replaces the target location's donor-owned equipment with copies from the donor location while preserving system criticals that belong to the target unit. Equipment that cannot fit is moved to unallocated storage.- Parameters:
target- The unit receiving equipmentdonor- The unit donating equipmentlocation- The location index to replace- Throws:
megamek.common.exceptions.LocationFullException- If copied equipment cannot be added to the target or unallocated storage
-
getDonorLocationTonnage
public static int getDonorLocationTonnage(megamek.common.units.Mek donor, int location) Gets the tonnage that should be used for a donated location. FrankenMek donors keep per-location tonnage; standard units donate body sections at their whole-unit weight.- Parameters:
donor- The unit donating the body sectionlocation- The location index being donated- Returns:
- The donor tonnage to apply to that location
-
getDonorSourceDisplayName
Gets the donor chassis display name stored for a FrankenMek location. The value is trimmed, and anullchassis is returned as an empty string.- Parameters:
donor- The unit donating the body section- Returns:
- The sanitized donor chassis display name
-
getDonorSourceType
Gets the type of the donor. For FrankenMek donors the location is important and the donor type of that FrankenMek location is returned (pass-through)..- Parameters:
donor- The unit donating the body sectionlocation- The donor location index, orEntity.LOC_NONEto use the whole donor unit- Returns:
- The donor type for the donated body section
-
getDonorLocationInvalidReason
@Nullable public static String getDonorLocationInvalidReason(megamek.common.units.Mek target, int location, int donorTonnage) Validates whether the donor location tonnage can be installed in the target FrankenMek location.- Parameters:
target- The FrankenMek being modifiedlocation- The target location indexdonorTonnage- The tonnage of the donated body section- Returns:
- An explanation when the donor location is invalid, or
nullwhen it can be installed
-