Class FrankenMekDonorUtil

java.lang.Object
megameklab.util.FrankenMekDonorUtil

public final class FrankenMekDonorUtil extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    static int
    getDonorLocationTonnage(megamek.common.units.Mek donor, int location)
    Gets the tonnage that should be used for a donated location.
    static String
    getDonorSourceDisplayName(megamek.common.units.Mek donor)
    Gets the donor chassis display name stored for a FrankenMek location.
    static String
    getDonorSourceType(megamek.common.units.Mek donor, int location)
    Gets the type of the donor.
    static void
    importLocation(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 void
    replaceLocationEquipment(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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 modified
      donor - The unit donating the body section
      location - The location index to import
      Throws:
      megamek.common.exceptions.LocationFullException - If copied equipment cannot be added to the target
      megamek.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 equipment
      donor - The unit donating equipment
      location - 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 section
      location - The location index being donated
      Returns:
      The donor tonnage to apply to that location
    • getDonorSourceDisplayName

      public static String getDonorSourceDisplayName(megamek.common.units.Mek donor)
      Gets the donor chassis display name stored for a FrankenMek location. The value is trimmed, and a null chassis is returned as an empty string.
      Parameters:
      donor - The unit donating the body section
      Returns:
      The sanitized donor chassis display name
    • getDonorSourceType

      public static String getDonorSourceType(megamek.common.units.Mek donor, int location)
      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 section
      location - The donor location index, or Entity.LOC_NONE to 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 modified
      location - The target location index
      donorTonnage - The tonnage of the donated body section
      Returns:
      An explanation when the donor location is invalid, or null when it can be installed