Class AbstractTransportedUnitsSummary

java.lang.Object
mekhq.campaign.unit.AbstractTransportedUnitsSummary
All Implemented Interfaces:
ITransportedUnitsSummary
Direct Known Subclasses:
ShipTransportedUnitsSummary, TacticalTransportedUnitsSummary, TowTransportedUnitsSummary

public abstract class AbstractTransportedUnitsSummary extends Object implements ITransportedUnitsSummary
Tracks what units this transport is transporting, and its current capacity for its different transporter types.
  • Field Details

    • transport

      protected Unit transport
  • Method Details

    • init

      protected void init()
    • unloadTransport

      public void unloadTransport(Set<Unit> transportedUnits)
      Main method to be used for unloading units from a transport
      Specified by:
      unloadTransport in interface ITransportedUnitsSummary
      Parameters:
      transportedUnits - Units we wish to unload
    • unloadTransport

      protected void unloadTransport(Unit transportedUnit)
    • recalculateTransportCapacity

      public void recalculateTransportCapacity(@Nullable Vector<megamek.common.Transporter> transporters)
      Recalculates transport capacity - make sure you pass in all the transporters of a given type (class), or just all the transporters an entity has.
      Specified by:
      recalculateTransportCapacity in interface ITransportedUnitsSummary
      Parameters:
      transporters - What transporters are we recalculating?
      See Also:
      • Entity.getTransports()
    • hasTransportCapacity

      public boolean hasTransportCapacity()
      If this unit is capable of transporting another unit, return true
      Specified by:
      hasTransportCapacity in interface ITransportedUnitsSummary
      Returns:
      true if the unit can transport another unit
    • getTransportCapabilities

      public Set<TransporterType> getTransportCapabilities()
      Gets the different kinds of transporters the transport has
      Specified by:
      getTransportCapabilities in interface ITransportedUnitsSummary
      Returns:
      Set of Transporter classes
    • hasTransportCapacity

      public boolean hasTransportCapacity(TransporterType transporterType)
      Returns true if the unit has capacity left for a transporter type
      Specified by:
      hasTransportCapacity in interface ITransportedUnitsSummary
      Parameters:
      transporterType - Does the unit have free capacity in this type?
      Returns:
      True if the unit has capacity, false if not
    • getCurrentTransportCapacity

      public double getCurrentTransportCapacity(TransporterType transporterType)
      Returns the current capacity of a transporter type
      Specified by:
      getCurrentTransportCapacity in interface ITransportedUnitsSummary
      Parameters:
      transporterType - What kind of transporter types are we checking?
      Returns:
      The current capacity of the transporter, or 0
    • setCurrentTransportCapacity

      public void setCurrentTransportCapacity(TransporterType transporterType, double capacity)
      Sets the current transport capacity for the provided transport type
      Specified by:
      setCurrentTransportCapacity in interface ITransportedUnitsSummary
      Parameters:
      transporterType - What kind of transporter are we changing the capacity of?
      capacity - What is the new capacity?
    • hasTransportedUnits

      public boolean hasTransportedUnits()
      Gets a value indicating whether or not this unit is transporting units.
      Specified by:
      hasTransportedUnits in interface ITransportedUnitsSummary
      Returns:
      true if the unit has any transported units
    • getTransportedUnits

      public Set<Unit> getTransportedUnits()
      Specified by:
      getTransportedUnits in interface ITransportedUnitsSummary
      Returns:
      the set of units being transported by this unit.
    • addTransportedUnit

      public void addTransportedUnit(Unit unit)
      Adds a unit to our set of transported units.
      Specified by:
      addTransportedUnit in interface ITransportedUnitsSummary
      Parameters:
      unit - The unit being transported by this instance.
    • removeTransportedUnit

      public boolean removeTransportedUnit(Unit unit)
      Removes a unit from our set of transported units.
      Specified by:
      removeTransportedUnit in interface ITransportedUnitsSummary
      Parameters:
      unit - The unit to remove from our set of transported units.
      Returns:
      True if the unit was removed, otherwise false.
    • clearTransportedUnits

      public void clearTransportedUnits()
      Clears the set of units being transported by this unit.
      Specified by:
      clearTransportedUnits in interface ITransportedUnitsSummary
    • clearTransportedEntities

      protected Set<megamek.common.Entity> clearTransportedEntities()
    • loadTransportedEntities

      protected void loadTransportedEntities()
    • loadEntity

      protected void loadEntity(megamek.common.Entity transportedEntity)
    • replaceTransportedUnits

      public void replaceTransportedUnits(Set<Unit> newTransportedUnits)
      When fixing references we need to replace the transported units
      Specified by:
      replaceTransportedUnits in interface ITransportedUnitsSummary
      Parameters:
      newTransportedUnits - The units that should be transported