Package megamek.common
Class LosEffects
java.lang.Object
megamek.common.LosEffects
Keeps track of the cumulative effects of intervening terrain on LOS
- Since:
- October 14, 2002, 11:19 PM
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(LosEffects other) static LosEffects.AttackInfo
buildAttackInfo
(Coords c1, Coords c2, int h1, int h2, int h1Floor, int h2Floor) Build line of sight effects between coordinates c1 and c2 at height h1 and h2 respectively.static LosEffects
calculateLos
(Game game, int attackerId, Targetable target) Deprecated.static LosEffects
calculateLos
(Game game, LosEffects.AttackInfo ai) static LosEffects
calculateLOS
(Game game, Entity attacker, Targetable target) Returns a LosEffects object representing the LOS effects of intervening terrain between the attacker and target.static LosEffects
calculateLOS
(Game game, Entity attacker, Targetable target, boolean spotting) Returns a LosEffects object representing the LOS effects of intervening terrain between the attacker and target.static LosEffects
calculateLOS
(Game game, Entity attacker, Targetable target, Coords attackerPosition, Coords targetPosition, boolean spotting) static LosEffects
calculateLowAtmoLOS
(Game game, Entity attacker, Targetable target, Coords attackerPosition, Coords targetPosition) boolean
canSee()
LOS check from ae to te.static int
dividedLeftBetter
(ArrayList<Coords> in, Game game, LosEffects.AttackInfo ai, boolean targetInBuilding, LosEffects los) Finds out if the left or right side of the divided LOS is better for the targetint
static String
getCoverName
(int cover, boolean switchSides) Returns the text name of a particular type of cover, given its id.int
int
int
int
int
int
int
int
int
int
int
int
int
Getter for property thruBldg.int
static boolean
hasFireBetween
(Coords start, Coords end, Game game) boolean
boolean
Getter for property attackerCover.boolean
boolean
boolean
boolean
Getter for property targetCover.losModifiers
(Game game) Returns ToHitData indicating the modifiers to fire for the specified LOS effects data.losModifiers
(Game game, boolean underWaterWeapon) losModifiers
(Game game, int eistatus, boolean underwaterWeapon) static LosEffects.AttackInfo
prepLosAttackInfo
(Game game, Entity ae, Entity te, Coords c1, Coords c2, boolean mekInFirst, boolean mekInSecond) void
setArcedAttack
(boolean isArced) Sets this LosEffects to the given isArced value.void
setAttackerCover
(int attackerCover) Setter for property attackerCover.void
setCoverBuildingPrimary
(Building coverBuilding) void
setCoverBuildingSecondary
(Building coverBuildingSecondary) void
setCoverDropshipPrimary
(Entity coverDropship) void
setCoverDropshipSecondary
(Entity coverDropshipSecondary) void
setCoverLocPrimary
(Coords coverLoc) void
setCoverLocSecondary
(Coords coverLocSecondary) void
setDamagableCoverTypePrimary
(int damagableCover) void
setDamagableCoverTypeSecondary
(int damagableCoverTypeSecondary) void
setMinimumWaterDepth
(int inVal) void
setTargetCover
(int targetCover) Setter for property targetCover.void
setThruBldg
(Building thruBldg) Setter for property thruBldg.boolean
-
Field Details
-
COVER_NONE
public static final int COVER_NONE- See Also:
-
COVER_LOWLEFT
public static final int COVER_LOWLEFT- See Also:
-
COVER_LOWRIGHT
public static final int COVER_LOWRIGHT- See Also:
-
COVER_LEFT
public static final int COVER_LEFT- See Also:
-
COVER_RIGHT
public static final int COVER_RIGHT- See Also:
-
COVER_HORIZONTAL
public static final int COVER_HORIZONTAL- See Also:
-
COVER_UPPER
public static final int COVER_UPPER- See Also:
-
COVER_FULL
public static final int COVER_FULL- See Also:
-
COVER_75LEFT
public static final int COVER_75LEFT- See Also:
-
COVER_75RIGHT
public static final int COVER_75RIGHT- See Also:
-
DAMAGABLE_COVER_NONE
public static final int DAMAGABLE_COVER_NONE- See Also:
-
DAMAGABLE_COVER_DROPSHIP
public static final int DAMAGABLE_COVER_DROPSHIP- See Also:
-
DAMAGABLE_COVER_BUILDING
public static final int DAMAGABLE_COVER_BUILDING- See Also:
-
-
Constructor Details
-
LosEffects
public LosEffects()
-
-
Method Details
-
getTargetPosition
-
getMinimumWaterDepth
public int getMinimumWaterDepth() -
setMinimumWaterDepth
public void setMinimumWaterDepth(int inVal) -
add
-
getPlantedFields
public int getPlantedFields() -
getHeavyIndustrial
public int getHeavyIndustrial() -
getLightWoods
public int getLightWoods() -
getHeavyWoods
public int getHeavyWoods() -
getUltraWoods
public int getUltraWoods() -
thruWoods
public boolean thruWoods() -
getLightSmoke
public int getLightSmoke() -
getHeavySmoke
public int getHeavySmoke() -
getScreen
public int getScreen() -
getSoftBuildings
public int getSoftBuildings() -
getHardBuildings
public int getHardBuildings() -
isBlocked
public boolean isBlocked() -
isBlockedByHill
public boolean isBlockedByHill() -
isBlockedByWater
public boolean isBlockedByWater() -
isTargetCover
public boolean isTargetCover()Getter for property targetCover.- Returns:
- Value of property targetCover.
-
getTargetCover
public int getTargetCover() -
setTargetCover
public void setTargetCover(int targetCover) Setter for property targetCover.- Parameters:
targetCover
- New value of property targetCover.
-
isAttackerCover
public boolean isAttackerCover()Getter for property attackerCover.- Returns:
- Value of property attackerCover.
-
getAttackerCover
public int getAttackerCover() -
setAttackerCover
public void setAttackerCover(int attackerCover) Setter for property attackerCover.- Parameters:
attackerCover
- New value of property attackerCover.
-
getThruBldg
Getter for property thruBldg.- Returns:
- Value of property thruBldg.
-
setThruBldg
Setter for property thruBldg.- Parameters:
thruBldg
- New value of property thruBldg.
-
canSee
public boolean canSee()LOS check from ae to te. -
prepLosAttackInfo
-
calculateLos
@Deprecated(since="0.50.04") public static LosEffects calculateLos(Game game, int attackerId, @Nullable Targetable target) Deprecated.since 0.50.04 - UsecalculateLOS(Game, Entity, Targetable)
insteadReturns a LosEffects object representing the LOS effects of intervening terrain between the attacker and target. Checks to see if the attacker and target are at an angle where the LOS line will pass between two hexes.- Parameters:
game
-attackerId
-target
-- Returns:
-
calculateLOS
public static LosEffects calculateLOS(Game game, @Nullable Entity attacker, @Nullable Targetable target) Returns a LosEffects object representing the LOS effects of intervening terrain between the attacker and target. Checks to see if the attacker and target are at an angle where the LOS line will pass between two hexes.- Parameters:
game
-attacker
-target
-- Returns:
-
calculateLOS
public static LosEffects calculateLOS(Game game, @Nullable Entity attacker, @Nullable Targetable target, boolean spotting) Returns a LosEffects object representing the LOS effects of intervening terrain between the attacker and target. Checks to see if the attacker and target are at an angle where the LOS line will pass between two hexes. If so, calls losDivided, otherwise calls losStraight.- Parameters:
game
- The currentGame
attacker
- the attacker, which may be null. If it is, the view is blocked.target
- the target, which may be null. If it is, the view is blocked.spotting
- if the person is spotting- Returns:
- the found LOS Effects
-
calculateLOS
public static LosEffects calculateLOS(Game game, @Nullable Entity attacker, @Nullable Targetable target, @Nullable Coords attackerPosition, @Nullable Coords targetPosition, boolean spotting) -
calculateLowAtmoLOS
public static LosEffects calculateLowAtmoLOS(Game game, @Nullable Entity attacker, @Nullable Targetable target, @Nullable Coords attackerPosition, @Nullable Coords targetPosition) -
calculateLos
-
losModifiers
Returns ToHitData indicating the modifiers to fire for the specified LOS effects data. -
losModifiers
-
losModifiers
-
hasFireBetween
-
setArcedAttack
public void setArcedAttack(boolean isArced) Sets this LosEffects to the given isArced value. When this is true, the line of sight is treated as for an indirect shot without spotter or with semi-guided ammo on a TAGged target, i.e. one that gets no terrain modifiers.- Parameters:
isArced
- True for a shot that shouldn't get any terrain modifiers
-
buildAttackInfo
public static LosEffects.AttackInfo buildAttackInfo(Coords c1, Coords c2, int h1, int h2, int h1Floor, int h2Floor) Build line of sight effects between coordinates c1 and c2 at height h1 and h2 respectively.- Parameters:
c1
- the source coordinates.c2
- the target coordinates.h1
- the height in the source tile that is being shot from.h2
- the height of the target tile to shoot for.- Returns:
- an attackInfo object that describes the applicable modifiers.
-
dividedLeftBetter
public static int dividedLeftBetter(ArrayList<Coords> in, Game game, LosEffects.AttackInfo ai, boolean targetInBuilding, LosEffects los) Finds out if the left or right side of the divided LOS is better for the target- Parameters:
in
-game
- The currentGame
ai
-targetInBuilding
-los
-- Returns:
- 0 if right is better, 1 if left is better, 2 if both are equal
-
getCoverName
Returns the text name of a particular type of cover, given its id. TacOps partial cover is assigned from the perspective of the attacker, so it's possible that the sides should be switched to make sense from the perspective of the target.- Parameters:
cover
- The int id that represents the cover type.switchSides
- A boolean that determines if left/right side should be switched. This is useful since cover is given from the perspective of the attacker, and the sides need to be switched for the target.- Returns:
-
getCoverBuildingPrimary
-
setCoverBuildingPrimary
-
getCoverDropshipPrimary
-
setCoverDropshipPrimary
-
getDamagableCoverTypePrimary
public int getDamagableCoverTypePrimary() -
setDamagableCoverTypePrimary
public void setDamagableCoverTypePrimary(int damagableCover) -
getCoverLocPrimary
-
setCoverLocPrimary
-
getCoverBuildingSecondary
-
setCoverBuildingSecondary
-
getCoverDropshipSecondary
-
setCoverDropshipSecondary
-
getDamagableCoverTypeSecondary
public int getDamagableCoverTypeSecondary() -
setDamagableCoverTypeSecondary
public void setDamagableCoverTypeSecondary(int damagableCoverTypeSecondary) -
getCoverLocSecondary
-
setCoverLocSecondary
-
infantryProtected
public boolean infantryProtected()
-
calculateLOS(Game, Entity, Targetable)
instead