Class LosEffects

java.lang.Object
megamek.common.LosEffects

public class LosEffects extends Object
Keeps track of the cumulative effects of intervening terrain on LOS
Since:
October 14, 2002, 11:19 PM
  • Field Details

  • Constructor Details

    • LosEffects

      public LosEffects()
  • Method Details

    • getTargetPosition

      public Coords getTargetPosition()
    • 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()
    • 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

      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.
    • prepLosAttackInfo

      public static LosEffects.AttackInfo prepLosAttackInfo(Game game, @Nullable Entity ae, @Nullable Entity te, Coords c1, Coords c2, boolean mekInFirst, boolean mekInSecond)
    • calculateLos

      @Deprecated(since="0.50.04") public static LosEffects calculateLos(Game game, int attackerId, @Nullable Targetable target)
      Deprecated.
      since 0.50.04 - Use calculateLOS(Game, Entity, Targetable) instead
      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 -
      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 current Game
      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

      public static LosEffects calculateLos(Game game, LosEffects.AttackInfo ai)
    • losModifiers

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

      public ToHitData losModifiers(Game game, boolean underWaterWeapon)
    • losModifiers

      public ToHitData losModifiers(Game game, int eistatus, boolean underwaterWeapon)
    • hasFireBetween

      public static boolean hasFireBetween(Coords start, Coords end, Game game)
    • 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 current Game
      ai -
      targetInBuilding -
      los -
      Returns:
      0 if right is better, 1 if left is better, 2 if both are equal
    • getCoverName

      public static String getCoverName(int cover, boolean switchSides)
      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

      public Building getCoverBuildingPrimary()
    • setCoverBuildingPrimary

      public void setCoverBuildingPrimary(Building coverBuilding)
    • getCoverDropshipPrimary

      public Entity getCoverDropshipPrimary()
    • setCoverDropshipPrimary

      public void setCoverDropshipPrimary(Entity coverDropship)
    • getDamagableCoverTypePrimary

      public int getDamagableCoverTypePrimary()
    • setDamagableCoverTypePrimary

      public void setDamagableCoverTypePrimary(int damagableCover)
    • getCoverLocPrimary

      public Coords getCoverLocPrimary()
    • setCoverLocPrimary

      public void setCoverLocPrimary(Coords coverLoc)
    • getCoverBuildingSecondary

      public Building getCoverBuildingSecondary()
    • setCoverBuildingSecondary

      public void setCoverBuildingSecondary(Building coverBuildingSecondary)
    • getCoverDropshipSecondary

      public Entity getCoverDropshipSecondary()
    • setCoverDropshipSecondary

      public void setCoverDropshipSecondary(Entity coverDropshipSecondary)
    • getDamagableCoverTypeSecondary

      public int getDamagableCoverTypeSecondary()
    • setDamagableCoverTypeSecondary

      public void setDamagableCoverTypeSecondary(int damagableCoverTypeSecondary)
    • getCoverLocSecondary

      public Coords getCoverLocSecondary()
    • setCoverLocSecondary

      public void setCoverLocSecondary(Coords coverLocSecondary)
    • infantryProtected

      public boolean infantryProtected()