use of megamek.common.Mounted in project megameklab by MegaMek.
the class BuildTab method resetCrits.
private void resetCrits() {
for (Mounted mount : getMech().getEquipment()) {
if (!UnitUtil.isFixedLocationSpreadEquipment(mount.getType())) {
UnitUtil.removeCriticals(getMech(), mount);
UnitUtil.changeMountStatus(getMech(), mount, Entity.LOC_NONE, Entity.LOC_NONE, false);
}
}
refresh.refreshAll();
}
use of megamek.common.Mounted in project megameklab by MegaMek.
the class BuildTab method autoFillCrits.
private void autoFillCrits() {
for (Mounted mount : buildView.getTableModel().getCrits()) {
int externalEngineHS = UnitUtil.getCriticalFreeHeatSinks(getMech(), getMech().hasCompactHeatSinks());
for (int location = Mech.LOC_HEAD; location < getMech().locations(); location++) {
if (!UnitUtil.isValidLocation(getMech(), mount.getType(), location)) {
continue;
}
int continuousNumberOfCrits = UnitUtil.getHighestContinuousNumberOfCrits(getMech(), location);
int critsUsed = UnitUtil.getCritsUsed(getMech(), mount.getType());
if (continuousNumberOfCrits < critsUsed) {
continue;
}
if ((mount.getLocation() == Entity.LOC_NONE)) {
if (UnitUtil.isHeatSink(mount) && (externalEngineHS-- > 0)) {
continue;
}
}
try {
if (mount.getType().isSpreadable() || (mount.isSplitable() && (critsUsed > 1))) {
for (int count = 0; count < critsUsed; count++) {
UnitUtil.addMounted(getMech(), mount, location, false);
}
} else {
UnitUtil.addMounted(getMech(), mount, location, false);
}
UnitUtil.changeMountStatus(getMech(), mount, location, Entity.LOC_NONE, false);
break;
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
refresh.refreshAll();
}
use of megamek.common.Mounted in project megameklab by MegaMek.
the class EquipmentTab method removeHeatSinks.
private void removeHeatSinks() {
int location = 0;
for (; location < equipmentList.getRowCount(); ) {
Mounted mount = (Mounted) equipmentList.getValueAt(location, CriticalTableModel.EQUIPMENT);
EquipmentType eq = mount.getType();
if ((eq instanceof MiscType) && (UnitUtil.isHeatSink(mount))) {
try {
equipmentList.removeCrit(location);
} catch (ArrayIndexOutOfBoundsException aioobe) {
return;
} catch (Exception ex) {
ex.printStackTrace();
}
} else {
location++;
}
}
}
use of megamek.common.Mounted in project megameklab by MegaMek.
the class StructureTab method enhancementChanged.
@Override
public void enhancementChanged(EquipmentType enhancement) {
UnitUtil.removeEnhancements(getMech());
if (null != enhancement) {
if (enhancement.hasFlag(MiscType.F_MASC)) {
Mounted mount = new Mounted(getMech(), enhancement);
try {
getMech().addEquipment(mount, Entity.LOC_NONE, false);
} catch (LocationFullException lfe) {
// this can't happen, we add to Entity.LOC_NONE
}
} else {
UnitUtil.createSpreadMounts(getMech(), enhancement);
}
}
refresh.refreshBuild();
refresh.refreshPreview();
refresh.refreshStatus();
}
use of megamek.common.Mounted in project megameklab by MegaMek.
the class StructureTab method patchworkChanged.
@Override
public void patchworkChanged(int location, EquipmentType armor) {
UnitUtil.resetArmor(getMech(), location);
// TODO: move this construction data out of the ui
int crits = 0;
switch(EquipmentType.getArmorType(armor)) {
case EquipmentType.T_ARMOR_STEALTH:
case EquipmentType.T_ARMOR_FERRO_LAMELLOR:
crits = 2;
break;
case EquipmentType.T_ARMOR_HEAVY_FERRO:
crits = 3;
break;
case EquipmentType.T_ARMOR_LIGHT_FERRO:
crits = 1;
break;
case EquipmentType.T_ARMOR_FERRO_FIBROUS:
case EquipmentType.T_ARMOR_REFLECTIVE:
case EquipmentType.T_ARMOR_REACTIVE:
if (armor.isClan()) {
crits = 1;
} else {
crits = 2;
}
break;
}
if (getMech().getEmptyCriticals(location) < crits) {
JOptionPane.showMessageDialog(null, armor.getName() + " does not fit in location " + getMech().getLocationName(location) + ". Resetting to Standard Armor in this location.", "Error", JOptionPane.INFORMATION_MESSAGE);
} else {
getMech().setArmorType(EquipmentType.getArmorType(armor), location);
getMech().setArmorTechLevel(armor.getTechLevel(getTechManager().getGameYear(), armor.isClan()));
for (; crits > 0; crits--) {
try {
getMech().addEquipment(new Mounted(getMech(), armor), location, false);
} catch (LocationFullException ex) {
}
}
}
panArmor.refresh();
panArmorAllocation.setFromEntity(getMech());
refresh.refreshBuild();
refresh.refreshPreview();
refresh.refreshSummary();
refresh.refreshStatus();
}
Aggregations