String nodeName = currNode.getNodeName(); if (nodeName.equalsIgnoreCase(BOMB)){ int[] bombChoices = ((IBomber) entity).getBombChoices(); String type = currEle.getAttribute(TYPE); String load = currEle.getAttribute(LOAD); ((IBomber) entity).setBombChoices(bombChoices);
@Override public void applyBombs() { // Make sure all of the aeros have their bombs applied, otherwise // problems // once the bombs are applied, the choices are cleared, so it's not an // issue if the bombs are applied twice for an Aero for (Integer fId : fighters) { IBomber fighter = (IBomber) game.getEntity(fId); fighter.applyBombs(); } computeSquadronBombLoadout(); }
/** * Fighters and VTOLs can carry any size bomb up to the maximum number of points, but LAMs are limited * to the number of bays in a single location. * * @return The largest single bomb that can be carried */ default int getMaxBombSize() { return getMaxBombPoints(); }
List<Mounted> mountedBombs = bomber.getBombs(); if (mountedBombs.size() > 0) { int[] bombChoices = bomber.getBombChoices(); for (Mounted m : mountedBombs) { if (!(m.getType() instanceof BombType)) { bomber.setBombChoices(bombChoices); bomber.clearBombs();
@SuppressWarnings("unchecked") private void initPanel() { maxPoints = bomber.getMaxBombPoints(); maxSize = bomber.getMaxBombSize(); int[] bombChoices = bomber.getBombChoices(); curBombPoints += bombChoices[i] * BombType.getBombCost(i); int availBombPoints = bomber.getMaxBombPoints() - curBombPoints;
IBomber b = (IBomber)entity; int[] bombChoices = new int[BombType.B_NUM]; bombChoices = b.getBombChoices(); if (bombChoices.length > 0) { output.write(indentStr(indentLvl+1) + "<bombs>"); for (Mounted m : b.getBombs()) { if (!(m.getType() instanceof BombType)) { continue;
for (int i = 0; i < getBombChoices()[type]; i++) { int loc = availableBombLocation(BombType.bombCosts[type]); if ((type == BombType.B_ALAMO) && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_AT2_NUKES)) { clearBombChoices();
private List<ViewElement> getBombs() { List<ViewElement> retVal = new ArrayList<>(); IBomber b = (IBomber) entity; int[] choices = b.getBombChoices(); for (int type = 0; type < BombType.B_NUM; type++) { if (choices[type] > 0) { retVal.add(new SingleLine(BombType.getBombName(type) + " (" + choices[type] + ")")); } } return retVal; }
public void applyChoice() { int[] choices = new int[BombType.B_NUM]; for (int type = 0; type < BombType.B_NUM; type++) { choices[type] = b_choices[type].getSelectedIndex(); } bomber.setBombChoices(choices); } public int[] getChoice() {
/** * @return The number of points taken up by all mounted bombs or other external stores. */ default int getBombPoints() { int points = 0; for (Mounted bomb : getBombs()) { if (bomb.getUsableShotsLeft() > 0) { points += BombType.getBombCost(((BombType) bomb.getType()).getBombType()); } } return points; }
private void updateBombButton() { MoveStep lastStep = cmd.getLastStep(); if ((lastStep == null) && !ce().isAirborneVTOLorWIGE()) { setBombEnabled(false); return; } if (lastStep != null && lastStep.getClearance() <= 0) { setBombEnabled(false); return; } if (ce().isBomber() && ((ce() instanceof LandAirMech) || clientgui.getClient().getGame().getOptions() .booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_VTOL_ATTACKS)) && ((IBomber)ce()).getBombPoints() > 0) { setBombEnabled(true); } }
private static String getBombChoiceString(IBomber bomber, int indentLvl) { String retVal = ""; int[] bombChoices = bomber.getBombChoices(); if (bombChoices.length > 0) { retVal += MekHqXmlUtil.indentStr(indentLvl+1) + "<bombs>\n"; for (int type = 0; type < BombType.B_NUM; type++) { if (bombChoices[type] > 0) { String typeName = BombType.getBombInternalName(type); retVal += MekHqXmlUtil.indentStr(indentLvl+2) + "<bomb type=\""; retVal += typeName; retVal += "\" load=\""; retVal += String.valueOf(bombChoices[type]); retVal += "\"/>\n"; } } retVal += MekHqXmlUtil.indentStr(indentLvl+1) + "</bombs>\n"; } return retVal; }
@Override public void setBombChoices(int[] bc) { // Set the bombs for the squadron if (bc.length == bombChoices.length) { bombChoices = bc; } // Update each fighter in the squadron for (Integer fId : fighters) { IBomber fighter = (IBomber) game.getEntity(fId); fighter.setBombChoices(bc); } }
public BombsDialog(IBomber iBomber, Campaign campaign, JFrame parent) { super(parent, "Select Bombs", true); this.bomber = iBomber; this.campaign = campaign; bombChoices = bomber.getBombChoices(); initGUI(); validate(); pack(); setLocationRelativeTo(parent); }
/** * Helper function that makes some of the units in the given list of entities * carry bombs. * @param entityList The list of entities to process * @param campaign Campaign object. In the future, may be used to check list of bombs * for technological availability. */ private static void populateAeroBombs(List<Entity> entityList, Campaign campaign) { int maxBombers = Compute.randomInt(entityList.size()) + 1; int numBombers = 0; for(Entity entity : entityList) { if(numBombers >= maxBombers) { break; } if(entity.isBomber()) { int[] bombChoices = new int[BombType.B_NUM]; int numBombs = (int) (entity.getWeight() / 5); int bombIndex = validBotBombs[(Compute.randomInt(validBotBombs.length))]; bombChoices[bombIndex] = numBombs; ((megamek.common.IBomber) entity).setBombChoices(bombChoices); numBombers++; } } }
entity.setUnloaded(true); if (entity instanceof IBomber) { ((IBomber)entity).applyBombs();
if (numLoadedBombs > ((IBomber)loadee).getMaxBombPoints()) { JOptionPane.showMessageDialog(clientgui.frame, Messages.getString("FighterSquadron.bomberror"), Messages.getString("FighterSquadron.error"), JOptionPane.ERROR_MESSAGE);