public void removeWeapon(String toRemove) { for (Mounted mounted : getMisc()) { if (mounted.getName().equals(toRemove)) { weaponList.remove(mounted); equipmentList.remove(mounted); break; } } }
/** * Removes the first misc eq. whose name equals the specified string. Used * for removing broken tree clubs. */ public void removeMisc(String toRemove) { for (Mounted mounted : getMisc()) { if (mounted.getName().equals(toRemove)) { miscList.remove(mounted); equipmentList.remove(mounted); break; } } }
public List<Mounted> getClubs() { List<Mounted> rv = new ArrayList<Mounted>(); for (Mounted m : getMisc()) { if (m.getType().hasFlag(MiscType.F_CLUB)) { rv.add(m); } } return rv; }
/** * Have to make one here because the one in MegaMek only returns true if * operable * * @return */ public boolean hasTSM() { for (Mounted mEquip : entity.getMisc()) { MiscType mtype = (MiscType) mEquip.getType(); if (null != mtype && mtype.hasFlag(MiscType.F_TSM)) { return true; } } return false; }
private void setupMines() { GridBagLayout gbl = new GridBagLayout(); panMines.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); int row = 0; for (Mounted m : entity.getMisc()) { if (!m.getType().hasFlag((MiscType.F_MINE)) && !m.getType().hasFlag((MiscType.F_VEHICLE_MINE_DISPENSER))) { continue; } gbc.gridy = row++; MineChoicePanel mcp = new MineChoicePanel(m); gbl.setConstraints(mcp, gbc); panMines.add(mcp); m_vMines.add(mcp); } }
public void deactivateRadicalHS() { for (Mounted m : getMisc()) { if (m.getType().hasFlag(MiscType.F_RADICAL_HEATSINK)) { m.setMode("Off"); // Can only have one radical heat sink break; } } }
/** * Returns the number of destroyed jump jets. */ public int damagedJumpJets() { int jumpJets = 0; for (Mounted mounted : getMisc()) { EquipmentType etype = mounted.getType(); if (!mounted.isDestroyed()) { continue; } if (etype.hasFlag(MiscType.F_JUMP_JET)) { jumpJets++; } } return jumpJets; }
/** * Returns true if the unit has a usable spotlight. It considers both * externally mounted spotlights as well as internally mounted ones. * * @return */ public boolean hasSpotlight() { for (Mounted m : getMisc()) { if (m.getType().hasFlag(MiscType.F_SEARCHLIGHT) && !m.isInoperable()) { return true; } } return hasExternalSpotlight; }
public boolean hasActivatedRadicalHS() { for (Mounted m : getMisc()) { if (m.getType().hasFlag(MiscType.F_RADICAL_HEATSINK) && m.curMode().equals("On")) { return true; } } return false; }
/** * Returns wether or not this entity has a Targeting Computer. */ public boolean hasTargComp() { for (Mounted m : getMisc()) { if ((m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_TARGCOMP)) { return !m.isInoperable(); } } return false; }
/** * get a supercharger mounted on this mech * * @return */ public Mounted getSuperCharger() { for (Mounted m : getMisc()) { MiscType mtype = (MiscType) m.getType(); if (mtype.hasFlag(MiscType.F_MASC) && m.isReady() && mtype.hasSubType(MiscType.S_SUPERCHARGER)) { return m; } } return null; }
private JMenu createRotateTurretMenu() { JMenu menu = new JMenu(); menu.setText("Turret Rotation"); if (myEntity instanceof Mech) { for (Mounted mount : myEntity.getMisc()) { if (mount.getType().hasFlag(MiscType.F_SHOULDER_TURRET) || mount.getType().hasFlag(MiscType.F_HEAD_TURRET) || mount.getType().hasFlag(MiscType.F_QUAD_TURRET)) { menu.add(createRotateTurretJMenuItem((Mech) myEntity, mount)); } } } return menu; }
/** * Returns whether there is CASE protecting the location. */ public boolean locationHasCase(int loc) { for (Mounted mounted : getMisc()) { if ((mounted.getLocation() == loc) && mounted.getType().hasFlag(MiscType.F_CASE)|(mounted.getType().hasFlag(MiscType.F_CASEP))) { return true; } } return false; }
/** * Does this entity have an undamaged HarJel system in this location? * (Type-dependent, defaults to false.) * Does not include Harjel II or Harjel III, as they do not prevent breach * checks like Harjel does. * * @param location the <code>int</code> location to check * @return a <code>boolean</code> value indicating a present HarJel system */ public boolean hasHarJelIn(int location) { for (Mounted mounted : getMisc()) { if ((mounted.getLocation() == location) && mounted.isReady() && (mounted.getType().hasFlag(MiscType.F_HARJEL))) { return true; } } return false; }
@Override public StringBuffer printMiscEquip(StringBuffer buff, int posLoc, int posWeight) { for (Mounted m : getEntity().getMisc()) { MiscType mt = (MiscType) m.getType(); buff.append(StringUtil.makeLength(mt.getName(), 20)); buff.append( StringUtil.makeLength(getLocationAbbr(m.getLocation()), getPrintSize() - 5 - 20)).append( TestEntity.makeWeightString(round(mt.getTonnage(getEntity()), Ceil.KILO))); buff.append("\n"); } return buff; }
/** * Returns whether there is CASE anywhere on this {@code Entity}. */ public boolean hasCase() { // Clan Mechs always have CASE! if (isClan()) { return true; } for (Mounted mounted : getMisc()) { if (mounted.getType().hasFlag(MiscType.F_CASE)||(mounted.getType().hasFlag(MiscType.F_CASEP)) ) { return true; } } return false; }
/** * get non-supercharger MASC mounted on this entity * * @return */ public Mounted getMASC() { for (Mounted m : getMisc()) { MiscType mtype = (MiscType) m.getType(); if (mtype.hasFlag(MiscType.F_MASC) && m.isReady() && !mtype.hasSubType(MiscType.S_SUPERCHARGER) && !mtype.hasSubType(MiscType.S_JETBOOSTER)) { return m; } } return null; }
public int countWorkingMisc(BigInteger flag, int location) { int count = 0; OUTER: for (Mounted m : getMisc()) { if (!m.isInoperable() && m.getType().hasFlag(flag) && ((location == -1) || (m.getLocation() == location))) { if (m.getType().hasModes()) { for (Enumeration<EquipmentMode> e = m.getType().getModes(); e.hasMoreElements();) { if (e.nextElement().equals("On") && !m.curMode().equals("On")) { continue OUTER; } } } count++; } } return count; }
/** * @return the initiative bonus this Entity grants for HQ */ public int getHQIniBonus() { int bonus = 0; for (Mounted misc : getMisc()) { if (misc.getType().hasFlag(MiscType.F_COMMUNICATIONS) && misc.curMode().equals("Default") && !misc.isInoperable()) { if (getTotalCommGearTons() >= 3) { bonus += 1; } if (getTotalCommGearTons() >= 7) { bonus += 1; } break; } } return bonus; }
private boolean isModular() { if(null == unit) { return false; } for (Mounted m : unit.getEntity().getMisc()){ if (m.getType() instanceof MiscType && m.getType().hasFlag(MiscType.F_BA_MEA) && type instanceof MiscType && type.hasFlag(MiscType.F_BA_MANIPULATOR) && this.getBaMountLocation()== m.getBaMountLoc()){ return true; } /*if (type instanceof InfantryWeapon && m.getType() instanceof MiscType && m.getType().hasFlag(MiscType.F_AP_MOUNT) && this.getBaMountLocation()== m.getBaMountLoc()){ return true; }*/ } return false; }