Class TrooperSlots

java.lang.Object
mekhq.campaign.unit.TrooperSlots

public class TrooperSlots extends Object
Which person wears which suit of a battle armor unit. Each suit is a trooper slot, numbered as MegaMek numbers the trooper locations, and holds at most one person. A person keeps their suit until they leave the unit, can no longer fight, or the suit can no longer be worn; anyone without a suit takes the best free one.
  • Constructor Details

    • TrooperSlots

      public TrooperSlots()
  • Method Details

    • getOccupant

      @Nullable public UUID getOccupant(int slot)
      Parameters:
      slot - the trooper slot
      Returns:
      the id of the person wearing that suit, or null if nobody does
    • findSlot

      @Nullable public Integer findSlot(UUID personId)
      Parameters:
      personId - the person
      Returns:
      the trooper slot the person wears, or null if they wear none
    • release

      public void release(UUID personId)
      Takes the person out of their suit, if they wear one.
      Parameters:
      personId - the person
    • seat

      public List<Integer> seat(List<UUID> crewIds, List<Integer> usableSlots)
      Puts the crew in the suits. A person keeps the suit they already wear while it can still be worn; anyone else takes the first free suit in usableSlots. People not in crewIds lose their suit.
      Parameters:
      crewIds - the people able to wear a suit, in the order they choose one
      usableSlots - the suits that can be worn, best first
      Returns:
      the suits now worn, in the order of usableSlots
    • findWearersOfLostSuits

      public Set<UUID> findWearersOfLostSuits(megamek.common.battleArmor.BattleArmor battleEntity)
      Finds the people whose suit was lost in a battle: they wore a suit that came back with no living trooper in it.
      Parameters:
      battleEntity - the squad as it came back from the battle
      Returns:
      the ids of the people in the lost suits
    • writeToXML

      public void writeToXML(PrintWriter printWriter, int indent)
      Writes the suit assignments, if there are any.
      Parameters:
      printWriter - where to write
      indent - the indent of the opening tag
    • isTrooperSlotsNode

      public static boolean isTrooperSlotsNode(String nodeName)
      Parameters:
      nodeName - the name of a child node of a saved unit
      Returns:
      true if the node holds the suit assignments
    • readFromXML

      public void readFromXML(Node trooperSlotsNode)
      Reads the suit assignments written by writeToXML(java.io.PrintWriter, int). An entry that cannot be read is skipped and logged; the person is then seated again the next time the crew is placed.
      Parameters:
      trooperSlotsNode - the trooperSlots node