/** * Helper function to determine whether an entity is an aero unit but not Small Craft/ * DropShip/JumpShip/WarShip. */ public boolean isFighter() { return isAero(); }
/** * Whether the given entity is a Spheroid dropship * @param e the entity to examine * @return True or false */ public static boolean isSpheroidDropship(Entity e) { return e.isAero() && ((IAero) e).isSpheroid(); } }
public boolean isDropping() { return isAirborne() && !(isAero()); }
/** * Gets the appropriate path ranker instance given an entity * Uses the entity's EType flags to figure out which one to return * Returns BasicPathRanker by default. * @param entity The entity whose ETYPE to check * @return Path ranker instance */ IPathRanker getPathRanker(Entity entity) { if(entity.hasETypeFlag(Entity.ETYPE_INFANTRY)) { return pathRankers.get(PathRankerType.Infantry); } else if (entity.isAero() && game.useVectorMove()) { return pathRankers.get(PathRankerType.NewtonianAerospace); } return pathRankers.get(PathRankerType.Basic); }
/** * Convenience method to determine whether this entity should be treated as an airborne aero on a ground map. * @return True if this is an airborne aircraft on a ground map. */ public boolean isAirborneAeroOnGroundMap() { return isAero() && isAirborne() && getGame().getBoard().onGround(); }
/** * Determines if the aircraft undertaking the given path will become a lawn dart * @param movePath the path to check * @return True or false */ public static boolean willCrash(MovePath movePath) { return movePath.getEntity().isAero() && (movePath.getFinalAltitude() < 1) && !movePath.contains(MoveStepType.VLAND) && !movePath.contains(MoveStepType.LAND); }
/** * Damage that an Aero suffers after a successful charge. */ public static int getDamageTakenBy(IAero attacker, Entity target) { int avel = attacker.getCurrentVelocity(); int tvel = 0; if(target.isAero()) { tvel = ((IAero)target).getCurrentVelocity(); } return getDamageTakenBy(attacker, target, ((Entity)attacker).getPriorPosition(), avel, tvel); }
/** * Damage that an Aero does on a successful ramming attack * */ public static int getDamageFor(IAero attacker, Entity target) { int avel = attacker.getCurrentVelocity(); int tvel = 0; if(target.isAero()) { tvel = ((IAero)target).getCurrentVelocity(); } return getDamageFor(attacker, target, ((Entity)attacker).getPriorPosition(), avel, tvel); }
public static boolean isAirToGround(Entity attacker, Targetable target) { if ((attacker == null) || (target == null)) { return false; } //Artillery attacks need to return differently, since none of the usual air to ground modifiers apply to them if (target.getTargetType() == Targetable.TYPE_HEX_ARTILLERY) { return false; } if (attacker.isSpaceborne()) { return false; } // According to errata, VTOL and WiGes are considered ground targets return attacker.isAirborne() && !target.isAirborne() && attacker.isAero(); }
private int calcHeatTolerance(final Entity entity, @Nullable Boolean isAero) { // If the unit doesn't track heat, we won't worry about it. if (DOES_NOT_TRACK_HEAT == entity.getHeatCapacity()) { return DOES_NOT_TRACK_HEAT; } final int baseTolerance = entity.getHeatCapacity() - entity.getHeat(); if (null == isAero) { isAero = entity.isAero(); } // Aeros *really* don't want to overheat. if (isAero) { return baseTolerance; } return baseTolerance + 5; // todo add Heat Tolerance to Behavior Settings. }
public boolean accept(Entity entity) { Integer id = new Integer(entity.getId()); if ((player == entity.getOwnerId()) && spottersBefore.contains(id) && !(LosEffects.calculateLos(game, entity.getId(), targ, true)) .isBlocked() && entity.isActive() // airborne aeros can't spot for arty && !((entity.isAero()) && entity .isAirborne()) && !entity.isINarcedWith(INarcPod.HAYWIRE)) { return true; } return false; } });
/** * Helper function to perform some modifications to a given path. * @param path The move path to process * @param expectedDamage The damage expected to be done by the unit as a result of the path * @return Altered move path */ private MovePath performPathPostProcessing(MovePath path, double expectedDamage) { MovePath retval = path; evadeIfNotFiring(retval, expectedDamage >= 0); unloadTransportedInfantry(retval); unjamRAC(retval); // if we are using vector movement, there's a whole bunch of post-processing that happens to // aircraft flight paths when a player does it, so we apply it here. if(path.getEntity().isAero()) { retval = SharedUtility.moveAero(retval, null); } return retval; }
public int getFinalVelocity() { if (getLastStep() != null) { return getLastStep().getVelocity(); } if (getEntity().isAero()) { return ((IAero) getEntity()).getCurrentVelocity(); } return 0; }
public int getFinalVelocityLeft() { if (getLastStep() != null) { return getLastStep().getVelocityLeft(); } if (getEntity().isAero()) { return ((IAero) getEntity()).getCurrentVelocity(); } return 0; }
private void updateStrafe() { if (ce().isAero()) { setStrafeEnabled(ce().getAltitude() <= 3 && !((IAero)ce()).isSpheroid()); } else { setStrafeEnabled(false); } }
private FiringPlan getBestFiringPlanUnderHeat(final Targetable target, final Entity shooter, final FiringPlan[] allPlans) { // Determine the best plan taking into account our heat tolerance. FiringPlan bestPlan = new FiringPlan(target); final boolean isAero = shooter.isAero(); final int heatTolerance = calcHeatTolerance(shooter, isAero); calculateUtility(bestPlan, heatTolerance, isAero); for (final FiringPlan firingPlan : allPlans) { calculateUtility(firingPlan, heatTolerance, isAero); if ((bestPlan.getUtility() < firingPlan.getUtility())) { bestPlan = firingPlan; } } return bestPlan; }
/** * Should we treat this movement as if it is occuring for an aerodyne unit * flying in atmosphere? */ boolean useAeroAtmosphere(IGame game, Entity en) { if (!en.isAero()) { return false; } if (((IAero) en).isSpheroid()) { return false; } // are we in space? if (game.getBoard().inSpace()) { return false; } // are we airborne in non-vacuum? return en.isAirborne() && !game.getPlanetaryConditions().isVacuum(); }
private void updateRollButton() { final Entity ce = ce(); if (null == ce) { return; } if (!ce.isAero()) { return; } setRollEnabled(true); if (!clientgui.getClient().getGame().getBoard().inSpace()) { setRollEnabled(false); } if (cmd.contains(MoveStepType.ROLL)) { setRollEnabled(false); } return; }
/** * A quick determination that checks the given path for the most common causes of a PSR and whether it leads us off board. * The idea being that a safe path off board should not include any PSRs. * @param movePath The path to check * @return True or false */ public static boolean isSafePathOffBoard(MovePath movePath) { // common causes of PSR include, but are not limited to: // stalling your aircraft // crashing your aircraft into the ground // executing maneuvers // thrusting too hard // see your doctor if you experience any of these symptoms as it may lead to your aircraft transforming into a lawn dart return !willStall(movePath) && !willCrash(movePath) && movePath.fliesOffBoard() && !movePath.contains(MoveStepType.MANEUVER) && (movePath.getMpUsed() <= movePath.getEntity().getWalkMP()) && (movePath.getEntity().isAero() && (movePath.getMpUsed() <= ((IAero) movePath.getEntity()).getSI())); }
private void updateAeroButtons() { if (ce() != null && ce().isAero()) { getBtn(MoveCommand.MOVE_THRUST).setEnabled(true); getBtn(MoveCommand.MOVE_YAW).setEnabled(true); getBtn(MoveCommand.MOVE_END_OVER).setEnabled(true); getBtn(MoveCommand.MOVE_TURN_LEFT).setEnabled(true); getBtn(MoveCommand.MOVE_TURN_RIGHT).setEnabled(true); setEvadeAeroEnabled(cmd != null && !cmd.contains(MoveStepType.EVADE)); setEjectEnabled(true); // no turning for spheroids in atmosphere if ((((IAero) ce()).isSpheroid() || clientgui.getClient().getGame() .getPlanetaryConditions().isVacuum()) && !clientgui.getClient().getGame().getBoard().inSpace()) { setTurnEnabled(false); } } }