@Override public String checkFixable() { if (null == unit) { return null; } if (isSalvaging()) { // check for armor if (unit.getEntity().getArmorForReal(loc, false) > 0 || (unit.getEntity().hasRearArmor(loc) && unit.getEntity().getArmorForReal(loc, true) > 0)) { return "must salvage armor in this location first"; } // you can only salvage a location that has nothing left on it int systemRepairable = 0; for (int i = 0; i < unit.getEntity().getNumberOfCriticals(loc); i++) { CriticalSlot slot = unit.getEntity().getCritical(loc, i); // ignore empty & non-hittable slots if ((slot == null) || !slot.isEverHittable()) { continue; } // we don't care about the final critical hit to the system // in locations because that just represents the location destruction if (slot.getType() == CriticalSlot.TYPE_SYSTEM) { if (slot.isRepairable()) { if (systemRepairable > 0) { return "Repairable parts in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first."; } else { systemRepairable++; } } } else if (slot.isRepairable()) { return "Repairable parts in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first."; } } // protomechs only have system stuff in the crits, so we need to also // check for mounted equipment separately for (Mounted m : unit.getEntity().getEquipment()) { if (m.isRepairable() && (m.getLocation() == loc || m.getSecondLocation() == loc)) { return "Repairable parts in " + unit.getEntity().getLocationName(loc) + " must be salvaged or scrapped first." + m.getName(); } } } return null; }
@Override public void remove(boolean salvage) { blownOff = false; if (null != unit) { unit.getEntity().setInternal(IArmorState.ARMOR_DESTROYED, loc); unit.getEntity().setLocationBlownOff(loc, false); Part spare = campaign.checkForExistingSparePart(this); if (!salvage) { campaign.removePart(this); } else if (null != spare) { spare.incrementQuantity(); campaign.removePart(this); } unit.removePart(this); if (loc != Protomech.LOC_TORSO) { Part missing = getMissingPart(); unit.addPart(missing); campaign.addPart(missing, 0); } // According to StratOps, this always destroys all equipment in that location as well for (int i = 0; i < unit.getEntity().getNumberOfCriticals(loc); i++) { final CriticalSlot cs = unit.getEntity().getCritical(loc, i); if (null == cs || !cs.isEverHittable()) { continue; } cs.setHit(true); cs.setDestroyed(true); cs.setRepairable(false); Mounted m = cs.getMount(); if (null != m) { m.setHit(true); m.setDestroyed(true); m.setRepairable(false); } } for (Mounted m : unit.getEntity().getEquipment()) { if (m.getLocation() == loc || m.getSecondLocation() == loc) { m.setHit(true); m.setDestroyed(true); m.setRepairable(false); } } } setUnit(null); updateConditionFromEntity(false); }