Class GunEmplacement

All Implemented Interfaces:
Serializable, ICarryable, Transporter, InGameObject, CombatRole, ForceAssignable, ITechnology, ITurnOrdered, PhaseUpdated, RoundUpdated, BTObject, Deployable, Fortifiable, RubbleClearer, Targetable

public class GunEmplacement extends Tank
A building with weapons fitted and, optionally, a turret. Taharqa: I am completely re-writing this entity to bring it up to code with TacOps rules GunEmplacements will not simply be the weapon loadouts that can be attached to buildings. They will not be targetable in game, but will be destroyed if their building hex is reduced.
See Also:
  • Field Details

    • LOC_GUNS

      public static final int LOC_GUNS
      See Also:
    • HIT_LOCATION_NAMES

      public static final String[] HIT_LOCATION_NAMES
    • TA_LIGHT_BUILDING

      public static final TechAdvancement TA_LIGHT_BUILDING
  • Constructor Details

    • GunEmplacement

      public GunEmplacement()
  • Method Details

    • getConstructionTechAdvancement

      public TechAdvancement getConstructionTechAdvancement()
      Description copied from class: Entity
      return - the base construction option tech advancement
      Overrides:
      getConstructionTechAdvancement in class Tank
    • getUnitType

      public int getUnitType()
      Overrides:
      getUnitType in class Tank
      See Also:
    • isTurret

      public boolean isTurret()
    • isImmobile

      public boolean isImmobile()
      Description copied from class: Entity
      Returns true if the target is considered immobile (-4 to hit) as a target and also if it is considered immobile or temporarily or permanently immbolized for active movement. Overriding methods should check the status of the unit (shutdown, damage) and also the status of the crew (unconscious).
      Specified by:
      isImmobile in interface Targetable
      Overrides:
      isImmobile in class Entity
      Returns:
      True if the target is considered immobile as a target and unable to move actively.
    • hasNoDualTurret

      public boolean hasNoDualTurret()
      Our gun emplacements do not support dual turrets at this time
      Overrides:
      hasNoDualTurret in class Tank
    • isEligibleForMovement

      public boolean isEligibleForMovement()
      Description copied from class: Entity
      Pretty much anybody's eligible for movement. If the game option is toggled on, inactive and immobile entities are not eligible. OffBoard units are always ineligible
      Overrides:
      isEligibleForMovement in class Entity
      Returns:
      whether the entity is allowed to move
    • getMovementString

      public String getMovementString(EntityMovementType movementType)
      Description copied from class: Tank
      Returns the name of the type of movement used. This is tank-specific.
      Overrides:
      getMovementString in class Tank
    • getMovementAbbr

      public String getMovementAbbr(EntityMovementType movementType)
      Description copied from class: Tank
      Returns the name of the type of movement used. This is tank-specific.
      Overrides:
      getMovementAbbr in class Tank
    • isLocationProhibited

      public boolean isLocationProhibited(Coords c, int testBoardId, int currElevation)
      Description copied from class: Tank
      Tanks have all sorts of prohibited terrain.
      Overrides:
      isLocationProhibited in class Tank
      Parameters:
      c - The position to test
      testBoardId - The board to test
      currElevation - The elevation or altitude to test
      Returns:
      True when the location is illegal to be in for this unit, regardless of elevation
      See Also:
    • getWalkMP

      public int getWalkMP(MPCalculationSetting mpCalculationSetting)
      Overrides:
      getWalkMP in class Tank
    • getRunMP

      public int getRunMP(MPCalculationSetting mpCalculationSetting)
      Overrides:
      getRunMP in class Tank
    • getSprintMP

      public int getSprintMP(MPCalculationSetting mpCalculationSetting)
      Description copied from class: Entity
      Returns this entity's sprinting MP, modified according to the given setting. For units that can't sprint, this is equal to the modified run/flank MP.
      Overrides:
      getSprintMP in class Tank
      Returns:
      This entity's modified sprinting MP
    • getJumpMP

      public int getJumpMP(MPCalculationSetting mpCalculationSetting)
      Overrides:
      getJumpMP in class Entity
    • getLocationAbbreviations

      public String[] getLocationAbbreviations()
      Overrides:
      getLocationAbbreviations in class Tank
    • getLocationNames

      public String[] getLocationNames()
      Overrides:
      getLocationNames in class Tank
    • locations

      public int locations()
      Description copied from class: Tank
      Returns the number of locations in the entity
      Overrides:
      locations in class Tank
    • getWeaponArc

      public int getWeaponArc(int weaponId)
      Description copied from class: Tank
      Returns the Compute.ARC that the weapon fires into.
      Overrides:
      getWeaponArc in class Tank
      Parameters:
      weaponId - integer equipment number, index from equipment list
      Returns:
      arc the specified weapon is in
    • isSecondaryArcWeapon

      public boolean isSecondaryArcWeapon(int weaponId)
      Description copied from class: Tank
      Returns true if this weapon fires into the secondary facing arc. If false, assume it fires into the primary.
      Overrides:
      isSecondaryArcWeapon in class Tank
    • sideTable

      public int sideTable(Coords src)
      Specified by:
      sideTable in interface Targetable
      Overrides:
      sideTable in class Entity
      Returns:
      side hit from location
    • rollHitLocation

      public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMode aimingMode, int cover)
      Description copied from class: Tank
      Rolls up a hit location
      Overrides:
      rollHitLocation in class Tank
    • rollHitLocation

      public HitData rollHitLocation(int table, int side)
      Description copied from class: Entity
      Rolls up a hit location
      Overrides:
      rollHitLocation in class Tank
    • addEntityBonuses

      public PilotingRollData addEntityBonuses(PilotingRollData prd)
      Description copied from class: Entity
      Add in any piloting skill mods
      Overrides:
      addEntityBonuses in class Tank
    • getNoOfSlots

      public int[] getNoOfSlots()
      Overrides:
      getNoOfSlots in class Tank
    • getTotalSlots

      public int getTotalSlots()
      Description copied from class: Tank
      get the total amount of item slots available for this tank
      Overrides:
      getTotalSlots in class Tank
    • autoSetInternal

      public void autoSetInternal()
      Description copied from class: Entity
      Sets the internal structure for every location to appropriate undamaged values for the unit and location.
      Overrides:
      autoSetInternal in class Tank
    • getMaxElevationChange

      public int getMaxElevationChange()
      Description copied from class: Entity
      The maximum elevation change the entity can cross
      Overrides:
      getMaxElevationChange in class Entity
    • isRepairable

      public boolean isRepairable()
      Description copied from class: Tank
      Determine if the unit can be repaired, or only harvested for spares.
      Overrides:
      isRepairable in class Tank
      Returns:
      A boolean that is true if the unit can be repaired (given enough time and parts); if this value is false, the unit is only a source of spares.
      See Also:
    • isTargetable

      public boolean isTargetable()
      Description copied from class: Entity
      Returns true if this entity is targetable for attacks. A unit is targetable if it is not destroyed, not doomed, deployed, not off board, not being transported, and not captured.
      Overrides:
      isTargetable in class Entity
    • canCharge

      public boolean canCharge()
      Overrides:
      canCharge in class Tank
      Returns:
      Whether this type of unit can perform charges
    • canFlee

      public boolean canFlee(Coords position)
      Description copied from class: Entity
      Returns true when this unit can flee from the given position in its current state. This requires the unit to have mobility and be in control as well as the position being eligible for fleeing. When no special flee area is set by a scenario, the latter will typically be true when the position is at the edge of its board. A null position as well as offboard units are considered to be eligible for fleeing.
      Overrides:
      canFlee in class Entity
      Returns:
      True when the unit can flee from the given position, given its current status
    • canGoDown

      public boolean canGoDown()
      Overrides:
      canGoDown in class Entity
    • canGoDown

      public boolean canGoDown(int assumed, Coords coords, int boardId)
      Description copied from class: Entity
      is it possible to go down, or are we landed/just above the water/treeline? assuming passed elevation.
      Overrides:
      canGoDown in class Entity
    • getCost

      public double getCost(CalculationReport calcReport, boolean ignoreAmmo)
      Description copied from class: Entity
      Calculates and returns the C-bill cost of the unit. The parameter ignoreAmmo can be used to include or exclude ("dry cost") the cost of ammunition on the unit. A report for the cost calculation will be written to the given calcReport.
      Overrides:
      getCost in class Tank
      Parameters:
      calcReport - A CalculationReport to write the report for the cost calculation to
      ignoreAmmo - When true, the cost of ammo on the unit will be excluded from the cost
      Returns:
      The cost in C-Bills of the 'Mek in question.
    • doomedInVacuum

      public boolean doomedInVacuum()
      Overrides:
      doomedInVacuum in class Tank
      Returns:
      True when this unit will not survive vacuum conditions.
    • addEquipment

      public void addEquipment(Mounted<?> mounted, int loc, boolean rearMounted) throws LocationFullException
      Description copied from class: Entity
      Adds the given mounted equipment to the unit in the given location, possibly rear-facing depending on the given parameter. This method adds the mounted to the right equipment lists, updates the unit's tech level and adds one-shot ammo where necessary. Overriding methods may perform more tasks. This method, by default, does *NOT* create crit slots, update or add linkages nor handle secondary locations. Overrides for unit types may however do that.
      Overrides:
      addEquipment in class Tank
      Parameters:
      mounted - The new equipment
      loc - The location; may be Entity.LOC_NONE
      rearMounted - True to make the equipment rear-facing
      Throws:
      LocationFullException - When the location is full
    • getTotalCommGearTons

      public int getTotalCommGearTons()
      Overrides:
      getTotalCommGearTons in class Tank
      Returns:
      the total tonnage of communications gear in this entity
    • isCrippled

      public boolean isCrippled(boolean checkCrew)
      Description copied from class: Entity
      Returns TRUE if the entity meets the requirements for crippling damage as detailed in TW pg 258. Excepting dead or non-existing crew issues
      Overrides:
      isCrippled in class Tank
      Returns:
      boolean
    • isDmgHeavy

      public boolean isDmgHeavy()
      Description copied from class: Entity
      Returns TRUE if the entity has been heavily damaged.
      Overrides:
      isDmgHeavy in class Tank
      Returns:
      boolean
    • isDmgLight

      public boolean isDmgLight()
      Description copied from class: Entity
      Returns TRUE if the entity has been lightly damaged.
      Overrides:
      isDmgLight in class Tank
      Returns:
      boolean
    • isDmgModerate

      public boolean isDmgModerate()
      Description copied from class: Entity
      Returns TRUE if the entity has been moderately damaged.
      Overrides:
      isDmgModerate in class Tank
      Returns:
      boolean
    • getEntityType

      public long getEntityType()
      Overrides:
      getEntityType in class Tank
    • hasEngine

      public boolean hasEngine()
      Overrides:
      hasEngine in class Entity
    • getArmorType

      public int getArmorType(int loc)
      Overrides:
      getArmorType in class Entity
    • getArmorTechLevel

      public int getArmorTechLevel(int loc)
      Overrides:
      getArmorTechLevel in class Entity
    • hasStealth

      public boolean hasStealth()
      Overrides:
      hasStealth in class Entity
      Returns:
      True if this unit has working stealth armor (not patchwork armor).
    • setDeployed

      public void setDeployed(boolean deployed)
      Sets the deployed flag. Has the side effect of initializing building CF if deployed
      Overrides:
      setDeployed in class Entity
    • getArmorRemainingPercent

      public double getArmorRemainingPercent()
      Description copied from class: Entity
      Returns the percent of the armor remaining
      Overrides:
      getArmorRemainingPercent in class Entity
    • getDamagedCriticalSlots

      public int getDamagedCriticalSlots(int type, int index, int loc)
      Gun emplacements don't have critical slots per se, so we simply return 1 if the piece of equipment has been hit and 0 otherwise.
      Overrides:
      getDamagedCriticalSlots in class Entity
    • getGenericBattleValue

      public int getGenericBattleValue()
      Description copied from class: Entity
      Calculates a "generic" Battle Value that is based on the average of all units of this type and tonnage. The purpose of this generic Battle Value is to allow a comparison of this unit's actual BV to that for units of its class. This can be used to balance forces without respect to unit or pilot quality.

      The generic BV values are calculated by a statistical elasticity model based on all data from the MegaMek database.

      Overrides:
      getGenericBattleValue in class Tank
      Returns:
      The generic Battle value for this unit based on its tonnage and type
    • isSideLocation

      public boolean isSideLocation(int location)
      Overrides:
      isSideLocation in class Tank
      Parameters:
      location - The location to check
      Returns:
      True when the given location is a side location, i.e. left, right or, on superheavy units, front or rear left/right.
    • isBuildingEntityOrGunEmplacement

      public boolean isBuildingEntityOrGunEmplacement()
      Replaced most instances of `instanceof GunEmplacement` to support BuildingEntity
      Returns:
      true if this unit is a BuildingEntity or GunEmplacement, false otherwise
    • isChassisFamiliarityEligible

      public boolean isChassisFamiliarityEligible()
      Description copied from class: Entity
      Returns whether this unit is a chassis-familiarity-eligible type for MekHQ's Familiarity system
      Overrides:
      isChassisFamiliarityEligible in class Tank
      Returns:
      true if familiarity is tracked for this unit