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++;
}
}
}
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();
}
}
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());
}
}
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();
}
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;
}
Aggregations