/** * 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. */ public boolean isTargetable() { return !destroyed && !doomed && deployed && !isOffBoard() && (conveyance == Entity.NONE) && !captured && (getPosition() != null); }
/** * Returns true if the entity should be deployed */ public boolean shouldDeploy(int round) { return (!deployed && (getDeployRound() <= round) && !isOffBoard()); }
private boolean isEntityOnMap(final Entity entity) { return entity.isDeployed() && !entity.isOffBoard(); }
public List<Entity> getEntitiesOwned() { ArrayList<Entity> result = new ArrayList<>(); for (Entity entity : game.getEntitiesVector()) { if (entity.getOwner().equals(getLocalPlayer()) && (entity.getPosition() != null) && !entity.isOffBoard()) { result.add(entity); } } return result; }
/** * Um, basically everything can spot for LRM indirect fire. * * @return true, if the entity is active */ public boolean canSpot() { if (game.getOptions().booleanOption(OptionsConstants.ADVANCED_PILOTS_CANNOT_SPOT) && (this instanceof MechWarrior)) { return false; } return isActive() && !isOffBoard(); }
public List<Entity> getFriendEntities() { List<Entity> result = new ArrayList<>(); for (Entity entity : game.getEntitiesVector()) { if (!entity.getOwner().isEnemyOf(getLocalPlayer()) && (entity.getPosition() != null) && !entity.isOffBoard()) { result.add(entity); } } return result; }
/** * Determines if this Entity is eligible to pre-designate hexes as * auto-hits. Per TacOps pg 180, if a player has offboard artillery they get * 5 pre- designated hexes per mapsheet. * * @return */ public boolean isEligibleForArtyAutoHitHexes() { return isEligibleForTargetingPhase() && (isOffBoard() || game.getOptions().booleanOption( OptionsConstants.ADVCOMBAT_ON_MAP_PREDESIGNATE)); }
public List<Entity> getEnemyEntities() { ArrayList<Entity> result = new ArrayList<>(); for (Entity entity : game.getEntitiesVector()) { if (entity.getOwner().isEnemyOf(getLocalPlayer()) && (entity.getPosition() != null) && !entity.isOffBoard() && (entity.getCrew() != null) && !entity.getCrew().isDead()) { result.add(entity); } } return result; }
/** * Returns the number of non-destroyed entities owned by the player, * including entities not yet deployed. Ignore offboard units and captured * Mek pilots. */ public int getLiveDeployedEntitiesOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player) && !entity.isDestroyed() && !entity.isCarcass() && !entity.isOffBoard() && !entity.isCaptured()) { count++; } } return count; }
public boolean hasNavalC3() { if (isShutDown() || isOffBoard()) { return false; } for (Mounted m : getEquipment()) { if ((m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_NAVAL_C3) && !m.isInoperable()) { return true; } } return false; }
/** * Returns the elevation of this entity, relative to the current Hex's * surface */ @Override public int getElevation() { if (Entity.NONE != getTransportId()) { return game.getEntity(getTransportId()).getElevation(); } if ((null == getPosition()) && (isDeployed())) { throw new IllegalStateException("Entity #" + getId() + " does not know its position."); } if (isOffBoard()) { return 0; } return elevation; }
/** * Calculate an indirect artillery "fire plan", taking into account the possibility of rotating the turret. * @param shooter Entity doing the shooting * @param game Game pointer * @param owner Princess pointer * @return Firing plan */ public FiringPlan calculateIndirectArtilleryPlan(Entity shooter, IGame game, Princess owner) { FiringPlan bestPlan = calculateIndirectArtilleryPlan(shooter, game, owner, 0); // simply loop through all possible facings and see if any of those is better than the no-turning plan if(!shooter.isOffBoard()) { for(int facingChange : FireControl.getValidFacingChanges(shooter)) { FiringPlan twistPlan = calculateIndirectArtilleryPlan(shooter, game, owner, facingChange); if(twistPlan.getUtility() > bestPlan.getUtility()) { bestPlan = twistPlan; } } } return bestPlan; }
/** * Returns the number of non-destroyed deployed entities owned by the * player. Ignore offboard units and captured Mek pilots. */ public int getLiveCommandersOwnedBy(IPlayer player) { int count = 0; for (Entity entity : entities) { if (entity.getOwner().equals(player) && !entity.isDestroyed() && !entity.isCarcass() && entity.isCommander() && !entity.isOffBoard() && !entity.isCaptured()) { count++; } } return count; }
public boolean hasBoostedC3() { if (isShutDown() || isOffBoard()) { return false; } for (Mounted m : getEquipment()) { if ((m.getType().hasFlag(MiscType.F_C3SBS) || m.getType().hasFlag( WeaponType.F_C3MBS)) && !m.isInoperable()) { return true; } } return false; }
/** * Returns whether this 'mech has a C3 Slave or not. */ public boolean hasC3S() { if (isShutDown() || isOffBoard()) { return false; } for (Mounted m : getEquipment()) { if ((m.getType() instanceof MiscType) && (m.getType().hasFlag(MiscType.F_C3S) || m.getType() .hasFlag(MiscType.F_C3SBS)) && !m.isInoperable()) { return true; } } return false; }
/** * Checks if we have nova CEWS that is not offline. * * @return */ public boolean hasActiveNovaCEWS() { if (isShutDown() || isOffBoard()) { return false; } for (Mounted m : getEquipment()) { if ((m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_NOVA) && !m.isInoperable() && !m.curMode().equals("Off")) { return true; } } return false; }
public boolean isEligibleForOffboard() { // if you're charging, no shooting if (isUnjammingRAC() || isCharging() || isMakingDfa()) { return false; } // if you're offboard, no shooting if (isOffBoard() || isAssaultDropInProgress()) { return false; } for (Mounted mounted : getWeaponList()) { WeaponType wtype = (WeaponType) mounted.getType(); if ((wtype != null) && (wtype.hasFlag(WeaponType.F_TAG) && mounted.isReady())) { return true; } } return false;// only things w/ tag are }
public boolean hasC3i() { if (isShutDown() || isOffBoard()) { return false; } for (Mounted m : getEquipment()) { if ((m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_C3I) && !m.isInoperable()) { return true; } } // check for Manei Domini implants if ((this instanceof Infantry) && (null != crew) //Fix for Bug Report #1194 && hasAbility(OptionsConstants.MD_ENH_MM_IMPLANTS) && hasAbility(OptionsConstants.MD_BOOST_COMM_IMPLANT)) { return true; } return false; }
/** * Apply PSR modifier for difficult terrain at the specified coordinates * * @param roll the PSR to modify * @param c the coordinates where the PSR happens * @param enteringRubble True if entering rubble, else false */ public void addPilotingModifierForTerrain(PilotingRollData roll, Coords c, boolean enteringRubble) { if ((c == null) || (roll == null)) { return; } if (isOffBoard() || !(isDeployed())) { return; } IHex hex = game.getBoard().getHex(c); hex.terrainPilotingModifier(getMovementMode(), roll, enteringRubble); if (hex.containsTerrain(Terrains.JUNGLE) && hasAbility(OptionsConstants.PILOT_TM_FOREST_RANGER)) { roll.addModifier(-1, "Forest Ranger"); } }
/** * defensively check and correct elevation */ public boolean fixElevation() { if (!isDeployed() || isOffBoard() || !game.getBoard().contains(getPosition())) { return false; } if (!isElevationValid(getElevation(), game.getBoard().getHex(getPosition()))) { System.err.println(getDisplayName() + " in hex " + HexTarget.coordsToId(getPosition()) + " is at invalid elevation: " + getElevation()); setElevation(0 - game.getBoard() .getHex(getPosition()).depth()); System.err.println(" moved to elevation " + getElevation()); return true; } return false; }