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 TypeMethodDescriptionvoid
addTransportedUnit
(Unit unit) Adds a unit to our set of transported units.protected Set<megamek.common.Entity>
void
Clears the set of units being transported by this unit.double
getCurrentTransportCapacity
(TransporterType transporterType) Returns the current capacity of a transporter typeGets the different kinds of transporters the transport hasboolean
If this unit is capable of transporting another unit, return trueboolean
hasTransportCapacity
(TransporterType transporterType) Returns true if the unit has capacity left for a transporter typeboolean
Gets a value indicating whether or not this unit is transporting units.protected void
init()
protected void
loadEntity
(megamek.common.Entity transportedEntity) protected void
void
recalculateTransportCapacity
(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.boolean
removeTransportedUnit
(Unit unit) Removes a unit from our set of transported units.void
replaceTransportedUnits
(Set<Unit> newTransportedUnits) When fixing references we need to replace the transported unitsvoid
setCurrentTransportCapacity
(TransporterType transporterType, double capacity) Sets the current transport capacity for the provided transport typevoid
unloadTransport
(Set<Unit> transportedUnits) Main method to be used for unloading units from a transportprotected void
unloadTransport
(Unit transportedUnit) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
unloadTransport
in interfaceITransportedUnitsSummary
- Parameters:
transportedUnits
- Units we wish to unload
-
unloadTransport
-
recalculateTransportCapacity
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 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:
hasTransportCapacity
in interfaceITransportedUnitsSummary
- Returns:
- true if the unit can transport another unit
-
getTransportCapabilities
Gets the different kinds of transporters the transport has- Specified by:
getTransportCapabilities
in interfaceITransportedUnitsSummary
- Returns:
- Set of Transporter classes
-
hasTransportCapacity
Returns true if the unit has capacity left for a transporter type- Specified by:
hasTransportCapacity
in 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:
getCurrentTransportCapacity
in 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:
setCurrentTransportCapacity
in 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 or not this unit is transporting units.- Specified by:
hasTransportedUnits
in interfaceITransportedUnitsSummary
- Returns:
- true if the unit has any transported units
-
getTransportedUnits
- Specified by:
getTransportedUnits
in interfaceITransportedUnitsSummary
- Returns:
- the set of units being transported by this unit.
-
addTransportedUnit
Adds a unit to our set of transported units.- Specified by:
addTransportedUnit
in interfaceITransportedUnitsSummary
- Parameters:
unit
- The unit being transported by this instance.
-
removeTransportedUnit
Removes a unit from our set of transported units.- Specified by:
removeTransportedUnit
in 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:
clearTransportedUnits
in interfaceITransportedUnitsSummary
-
clearTransportedEntities
-
loadTransportedEntities
protected void loadTransportedEntities() -
loadEntity
protected void loadEntity(megamek.common.Entity transportedEntity) -
replaceTransportedUnits
When fixing references we need to replace the transported units- Specified by:
replaceTransportedUnits
in interfaceITransportedUnitsSummary
- Parameters:
newTransportedUnits
- The units that should be transported
-