Search in sources :

Example 36 with EquipmentType

use of megamek.common.EquipmentType in project megameklab by MegaMek.

the class EquipmentTab method loadEquipmentTable.

private void loadEquipmentTable() {
    for (Mounted mount : getMech().getWeaponList()) {
        equipmentList.addCrit(mount);
    }
    for (Mounted mount : getMech().getAmmo()) {
        equipmentList.addCrit(mount);
    }
    List<EquipmentType> spreadAlreadyAdded = new ArrayList<EquipmentType>();
    for (Mounted mount : getMech().getMisc()) {
        EquipmentType etype = mount.getType();
        if (UnitUtil.isHeatSink(mount) || etype.hasFlag(MiscType.F_JUMP_JET) || etype.hasFlag(MiscType.F_JUMP_BOOSTER) || etype.hasFlag(MiscType.F_TSM) || etype.hasFlag(MiscType.F_INDUSTRIAL_TSM) || (etype.hasFlag(MiscType.F_MASC) && !etype.hasSubType(MiscType.S_SUPERCHARGER)) || ((getMech().getEntityType() & Entity.ETYPE_QUADVEE) == Entity.ETYPE_QUADVEE && etype.hasFlag(MiscType.F_TRACKS)) || UnitUtil.isArmorOrStructure(etype)) {
            continue;
        }
        // if (UnitUtil.isUnitEquipment(mount.getType(), unit) || UnitUtil.isUn) {
        if (UnitUtil.isFixedLocationSpreadEquipment(etype) && !spreadAlreadyAdded.contains(etype)) {
            equipmentList.addCrit(mount);
            // keep track of spreadable equipment here, so it doesn't
            // show up multiple times in the table
            spreadAlreadyAdded.add(etype);
        } else {
            equipmentList.addCrit(mount);
        }
    // }
    }
}
Also used : Mounted(megamek.common.Mounted) ArrayList(java.util.ArrayList) EquipmentType(megamek.common.EquipmentType)

Example 37 with EquipmentType

use of megamek.common.EquipmentType in project megameklab by MegaMek.

the class EquipmentTab method actionPerformed.

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(ADD_COMMAND)) {
        int view = masterEquipmentTable.getSelectedRow();
        if (view < 0) {
            // selection got filtered away
            return;
        }
        int selected = masterEquipmentTable.convertRowIndexToModel(view);
        EquipmentType equip = masterEquipmentList.getType(selected);
        addEquipment(equip);
    } else if (e.getActionCommand().equals(REMOVE_COMMAND)) {
        int[] selectedRows = equipmentTable.getSelectedRows();
        for (Integer row : selectedRows) {
            equipmentList.removeMounted(row);
        }
        equipmentList.removeCrits(selectedRows);
    } else if (e.getActionCommand().equals(REMOVEALL_COMMAND)) {
        removeAllEquipment();
    } else {
        return;
    }
    fireTableRefresh();
}
Also used : EquipmentType(megamek.common.EquipmentType)

Example 38 with EquipmentType

use of megamek.common.EquipmentType in project megameklab by MegaMek.

the class StructureTab method createArmorMountsAndSetArmorType.

private void createArmorMountsAndSetArmorType(int at, int aTechLevel) {
    getMech().setArmorTechLevel(aTechLevel);
    getMech().setArmorType(at);
    final EquipmentType armor = EquipmentType.get(EquipmentType.getArmorTypeName(at, TechConstants.isClan(aTechLevel)));
    int armorCount = armor.getCriticals(getMech());
    if (armorCount < 1) {
        return;
    }
    // auto-place stealth crits
    if (getMech().getArmorType(0) == EquipmentType.T_ARMOR_STEALTH) {
        Mounted mount = UnitUtil.createSpreadMounts(getMech(), EquipmentType.get(EquipmentType.getArmorTypeName(getMech().getArmorType(0), false)));
        if (mount == null) {
            JOptionPane.showMessageDialog(null, "Stealth Armor does not fit in location.", "Resetting to Standard Armor", JOptionPane.INFORMATION_MESSAGE);
            getMech().setArmorType(EquipmentType.T_ARMOR_STANDARD);
            getMech().setArmorTechLevel(TechConstants.T_INTRO_BOXSET);
            panArmor.setFromEntity(getMech());
        }
    } else {
        for (; armorCount > 0; armorCount--) {
            try {
                getMech().addEquipment(new Mounted(getMech(), armor), Entity.LOC_NONE, false);
            } catch (Exception ex) {
            }
        }
    }
}
Also used : Mounted(megamek.common.Mounted) EquipmentType(megamek.common.EquipmentType) EntityLoadingException(megamek.common.loaders.EntityLoadingException) LocationFullException(megamek.common.LocationFullException)

Example 39 with EquipmentType

use of megamek.common.EquipmentType in project megameklab by MegaMek.

the class SummaryView method runThroughEquipment.

