Package megamek.common
Class Terrain
java.lang.Object
megamek.common.Terrain
- All Implemented Interfaces:
Serializable
Represents a single type of terrain or condition in a hex. The type of a
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 int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyPilotingModifier
(EntityMovementMode moveMode, PilotingRollData roll, boolean enteringRubble) boolean
Terrains are equal if their types and levels are equal.boolean
void
flipExits
(boolean horiz, boolean vert) Flips the exits around the vertical axis (North-for-South) and/or the horizontal axis (East-for-West).int
getBogDownModifier
(EntityMovementMode moveMode, boolean largeVee) int
getExits()
int
getLevel()
int
getTerrainElevation
(boolean inAtmosphere) int
int
getType()
void
getUnstuckModifier
(int elev, PilotingRollData rollTarget) boolean
int
hashCode()
int
The fire ignition modifier for this terrainboolean
Returns true when this terrain is valid, i.e.static int
int
void
setExit
(int direction, boolean connection) Sets the exit in specified directionvoid
setExits
(int exits) void
setTerrainFactor
(int tf) toString()
-
Field Details
-
LEVEL_NONE
public static final int LEVEL_NONE- See Also:
-
WILDCARD
public static final int WILDCARD- See Also:
-
ATLEAST
public static final int ATLEAST- 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
- aboolean
value that, iftrue
, indicates that the exits are being flipped North-for-South.vert
- aboolean
value 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 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
-