/** * Whether the given entity is a VTOL * @param e the entity to examine * @return True or false */ public static boolean isVTOL(Entity e) { return e.getEntityType() == Entity.ETYPE_VTOL; }
MekHQ.getLogger().log(getClass(), METHOD_NAME, LogLevel.ERROR, getName() + " has no Spare Parts value for unit type " + Entity.getEntityTypeName(entity.getEntityType()));
/** * Convenience method that checks whether a bit is set in the entity type field. * * @param flag An ETYPE_* value * @return true if getEntityType() has the flag set */ public boolean hasETypeFlag(long flag) { return (getEntityType() & flag) == flag; }
Entity entity = unit.getEntity(); if (null != entity) { if ((entity.getEntityType() & Entity.ETYPE_MECH) != 0) { armor += 1; } else if ((entity.getEntityType() & Entity.ETYPE_AERO) != 0) { other += 0.5; } else if ((entity.getEntityType() & Entity.ETYPE_TANK) != 0) { armor += 0.5; } else if ((entity.getEntityType() & Entity.ETYPE_PROTOMECH) != 0) { other += 0.2; } else if ((entity.getEntityType() & Entity.ETYPE_INFANTRY) != 0) { infantry += ((Infantry)entity).isSquad()?0.2:1;
public static List<Integer> getValidFacingChanges(final Entity shooter) { // figure out all valid twists or turret turns // mechs can turn: // one left, one right unless he has "no torso twist" quirk or is on the ground // two left, two right if he has "extended torso twist" quirk // vehicles and turrets can turn any direction unless he has no turret final List<Integer> validFacingChanges = new ArrayList<>(); if (((Entity.ETYPE_MECH & shooter.getEntityType()) > 0) && !shooter.hasQuirk(OptionsConstants.QUIRK_NEG_NO_TWIST) && !shooter.hasFallen()) { validFacingChanges.add(1); validFacingChanges.add(-1); if (shooter.hasQuirk(OptionsConstants.QUIRK_POS_EXT_TWIST)) { validFacingChanges.add(2); validFacingChanges.add(-2); } } else if (shooter instanceof Tank && !((Tank) shooter).hasNoTurret()) { validFacingChanges.add(1); validFacingChanges.add(-1); validFacingChanges.add(2); validFacingChanges.add(-2); validFacingChanges.add(3); } return validFacingChanges; }
if ((u.getEntity().getEntityType() & Entity.ETYPE_WARSHIP) == Entity.ETYPE_WARSHIP) { totalAero++; } else if ((u.getEntity().getEntityType() & Entity.ETYPE_JUMPSHIP) == Entity.ETYPE_JUMPSHIP) { } else if ((u.getEntity().getEntityType() & Entity.ETYPE_AERO) == Entity.ETYPE_AERO) { totalAero++; } else if ((u.getEntity().getEntityType() & Entity.ETYPE_DROPSHIP) == Entity.ETYPE_DROPSHIP) { totalAero++; } else if (((u.getEntity().getEntityType() & Entity.ETYPE_MECH) == Entity.ETYPE_MECH) || ((u.getEntity().getEntityType() & Entity.ETYPE_TANK) == Entity.ETYPE_TANK)) { totalGround++; } else if ((u.getEntity().getEntityType() & Entity.ETYPE_BATTLEARMOR) == Entity.ETYPE_BATTLEARMOR) { totalBattleArmor++; } else if ((u.getEntity().getEntityType() & Entity.ETYPE_INFANTRY) == Entity.ETYPE_INFANTRY) { totalInfantry++;
/** * Computes the maximum number of armor points for a given Aero * at the given tonnage. * * @param entity_type * @param tonnage * @return */ public static int maxArmorPoints(Entity aero, double tonnage){ long eType = aero.getEntityType(); if (aero.hasETypeFlag(Entity.ETYPE_SMALL_CRAFT)) { return TestSmallCraft.maxArmorPoints((SmallCraft)aero); } else if (aero.hasETypeFlag(Entity.ETYPE_CONV_FIGHTER)) { return (int)(tonnage * 1); } else if (eType == Entity.ETYPE_AERO){ return (int)(tonnage * 8); } else { return 0; } }
/** * Generate a Quirk's Unit ID given an Entity. * * @param ent Entity to generate UnitId from * @param useModel determines if the model should be used, or be 'all' * @return The ID for the unit. */ private static String getUnitId(Entity ent, boolean useModel) { String typeText = Entity.getEntityMajorTypeName(ent.getEntityType()); if (useModel) { return ent.getChassis() + "~" + ent.getModel() + "~" + typeText; } else { return ent.getChassis() + "~~" + typeText; } }
/** * Returns the first set of valid deployment coordinates for the given unit out of the given deployment coordinates. * It's possible to return null, which indicates that there are no valid hexes for the given unit to deploy into. */ @Nullable @Override protected Coords getFirstValidCoords(final Entity deployedUnit, final List<Coords> possibleDeployCoords) { if (Entity.ETYPE_GUN_EMPLACEMENT == (deployedUnit.getEntityType() & Entity.ETYPE_GUN_EMPLACEMENT)) { final List<Coords> validCoords = calculateTurretDeploymentLocations((GunEmplacement) deployedUnit, possibleDeployCoords); if (0 < validCoords.size()) { return validCoords.get(0); } return null; } else if(getGame().useVectorMove()) { return calculateAdvancedAerospaceDeploymentCoords(deployedUnit, possibleDeployCoords); } else { return super.getFirstValidCoords(deployedUnit, possibleDeployCoords); } }
if (chksAllyLost.get(i).isSelected()) { breaches++; long etype = scenario.getEntity(scenario.getAttachedUnitIds().get(i)).getEntityType(); if ((etype & megamek.common.Entity.ETYPE_DROPSHIP) != 0) { breaches += 4;
Entity entity = unit.getEntity(); if (null != entity) { if ((entity.getEntityType() & Entity.ETYPE_MECH) != 0 || (entity.getEntityType() & Entity.ETYPE_PROTOMECH) != 0 || (entity.getEntityType() & Entity.ETYPE_INFANTRY) != 0) { weight += entity.getWeight(); } else if ((entity.getEntityType() & Entity.ETYPE_TANK) != 0) { if (c.getFaction().isClan() || c.getCampaignOptions().getAdjustPlayerVehicles()) { weight += entity.getWeight() * 0.5; weight += entity.getWeight(); } else if ((entity.getEntityType() & Entity.ETYPE_AERO) != 0) { if (c.getFaction().isClan()) { weight += entity.getWeight() * 0.5;
continue; if (en instanceof Mech || en.getEntityType() == Entity.ETYPE_AERO) { int rangeIndex = 1; int base = (int)Math.round(weaponLocations[loc].getDamage(1)); && (en instanceof Mech || en.getEntityType() == Entity.ETYPE_AERO)) { int heatLong = en.getWeaponList().stream() .filter(m -> m.getType() instanceof WeaponType
public int getMaxWeaponRange() { // Aeros on the ground map must shoot along their flight path, giving // them effectively 0 range if (isAero() && isAirborne() && game.getBoard().onGround()) { return 0; } int maxRange = 0; if ((ETYPE_MECH == getEntityType()) || (ETYPE_INFANTRY == getEntityType()) || (ETYPE_PROTOMECH == getEntityType())) { // account for physical attacks. maxRange = 1; } for (Mounted weapon : getWeaponList()) { if (!weapon.isReady()) { continue; } WeaponType type = (WeaponType) weapon.getType(); int range = (game.getOptions().booleanOption( OptionsConstants.ADVCOMBAT_TACOPS_RANGE) ? type.getExtremeRange() : type.getLongRange()); if (range > maxRange) { maxRange = range; } } return maxRange; }
public AlphaStrikeElement(Entity en) { super(en); asUnitType = ASUnitType.getUnitType(en); if (en.getEntityType() == Entity.ETYPE_INFANTRY) { double divisor = ((Infantry)en).getDamageDivisor(); if (((Infantry)en).isMechanized()) { divisor /= 2.0; } armor *= divisor; } //Armored Glove counts as an additional AP mounted weapon if (en instanceof BattleArmor && en.hasWorkingMisc(MiscType.F_ARMORED_GLOVE)) { double apDamage = AP_MOUNT_DAMAGE * (TROOP_FACTOR[Math.min(((BattleArmor)en).getShootingStrength(), 30)] + 0.5); weaponLocations[0].addDamage(0, apDamage); weaponLocations[0].addDamage(WeaponType.BFCLASS_STANDARD, 0, apDamage); } }
if ((entity.getEntityType() == Entity.ETYPE_AERO) && (entity.getEntityType() != Entity.ETYPE_DROPSHIP) && (entity.getEntityType() != Entity.ETYPE_SMALL_CRAFT) && (entity.getEntityType() != Entity.ETYPE_FIGHTER_SQUADRON) && (entity.getEntityType() != Entity.ETYPE_JUMPSHIP) && (entity.getEntityType() != Entity.ETYPE_SPACE_STATION)) { testEntity = new TestAero((Aero)entity,
/** * Refits may require adding or removing heat sinks that are not tracked as parts. For Mechs and * ASFs this would be engine-integrated heat sinks if the heat sink type is changed. For vehicles and * conventional fighters this would be heat sinks required by energy weapons. * * @param entity Either the starting or the ending unit of the refit. * @return The number of heat sinks the unit mounts that are not tracked as parts. */ private int untrackedHeatSinkCount(Entity entity) { if (entity instanceof Mech) { return Math.min(((Mech) entity).heatSinks(), entity.getEngine().integralHeatSinkCapacity(((Mech) entity).hasCompactHeatSinks())); } else if ((entity instanceof Aero) && (entity.getEntityType() & (Entity.ETYPE_CONV_FIGHTER | Entity.ETYPE_SMALL_CRAFT | Entity.ETYPE_JUMPSHIP)) == 0) { return entity.getEngine().integralHeatSinkCapacity(false); } else { EntityVerifier verifier = EntityVerifier.getInstance(new File( "data/mechfiles/UnitVerifierOptions.xml")); TestEntity te = null; if (entity instanceof Tank) { te = new TestTank((Tank) entity, verifier.tankOption, null); return te.getCountHeatSinks(); } else if (entity instanceof ConvFighter) { te = new TestAero((Aero) entity, verifier.aeroOption, null); return te.getCountHeatSinks(); } else { return 0; } } }
@Override public void updateConditionFromEntity(boolean checkForDestruction) { int priorHits = hits; if(null != unit && (unit.getEntity().getEntityType() & (Entity.ETYPE_AERO | Entity.ETYPE_LAND_AIR_MECH)) != 0) { hits = ((IAero)unit.getEntity()).getAvionicsHits(); if(checkForDestruction && hits > priorHits && (hits < 3 && !campaign.getCampaignOptions().useAeroSystemHits()) && Compute.d6(2) < campaign.getCampaignOptions().getDestroyPartTarget()) { remove(false); return; } else if (hits >= 3) { remove(false); return; } } }
&& ((shooter.getEntityType() & Entity.ETYPE_INFANTRY) == 0)) { return alphaStrike; // No need to worry about heat if the unit
return false; if ((entity.getEntityType() & ETYPE_GROUND) != 0) { hasGround = true;
continue; if (noInfantry && ((u.getEntity().getEntityType() & Entity.ETYPE_INFANTRY) == Entity.ETYPE_INFANTRY) && !((u.getEntity().getEntityType() & Entity.ETYPE_BATTLEARMOR) == Entity.ETYPE_BATTLEARMOR)) { continue;