use of megamek.common.verifier.TestProtomech.ProtomechArmor in project megameklab by MegaMek.
the class PMStructureTab method createArmorMountsAndSetArmorType.
private void createArmorMountsAndSetArmorType(EquipmentType armor) {
ProtomechArmor pmArmor = ProtomechArmor.getArmor(EquipmentType.getArmorType(armor));
List<Mounted> armorMounts = getProtomech().getMisc().stream().filter(m -> EquipmentType.getArmorType(m.getType()) != EquipmentType.T_ARMOR_UNKNOWN).collect(Collectors.toList());
for (Mounted m : armorMounts) {
UnitUtil.removeMounted(getProtomech(), m);
}
if (pmArmor == null) {
getProtomech().setArmorType(EquipmentType.T_ARMOR_STANDARD);
getProtomech().setArmorTechLevel(TechConstants.T_ALL_CLAN);
return;
} else {
getProtomech().setArmorType(pmArmor.getType());
getProtomech().setArmorTechLevel(pmArmor.getArmorTech());
}
if (pmArmor.getTorsoSlots() > 0) {
if (freeUpSpace(Protomech.LOC_TORSO, pmArmor.getTorsoSlots())) {
try {
Mounted mount = new Mounted(getProtomech(), pmArmor.getArmorEqType());
getProtomech().addEquipment(mount, Protomech.LOC_TORSO, false);
return;
} catch (LocationFullException ignored) {
// fall through
}
}
JOptionPane.showMessageDialog(null, "Requires free torso slot. Resetting to Standard Armor", "Location Full", JOptionPane.INFORMATION_MESSAGE);
getProtomech().setArmorType(EquipmentType.T_ARMOR_STANDARD);
getProtomech().setArmorTechLevel(TechConstants.T_ALL_CLAN);
panArmor.setFromEntity(getProtomech());
}
}
Aggregations