Search in sources :

Example 91 with Mounted

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

the class AbstractEquipmentTab method removeHeatSinks.

private void removeHeatSinks() {
    for (int location = 0; location < loadoutModel.getRowCount(); ) {
        Mounted mount = (Mounted) loadoutModel.getValueAt(location, CriticalTableModel.EQUIPMENT);
        EquipmentType eq = mount.getType();
        if ((eq instanceof MiscType) && (UnitUtil.isHeatSink(mount))) {
            try {
                loadoutModel.removeCrit(location);
            } catch (IndexOutOfBoundsException ignored) {
                return;
            } catch (Exception ex) {
                LogManager.getLogger().error("", ex);
                return;
            }
        } else {
            location++;
        }
    }
}
Also used : Mounted(megamek.common.Mounted) MiscType(megamek.common.MiscType) EquipmentType(megamek.common.EquipmentType)

Example 92 with Mounted

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

the class UnallocatedView method jMenuLoadComponent_actionPerformed.

private void jMenuLoadComponent_actionPerformed(int location, int selectedRow) {
    Mounted eq = (Mounted) equipmentTable.getModel().getValueAt(selectedRow, CriticalTableModel.EQUIPMENT);
    UnitUtil.changeMountStatus(getEntity(), eq, location, -1, false);
    try {
        getEntity().addEquipment(eq, location, false);
    } catch (Exception ex) {
        LogManager.getLogger().error("", ex);
    }
    if (refresh.get() != null) {
        refresh.get().refreshAll();
    }
}
Also used : Mounted(megamek.common.Mounted)

Example 93 with Mounted

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

the class UnallocatedView method mousePressed.

public void mousePressed(MouseEvent e) {
    if (e.getButton() == MouseEvent.BUTTON3) {
        JPopupMenu popup = new JPopupMenu();
        JMenuItem item;
        final int selectedRow = equipmentTable.rowAtPoint(e.getPoint());
        Mounted mount = (Mounted) equipmentTable.getModel().getValueAt(selectedRow, CriticalTableModel.EQUIPMENT);
        String[] locations;
        locations = getEntity().getLocationNames();
        for (int location = 0; location < getEntity().locations(); location++) {
            if (UnitUtil.isValidLocation(getEntity(), mount.getType(), location)) {
                item = new JMenuItem("Add to " + locations[location]);
                final int loc = location;
                item.addActionListener(e1 -> jMenuLoadComponent_actionPerformed(loc, selectedRow));
                popup.add(item);
            }
        }
        popup.show(this, e.getX(), e.getY());
    }
}
Also used : Mounted(megamek.common.Mounted)

Example 94 with Mounted

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

the class CVEquipmentView method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(ADD_COMMAND)) {
        EquipmentType equip = (EquipmentType) equipmentCombo.getSelectedItem();
        Mounted mount = null;
        boolean isMisc = equip instanceof MiscType;
        if (isMisc && equip.hasFlag(MiscType.F_TARGCOMP)) {
            if (!UnitUtil.hasTargComp(getTank())) {
                mount = UnitUtil.updateTC(getTank(), equip);
            }
        } else {
            try {
                mount = getTank().addEquipment(equip, Entity.LOC_NONE, false);
            } catch (Exception ex) {
                LogManager.getLogger().error("", ex);
            }
        }
        equipmentList.addCrit(mount);
    } else if (e.getActionCommand().equals(REMOVE_COMMAND)) {
        int startRow = equipmentTable.getSelectedRow();
        int count = equipmentTable.getSelectedRowCount();
        for (; count > 0; count--) {
            if (startRow > -1) {
                equipmentList.removeMounted(startRow);
                equipmentList.removeCrit(startRow);
            }
        }
    } else if (e.getActionCommand().equals(REMOVEALL_COMMAND)) {
        removeAllEquipment();
    } else {
        return;
    }
    fireTableRefresh();
}
Also used : Mounted(megamek.common.Mounted) MiscType(megamek.common.MiscType) EquipmentType(megamek.common.EquipmentType)

Example 95 with Mounted

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

the class ASStatusBar method calculateTotalHeat.

public double calculateTotalHeat() {
    double heat = 0;
    for (Mounted mounted : getAero().getWeaponList()) {
        WeaponType wtype = (WeaponType) mounted.getType();
        double weaponHeat = wtype.getHeat();
        // only count non-damaged equipment
        if (mounted.isMissing() || mounted.isHit() || mounted.isDestroyed() || mounted.isBreached()) {
            continue;
        }
        // one shot weapons count 1/4
        if ((wtype.getAmmoType() == AmmoType.T_ROCKET_LAUNCHER) || wtype.hasFlag(WeaponType.F_ONESHOT)) {
            weaponHeat *= 0.25;
        }
        // double heat for ultras
        if ((wtype.getAmmoType() == AmmoType.T_AC_ULTRA) || (wtype.getAmmoType() == AmmoType.T_AC_ULTRA_THB)) {
            weaponHeat *= 2;
        }
        // Six times heat for RAC
        if (wtype.getAmmoType() == AmmoType.T_AC_ROTARY) {
            weaponHeat *= 6;
        }
        // half heat for streaks
        if ((wtype.getAmmoType() == AmmoType.T_SRM_STREAK) || (wtype.getAmmoType() == AmmoType.T_LRM_STREAK)) {
            weaponHeat *= 0.5;
        }
        heat += weaponHeat;
    }
    if (getAero().hasStealth()) {
        heat += 10;
    }
    for (Mounted m : getAero().getMisc()) {
        heat += m.getType().getHeat();
    }
    return heat;
}
Also used : Mounted(megamek.common.Mounted) WeaponType(megamek.common.WeaponType)

Aggregations

Mounted (megamek.common.Mounted)162 MiscType (megamek.common.MiscType)50 LocationFullException (megamek.common.LocationFullException)39 AmmoType (megamek.common.AmmoType)36 EquipmentType (megamek.common.EquipmentType)34 CriticalSlot (megamek.common.CriticalSlot)31 ArrayList (java.util.ArrayList)30 WeaponType (megamek.common.WeaponType)29 Vector (java.util.Vector)25 EntityLoadingException (megamek.common.loaders.EntityLoadingException)21 Font (java.awt.Font)14 Entity (megamek.common.Entity)13 List (java.util.List)12 Dimension (java.awt.Dimension)11 JLabel (javax.swing.JLabel)11 JMenuItem (javax.swing.JMenuItem)11 JPopupMenu (javax.swing.JPopupMenu)11 BattleArmor (megamek.common.BattleArmor)11 ActionEvent (java.awt.event.ActionEvent)10 Weapon (megamek.common.weapons.Weapon)10