Package megamek.common.units
Interface Fortifiable
- All Known Implementing Classes:
BipedMek,GunEmplacement,LandAirMek,LargeSupportTank,Mek,MekWithArms,QuadMek,QuadVee,SuperHeavyTank,SupportTank,SupportVTOL,Tank,TripodMek,VTOL
public interface Fortifiable
Shared vehicle-style fieldworks behaviour for units that build a fortified hex over several turns with a bulldozer,
backhoe or equivalent (Vehicles and Fieldworks, TO:AUE p.153, Corrected Sixth Printing). A unit progresses through
DUG_IN_FORTIFYING_* stages, one per turn, and the hex is fortified once it reaches the final stage; damage
taken during a turn holds the progress rather than advancing it.
An implementor supplies the small amount of per-unit state - the dug-in stage counter, the FortifyState
damage tracker and its current health signature - and inherits the stage logic as default methods. Both Tank
and Mek implement this so the machine lives in one place rather than being duplicated. Infantry is
intentionally not a Fortifiable: it interleaves foxhole dig-in stages with fortifying and so uses a different
stage encoding.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intFirst turn of fieldwork.static final intFinal turn of fieldwork; the hex is fortified at the end of this turn.static final intNot building a fortification.static final MMLogger -
Method Summary
Modifier and TypeMethodDescriptiondefault voidAdvances one round of fieldwork, called fromnewRound: damage taken during the turn holds the progress counter for a turn (TO:AUE p.153, Corrected Sixth Printing); otherwise the stage advances and rolls back toDUG_IN_NONEonce it passes the final stage (completion is recognized separately during END-phase resolution).default voidBegins the multi-turn fieldwork that raises a fortified hex (TO:AUE p.153, Corrected Sixth Printing).default voidStops any in-progress fieldwork and clears the damage baseline.intintgetDugIn()default intdefault intdefault booleandefault booleandefault booleanvoidsetDugIn(int stage)
-
Field Details
-
FORTIFY_LOGGER
-
DUG_IN_NONE
static final int DUG_IN_NONENot building a fortification.- See Also:
-
DUG_IN_FORTIFYING_FIRST
static final int DUG_IN_FORTIFYING_FIRSTFirst turn of fieldwork.- See Also:
-
DUG_IN_FORTIFYING_LAST
static final int DUG_IN_FORTIFYING_LASTFinal turn of fieldwork; the hex is fortified at the end of this turn.- See Also:
-
-
Method Details
-
getDugIn
int getDugIn()- Returns:
- the current dug-in stage (
DUG_IN_NONEor one of theDUG_IN_FORTIFYING_*stages).
-
setDugIn
void setDugIn(int stage) - Parameters:
stage- the dug-in stage to set
-
getFortifyState
FortifyState getFortifyState()- Returns:
- the per-unit fortification damage tracker.
-
currentFortifyHealthSignature
int currentFortifyHealthSignature()- Returns:
- the health signature used to detect damage between fortifying turns: total armor plus internal structure. Any loss between turns lowers this and marks the turn as interrupted.
-
getShortName
String getShortName()- Returns:
- the unit's short name, for diagnostic logging.
-
beginFortify
default void beginFortify()Begins the multi-turn fieldwork that raises a fortified hex (TO:AUE p.153, Corrected Sixth Printing). Seeds the damage baseline used to detect an interrupting attack that extends the effort. -
isFortifying
default boolean isFortifying()- Returns:
trueif this unit is partway through building a fortified hex.
-
getFortifyStage
default int getFortifyStage()- Returns:
- the current fortification stage (1..
getFortifyTotalStages()), or 0 when not fortifying.
-
getFortifyTotalStages
default int getFortifyTotalStages()- Returns:
- the number of turns of work a fortified hex takes to complete.
-
isFortifyExtendedThisRound
default boolean isFortifyExtendedThisRound()- Returns:
trueif this unit's fortification effort was set back by damage this round. TO:AUE p.153, Corrected Sixth Printing.
-
isFortifyOnFinalStage
default boolean isFortifyOnFinalStage()- Returns:
trueif this unit is on the final turn of fieldwork (the hex is fortified at end of turn).
-
cancelFortify
default void cancelFortify()Stops any in-progress fieldwork and clears the damage baseline. -
advanceFortifyRound
default void advanceFortifyRound()Advances one round of fieldwork, called fromnewRound: damage taken during the turn holds the progress counter for a turn (TO:AUE p.153, Corrected Sixth Printing); otherwise the stage advances and rolls back toDUG_IN_NONEonce it passes the final stage (completion is recognized separately during END-phase resolution).
-