/** * get the bay that ammo is associated with * * @param mammo * @return */ public Mounted getBayByAmmo(Mounted mammo) { for (Mounted m : getWeaponBayList()) { for (int bayAmmoId : m.getBayAmmo()) { Mounted bayammo = getEquipment(bayAmmoId); if (bayammo == mammo) { return m; } } } return null; }
public BayMunitionsChoicePanel(Entity entity, IGame game) { this.entity = entity; this.game = game; setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(10, 0, 10, 0); for (Mounted bay : entity.getWeaponBayList()) { Map<List<Integer>,List<Mounted>> ammoByType = new HashMap<>(); for (Integer aNum : bay.getBayAmmo()) { final Mounted ammo = entity.getEquipment(aNum); if ((null != ammo) && (ammo.getType() instanceof AmmoType)) { AmmoType atype = (AmmoType) ammo.getType(); List<Integer> key = new ArrayList<>(2); key.add(atype.getAmmoType()); key.add(atype.getRackSize()); ammoByType.putIfAbsent(key, new ArrayList<>()); ammoByType.get(key).add(ammo); } } for (List<Integer> key : ammoByType.keySet()) { AmmoRowPanel row = new AmmoRowPanel(bay, key.get(0), key.get(1), ammoByType.get(key)); gbc.gridy++; add(row, gbc); rows.add(row); } } }
/** * @return The <code>Mounted</code> of the unit's <code>Entity</code> that contains this ammo bin, * or null if there is no unit or the ammo bin is not in any bay. */ public @Nullable Mounted getBay() { final String METHOD_NAME = "getBay()"; //$NON-NLS-1$ if ((null != bay) || (null == unit)) { return null; } if (bayEqNum >= 0) { Mounted m = unit.getEntity().getEquipment(bayEqNum); if (m.getBayAmmo().contains(equipmentNum)) { bay = m; return bay; } } for (Mounted m : unit.getEntity().getWeaponBayList()) { if (m.getBayAmmo().contains(equipmentNum)) { return m; } } MekHQ.getLogger().log(LargeCraftAmmoBin.class, METHOD_NAME, LogLevel.WARNING, "Could not find weapon bay for " + typeName + " for " + unit.getName()); return null; }
/** * @return The <code>Mounted</code> of the unit's <code>Entity</code> that contains this ammo bin, * or null if there is no unit or the ammo bin is not in any bay. */ public @Nullable Mounted getBay() { final String METHOD_NAME = "getBay()"; //$NON-NLS-1$ if ((null != bay) || (null == unit)) { return null; } if (bayEqNum >= 0) { Mounted m = unit.getEntity().getEquipment(bayEqNum); if (m.getBayAmmo().contains(equipmentNum)) { bay = m; return bay; } } for (Mounted m : unit.getEntity().getWeaponBayList()) { if (m.getBayAmmo().contains(equipmentNum)) { return m; } } MekHQ.getLogger().log(LargeCraftAmmoBin.class, METHOD_NAME, LogLevel.WARNING, "Could not find weapon bay for " + typeName + " for " + unit.getName()); return null; }
final int multiplier = ((WeaponType) bay.getType()).isCapital() ? 10 : 1; EquipmentType linker = null; final Map<AmmoType, Integer> shotsByAmmoType = bay.getBayAmmo().stream().map(num -> aero.getEquipment(num)) .collect(Collectors.groupingBy(m -> (AmmoType) m.getType(), Collectors.summingInt(Mounted::getBaseShotsLeft)));
@Override public StringBuffer printWeapon() { if (!getEntity().usesWeaponBays()) { return super.printWeapon(); } StringBuffer buffer = new StringBuffer(); for (Mounted m : getEntity().getWeaponBayList()) { buffer.append(m.getName()).append(" ") .append(getLocationAbbr(m.getLocation())); if (m.isRearMounted()) { buffer.append(" (R)"); } buffer.append("\n"); for (Integer wNum : m.getBayWeapons()) { final Mounted w = getEntity().getEquipment(wNum); buffer.append(" ").append(StringUtil.makeLength(w.getName(), getPrintSize() - 25)).append(w.getType().getTonnage(getEntity())) .append("\n"); } for (Integer aNum : m.getBayAmmo()) { final Mounted a = getEntity().getEquipment(aNum); double weight = a.getType().getTonnage(getEntity()) * a.getBaseShotsLeft() / ((AmmoType)a.getType()).getShots(); buffer.append(" ").append(StringUtil.makeLength(a.getName(), getPrintSize() - 25)).append(weight).append("\n"); } } return buffer; }
for (Integer aNum : bay.getBayAmmo()) { final Mounted a = vessel.getEquipment(aNum); if (a.getType() instanceof AmmoType) {
@Override public StringBuffer printWeapon() { if (!getEntity().usesWeaponBays()) { return super.printWeapon(); } StringBuffer buffer = new StringBuffer(); for (Mounted m : getEntity().getWeaponBayList()) { buffer.append(m.getName()).append(" ") .append(getLocationAbbr(m.getLocation())); if (m.isRearMounted()) { buffer.append(" (R)"); } buffer.append("\n"); for (Integer wNum : m.getBayWeapons()) { final Mounted w = getEntity().getEquipment(wNum); buffer.append(" ").append(StringUtil.makeLength(w.getName(), getPrintSize() - 25)).append(w.getType().getTonnage(getEntity())) .append("\n"); } for (Integer aNum : m.getBayAmmo()) { final Mounted a = getEntity().getEquipment(aNum); double weight = ceil(a.getType().getTonnage(getEntity()) * a.getBaseShotsLeft() / ((AmmoType)a.getType()).getShots(), Ceil.HALFTON); buffer.append(" ").append(StringUtil.makeLength(a.getName(), getPrintSize() - 25)).append(weight).append("\n"); } } return buffer; }
for (Integer aNum : bay.getBayAmmo()) { final Mounted a = smallCraft.getEquipment(aNum); if (a.getType() instanceof AmmoType) {
slot.getMount().getBayAmmo().size() > 0) { baySlotMap.put(slot.getMount(), loop + 1);
for(int aId : mounted.getBayAmmo()) { Mounted m = entity.getEquipment(aId); if(null == m) {
for (Integer aNum : m.getBayAmmo()) { Mounted a = t.getEquipment(aNum); String name = a.getType().getInternalName();