Class TankTrailerHitch

java.lang.Object
megamek.common.TankTrailerHitch
All Implemented Interfaces:
Serializable, Transporter

public class TankTrailerHitch extends Object implements Transporter
Represents a trailer hitch that allows a wheeled or tracked vehicle to tow trailers.
See Also:
  • Field Details

    • towed

      protected int towed
      The entity being towed by this hitch.
  • Constructor Details

    • TankTrailerHitch

      public TankTrailerHitch(boolean rear)
      Create a new hitch, specified as a (front) or rear mount.
  • Method Details

    • getRearMounted

      public boolean getRearMounted()
    • getVacancyString

      protected String getVacancyString(boolean isLoaded)
      Get the String to report the presence (or lack thereof) of a towed trailer.

      Sub-classes are encouraged to override this method.

      Parameters:
      isLoaded - - a boolean that indicates a trailer is currently loaded (if the value is true) or not (if the value is false).
      Returns:
      a String describing the occupancy state of this transporter.
    • canLoad

      public boolean canLoad(Entity unit)
      Determines if this object can accept the given unit. The unit may not be of the appropriate type or there may be no room for the unit.

      Specified by:
      canLoad in interface Transporter
      Parameters:
      unit - - the Entity to be loaded.
      Returns:
      true if the unit can be loaded, false otherwise.
    • canTow

      public boolean canTow(Entity unit)
      Description copied from interface: Transporter
      Determines if this transporter can tow the given unit. By default, no.
      Specified by:
      canTow in interface Transporter
    • load

      public final void load(Entity unit) throws IllegalArgumentException
      Load the given unit.
      Specified by:
      load in interface Transporter
      Parameters:
      unit - the Entity to be loaded.
      Throws:
      IllegalArgumentException - If the unit can't be loaded
    • getLoadedUnits

      public final Vector<Entity> getLoadedUnits()
      Get a List of the units currently loaded into this payload.
      Specified by:
      getLoadedUnits in interface Transporter
      Returns:
      A Vector of loaded Entity units. This list will never be null, but it may be empty. The returned List is independent from the under- lying data structure; modifying one does not affect the other.
    • unload

      public final boolean unload(Entity unit)
      Unload the given unit.
      Specified by:
      unload in interface Transporter
      Parameters:
      unit - - the Entity to be unloaded.
      Returns:
      true if the unit was contained is loaded in this space, false otherwise.
    • getUnusedString

      public final String getUnusedString()
      Return a string that identifies the unused capacity of this transporter.

      Sub-classes should override the getVacancyString method.

      Specified by:
      getUnusedString in interface Transporter
      Returns:
      A String meant for a human.
      See Also:
    • getUnused

      public double getUnused()
      Specified by:
      getUnused in interface Transporter
      Returns:
      the number of unused spaces in this transporter.
    • resetTransporter

      public void resetTransporter()
      Description copied from interface: Transporter
      clear out all troops listed in the transporter. Used by MHQ to reset units after game
      Specified by:
      resetTransporter in interface Transporter
    • isWeaponBlockedAt

      public boolean isWeaponBlockedAt(int loc, boolean isRear)
      Determine if transported units prevent a weapon in the given location from firing.
      Specified by:
      isWeaponBlockedAt in interface Transporter
      Parameters:
      loc - - the int location attempting to fire.
      isRear - - a boolean value stating if the given location is rear facing; if false, the location is front facing.
      Returns:
      true if a transported unit is in the way, false if the weapon can fire.
    • getExteriorUnitAt

      public final Entity getExteriorUnitAt(int loc, boolean isRear)
      If a unit is being transported on the outside of the transporter, it can suffer damage when the transporter is hit by an attack. Currently, no more than one unit can be at any single location; that same unit can be "spread" over multiple locations.

      Specified by:
      getExteriorUnitAt in interface Transporter
      Parameters:
      loc - - the int location hit by attack.
      isRear - - a boolean value stating if the given location is rear facing; if false, the location is front facing.
      Returns:
      The Entity being transported on the outside at that location. This value will be null if no unit is transported on the outside at that location.
    • getExternalUnits

      public final List<Entity> getExternalUnits()
      Specified by:
      getExternalUnits in interface Transporter
      Returns:
      list of all units carried externally by this transporter
    • getCargoMpReduction

      public int getCargoMpReduction(Entity carrier)
      Specified by:
      getCargoMpReduction in interface Transporter
      Returns:
      the MP reduction due to cargo carried by this transporter
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setGame

      public void setGame(Game game)
      Specified by:
      setGame in interface Transporter