public int getCustomWeaponOrder(Mounted weapon) { int eqId = getEquipmentNum(weapon); if (customWeapOrder == null) { return eqId; } Integer order = customWeapOrder.get(eqId); if (order == null) { return -1; } else { return order; } }
/** * Get the id of the mine the player wants to use. * * @return the <code>int</code> id of the mine to lay */ public int getMine() { Mounted mine = vMines.get(chMines.getSelectedIndex()); return entity.getEquipmentNum(mine); } }
/** * Returns the equipment ID number for the weapon currently selected */ public int getSelectedWeaponNum() { int selected = weaponList.getSelectedIndex(); if (selected == -1) { return -1; } return entity.getEquipmentNum(((WeaponListModel) weaponList .getModel()).getWeaponAt(selected)); }
public MechDisplayEvent(Object source, Entity entity, Mounted weapon) { super(source); this.entity = entity; this.entityId = entity.getId(); this.type = WEAPON_SELECTED; this.equip = weapon; this.weaponId = entity.getEquipmentNum(weapon); }
/** * Sets the bay for this ammo bin. Does not check whether the ammo bin is actually in the bay. * @param bay */ public void setBay(Mounted bay) { if (null != unit) { bayEqNum = unit.getEntity().getEquipmentNum(bay); this.bay = bay; } }
public int compare(Mounted obj1, Mounted obj2) { if (obj1.getType() instanceof WeaponType && obj2.getType() instanceof WeaponType) { int weapNum1 = entity.getEquipmentNum(obj1); int weapNum2 = entity.getEquipmentNum(obj2); return weapNum1 - weapNum2; } throw new ClassCastException("Passed Mounteds are not Weapons"); } }
public void setCustomWeaponOrder(Mounted weapon, int order) { setWeapOrderChanged(true); int eqId = getEquipmentNum(weapon); if (eqId == -1) { return; } customWeapOrder.put(eqId, order); }
/** * Sets the bay for this ammo bin. Does not check whether the ammo bin is actually in the bay. * @param bay */ public void setBay(Mounted bay) { if (null != unit) { bayEqNum = unit.getEntity().getEquipmentNum(bay); this.bay = bay; } }
public void setWeaponSortOrder(WeaponSortOrder weaponSortOrder) { if (weaponSortOrder != this.weaponSortOrder) { setWeapOrderChanged(true); } // If sort mode is custom, and the custom order is null, create it // and make the order the same as default (based on eqId) if ((weaponSortOrder == WeaponSortOrder.CUSTOM) && (customWeapOrder == null)) { customWeapOrder = new HashMap<Integer, Integer>(); for (Mounted weap : weaponList) { int eqId = getEquipmentNum(weap); customWeapOrder.put(eqId, eqId); } } this.weaponSortOrder = weaponSortOrder; }
public int getNextWeaponNum() { int selected = getNextWeaponListIdx(); if ((selected >= 0) && (selected < entity.getWeaponList().size())) { return entity.getEquipmentNum(((WeaponListModel) weaponList .getModel()).getWeaponAt(selected)); } else { return -1; } }
/** * Selects the next valid weapon in the weapon list. * * @return The weaponId for the selected weapon */ public int selectNextWeapon() { int selected = getNextWeaponListIdx(); weaponList.setSelectedIndex(selected); weaponList.ensureIndexIsVisible(selected); if ((selected >= 0) && (selected < entity.getWeaponList().size())) { return entity.getEquipmentNum(((WeaponListModel) weaponList .getModel()).getWeaponAt(selected)); } else { return -1; } }
/** * Selects the prevous valid weapon in the weapon list. * * @return The weaponId for the selected weapon */ public int selectPrevWeapon() { int selected = getPrevWeaponListIdx(); weaponList.setSelectedIndex(selected); weaponList.ensureIndexIsVisible(selected); if ((selected >= 0) && (selected < entity.getWeaponList().size())) { return entity.getEquipmentNum(((WeaponListModel) weaponList .getModel()).getWeaponAt(selected)); } else { return -1; } }
private void initGUI() { //Set up the megamek QuirksPanel. for (Mounted m : entity.getWeaponList()) { h_wpnQuirks.put(entity.getEquipmentNum(m), m.getQuirks()); } qpanel = new QuirksPanel(entity, entity.getQuirks(), true, this, h_wpnQuirks); qpanel.refreshQuirks(); //Set up the display of this dialog. JScrollPane scroller = new JScrollPane(qpanel); scroller.setPreferredSize(new Dimension(300,200)); setLayout(new BorderLayout()); add(scroller, BorderLayout.CENTER); add(buildButtonPanel(), BorderLayout.SOUTH); }
/** * handle this weapons firing * * @return a <code>boolean</code> value indicating wether this should be * kept or not */ @Override public boolean handle(IGame.Phase phase, Vector<Report> vPhaseReport) { // just launch the tele-missile server.deployTeleMissile(ae, wtype, getBayAmmoType(), ae.getEquipmentNum(weapon), getCapMisMod(), calcBayDamageAndHeat(), missileArmor, vPhaseReport); return false; }
/** * Worker function that selects the appropriate ammo for the given entity and weapon. * @param shooter * @param currentWeapon * @param game * @return */ private int findAmmo(Entity shooter, Mounted currentWeapon, IGame game) { int ammoEquipmentNum = NO_AMMO; // simply grab the first valid ammo and let 'er rip. for(Mounted ammo : shooter.getAmmo()) { if(!ammo.isAmmoUsable() || !AmmoType.isAmmoValid(ammo, (WeaponType) currentWeapon.getType())) { continue; } ammoEquipmentNum = shooter.getEquipmentNum(ammo); break; // TODO: Attempt to select homing ammo if the target is tagged. // To do so, check ammoType.getMunitionType() == AmmoType.M_HOMING } return ammoEquipmentNum; }
/** * Worker function that takes an entity, a location, an ammo type string and the critical index * of a weapons bay in the given location and attempts to add the ammo type there. * @param entity The entity we're working on loading * @param loc The location index on the entity * @param type The ammo type string * @param bayIndex The crit index of the bay where we want to load the ammo on the location where the bay is * @return A generated critical slot entry */ private void addExtraAmmoToBay(Entity entity, int loc, String type, String bayIndex) { // here, we need to do the following: // 1: get the bay to which this ammo belongs, and add it to said bay // 2: add the ammo to the entity as a "new" piece of equipment // 3: add the ammo to a crit slot on the bay's location int bayCritIndex = Integer.parseInt(bayIndex); Mounted bay = entity.getCritical(loc, bayCritIndex - 1).getMount(); Mounted ammo = new Mounted(entity, AmmoType.get(type)); try { entity.addEquipment(ammo, loc, bay.isRearMounted()); } catch(LocationFullException lfe) { // silently swallow it, since dropship locations have about a hundred crit slots } bay.addAmmoToBay(entity.getEquipmentNum(ammo)); }
@Override public void updateConditionFromPart() { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { mounted.setHit(true); mounted.setDestroyed(true); mounted.setRepairable(false); unit.destroySystem(CriticalSlot.TYPE_EQUIPMENT, unit.getEntity().getEquipmentNum(mounted)); } } }
public boolean hasLinkedMGA(Mounted mounted) { for (Mounted m : getWeaponList()) { if ((m.getLocation() == mounted.getLocation()) && m.getType().hasFlag(WeaponType.F_MGA) && !(m.isDestroyed() || m.isBreached()) && m.getBayWeapons().contains(getEquipmentNum(mounted)) && m.getType().hasModes() && m.curMode().equals("Linked")) { return true; } } return false; }
private WeaponAttackAction buildBombAttackAction(final int[] bombPayload) { final WeaponAttackAction diveBomb = new WeaponAttackAction(getShooter().getId(), getTarget().getTargetType(), getTarget().getTargetId(), getShooter().getEquipmentNum(getWeapon())); diveBomb.setBombPayload(bombPayload); return diveBomb; }
WeaponAttackAction buildWeaponAttackAction() { if (!getWeapon().getType().hasFlag(WeaponType.F_ARTILLERY)) { return new WeaponAttackAction(getShooter().getId(), getTarget().getTargetType(), getTarget().getTargetId(), getShooter().getEquipmentNum(getWeapon())); } else { return new ArtilleryAttackAction(getShooter().getId(), getTarget().getTargetType(), getTarget().getTargetId(), getShooter().getEquipmentNum(getWeapon()), getGame()); } }