megamek.common
Class LosEffects

java.lang.Object
  extended by megamek.common.LosEffects

public class LosEffects
extends java.lang.Object

Keeps track of the cumulative effects of intervening terrain on LOS

Author:
Ben

Nested Class Summary
static class LosEffects.AttackInfo
           
 
Field Summary
(package private)  boolean arcedShot
           
(package private)  int attackerCover
           
(package private)  boolean blocked
           
(package private)  boolean blockedByHill
           
(package private)  boolean blockedByWater
           
(package private)  int buildingLevelsOrHexes
           
static int COVER_75LEFT
           
static int COVER_75RIGHT
           
static int COVER_FULL
           
static int COVER_HORIZONTAL
           
static int COVER_LEFT
           
static int COVER_LOWLEFT
           
static int COVER_LOWRIGHT
           
static int COVER_NONE
           
static int COVER_RIGHT
           
static int COVER_UPPER
           
(package private)  boolean deadZone
           
(package private)  int hardBuildings
           
(package private)  boolean hasLoS
           
(package private)  int heavyIndustrial
           
(package private)  int heavySmoke
           
(package private)  int heavyWoods
           
(package private)  boolean infProtected
           
(package private)  int lightSmoke
           
(package private)  int lightWoods
           
(package private)  int minimumWaterDepth
           
(package private)  int plantedFields
           
(package private)  int screen
           
(package private)  int softBuildings
           
(package private)  int targetCover
           
(package private)  Building thruBldg
           
(package private)  int ultraWoods
           
 
Constructor Summary
LosEffects()
           
 
Method Summary
 void 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 respectivly.
static LosEffects calculateLos(IGame game, int attackerId, Targetable target)
          Returns a LosEffects object representing the LOS effects of interveing terrain between the attacker and target.
static LosEffects calculateLos(IGame game, int attackerId, Targetable target, boolean spotting)
           
static LosEffects calculateLos(IGame game, LosEffects.AttackInfo ai)
           
 boolean canSee()
          LOS check from ae to te.
static int dividedLeftBetter(java.util.ArrayList<Coords> in, IGame game, LosEffects.AttackInfo ai, boolean targetInBuilding, LosEffects los)
          find out if the left or right side of the divided LOS is better for the target return 0 if right is better, 1 if left is better, 2 if both are equal
 int getAttackerCover()
           
 int getHardBuildings()
           
 int getHeavyIndustrial()
           
 int getHeavySmoke()
           
 int getHeavyWoods()
           
 int getLightSmoke()
           
 int getLightWoods()
           
 int getMinimumWaterDepth()
           
 int getPlantedFields()
           
 int getScreen()
           
 int getSoftBuildings()
           
 int getTargetCover()
           
 Building getThruBldg()
          Getter for property thruBldg.
 int getUltraWoods()
           
static boolean hasFireBetween(Coords start, Coords end, IGame game)
           
 boolean isAttackerCover()
          Getter for property attackerCover.
 boolean isBlocked()
           
 boolean isBlockedByHill()
           
 boolean isBlockedByWater()
           
 boolean isTargetCover()
          Getter for property targetCover.
 ToHitData losModifiers(IGame game)
          Returns ToHitData indicating the modifiers to fire for the specified LOS effects data.
 ToHitData losModifiers(IGame game, int eistatus)
           
 void setArcedAttack(boolean attack)
           
 void setAttackerCover(int attackerCover)
          Setter for property attackerCover.
 void setMinimumWaterDepth(int inVal)
           
 void setTargetCover(int targetCover)
          Setter for property targetCover.
 void setThruBldg(Building thruBldg)
          Setter for property thruBldg.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COVER_NONE

public static final int COVER_NONE
See Also:
Constant Field Values

COVER_LOWLEFT

public static final int COVER_LOWLEFT
See Also:
Constant Field Values

COVER_LOWRIGHT

public static final int COVER_LOWRIGHT
See Also:
Constant Field Values

COVER_LEFT

public static final int COVER_LEFT
See Also:
Constant Field Values

COVER_RIGHT

public static final int COVER_RIGHT
See Also:
Constant Field Values

COVER_HORIZONTAL

public static final int COVER_HORIZONTAL
See Also:
Constant Field Values

COVER_UPPER

public static final int COVER_UPPER
See Also:
Constant Field Values

COVER_FULL

public static final int COVER_FULL
See Also:
Constant Field Values

COVER_75LEFT

public static final int COVER_75LEFT
See Also:
Constant Field Values

COVER_75RIGHT

public static final int COVER_75RIGHT
See Also:
Constant Field Values

blocked

boolean blocked

deadZone

boolean deadZone

infProtected

boolean infProtected

hasLoS

boolean hasLoS

plantedFields

int plantedFields

heavyIndustrial

int heavyIndustrial

lightWoods

int lightWoods

heavyWoods

int heavyWoods

ultraWoods

int ultraWoods

lightSmoke

int lightSmoke

heavySmoke

int heavySmoke

screen

int screen

softBuildings

int softBuildings

hardBuildings

int hardBuildings

buildingLevelsOrHexes

int buildingLevelsOrHexes

blockedByHill

boolean blockedByHill

blockedByWater

boolean blockedByWater

targetCover

int targetCover

attackerCover

int attackerCover

thruBldg

Building thruBldg

minimumWaterDepth

int minimumWaterDepth

arcedShot

boolean arcedShot
Constructor Detail

LosEffects

public LosEffects()
Method Detail

getMinimumWaterDepth

public int getMinimumWaterDepth()

setMinimumWaterDepth

public void setMinimumWaterDepth(int inVal)

add

public void add(LosEffects other)

getPlantedFields

public int getPlantedFields()

getHeavyIndustrial

public int getHeavyIndustrial()

getLightWoods

public int getLightWoods()

getHeavyWoods

public int getHeavyWoods()

getUltraWoods

public int getUltraWoods()

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

public Building getThruBldg()
Getter for property thruBldg.

Returns:
Value of property thruBldg.

setThruBldg

public void setThruBldg(Building thruBldg)
Setter for property thruBldg.

Parameters:
thruBldg - New value of property thruBldg.

canSee

public boolean canSee()
LOS check from ae to te.


calculateLos

public static LosEffects calculateLos(IGame game,
                                      int attackerId,
                                      Targetable target)
Returns a LosEffects object representing the LOS effects of interveing 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.


calculateLos

public static LosEffects calculateLos(IGame game,
                                      int attackerId,
                                      Targetable target,
                                      boolean spotting)

calculateLos

public static LosEffects calculateLos(IGame game,
                                      LosEffects.AttackInfo ai)

losModifiers

public ToHitData losModifiers(IGame game)
Returns ToHitData indicating the modifiers to fire for the specified LOS effects data.


losModifiers

public ToHitData losModifiers(IGame game,
                              int eistatus)

hasFireBetween

public static boolean hasFireBetween(Coords start,
                                     Coords end,
                                     IGame game)

setArcedAttack

public void setArcedAttack(boolean attack)

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 respectivly.

Parameters:
c1 - the source coordiantes.
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 apliable modifiers.

dividedLeftBetter

public static int dividedLeftBetter(java.util.ArrayList<Coords> in,
                                    IGame game,
                                    LosEffects.AttackInfo ai,
                                    boolean targetInBuilding,
                                    LosEffects los)
find out if the left or right side of the divided LOS is better for the target return 0 if right is better, 1 if left is better, 2 if both are equal

Parameters:
in -
game -
ai -
targetInBuilding -
los -