private void runThroughEquipment(TestMech testMech) {
    double weightJJ = 0.0f;
    double weightEnhance = 0.0f;
    double weightEquip = 0.0f;
    int critJJ = 0;
    int critEquip = 0;
    int critEnhance = 0;
    for (Mounted m : getMech().getMisc()) {
        MiscType mt = (MiscType) m.getType();
        if (UnitUtil.isArmorOrStructure(mt)) {
            continue;
        } else if (mt.hasFlag(MiscType.F_TSM) || mt.hasFlag(MiscType.F_INDUSTRIAL_TSM) || mt.hasFlag(MiscType.F_MASC)) {
            weightEnhance += mt.getTonnage(getMech(), m.getLocation());
            critEnhance += UnitUtil.getCritsUsed(getMech(), mt);
        } else if (mt.hasFlag(MiscType.F_JUMP_JET) || mt.hasFlag(MiscType.F_JUMP_BOOSTER)) {
            weightJJ += mt.getTonnage(getMech(), m.getLocation());
            critJJ += mt.getCriticals(getMech());
        } else if (mt.hasFlag(MiscType.F_HEAT_SINK) || mt.hasFlag(MiscType.F_DOUBLE_HEAT_SINK)) {
            continue;
        } else {
            weightEquip += mt.getTonnage(getMech(), m.getLocation());
            critEquip += mt.getCriticals(getMech());
        }
    }
    for (Mounted m : getMech().getWeaponList()) {
        EquipmentType et = m.getType();
        weightEquip += et.getTonnage(getMech());
        critEquip += et.getCriticals(getMech());
    }
    for (Mounted m : getMech().getAmmo()) {
        EquipmentType et = m.getType();
        weightEquip += et.getTonnage(getMech());
        critEquip += et.getCriticals(getMech());
    }
    txtJumpTon.setText(Double.toString(weightJJ));
    txtEnhanceTon.setText(Double.toString(weightEnhance));
    txtEquipTon.setText(Double.toString(weightEquip));
    txtJumpCrit.setText(Integer.toString(critJJ));
    txtEnhanceCrit.setText(Integer.toString(critEnhance));
    txtEquipCrit.setText(Integer.toString(critEquip));
}
Also used : Mounted(megamek.common.Mounted) MiscType(megamek.common.MiscType) EquipmentType(megamek.common.EquipmentType)

Example 40 with EquipmentType

use of megamek.common.EquipmentType in project megameklab by MegaMek.

the class EquipmentTab method loadEquipmentTable.

private void loadEquipmentTable() {
    // On this table we want to show individual weapons, not bays.
    for (Mounted mount : getAero().getTotalWeaponList()) {
        if ((mount.getType() instanceof BayWeapon) || mount.isWeaponGroup()) {
            continue;
        }
        equipmentList.addCrit(mount);
    }
    for (Mounted mount : getAero().getAmmo()) {
        equipmentList.addCrit(mount);
    }
    List<EquipmentType> spreadAlreadyAdded = new ArrayList<EquipmentType>();
    for (Mounted mount : getAero().getMisc()) {
        EquipmentType etype = mount.getType();
        if (UnitUtil.isHeatSink(mount) || etype.hasFlag(MiscType.F_JUMP_JET) || etype.hasFlag(MiscType.F_JUMP_BOOSTER) || etype.hasFlag(MiscType.F_TSM) || etype.hasFlag(MiscType.F_INDUSTRIAL_TSM) || (etype.hasFlag(MiscType.F_MASC) && !etype.hasSubType(MiscType.S_SUPERCHARGER)) || UnitUtil.isArmorOrStructure(etype)) {
            continue;
        }
        // if (UnitUtil.isUnitEquipment(mount.getType(), unit) || UnitUtil.isUn) {
        if (UnitUtil.isFixedLocationSpreadEquipment(etype) && !spreadAlreadyAdded.contains(etype)) {
            equipmentList.addCrit(mount);
            // keep track of spreadable equipment here, so it doesn't
            // show up multiple times in the table
            spreadAlreadyAdded.add(etype);
        } else {
            equipmentList.addCrit(mount);
        }
    // }
    }
}
Also used : Mounted(megamek.common.Mounted) ArrayList(java.util.ArrayList) BayWeapon(megamek.common.weapons.bayweapons.BayWeapon) EquipmentType(megamek.common.EquipmentType)

Aggregations

EquipmentType (megamek.common.EquipmentType)49 Mounted (megamek.common.Mounted)24 MiscType (megamek.common.MiscType)14 LocationFullException (megamek.common.LocationFullException)10 ArrayList (java.util.ArrayList)8 JLabel (javax.swing.JLabel)6 AmmoType (megamek.common.AmmoType)6 CriticalSlot (megamek.common.CriticalSlot)6 WeaponType (megamek.common.WeaponType)5 Dimension (java.awt.Dimension)4 List (java.util.List)4 Vector (java.util.Vector)4 BattleArmor (megamek.common.BattleArmor)4 Mech (megamek.common.Mech)4 EntitySource (megameklab.com.ui.EntitySource)4 RefreshListener (megameklab.com.util.RefreshListener)4 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3 ActionEvent (java.awt.event.ActionEvent)3 StringJoiner (java.util.StringJoiner)3