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