Package mekhq.campaign.unit
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidaddTransportedUnit(Unit unit) Adds a unit to our set of transported units.voidCompletely clears the capacity map.protected voidvoidClears the set of units being transported by this unit.doublegetCurrentTransportCapacity(TransporterType transporterType) Returns the current capacity of a transporter typeGets the different kinds of transporters the transport hasbooleanIf this unit is capable of transporting another unit, return truebooleanhasTransportCapacity(TransporterType transporterType) Returns true if the unit has capacity left for a transporter typebooleanGets a value indicating whether this unit is transporting units.protected voidinit()protected voidloadEntity(megamek.common.units.Entity transportedEntity) protected voidvoidrecalculateTransportCapacity(Vector<megamek.common.equipment.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.booleanremoveTransportedUnit(Unit unit) Removes a unit from our set of transported units.voidreplaceTransportedUnits(Set<Unit> newTransportedUnits) When fixing references we need to replace the transported unitsvoidsetCurrentTransportCapacity(TransporterType transporterType, double capacity) Sets the current transport capacity for the provided transport typevoidunloadTransport(Set<Unit> transportedUnits) Main method to be used for unloading units from a transportprotected voidunloadTransport(Unit transportedUnit) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface mekhq.campaign.unit.ITransportedUnitsSummary
clearTransportedUnits, fixReferences
-
Field Details
-
transport
-
-
Method Details
-
init
protected void init() -
unloadTransport
Main method to be used for unloading units from a transport- Specified by:
unloadTransportin interfaceITransportedUnitsSummary- Parameters:
transportedUnits- Units we wish to unload
-
unloadTransport
-
recalculateTransportCapacity
public void recalculateTransportCapacity(@Nullable Vector<megamek.common.equipment.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:
recalculateTransportCapacityin interfaceITransportedUnitsSummary- 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:
hasTransportCapacityin interfaceITransportedUnitsSummary- Returns:
- true if the unit can transport another unit
-
getTransportCapabilities
Gets the different kinds of transporters the transport has- Specified by:
getTransportCapabilitiesin interfaceITransportedUnitsSummary- Returns:
- Set of Transporter classes
-
hasTransportCapacity
Returns true if the unit has capacity left for a transporter type- Specified by:
hasTransportCapacityin interfaceITransportedUnitsSummary- Parameters:
transporterType- Does the unit have free capacity in this type?- Returns:
- True if the unit has capacity, false if not
-
getCurrentTransportCapacity
Returns the current capacity of a transporter type- Specified by:
getCurrentTransportCapacityin interfaceITransportedUnitsSummary- Parameters:
transporterType- What kind of transporter types are we checking?- Returns:
- The current capacity of the transporter, or 0
-
setCurrentTransportCapacity
Sets the current transport capacity for the provided transport type- Specified by:
setCurrentTransportCapacityin interfaceITransportedUnitsSummary- 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 this unit is transporting units.- Specified by:
hasTransportedUnitsin interfaceITransportedUnitsSummary- Returns:
- true if the unit has any transported units
-
getTransportedUnits
- Specified by:
getTransportedUnitsin interfaceITransportedUnitsSummary- Returns:
- the set of units being transported by this unit.
-
addTransportedUnit
Adds a unit to our set of transported units.- Specified by:
addTransportedUnitin interfaceITransportedUnitsSummary- Parameters:
unit- The unit being transported by this instance.
-
removeTransportedUnit
Removes a unit from our set of transported units.- Specified by:
removeTransportedUnitin interfaceITransportedUnitsSummary- 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:
clearTransportedUnitsin interfaceITransportedUnitsSummary
-
clearTransportCapacityMap
public void clearTransportCapacityMap()Completely clears the capacity map. Helpful if the transportCapacity has a TransporterType for a Transporter the unit no longer has - such as after a refit. -
clearTransportedEntities
protected void clearTransportedEntities() -
loadTransportedEntities
protected void loadTransportedEntities() -
loadEntity
protected void loadEntity(megamek.common.units.Entity transportedEntity) -
replaceTransportedUnits
When fixing references we need to replace the transported units- Specified by:
replaceTransportedUnitsin interfaceITransportedUnitsSummary- Parameters:
newTransportedUnits- The units that should be transported
-