Class FighterSquadron

All Implemented Interfaces:
Serializable, BTObject, CombatRole, Deployable, ForceAssignable, IAero, IBomber, InGameObject, ITechnology, ITurnOrdered, PhaseUpdated, RoundUpdated, Targetable, Transporter

public class FighterSquadron extends AeroSpaceFighter
Fighter squadrons are basically "containers" for a bunch of fighters.
See Also:
  • Field Details

  • Constructor Details

    • FighterSquadron

      public FighterSquadron()
    • FighterSquadron

      public FighterSquadron(String name)
  • Method Details

    • 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 Aero
      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.
    • isCapitalFighter

      public boolean isCapitalFighter()
      Overrides:
      isCapitalFighter in class Entity
    • getOSI

      public int getOSI()
      Specified by:
      getOSI in interface IAero
      Overrides:
      getOSI in class Aero
    • getSI

      public int getSI()
      Specified by:
      getSI in interface IAero
      Overrides:
      getSI in class Aero
    • getTotalArmor

      public int getTotalArmor()
      Description copied from class: Entity
      Returns the total amount of armor on the entity.
      Overrides:
      getTotalArmor in class Entity
    • getTotalOArmor

      public int getTotalOArmor()
      Description copied from class: Entity
      Returns the total amount of armor on the entity.
      Overrides:
      getTotalOArmor in class Entity
    • isCrippled

      public boolean isCrippled(boolean checkCrew)
      Per SO, fighter squadrons can't actually be crippled Individual crippled fighters should be detached and sent home, but it isn't required by the rules
      Overrides:
      isCrippled in class Aero
      Returns:
      boolean
      See Also:
    • getArmorRemainingPercent

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

      public int getWalkMP(MPCalculationSetting mpCalculationSetting)
      Overrides:
      getWalkMP in class Aero
    • getCurrentThrust

      public int getCurrentThrust()
      Specified by:
      getCurrentThrust in interface IAero
      Overrides:
      getCurrentThrust in class Aero
      Returns:
      same as Aero.getWalkMP(megamek.common.MPCalculationSetting), but does not divide by 2 when grounded
    • getFuel

      public int getFuel()
      Specified by:
      getFuel in interface IAero
      Overrides:
      getFuel in class Aero
    • getCurrentFuel

      public int getCurrentFuel()
      Specified by:
      getCurrentFuel in interface IAero
      Overrides:
      getCurrentFuel in class Aero
    • getInternalRemainingPercent

      public double getInternalRemainingPercent()
      Squadrons have an SI for PSR purposes, but don't take SI damage. This should return 100%.
      Overrides:
      getInternalRemainingPercent in class Aero
    • hasTargComp

      public boolean hasTargComp()
      Description copied from class: Entity
      Returns whether or not this entity has a Targeting Computer.
      Overrides:
      hasTargComp in class Entity
    • hasActiveECM

      public boolean hasActiveECM()
      Description copied from class: Entity
      Does the Mek have a functioning ECM unit?
      Overrides:
      hasActiveECM in class Entity
    • loadedUnitsHaveActiveECM

      public boolean loadedUnitsHaveActiveECM()
      Description copied from class: Entity
      Do units loaded onto this entity still have active ECM/ECCM/etc.?
      Overrides:
      loadedUnitsHaveActiveECM in class Entity
    • addEntityBonuses

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

      public int getClusterMods()
      Description copied from class: Aero
      get modifications to the cluster hit table for critical hits
      Specified by:
      getClusterMods in interface IAero
      Overrides:
      getClusterMods in class Aero
    • doBattleValueCalculation

      public int doBattleValueCalculation(boolean ignoreC3, boolean ignoreSkill, CalculationReport calculationReport)
      Description copied from class: Entity
      Calculates and returns the Battle Value of this unit taking into account the parameters. This method should be overridden by subclasses of Entity to provide a unit type specific calculation of the Battle Value. A report of the calculation should be written to the given calculationReport.
      Overrides:
      doBattleValueCalculation in class Entity
      Parameters:
      ignoreC3 - When true, the BV contributions of any C3 computers are not added
      ignoreSkill - When true, the skill of the crew / pilot is not taken into account for BV
      calculationReport - A CalculationReport to write the BV calculation to
      Returns:
      The Battle Value of this unit calculated from its current state
    • getHeatSinks

      public int getHeatSinks()
      Specified by:
      getHeatSinks in interface IAero
      Overrides:
      getHeatSinks in class Aero
    • getHeatCapacity

      public int getHeatCapacity(boolean includeRadicalHeatSink)
      Overrides:
      getHeatCapacity in class Aero
    • resetHeatCapacity

      public void resetHeatCapacity()
    • getWeight

      public double getWeight()
      Overrides:
      getWeight in class Entity
      Returns:
      the tonnage of the Entity, not its weight
    • rollHitLocation

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

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

      public void newRound(int roundNumber)
      Description copied from class: Entity
      Start a new round
      Specified by:
      newRound in interface RoundUpdated
      Overrides:
      newRound in class Aero
      Parameters:
      roundNumber - the int number of the new round
    • updateSensors

      public void updateSensors()
      Update sensors. Use the active sensor of the first fighter in the squadron that hasn't taken 3 sensor hits BAPs don't count as active sensors in space, but they do make detection rolls easier
    • updateWeaponGroups

      public void updateWeaponGroups()
      instead of trying to track the individual units weapons, just recompile the weapon groups for this squadron each round
    • updateSkills

      public void updateSkills()
    • getAmmo

      public List<AmmoMounted> getAmmo()
      Overrides:
      getAmmo in class Entity
    • useFuel

      public void useFuel(int fuel)
      Description copied from interface: IAero
      use the specified amount of fuel for this Aero. The amount may be adjusted by certain game options
      Parameters:
      fuel - The number of fuel points to use
    • autoSetMaxBombPoints

      public void autoSetMaxBombPoints()
      Overrides:
      autoSetMaxBombPoints in class AeroSpaceFighter
    • setBombChoices

      public void setBombChoices(int... bc)
      Description copied from interface: IBomber
      Backwards compatibility bomb choice setter that only affects external stores.
    • getBombLoadout

      public int[] getBombLoadout()
      Produce an int array of the number of bombs of each type based on the current bomblist. Since this is a FighterSquadron, these numbers represent the number of bombs in a salvo. That is, it is a count of the number of fighters in the squadron that have a bomb of the particular type mounted.
      Overrides:
      getBombLoadout in class Entity
      Returns:
      an int array of the number of bombs of each type based on the current bomb list
    • applyBombs

      public void applyBombs()
      Description copied from interface: IBomber
      Iterate through the bomb choices that were configured prior to deployment and add the corresponding equipment.
    • computeSquadronBombLoadout

      public void computeSquadronBombLoadout()
      This method looks at the bombs equipped on all the fighters in the squadron and determines what possible bombing attacks the squadrons can make. TODO: Make this into a generic "clean up bomb loadout" method
    • getMaxSize

      public int getMaxSize()
      Returns:
      The maximum fighter count of a fighter squadron. This depends on game options ("Large Squadrons").
    • canLoad

      public boolean canLoad(Entity unit, boolean checkFalse)
      Description copied from class: Aero
      Determines if this object can accept the given unit. The unit may not be of the appropriate type or there may be no room for the unit.
      Overrides:
      canLoad in class Aero
      Parameters:
      unit - - the Entity to be loaded.
      Returns:
      true if the unit can be loaded, false otherwise.
    • load

      public void load(Entity unit, boolean checkFalse, int bayNumber) throws IllegalArgumentException
      Description copied from class: Entity
      Load the given unit.
      Overrides:
      load in class Entity
      Parameters:
      unit - - the Entity to be loaded.
      Throws:
      IllegalArgumentException - If the unit can't be loaded
    • unload

      public boolean unload(Entity unit)
      Description copied from interface: Transporter
      Unload the given unit.
      Specified by:
      unload in interface Transporter
      Overrides:
      unload in class Entity
      Parameters:
      unit - - the Entity to be unloaded.
      Returns:
      true if the unit was contained in this space, false otherwise.
    • getLoadedUnits

      public Vector<Entity> getLoadedUnits()
      Description copied from class: Entity
      Get a List of the units currently loaded into this payload.
      Specified by:
      getLoadedUnits in interface Transporter
      Overrides:
      getLoadedUnits in class Entity
      Returns:
      A List of loaded Entity units. This list will never be null, but it may be empty. The returned List is independent from the under- lying data structure; modifying one does not affect the other.
    • getUnusedString

      public String getUnusedString()
      Description copied from interface: Transporter
      Return a string that identifies the unused capacity of this transporter.
      Specified by:
      getUnusedString in interface Transporter
      Overrides:
      getUnusedString in class Entity
      Returns:
      A String meant for a human.
    • getUnused

      public double getUnused()
      Specified by:
      getUnused in interface Transporter
      Overrides:
      getUnused in class Entity
      Returns:
      the number of unused spaces in this transporter.
    • getUnused

      public double getUnused(Entity e)
      Description copied from class: Entity
      Returns the current amount of cargo space for an entity of the given type.
      Overrides:
      getUnused in class Entity
      Parameters:
      e - An entity that defines the unit class
      Returns:
      The number of units of the given type that can be loaded in this Entity
    • isWeaponBlockedAt

      public boolean isWeaponBlockedAt(int loc, boolean isRear)
      Description copied from interface: Transporter
      Determine if transported units prevent a weapon in the given location from firing.
      Specified by:
      isWeaponBlockedAt in interface Transporter
      Overrides:
      isWeaponBlockedAt in class Entity
      Parameters:
      loc - the location attempting to fire.
      isRear - true if the weapon is rear-facing
      Returns:
      True if a transported unit is in the way, false if the weapon can fire.
    • getExteriorUnitAt

      public Entity getExteriorUnitAt(int loc, boolean isRear)
      Description copied from interface: Transporter
      If a unit is being transported on the outside of the transporter, it can suffer damage when the transporter is hit by an attack. Currently, no more than one unit can be at any single location; that same unit can be "spread" over multiple locations.
      Specified by:
      getExteriorUnitAt in interface Transporter
      Overrides:
      getExteriorUnitAt in class Entity
      Parameters:
      loc - - the int location hit by attack.
      isRear - - a boolean value stating if the given location is rear facing; if false, the location is front facing.
      Returns:
      The Entity being transported on the outside at that location. This value will be null if no unit is transported on the outside at that location.
    • getCargoMpReduction

      public int getCargoMpReduction(Entity carrier)
      Specified by:
      getCargoMpReduction in interface Transporter
      Overrides:
      getCargoMpReduction in class Entity
      Returns:
      the MP reduction due to cargo carried by this transporter
    • getEntityType

      public long getEntityType()
      Overrides:
      getEntityType in class AeroSpaceFighter
    • getEngine

      public Engine getEngine()
      Overrides:
      getEngine in class Entity
    • hasEngine

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

      public EntityMovementMode getMovementMode()
      Description copied from class: Entity
      Get the movement mode of the entity
      Overrides:
      getMovementMode in class Entity
    • getSubEntities

      public List<Entity> getSubEntities()
      Description copied from class: Entity
      This method (and getActiveSubEntities()) is meant for groups of entities handled as a singular one. Examples include fighter squadrons on space maps or lances in BattleForce game modes.

      To check if a given entity consists of multiple sub-entities, use

       if (entity.getSubEntities().isPresent()) {
           ...
       }
       

      To iterate over entities (if present), use:

       entity.getSubEntities().ifPresent(entities -> entities.forEach(
           subEntity -> {
               ...
           });
       
      Overrides:
      getSubEntities in class Entity
      Returns:
      an optional collection of sub-entities, if this entity is considered a grouping of them.
    • getActiveSubEntities

      public List<Entity> getActiveSubEntities()
      Description copied from class: Entity
      A list of all active sub-entities. In most cases, this is simply an empty list.
      Overrides:
      getActiveSubEntities in class Entity
      Returns:
      an optional collection of sub-entities, if this entity is considered a grouping of them, pre-filtered to only contain active (non-destroyed and non-doomed) entities.
    • isUnitGroup

      public boolean isUnitGroup()
      Description copied from interface: BTObject
      Returns true when this is a group of units or elements such as a TW Squadron, BF Unit or SBF Formation even if it happens to contain only a single element at the time.
      Returns:
      True when this is a group type unit
    • isFighter

      public boolean isFighter()
      Description copied from interface: BTObject
      Returns true when this object is a fighter (aerospace or conventional) including Fixed-Wing Support or of type CF/AF/SV(MV a) for Alpha Strike. Returns false for any type of unit group even if it is of the right type.
      Specified by:
      isFighter in interface BTObject
      Overrides:
      isFighter in class AeroSpaceFighter
      Returns:
      True when this is a fighter including fixed-wing support
    • isCapitalScale

      public boolean isCapitalScale()
      Overrides:
      isCapitalScale in class Entity
      Returns:
      True when this unit has capital-scale armor.
    • setTransportId

      public void setTransportId(int transportId)
      Override of Entity method. This needs to be set or we can't do a reverse lookup from a Capital Fighter to its Squadron.
      Overrides:
      setTransportId in class Entity
      Parameters:
      transportId - - the int ID of our transport. The ID is not validated. This value should be Entity.NONE if this unit has been unloaded.
    • damageCapFighterWeapons

      public void damageCapFighterWeapons(int loc)
      Damage a capital fighter's weapons. WeaponGroups are damaged by critical hits. This matches up the individual fighter's weapons and critical slots and damages those for MHQ resolution
      Parameters:
      loc - - Int corresponding to the location struck