Class Unit
- All Implemented Interfaces:
megamek.common.ITechnology
- Direct Known Subclasses:
Part.PartUnitRef
,Person.PersonUnitRef
,TestUnit
,Unit.UnitRef
,UnitOrder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents an unresolved reference to a Person from a Unit.static class
Represents an unresolved reference to a Unit from a Unit.Nested classes/interfaces inherited from interface megamek.common.ITechnology
megamek.common.ITechnology.AvailabilityValue, megamek.common.ITechnology.Era, megamek.common.ITechnology.Faction, megamek.common.ITechnology.FactionAffiliation, megamek.common.ITechnology.TechBase, megamek.common.ITechnology.TechRating
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected megamek.common.Entity
static final int
protected int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
Fields inherited from interface megamek.common.ITechnology
DATE_ES, DATE_NONE, DATE_PS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
void
void
void
addPilotOrSoldier
(Person person) void
addPilotOrSoldier
(Person person, boolean useTransfers) void
addPilotOrSoldier
(Person person, Unit oldUnit, boolean useTransfers) void
addShipTransportedUnit
(Unit unit) Adds a unit to our set of transported units.void
void
addVesselCrew
(Person person, boolean useTransfers) megamek.common.ITechnology.AvailabilityValue
calcYearAvailability
(int year, boolean clan, megamek.common.ITechnology.Faction faction) void
Cancels a pending mothball or activation work order.boolean
boolean
boolean
boolean
boolean
boolean
boolean
Validates the deployment readiness of the unit.void
void
void
Clears the set of units being transported by this unit.void
clearTransportedUnits
(CampaignTransportType campaignTransportType) Clears the set of units being transported by this unit.void
Completes the activation of a unit.void
Completes the mothballing of a unit.void
damageSystem
(int type, int equipmentNum, int hits) int
damageSystem
(int type, int equipmentNum, int loc, int hits) void
destroySystem
(int type, int equipmentNum) void
destroySystem
(int type, int equipmentNum, int loc) void
destroySystem
(int type, int equipmentNum, int loc, int hits) Returns the engineer responsible for the mothballing or activation of this unit.boolean
Find a part on a unit.void
fixReferences
(Campaign campaign) static Unit
generateInstanceFromXML
(Node wn, megamek.Version version, Campaign campaign) int
Returns all soldiers or battle armor assigned to the unit.double
int
Deprecated, for removal: This API element is subject to removal in a future version.no indicated uses.megamek.common.ITechnology.AvailabilityValue
getAvailability
(int era) megamek.common.ITechnology.AvailabilityValue
getBaseAvailability
(megamek.common.ITechnology.Era era) double
megamek.common.icons.Camouflage
double
Calculates the total cargo capacity of the entity, considering the usable capacities of transport bays and mounted equipment designated for cargo.Returns the commander of the entity.int
double
getCorrectBayCapacity
(int unitType, double unitWeight) Convenience method to call the right capacity getter based on unit type and weightgetCrew()
double
Deprecated.this only checks ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisdouble
Deprecated.this only checks a ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisint
Deprecated.this only checks ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisdouble
Deprecated.this only checks a ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisdouble
Deprecated.this only checks a ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisdouble
Deprecated.this only checks a ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisdouble
Deprecated.this only checks ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisdouble
Deprecated.this only checks ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisdouble
getCurrentShipTransportCapacity
(TransporterType transporterType) Returns the current capacitydouble
Deprecated.this only checks ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisdouble
Deprecated.this only checks a ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisdouble
getCurrentTransportCapacity
(CampaignTransportType campaignTransportType, TransporterType transporterType) Returns the current capacityint
static int
getDamageState
(megamek.common.Entity en) static String
getDamageStateName
(int i) double
int
int
getDocks()
megamek.common.Entity
int
int
getExtinctionDate
(boolean clan, megamek.common.ITechnology.Faction faction) getFighterFuelCost
(megamek.common.Entity e) int
getFuelCost
(int hydrogenProduction) Calculates the monthly fuel cost for this unit, applying any available hydrogen production credits.int
double
int
getHitCriticals
(int type, int index) Number of slots doomed, missing or destroyed in all locationsint
getHitCriticals
(int type, int index, int loc) Number of slots doomed, missing or destroyed in a locationgetId()
double
getInfantryFuelCost
(megamek.common.Entity e) double
int
int
getIntroductionDate
(boolean clan, megamek.common.ITechnology.Faction faction) double
double
double
double
Deprecated, for removal: This API element is subject to removal in a future version.no indicated uses.The weekly maintenance cycle combined with a user defined maintenance cycle length is confusing and difficult to manage so lets just make maintenance costs relative to the length of the maintenance cycle that the user definedint
int
Calculates the maintenance time required for the associated entity, factoring in its type, weight class, and the maintenance multiplier.int
Returns a personnel count for each marine platoon/squad assigned to this unitdouble
int
Gets the time (in minutes) remaining to mothball or activate the unit.getName()
getPartForEquipmentNum
(int index, int loc) getParts()
getPartsNeedingFixing
(boolean onlyNotBeingWorkedOn) Gets a list of every part on a unit which need service (either repair or salvage), including parts currently being worked on.getPartsNeedingService
(boolean onlyNotBeingWorkedOn) Gets a list of parts on a unit which need service (either repair or salvage), optionally excluding parts already being worked on.int
int
getProductionDate
(boolean clan, megamek.common.ITechnology.Faction faction) double
int
int
getPrototypeDate
(boolean clan, megamek.common.ITechnology.Faction faction) static PartQuality
getRandomUnitQuality
(int modifier) Generates a random unit quality based on a 2d6 roll and a modifier.getRefit()
double
int
int
getReintroductionDate
(boolean clan, megamek.common.ITechnology.Faction faction) getSalvageableParts
(boolean onlyNotBeingWorkedOn) int
megamek.common.SimpleTechLevel
megamek.common.SimpleTechLevel
getSimpleTechLevel
(int year) megamek.common.SimpleTechLevel
getSimpleTechLevel
(int year, boolean clan, megamek.common.ITechnology.Faction faction) int
getSite()
megamek.common.TargetRoll
static String
getSiteName
(int loc) static String
getSiteToolTipText
(int loc) double
megamek.common.SimpleTechLevel
double
Gets the tactical transport assignment for this unit, or null if this unit is not being transported.getTech()
megamek.common.ITechnology.TechBase
megamek.common.ITechnology.TechRating
getTonsBurnMonthCost
(megamek.common.Entity entity) On average, how much does this spaceshift spend burning fuel per month? Based on CO p.int
Compute the number of generic space/vehicle crew (e.g.int
int
double
getTotalWeightOfUnitsAssignedToBeTransported
(CampaignTransportType transportType, TransporterType transporterType) Calculates the total weight of all units assigned to be transported in this unit for a specific transport type and transporter type.getTransportAssignment
(CampaignTransportType campaignTransportType) Returns the transport assignment for the given transport type, or null if none is providedgetTransportCapabilities
(CampaignTransportType campaignTransportType) For the provided campaign transport type (enum), return the transporters this unitgetTransportedUnits
(CampaignTransportType campaignTransportType) For the given transport type, return the set of units it's transporting, or an empty setgetTransportedUnitsSummary
(CampaignTransportType campaignTransportType) For the provided campaign transport type, what's this unit's transported units summaryGets the transport ship assignment for this unit, or null if this unit is not being transported.Like UnitType.getTypeDisplayableName but prepends "Omni" to omni unitsmegamek.common.icons.Camouflage
getUtilizedCamouflage
(Campaign campaign) getVehicleFuelCost
(megamek.common.Entity e) boolean
hasBadHipOrShoulder
(int loc) boolean
int
hashCode()
boolean
Determines if this unit has parts in need of repair.boolean
hasPilot()
boolean
Prototype TSM makes a unit harder to repair and maintain.boolean
Determines if this unit has parts that are salvageable.boolean
Gets a value indicating whether this unit is transporting units.boolean
Gets a value indicating whether this unit is assigned to transport.boolean
Does this unit have any assigned tactical transported units?boolean
hasTransportAssignment
(CampaignTransportType campaignTransportType) Does this unit have a transport assignment for this campaign transport type?boolean
hasTransportedUnits
(CampaignTransportType campaignTransportType) For the given transport type, is this unit transporting any other units?boolean
Gets a value indicating whether this unit is assigned to a transport ship.boolean
hasTSM()
void
incrementDaysSinceMaintenance
(Campaign campaign, boolean maintained, int astechs) void
For each CampaignTransportType, initialize the transport capacity.void
initializeParts
(boolean addParts) This will check a unit for certain parts and if they are missing, it will create a new version and update its condition.void
Initializes the transport capacity.void
Initializes the transport capacity.void
initializeTransportSpace
(CampaignTransportType campaignTransportType) Initializes the transport capacity.boolean
A convenience function to tell whether the unit can be acted upon e.g.boolean
isAvailable
(boolean ignoreRefit) A convenience function to tell whether the unit can be acted upon e.g.boolean
Checks if the associated entity is classified as battle armor.boolean
isBattleArmorSuitOperable
(int trooper) Checks to see if a particular BA suit on BA is currently operable This requires the suit to not be destroyed and to have not missing equipment partsboolean
Gets a value indicating whether we are transporting any ground units.boolean
Gets a value indicating whether we are transporting any smaller aero unitsboolean
isClan()
boolean
isCommander
(Person person) Checks whether a person is considered the commander of this unit.boolean
boolean
boolean
boolean
boolean
isExtinctIn
(int year) boolean
boolean
static boolean
isFunctional
(megamek.common.Entity en) boolean
boolean
isIntroducedBy
(int year) boolean
isLocationBreached
(int loc) boolean
isLocationDestroyed
(int loc) Is the given location on the entity destroyed?boolean
Not always opposite to isUnmaintained() - both are false for units that do not require maintenance.boolean
boolean
Gets a value indicating whether this unit is mothballed.boolean
Gets a value indicating whether the unit is being mothballed or activated.boolean
isNavigator
(Person person) boolean
boolean
boolean
static boolean
isRepairable
(megamek.common.Entity en) boolean
boolean
boolean
Determines if this unit can be serviced.boolean
isSystemMissing
(int system, int loc) Returns true if there is at least one missing critical slot for this system in the given locationboolean
boolean
boolean
Not always opposite to isMaintained() - both are false for units that do not require maintenance.boolean
boolean
A trailer with no engine or weapons doesn't end any crew.loadShipTransport
(TransporterType transporterType, Set<Unit> units) Bay loading utility used when assigning units to bay-equipped transport units For each passed-in unit, this will find the first available, transport bay and set both the target bay and the UUID of the transport ship.loadTacticalTransport
(TransporterType transporterType, Set<Unit> units) Transporter loading utility used when assigning units to transport units For each passed-in unit, this will assign the unit to the specified bay, or the type of Transporter if one isn't provided.void
reCalc()
void
void
void
removePart
(Part part) void
Removes all the parts from a unit.boolean
Removes a unit from our set of transported units.void
void
repairSystem
(int type, int equipmentNum) void
repairSystem
(int type, int equipmentNum, int loc) boolean
void
void
void
void
runDiagnostic
(boolean checkForDestruction) Run a diagnostic on this unitvoid
setASFCapacity
(double bays) Deprecated.this only sets for ship transport type.void
setBattleArmorCapacity
(double bays) Deprecated.this only sets for a ship transport type.void
void
setCurrentShipTransportCapacity
(TransporterType transporterType, double capacity) Set the transport capacity for the specified transporter type to a specific capacityvoid
setDaysToArrival
(int days) void
setDocks
(int docks) Deprecated.this only sets for a ship transport type.void
setEntity
(megamek.common.Entity en) void
setFluffName
(String fluffName) void
setForceId
(int id) void
setHeavyVehicleCapacity
(double bays) Deprecated.this only sets for a ship transport type.void
setHistory
(String s) void
void
setInfantryCapacity
(double tonnage) Deprecated.this only sets for ship transport type.void
void
setLightVehicleCapacity
(double bays) Deprecated.this only sets for a ship transport type.void
setMaintenanceMultiplier
(int value) void
setMekCapacity
(double bays) Deprecated.this only sets for ship transport type.void
setMothballed
(boolean b) Sets a value indicating whether this unit is mothballed.void
setMothballTime
(int t) Sets the time (in minutes) remaining to mothball or activate the unit.void
void
setNavigator
(Person person, boolean useTransfers) void
void
setProtoCapacity
(double bays) Deprecated.this only sets for ship transport type.void
void
void
setSalvage
(boolean b) void
setScenarioId
(int i) void
setSite
(int i) void
setSmallCraftCapacity
(double bays) Deprecated.this only sets for ship transport type.void
setSuperHeavyVehicleCapacity
(double bays) Deprecated.this only sets for a ship transport type.void
setTacticalTransportAssignment
(ITransportAssignment assignment) Sets the transport assignment for this unit.void
void
void
setTechOfficer
(Person person, boolean useTransfers) void
setTransportAssignment
(CampaignTransportType campaignTransportType, ITransportAssignment assignment) Set this unit's transport assignment to the provided assignment, if possiblevoid
setTransportShipAssignment
(TransportShipAssignment assignment) Sets the transport ship assignment for this unit.void
startActivating
(Person activationTech) Begins activating a unit which has been mothballed.void
startActivating
(Person activationTech, boolean isGM) Begins activating a unit which has been mothballed, optionally as a GM action.void
startMothballing
(Person mothballTech) Begins mothballing a unit.void
startMothballing
(Person mothballTech, boolean isGM) Begins mothballing a unit, optionally as a GM action.toString()
towTrailer
(Unit transportedUnit, megamek.common.Transporter transportedLocation, TransporterType transporterType) Trailer hitching utility used when assigning a trailer to a tractor.void
undeploy()
unloadFromTransport
(CampaignTransportType campaignTransportType) Unloads a unit from transport of the provided campaign transport typevoid
unloadFromTransportShip
(Unit unit) Bay unloading utility used when removing units from bay-equipped transport units and/or moving them to a new transportvoid
unloadTacticalTransport
(Unit transportedUnit) Bay unloading utility used when removing units from bay-equipped transport units and/or moving them to a new transportvoid
unloadTransport
(CampaignTransportType campaignTransportType) Bay unloading utility used when removing a bay-equipped Transport unit This removes all units assigned to the transport from itvoid
updateBayCapacity
(int unitType, double unitWeight, boolean addUnit, int bayNumber) Convenience method to call the right capacity update based on unit type When updating capacity, this method is concerned primarily with ensuring that space isn't released beyond the unit's maximum.boolean
boolean
void
writeToXML
(PrintWriter pw, int indent) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface megamek.common.ITechnology
calcEraAvailability, calcEraAvailability, calcYearAvailability, calcYearAvailability, findMinimumRulesLevel, findMinimumRulesLevel, getAdvancedRange, getAdvancedRange, getCodeFromIOAbbr, getCodeFromMMAbbr, getCommonDate, getEraAvailabilityName, getEraAvailabilityName, getExperimentalRange, getExperimentalRange, getExtinctionDate, getExtinctionRange, getExtinctionRange, getFullRatingName, getFullRatingName, getIntroductionDate, getProductionDate, getPrototypeDate, getReintroductionDate, getSimpleLevel, getSimpleLevel, getSimpleLevel, getStandardRange, getStandardRange, getTechLevel, getTechLevel, getTechRatingName, isAvailableIn, isAvailableIn, isAvailableIn, isExtinct, isExtinct, isExtinct, isIntroLevel, isLegal, isLegal, isUnofficial
-
Field Details
-
SITE_IMPROVISED
public static final int SITE_IMPROVISED- See Also:
-
SITE_FIELD_WORKSHOP
public static final int SITE_FIELD_WORKSHOP- See Also:
-
SITE_FACILITY_BASIC
public static final int SITE_FACILITY_BASIC- See Also:
-
SITE_FACILITY_MAINTENANCE
public static final int SITE_FACILITY_MAINTENANCE- See Also:
-
SITE_FACTORY_CONDITIONS
public static final int SITE_FACTORY_CONDITIONS- See Also:
-
SITE_UNKNOWN
public static final int SITE_UNKNOWN- See Also:
-
ETYPE_MOTHBALLED
public static final int ETYPE_MOTHBALLED- See Also:
-
TECH_WORK_DAY
public static final int TECH_WORK_DAY- See Also:
-
entity
protected megamek.common.Entity entity -
scenarioId
protected int scenarioId -
daysToArrival
protected int daysToArrival
-
-
Constructor Details
-
Unit
public Unit() -
Unit
-
-
Method Details
-
getDamageStateName
-
getCampaign
-
setCampaign
-
isAvailable
public boolean isAvailable()A convenience function to tell whether the unit can be acted upon e.g. assigned pilots, techs, repaired, etc.- Returns:
-
isAvailable
public boolean isAvailable(boolean ignoreRefit) A convenience function to tell whether the unit can be acted upon e.g. assigned pilots, techs, repaired, etc.- Returns:
-
getStatus
-
getCondition
-
getCrewState
-
getTypeDisplayableNameWithOmni
Like UnitType.getTypeDisplayableName but prepends "Omni" to omni units- Returns:
- String displayable name with possible "Omni"
-
reCalc
public void reCalc() -
initializeShipTransportSpace
public void initializeShipTransportSpace()Initializes the transport capacity. If the campaign transport capacity type doesn't exist yet, try to create it. If it does already exist, let's recalculate the transport capacity instead for all transporters that this Unit has -
initializeTacticalTransportSpace
public void initializeTacticalTransportSpace()Initializes the transport capacity. If the campaign transport capacity type doesn't exist yet, try to create it. If it does already exist, let's recalculate the transport capacity instead for all transporters that this Unit has -
initializeAllTransportSpace
public void initializeAllTransportSpace()For each CampaignTransportType, initialize the transport capacity. If the campaign transport capacity type doesn't exist yet, try to create it. If it does already exist, let's recalculate the transport capacity instead for all transporters that this Unit has -
clearAllTransportSpace
public void clearAllTransportSpace() -
initializeTransportSpace
Initializes the transport capacity. If the campaign transport capacity type doesn't exist yet, try to create it. If it does already exist, let's recalculate the transport capacity instead for all transporters that this Unit has- Parameters:
campaignTransportType
- transport type we want to prepare
-
getTransportedUnitsSummary
@Nullable public AbstractTransportedUnitsSummary getTransportedUnitsSummary(CampaignTransportType campaignTransportType) For the provided campaign transport type, what's this unit's transported units summary- Parameters:
campaignTransportType
- what kind of transport type are we checking- Returns:
- transported units summary of that type, or null
-
setEntity
public void setEntity(megamek.common.Entity en) -
getEntity
public megamek.common.Entity getEntity() -
getId
-
setId
-
hasTransportedUnits
For the given transport type, is this unit transporting any other units?- Parameters:
campaignTransportType
- Transport Type (Enum) we're checking- Returns:
- true if it has transported units
- See Also:
-
getTransportedUnits
For the given transport type, return the set of units it's transporting, or an empty set- Parameters:
campaignTransportType
- Transport Type (Enum) we're checking- Returns:
- Set of Units this transport is carrying, or an empty set
-
clearTransportedUnits
Clears the set of units being transported by this unit. -
hasTransportAssignment
Does this unit have a transport assignment for this campaign transport type?- Parameters:
campaignTransportType
- the transport type (enum) we're interested in- Returns:
- true if there is a transport assignment of that type, false if not
-
getTransportAssignment
@Nullable public ITransportAssignment getTransportAssignment(CampaignTransportType campaignTransportType) Returns the transport assignment for the given transport type, or null if none is provided- Parameters:
campaignTransportType
- the transport type (enum) we're interested in- Returns:
- corresponding transport assignment, or null if there isn't one
-
setTransportAssignment
public void setTransportAssignment(CampaignTransportType campaignTransportType, @Nullable ITransportAssignment assignment) Set this unit's transport assignment to the provided assignment, if possible- Parameters:
campaignTransportType
- type (enum) of transport typeassignment
- the assignment we're setting for this unit- See Also:
-
unloadFromTransport
Unloads a unit from transport of the provided campaign transport type- Parameters:
campaignTransportType
- type (enum) of transport type we want to unload from- Returns:
- transport the unit was assigned to
-
hasTransportShipAssignment
public boolean hasTransportShipAssignment()Gets a value indicating whether this unit is assigned to a transport ship. -
getTransportShipAssignment
Gets the transport ship assignment for this unit, or null if this unit is not being transported. -
setTransportShipAssignment
Sets the transport ship assignment for this unit.- Parameters:
assignment
- The transport ship assignment, or null if this unit is not being transported.
-
hasShipTransportedUnits
public boolean hasShipTransportedUnits()Gets a value indicating whether this unit is transporting units. -
getShipTransportedUnits
- Returns:
- the set of units being transported by this unit.
-
addShipTransportedUnit
Adds a unit to our set of transported units.- Parameters:
unit
- The unit being transported by this instance.
-
removeShipTransportedUnit
Removes a unit from our set of transported units.- Parameters:
unit
- The unit to remove from our set of transported units.- Returns:
- True if the unit was removed from our bays, otherwise false.
-
clearShipTransportedUnits
public void clearShipTransportedUnits()Clears the set of units being transported by this unit. -
isCarryingSmallerAero
public boolean isCarryingSmallerAero()Gets a value indicating whether we are transporting any smaller aero units -
isCarryingGround
public boolean isCarryingGround()Gets a value indicating whether we are transporting any ground units. -
getSite
public int getSite() -
setSite
public void setSite(int i) -
isSalvage
public boolean isSalvage() -
setSalvage
public void setSalvage(boolean b) -
getHistory
-
setHistory
-
isFunctional
public static boolean isFunctional(megamek.common.Entity en) -
isFunctional
public boolean isFunctional() -
isRepairable
public static boolean isRepairable(megamek.common.Entity en) -
isRepairable
public boolean isRepairable() -
isServiceable
public boolean isServiceable()Determines if this unit can be serviced.- Returns:
true
if the unit has parts that are salvageable or in need of repair.
-
isLocationDestroyed
public boolean isLocationDestroyed(int loc) Is the given location on the entity destroyed?- Parameters:
loc
- - anint
for the location- Returns:
true
if the location is destroyed
-
isLocationBreached
public boolean isLocationBreached(int loc) -
hasBadHipOrShoulder
public boolean hasBadHipOrShoulder(int loc) -
runDiagnostic
public void runDiagnostic(boolean checkForDestruction) Run a diagnostic on this unit -
getPartsNeedingService
Gets a list of every part on a unit which need service (either repair or salvage), including parts currently being worked on. -
getPartsNeedingService
Gets a list of parts on a unit which need service (either repair or salvage), optionally excluding parts already being worked on.- Parameters:
onlyNotBeingWorkedOn
- When true, excludes parts currently being repaired or salvaged.
-
getPartsNeedingFixing
-
hasPartsNeedingFixing
public boolean hasPartsNeedingFixing()Determines if this unit has parts in need of repair.- Returns:
true
if the unit has parts that are in need of repair.
-
getPartsNeedingFixing
-
getSalvageableParts
-
hasSalvageableParts
public boolean hasSalvageableParts()Determines if this unit has parts that are salvageable.- Returns:
true
if the unit has parts that are salvageable.
-
getSalvageableParts
-
getPartsNeeded
-
getValueOfAllMissingParts
-
removePart
-
hasPilot
public boolean hasPilot() -
getPilotDesc
-
getSiteMod
public megamek.common.TargetRoll getSiteMod() -
getSiteName
-
getSiteToolTipText
-
getCurrentSiteName
-
isDeployed
public boolean isDeployed() -
undeploy
public void undeploy() -
checkDeployment
Validates the deployment readiness of the unit.This method checks multiple conditions to determine whether the unit is deployable. If the unit is not deployable, a descriptive error message is returned indicating the reason for its ineligibility. If the unit passes all validations,
null
is returned, implying it is ready for deployment.Deployment checks performed:
- If the unit is not functional, it cannot be deployed.
- If the unit is unmanned and is not an unmanned trailer, it cannot be deployed.
- If the unit is in the process of being refitted, it cannot be deployed.
- If the unit is a tank and does not have the required crew size, it cannot be deployed.
- If the unit is a BattleArmor unit with empty suits, it cannot be deployed until these are filled or salvaged.
- Returns:
- A descriptive
String
error message if the unit cannot be deployed, ornull
if the unit is deployable.
-
hasTSM
public boolean hasTSM()- Returns:
- Have to make one here because the one in MegaMek only returns true if operable
-
isSystemMissing
public boolean isSystemMissing(int system, int loc) Returns true if there is at least one missing critical slot for this system in the given location -
getHitCriticals
public int getHitCriticals(int type, int index) Number of slots doomed, missing or destroyed in all locations- Parameters:
type
-index
-- Returns:
-
getHitCriticals
public int getHitCriticals(int type, int index, int loc) Number of slots doomed, missing or destroyed in a location -
damageSystem
public void damageSystem(int type, int equipmentNum, int hits) -
damageSystem
public int damageSystem(int type, int equipmentNum, int loc, int hits) -
destroySystem
public void destroySystem(int type, int equipmentNum) -
destroySystem
public void destroySystem(int type, int equipmentNum, int loc) -
destroySystem
public void destroySystem(int type, int equipmentNum, int loc, int hits) -
repairSystem
public void repairSystem(int type, int equipmentNum) -
repairSystem
public void repairSystem(int type, int equipmentNum, int loc) -
isDamaged
public boolean isDamaged() -
getSellValue
-
getCargoCapacity
public double getCargoCapacity()Calculates the total cargo capacity of the entity, considering the usable capacities of transport bays and mounted equipment designated for cargo. The calculation is performed only if the entity is fully crewed.The total cargo capacity is derived from the following:
- The usable capacities of transport bays (
CargoBay
,RefrigeratedCargoBay
, orInsulatedCargoBay
), adjusted for existing damage. - The tonnage of mounted equipment tagged with the
F_CARGO
flag, provided the equipment is operable and located in non-destroyed sections of the entity.
Special Conditions:
- The method returns
0.0
if the entity is not fully crewed. - Bays or mounted equipment damaged beyond usability are excluded from the total.
- Only equipment in valid (non-destroyed) sections of the entity are considered.
- Returns:
- The total cargo capacity of the entity if fully crewed; otherwise,
0.0
.
- The usable capacities of transport bays (
-
getRefrigeratedCargoCapacity
public double getRefrigeratedCargoCapacity() -
getLiquidCargoCapacity
public double getLiquidCargoCapacity() -
getLivestockCargoCapacity
public double getLivestockCargoCapacity() -
getInsulatedCargoCapacity
public double getInsulatedCargoCapacity() -
getTotalWeightOfUnitsAssignedToBeTransported
public double getTotalWeightOfUnitsAssignedToBeTransported(CampaignTransportType transportType, TransporterType transporterType) Calculates the total weight of all units assigned to be transported in this unit for a specific transport type and transporter type.This method:
- Finds all units currently assigned to be transported by this unit with the specified transport type.
- For each transported unit, checks if it is assigned to a transporter of the specified type.
- Adds the full weight of each matching transported unit to the total.
- Parameters:
transportType
- The transport type to match when retrieving transported units.transporterType
- The transporter type to filter assignments (only units assigned to this type are considered).- Returns:
- The sum weight of all units assigned to this unit via the given transport and transporter type.
- Since:
- 0.50.05
-
getCorrectBayCapacity
public double getCorrectBayCapacity(int unitType, double unitWeight) Convenience method to call the right capacity getter based on unit type and weight- Parameters:
unitType
- integer obtained from a unit's entity that denotes its type (mek, tank, etc.)unitWeight
- double Weight in tons of the unit's entity. Important for tanks and infantry
-
updateBayCapacity
public void updateBayCapacity(int unitType, double unitWeight, boolean addUnit, int bayNumber) Convenience method to call the right capacity update based on unit type When updating capacity, this method is concerned primarily with ensuring that space isn't released beyond the unit's maximum. Checks are made to keep from going below 0 before we ever get here.- Parameters:
unitType
- integer obtained from a unit's entity that denotes its type (mek, tank, etc.)unitWeight
- double Weight in tons of the unit's entity. Important for infantryaddUnit
- boolean value that determines whether to add or subtract 1 from bay capacitybayNumber
- integer representing the bay number that has been assigned to a cargo entity
-
getDocks
public int getDocks() -
getCurrentDocks
Deprecated.this only checks ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisGet only collars to which a DropShip has been assigned Capacity -
setDocks
Deprecated.this only sets for a ship transport type. Transport Capacities should not be manually updated with this, it should happen inside any loading flows. If you really need to replicate this, use setCurrentShipTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) - but you probably don't want to do thatUsed to assign a Drop-ship to a collar on a specific Jumpship in the TOE -
getLightVehicleCapacity
public double getLightVehicleCapacity() -
getCurrentLightVehicleCapacity
Deprecated.this only checks a ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisGet only bays to which a light tank has been assigned- Returns:
- capacity
- See Also:
-
setLightVehicleCapacity
Deprecated.this only sets for a ship transport type. Transport Capacities should not be manually updated with this, it should happen inside any loading flows. If you really need to replicate this use setCurrentShipTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) - but you probably don't want to do thatUsed to assign a tank to a bay on a specific transport ship in the TOE -
getHeavyVehicleCapacity
public double getHeavyVehicleCapacity() -
getCurrentHeavyVehicleCapacity
Deprecated.this only checks a ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisGet only bays to which a heavy tank has been assigned- Returns:
- capacity
- See Also:
-
setHeavyVehicleCapacity
Deprecated.this only sets for a ship transport type. Transport Capacities should not be manually updated with this, it should happen inside any loading flows. If you really need to replicate this use setCurrentShipTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) - but you probably don't want to do thatUsed to assign a tank to a bay on a specific transport ship in the TOE -
getSuperHeavyVehicleCapacity
public double getSuperHeavyVehicleCapacity() -
getCurrentSuperHeavyVehicleCapacity
Deprecated.this only checks a ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisGet only bays to which a super heavy tank has been assigned -
setSuperHeavyVehicleCapacity
Deprecated.this only sets for a ship transport type. Transport Capacities should not be manually updated with this, it should happen inside any loading flows. If you really need to replicate this use setCurrentShipTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) - but you probably don't want to do thatUsed to assign a tank to a bay on a specific transport ship in the TOE -
getBattleArmorCapacity
public double getBattleArmorCapacity() -
getCurrentBattleArmorCapacity
Deprecated.this only checks a ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisGet only bays to which a ba squad has been assigned- Returns:
- capacity
- See Also:
-
setBattleArmorCapacity
Deprecated.this only sets for a ship transport type. Transport Capacities should not be manually updated with this, it should happen inside any loading flows. If you really need to replicate this use setCurrentShipTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) - but you probably don't want to do thatUsed to assign a ba squad to a bay on a specific transport ship in the TOE -
getInfantryCapacity
public double getInfantryCapacity() -
getCurrentInfantryCapacity
Deprecated.this only checks a ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisReturn the unused tonnage of any conventional infantry bays- Returns:
- capacity
- See Also:
-
setInfantryCapacity
Deprecated.this only sets for ship transport type. Transport Capacities should not be manually updated with this, it should happen inside any loading flows. If you really need to replicate this use setCurrentShipTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) - but you probably don't want to do thatUsed to assign an infantry unit to a bay on a specific transport ship in the TOE Tonnage consumed depends on the platoon/squad weight -
getASFCapacity
public double getASFCapacity() -
getCurrentASFCapacity
Deprecated.this only checks ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisGet only bays to which a fighter has been assigned- Returns:
- capacity
- See Also:
-
setASFCapacity
Deprecated.this only sets for ship transport type. Transport Capacities should not be manually updated with this, it should happen inside any loading flows. If you really need to replicate this use setCurrentShipTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) - but you probably don't want to do thatUsed to assign a fighter to a bay on a specific transport ship in the TOE -
getSmallCraftCapacity
public double getSmallCraftCapacity() -
getCurrentSmallCraftCapacity
Deprecated.this only checks ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisGet only bays to which a small craft has been assigned- Returns:
- capacity
- See Also:
-
setSmallCraftCapacity
Deprecated.this only sets for ship transport type. Transport Capacities should not be manually updated with this, it should happen inside any loading flows. If you really need to replicate this use setCurrentShipTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) - but you probably don't want to do thatUsed to assign a small craft to a bay on a specific transport ship in the TOE -
getMekCapacity
public double getMekCapacity() -
getCurrentMekCapacity
Deprecated.this only checks ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisGet only bays to which a mek has been assigned- Returns:
- capacity
- See Also:
-
setMekCapacity
Deprecated.this only sets for ship transport type. Transport Capacities should not be manually updated with this, it should happen inside any loading flows. If you really need to replicate this use setCurrentShipTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) - but you probably don't want to do thatUsed to assign a mek or LAM to a bay on a specific transport ship in the TOE -
getProtoMekCapacity
public double getProtoMekCapacity() -
getCurrentProtoMekCapacity
Deprecated.this only checks ship transport type, use getCurrentTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) to replicate thisGet only bays to which a protomek has been assigned- Returns:
- capacity
- See Also:
-
setProtoCapacity
Deprecated.this only sets for ship transport type. Transport Capacities should not be manually updated with this, it should happen inside any loading flows. If you really need to replicate this use setCurrentShipTransportCapacity(CampaignTransportType.SHIP_TRANSPORT, appropriate bay class) - but you probably don't want to do thatUsed to assign a ProtoMek to a bay on a specific transport ship in the TOE -
loadShipTransport
Bay loading utility used when assigning units to bay-equipped transport units For each passed-in unit, this will find the first available, transport bay and set both the target bay and the UUID of the transport ship. Once in the MM lobby, this data will be used to actually load the unit into a bay on the transport.- Parameters:
transporterType
- type (Enum) of Transporter to transport the units inunits
- Vector of units that we wish to load into this transport
-
unloadFromTransportShip
Bay unloading utility used when removing units from bay-equipped transport units and/or moving them to a new transport- Parameters:
unit
- The unit that we wish to unload from this transport
-
getCurrentShipTransportCapacity
Returns the current capacity- Parameters:
transporterType
- class of Transporter- Returns:
- capacity
-
hasTacticalTransportAssignment
public boolean hasTacticalTransportAssignment()Gets a value indicating whether this unit is assigned to transport.- Returns:
- true if this unit has a tacticalTransportAssignment that isn't null
-
getTacticalTransportAssignment
Gets the tactical transport assignment for this unit, or null if this unit is not being transported.- Returns:
- transport assignment
-
setTacticalTransportAssignment
Sets the transport assignment for this unit.- Parameters:
assignment
- The transport ship assignment, or null if this unit is not being transported.
-
getCurrentTransportCapacity
public double getCurrentTransportCapacity(CampaignTransportType campaignTransportType, TransporterType transporterType) Returns the current capacity- Parameters:
campaignTransportType
- type (enum) being checkedtransporterType
- class of Transporter- Returns:
- remaining capacity
- See Also:
-
setCurrentShipTransportCapacity
Set the transport capacity for the specified transporter type to a specific capacity- Parameters:
transporterType
- type (Enum) of transporter we want to set the capacitycapacity
- how much this transporter should be able to transport
-
getTransportCapabilities
For the provided campaign transport type (enum), return the transporters this unit- Parameters:
campaignTransportType
- type (enum) of campaign transport- Returns:
- set of Transporter types (class)
-
hasTacticalTransportedUnits
public boolean hasTacticalTransportedUnits()Does this unit have any assigned tactical transported units?- Returns:
- true if the unit is assigned tactical transports
-
unloadTacticalTransport
Bay unloading utility used when removing units from bay-equipped transport units and/or moving them to a new transport- Parameters:
transportedUnit
- The unit that we wish to unload from this transport
-
loadTacticalTransport
Transporter loading utility used when assigning units to transport units For each passed-in unit, this will assign the unit to the specified bay, or the type of Transporter if one isn't provided. Once in the MM lobby, will be used to actually load the unit into a bay on the transport.- Parameters:
transporterType
- type (Enum) of bay or Transporterunits
- units being loaded- Returns:
- the old transports of the units, or an empty set if none
-
towTrailer
@Nullable public Unit towTrailer(Unit transportedUnit, @Nullable megamek.common.Transporter transportedLocation, TransporterType transporterType) Trailer hitching utility used when assigning a trailer to a tractor. It's a bit different from normal loading so it gets its own method. This should be called on the towing unit (or towing entity) - the unit that is specifically pulling the transportedUnit. Do not pass in the tractor that is pulling the entire "train" unless you want the transportedUnit specifically attached to the tractor.- Parameters:
transportedUnit
- trailer Unit that should be towedtransportedLocation
- specific hitch the trailer should be attached totransporterType
- type of transporter towing the trailer, should probably be a TANK_TRAILER_HITCH- Returns:
- original towing unit (Unit) that was pulling the transportedUnit
- See Also:
-
unloadTransport
Bay unloading utility used when removing a bay-equipped Transport unit This removes all units assigned to the transport from it -
getBuyCost
-
writeToXML
-
generateInstanceFromXML
-
getQuirksList
- Returns:
- a html-coded list that says what quirks are enabled for this unit
-
getMaintenanceCost
The weekly maintenance cycle combined with a user defined maintenance cycle length is confusing and difficult to manage so lets just make maintenance costs relative to the length of the maintenance cycle that the user defined- Returns:
-
getWeeklyMaintenanceCost
-
addPart
-
initializeParts
public void initializeParts(boolean addParts) This will check a unit for certain parts and if they are missing, it will create a new version and update its condition. checking for existing parts makes this a more complicated method, but it also ensures that you can call this at any time, and you won't overwrite existing parts -
getParts
-
findPart
Find a part on a unit.- Parameters:
predicate
- A predicate to apply to each part on the unit.- Returns:
- The first part which matched the predicate, otherwise null.
-
setParts
-
getPodSpace
-
refreshPodSpace
public void refreshPodSpace() -
getWorkingAmmoBins
-
getCamouflage
public megamek.common.icons.Camouflage getCamouflage() -
getUtilizedCamouflage
-
getImage
-
getImage
-
determineForegroundColor
-
determineBackgroundColor
-
getCommander
Returns the commander of the entity.The commander is determined based on the merged list of all crew members, prioritizing certain roles over others. The commander is initialized as the first person in the merged list and then updated by iterating over all crew members and comparing their rank with the current commander. If a crew member outranks the current commander or has the same rank, they are considered as the new commander.
- Returns:
- the commander of the entity, or null if the entity is null or if there are no crew members
-
hasCommander
public boolean hasCommander() -
resetPilotAndEntity
public void resetPilotAndEntity() -
resetEngineer
public void resetEngineer() -
getAeroCrewNeeds
public int getAeroCrewNeeds() -
getFullCrewSize
public int getFullCrewSize() -
getTotalDriverNeeds
public int getTotalDriverNeeds() -
getTotalCrewNeeds
public int getTotalCrewNeeds()Compute the number of generic space/vehicle crew (e.g. not driver, gunner, or navigator)- Returns:
- The number of generic crew required
-
canTakeMoreDrivers
public boolean canTakeMoreDrivers() -
canTakeMoreVesselCrew
public boolean canTakeMoreVesselCrew() -
canTakeTechOfficer
public boolean canTakeTechOfficer() -
canTakeTech
public boolean canTakeTech() -
determineUnitTechSkillType
-
canTakeMoreGunners
public boolean canTakeMoreGunners() -
getTotalGunnerNeeds
public int getTotalGunnerNeeds() -
usesSoloPilot
public boolean usesSoloPilot() -
usesSoldiers
public boolean usesSoldiers() -
addDriver
-
addDriver
-
addGunner
-
addGunner
-
addVesselCrew
-
addVesselCrew
-
isTechOfficer
-
setTechOfficer
-
setTechOfficer
-
setTech
-
removeTech
public void removeTech() -
addPilotOrSoldier
-
addPilotOrSoldier
-
addPilotOrSoldier
-
remove
- Parameters:
person
- the person to remove. If this is null we return immediately without parsing.log
- whether to log the removal
-
isUnmanned
public boolean isUnmanned() -
isUnmannedTrailer
public boolean isUnmannedTrailer()A trailer with no engine or weapons doesn't end any crew.- Returns:
- true if this Unit is an unmanned trailer, false if it isn't a trailer or has a crew
-
getForceId
public int getForceId() -
setForceId
public void setForceId(int id) -
getScenarioId
public int getScenarioId() -
setScenarioId
public void setScenarioId(int i) -
getCrew
-
clearCrew
public void clearCrew() -
getDrivers
-
getGunners
-
getVesselCrew
-
getTechOfficer
-
getTech
-
isMothballing
public boolean isMothballing()Gets a value indicating whether the unit is being mothballed or activated.- Returns:
- True if the unit is undergoing mothballing or activation, otherwise false.
-
getMothballTime
public int getMothballTime()Gets the time (in minutes) remaining to mothball or activate the unit.- Returns:
- The time (in minutes) remaining to mothball or activate the unit.
-
setMothballTime
public void setMothballTime(int t) Sets the time (in minutes) remaining to mothball or activate the unit.- Parameters:
t
- The time (in minutes) remaining to mothball or activate the unit.
-
isMothballed
public boolean isMothballed()Gets a value indicating whether this unit is mothballed.- Returns:
- True if the unit is mothballed, otherwise false.
-
setMothballed
public void setMothballed(boolean b) Sets a value indicating whether this unit is mothballed.If the unit is being mothballed, all of its personnel will be removed. If the unit is being activated, all of its personnel will be restored (if applicable) and its maintenance cycle will be reset.
- Parameters:
b
- True if the unit is now mothballed, or false if the unit is now activated.
-
startMothballing
Begins mothballing a unit.- Parameters:
mothballTech
- The tech performing the mothball.
-
startMothballing
Begins mothballing a unit, optionally as a GM action.- Parameters:
mothballTech
- The tech performing the mothball.isGM
- A value indicating if the mothball action should be performed immediately by the GM.
-
engineerResponsible
Returns the engineer responsible for the mothballing or activation of this unit.- Returns:
- Person the previous engineer that worked on this vessel, or an empty object.
-
completeMothball
public void completeMothball()Completes the mothballing of a unit. -
startActivating
Begins activating a unit which has been mothballed.- Parameters:
activationTech
- The tech performing the activation.
-
startActivating
Begins activating a unit which has been mothballed, optionally as a GM action.- Parameters:
activationTech
- The tech performing the activation.isGM
- A value indicating if the activation action should be performed immediately by the GM.
-
completeActivation
public void completeActivation()Completes the activation of a unit. -
cancelMothballOrActivation
public void cancelMothballOrActivation()Cancels a pending mothball or activation work order. -
getAllInfantry
Returns all soldiers or battle armor assigned to the unit. As members of this category appear in both the drivers and gunners list, we only check drivers -
getActiveCrew
-
isFullyCrewed
public boolean isFullyCrewed()- Returns:
- true if the unit is fully crewed, false otherwise.
-
hasPrototypeTSM
public boolean hasPrototypeTSM()Prototype TSM makes a unit harder to repair and maintain.- Returns:
- Whether the unit has prototype TSM
-
getMarineCount
public int getMarineCount()Returns a personnel count for each marine platoon/squad assigned to this unit- Returns:
- The number of marines aboard
-
isDriver
-
isGunner
-
isCommander
Checks whether a person is considered the commander of this unit.- Parameters:
person
- APerson
in the campaign. The person need not be assigned to the unit as crew, in which case the return value will be false.- Returns:
- Whether the person is considered the unit commander. If
person
is null or the unit has no crew, this method will return false - See Also:
-
setRefit
-
getRefit
-
isRefitting
public boolean isRefitting() -
getName
-
getHyperlinkedName
-
equals
-
hashCode
public int hashCode() -
getEngineer
-
getPartForEquipmentNum
-
getAvailability
public megamek.common.ITechnology.AvailabilityValue getAvailability(int era) -
setDaysToArrival
public void setDaysToArrival(int days) -
getDaysToArrival
public int getDaysToArrival() -
checkArrival
public boolean checkArrival() -
isPresent
public boolean isPresent() -
getMaintenanceTime
public int getMaintenanceTime()Calculates the maintenance time required for the associated entity, factoring in its type, weight class, and the maintenance multiplier.The method determines the time in minutes needed for maintenance based on the specific class of the entity (such as Mek, ProtoMek, BattleArmor, Tank, SmallCraft, etc.) and applies a multiplier for any necessary adjustments. Entity types not specifically handled by this method are considered self-maintaining and return 0.
- Returns:
- the total maintenance time in minutes required per day, or 0 if no maintenance is needed
-
incrementDaysSinceMaintenance
-
resetDaysSinceMaintenance
public void resetDaysSinceMaintenance() -
getDaysSinceMaintenance
public double getDaysSinceMaintenance() -
getMaintainedPct
Deprecated, for removal: This API element is subject to removal in a future version.no indicated uses.there are no official rules about partial maintenance lets say less than half is +2 more than half is +1 penalty also we will take the average rounded down of the number of astechs to figure out shorthanded penalty -
getAstechsMaintained
Deprecated, for removal: This API element is subject to removal in a future version.no indicated uses. -
getMaintenanceMultiplier
public int getMaintenanceMultiplier() -
setMaintenanceMultiplier
public void setMaintenanceMultiplier(int value) -
getQuality
-
setQuality
-
getQualityName
-
requiresMaintenance
public boolean requiresMaintenance() -
isMaintained
public boolean isMaintained()Not always opposite to isUnmaintained() - both are false for units that do not require maintenance.- Returns:
- true if unit requires maintenance and has a tech assigned, false otherwise.
- See Also:
-
isUnmaintained
public boolean isUnmaintained()Not always opposite to isMaintained() - both are false for units that do not require maintenance.- Returns:
- true if unit requires maintenance and does not have a tech assigned, false otherwise.
- See Also:
-
isSelfCrewed
public boolean isSelfCrewed() -
isUnderRepair
public boolean isUnderRepair() -
getLastMaintenanceReport
-
setLastMaintenanceReport
-
getDamageState
public int getDamageState() -
getDamageState
public static int getDamageState(megamek.common.Entity en) -
removeParts
public void removeParts()Removes all the parts from a unit.NOTE: this puts the unit in an inconsistent state, and the unit should not be used until its parts have been re-assigned.
-
getFluffName
- Returns:
- the name
-
setFluffName
- Parameters:
fluffName
- the name to set
-
isBattleArmorSuitOperable
public boolean isBattleArmorSuitOperable(int trooper) Checks to see if a particular BA suit on BA is currently operable This requires the suit to not be destroyed and to have not missing equipment parts -
isConventionalInfantry
public boolean isConventionalInfantry()- Returns:
- true if the unit is conventional infantry, otherwise false
-
isBattleArmor
public boolean isBattleArmor()Checks if the associated entity is classified as battle armor.This method determines whether the entity linked to this object is considered battle armor. It first verifies that the entity is not null, and then checks if the entity meets the criteria for battle armor.
- Returns:
true
if the entity is classified as battle armor and is not null, otherwisefalse
.
-
isIntroducedBy
public boolean isIntroducedBy(int year) -
isExtinctIn
public boolean isExtinctIn(int year) -
toString
-
displayMonthlyCost
-
getSparePartsCost
-
getAmmoCost
-
getFuelCost
Calculates the monthly fuel cost for this unit, applying any available hydrogen production credits.Different entity types have different fuel requirements:
- Large Craft and Small Craft: Calculated based on tons burned per day
- Conventional Fighters: Use fighter-specific fuel cost calculation
- Aerospace Fighters: Based on fuel tonnage multiplied by a factor of 4
- Vehicles and Meks: Use vehicle-specific fuel cost calculation
- Infantry: Use infantry-specific fuel cost calculation
Hydrogen produced by fusion engines is credited against the unit's hydrogen usage, reducing the overall fuel cost.
- Parameters:
hydrogenProduction
- The amount of hydrogen produced by fusion engines, which offsets hydrogen usage costs- Returns:
- The calculated fuel cost as a Money object, always non-negative
-
getTonsBurnMonthCost
On average, how much does this spaceshift spend burning fuel per month? Based on CO p. 24- Parameters:
entity
-- Returns:
- fuel cost for operating this Entity for a month
-
getFighterFuelCost
-
getVehicleFuelCost
-
getInfantryFuelCost
-
isClan
public boolean isClan()- Specified by:
isClan
in interfacemegamek.common.ITechnology
-
isMixedTech
public boolean isMixedTech()- Specified by:
isMixedTech
in interfacemegamek.common.ITechnology
-
getTechBase
public megamek.common.ITechnology.TechBase getTechBase()- Specified by:
getTechBase
in interfacemegamek.common.ITechnology
-
getIntroductionDate
public int getIntroductionDate()- Specified by:
getIntroductionDate
in interfacemegamek.common.ITechnology
-
getPrototypeDate
public int getPrototypeDate()- Specified by:
getPrototypeDate
in interfacemegamek.common.ITechnology
-
getProductionDate
public int getProductionDate()- Specified by:
getProductionDate
in interfacemegamek.common.ITechnology
-
getCommonDate
public int getCommonDate()- Specified by:
getCommonDate
in interfacemegamek.common.ITechnology
-
getExtinctionDate
public int getExtinctionDate()- Specified by:
getExtinctionDate
in interfacemegamek.common.ITechnology
-
getReintroductionDate
public int getReintroductionDate()- Specified by:
getReintroductionDate
in interfacemegamek.common.ITechnology
-
getTechRating
public megamek.common.ITechnology.TechRating getTechRating()- Specified by:
getTechRating
in interfacemegamek.common.ITechnology
-
getBaseAvailability
public megamek.common.ITechnology.AvailabilityValue getBaseAvailability(megamek.common.ITechnology.Era era) - Specified by:
getBaseAvailability
in interfacemegamek.common.ITechnology
-
getIntroductionDate
public int getIntroductionDate(boolean clan, megamek.common.ITechnology.Faction faction) - Specified by:
getIntroductionDate
in interfacemegamek.common.ITechnology
-
getPrototypeDate
public int getPrototypeDate(boolean clan, megamek.common.ITechnology.Faction faction) - Specified by:
getPrototypeDate
in interfacemegamek.common.ITechnology
-
getProductionDate
public int getProductionDate(boolean clan, megamek.common.ITechnology.Faction faction) - Specified by:
getProductionDate
in interfacemegamek.common.ITechnology
-
getExtinctionDate
public int getExtinctionDate(boolean clan, megamek.common.ITechnology.Faction faction) - Specified by:
getExtinctionDate
in interfacemegamek.common.ITechnology
-
getReintroductionDate
public int getReintroductionDate(boolean clan, megamek.common.ITechnology.Faction faction) - Specified by:
getReintroductionDate
in interfacemegamek.common.ITechnology
-
getSimpleTechLevel
public megamek.common.SimpleTechLevel getSimpleTechLevel() -
getSimpleTechLevel
public megamek.common.SimpleTechLevel getSimpleTechLevel(int year) -
getSimpleTechLevel
public megamek.common.SimpleTechLevel getSimpleTechLevel(int year, boolean clan, megamek.common.ITechnology.Faction faction) -
getStaticTechLevel
public megamek.common.SimpleTechLevel getStaticTechLevel()- Specified by:
getStaticTechLevel
in interfacemegamek.common.ITechnology
-
calcYearAvailability
public megamek.common.ITechnology.AvailabilityValue calcYearAvailability(int year, boolean clan, megamek.common.ITechnology.Faction faction) - Specified by:
calcYearAvailability
in interfacemegamek.common.ITechnology
-
fixReferences
-
getRandomUnitQuality
Generates a random unit quality based on a 2d6 roll and a modifier.- Parameters:
modifier
- the modifier to be applied to the 2d6 roll- Returns:
- an integer representing the generated unit quality
- Throws:
IllegalStateException
- if an unexpected value is encountered during the switch statement
-