Package megamek.common.units
Class Terrain
java.lang.Object
megamek.common.units.Terrain
- All Implemented Interfaces:
Serializable
Represents a single type of terrain or condition in a hex. The type of terrain is immutable, once created, but the
level and exits are changeable. Each type of terrain should only be represented once in a hex.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intA terrain level value for use when the terrain isn't present.static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyPilotingModifier(EntityMovementMode moveMode, PilotingRollData roll, boolean enteringRubble) booleanTerrains are equal if their types and levels are equal.booleanvoidflipExits(boolean horiz, boolean vert) Flips the exits around the vertical axis (North-for-South) and/or the horizontal axis (East-for-West).intgetBogDownModifier(EntityMovementMode moveMode, boolean largeVee) intgetExits()intgetLevel()intgetTerrainElevation(boolean inAtmosphere) intintgetType()voidgetUnstuckModifier(int elev, PilotingRollData rollTarget) booleaninthashCode()intThe fire ignition modifier for this terrainbooleanReturns true when this terrain is valid, i.e.static intintvoidsetExit(int direction, boolean connection) Sets the exit in specified directionvoidsetExits(int exits) voidsetTerrainFactor(int tf) toString()
-
Field Details
-
LEVEL_NONE
public static final int LEVEL_NONEA terrain level value for use when the terrain isn't present. Must remain negative as many checks rely on this.- See Also:
-
WILDCARD
public static final int WILDCARD- See Also:
-
AT_LEAST
public static final int AT_LEAST- See Also:
-
-
Constructor Details
-
Terrain
public Terrain(int type, int level) -
Terrain
public Terrain(int type, int level, boolean exitsSpecified, int exits) -
Terrain
-
Terrain
Parses a string containing terrain info into the actual terrain
-
-
Method Details
-
levelFor
-
getType
public int getType() -
getLevel
public int getLevel() -
getTerrainFactor
public int getTerrainFactor() -
setTerrainFactor
public void setTerrainFactor(int tf) -
getTerrainElevation
public int getTerrainElevation(boolean inAtmosphere) -
getExits
public int getExits() -
hasExitsSpecified
public boolean hasExitsSpecified() -
setExits
public void setExits(int exits) -
setExit
public void setExit(int direction, boolean connection) Sets the exit in specified direction- Parameters:
direction- the direction to add/remove the exitconnection- true to add, false to remove
-
flipExits
public void flipExits(boolean horiz, boolean vert) Flips the exits around the vertical axis (North-for-South) and/or the horizontal axis (East-for-West).- Parameters:
horiz- abooleanvalue that, iftrue, indicates that the exits are being flipped North-for-South.vert- abooleanvalue that, iftrue, indicates that the exits are being flipped East-for-West.
-
exitsTo
- Returns:
- true if the terrain in this hex exits to the terrain in the other hex.
-
hashCode
public int hashCode() -
equals
Terrains are equal if their types and levels are equal. Does not pay attention to exits. -
toString
-
applyPilotingModifier
public void applyPilotingModifier(EntityMovementMode moveMode, PilotingRollData roll, boolean enteringRubble) - Parameters:
moveMode- the movement mode of the pilotroll- the piloting rollenteringRubble- if the entered terrain contains rubble
-
movementCost
- Returns:
- The additional movement cost for this terrain
-
ignitionModifier
public int ignitionModifier()The fire ignition modifier for this terrain -
getBogDownModifier
-
getUnstuckModifier
-
isValid
Returns true when this terrain is valid, i.e. if its level is an allowed value for its type. Exits have no limitations and are not checked. If an error is found, a line detailing the error is added to the given errors list if it is not null.- Parameters:
errors- A list of errors to append new errors to if it is not null- Returns:
- True when this terrain is valid, false otherwise
-