/** * Tries to load the specified weapon with the specified ammo. Returns true * if successful, false otherwise. */ public boolean loadWeaponWithSameAmmo(Mounted mounted, Mounted mountedAmmo) { AmmoType atype = (AmmoType) mountedAmmo.getType(); Mounted oldammo = mounted.getLinked(); if ((oldammo != null) && (!((AmmoType) oldammo.getType()).equals(atype) || (((AmmoType) oldammo .getType()).getMunitionType() != atype .getMunitionType()))) { return false; } return loadWeapon(mounted, mountedAmmo); }
.getCampaignOptions().getTechLevel())) { cbMenuItem = new JCheckBoxMenuItem(atype.getDesc()); if (atype.equals(curType) && atype.getMunitionType() == curType.getMunitionType()) { cbMenuItem.setSelected(true);
@Override public boolean isSamePartType(Part part) { if (part instanceof AmmoStorage) { if (getType() instanceof BombType) { return ((EquipmentPart)part).getType() instanceof BombType && ((BombType)getType()).getBombType() == ((BombType)((EquipmentPart)part).getType()).getBombType(); } else { return ((AmmoType)getType()).getMunitionType() == ((AmmoType)((AmmoStorage)part).getType()).getMunitionType() && ((AmmoType)getType()).equals( (Object)((EquipmentPart)part).getType()); } } return false; }
if(aType.equals(curType) && curType.getMunitionType() == aType.getMunitionType()) { a = (AmmoStorage)part; if (amount < 0 && campaign.getCampaignOptions().useAmmoByType()
public void changeAmountAvailable(int amount, AmmoType curType) { AmmoStorage a = null; long curMunition = curType.getMunitionType(); for(Part part : campaign.getSpareParts()) { if(!part.isPresent()) { continue; } if(part instanceof AmmoStorage && ((AmmoType)((AmmoStorage)part).getType()).equals((Object)curType) && curMunition == ((AmmoType)((AmmoStorage)part).getType()).getMunitionType()) { a = (AmmoStorage)part; a.changeShots(amount); break; } } if(null != a && a.getShots() <= 0) { campaign.removePart(a); } else if(null == a && amount > 0) { campaign.addPart(new AmmoStorage(1,curType,amount,campaign), 0); } }
public int getAmountAvailable() { int amount = 0; AmmoStorage a = null; AmmoType aType = null; AmmoType thisType = null; for(Part part : campaign.getSpareParts()) { if(!part.isPresent()) { continue; } if(part instanceof AmmoStorage) { a = (AmmoStorage)part; aType = ((AmmoType)((AmmoStorage)a).getType()); thisType = ((AmmoType)getType()); if(aType.equals((Object)getType()) && thisType.getMunitionType() == aType.getMunitionType()) { amount += a.getShots(); if (!(campaign.getCampaignOptions().useAmmoByType())) { break; } } else if (isCompatibleAmmo(aType, thisType) && thisType.getRackSize() != 0) { amount += a.getShots()*aType.getRackSize()/thisType.getRackSize(); } } } return amount; }