if (mech.getCritical(location, i) == null) {
long critical = crits[i];
String criticalName = getCriticalName(critical);
if (isFusionEngine(critical)) {
mech.setCritical(location, i, new CriticalSlot(
CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE));
} else if (isGyro(critical)) {
mech.setCritical(location, i, new CriticalSlot(
CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_GYRO));
} else if (isCockpit(critical)) {
mech.setCritical(location, i, new CriticalSlot(
CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_COCKPIT));
} else if (isLifeSupport(critical)) {
mech
.setCritical(location, i, new CriticalSlot(
CriticalSlot.TYPE_SYSTEM,
Mech.SYSTEM_LIFE_SUPPORT));
} else if (isSensor(critical)) {
mech.setCritical(location, i, new CriticalSlot(
CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS));
} else if (isJumpJet(critical)) {
try {
if (jjType == 0) {
mech.addEquipment(EquipmentType.get("Jump Jet"),
location, false);
} else if (jjType == 1) {
mech.addEquipment(EquipmentType
.get("Improved Jump Jet"), location, false);
}
} catch (LocationFullException ex) {
System.err
.print("Location was full when adding jump jets to slot #");
System.err.print(i);
System.err.print(" of location ");
System.err.println(location);
ex.printStackTrace(System.err);
System.err.println("... aborting entity loading.");
throw new EntityLoadingException(ex.getMessage());
}
} else if (criticalName != null) {
EquipmentType equipment = null;
try {
equipment = EquipmentType.get(criticalName);
if (equipment != null) {
// for experimental or unofficial equipment, we need
// to adjust the mech's techlevel, because HMP only
// knows lvl1/2/3
if ((equipment.getTechLevel() > mech.getTechLevel())
&& (mech.getTechLevel() >= TechConstants.T_IS_ADVANCED)) {
boolean isClan = mech.isClan();
if ((equipment.getTechLevel() == TechConstants.T_IS_EXPERIMENTAL) ||
(equipment.getTechLevel() == TechConstants.T_CLAN_EXPERIMENTAL)) {
mech.setTechLevel(isClan?TechConstants.T_CLAN_EXPERIMENTAL:TechConstants.T_IS_EXPERIMENTAL);
} else if ((equipment.getTechLevel() == TechConstants.T_IS_UNOFFICIAL) ||
(equipment.getTechLevel() == TechConstants.T_CLAN_UNOFFICIAL)) {
mech.setTechLevel(isClan?TechConstants.T_CLAN_UNOFFICIAL:TechConstants.T_IS_UNOFFICIAL);
}
}
boolean rearMounted = (equipment instanceof WeaponType)
&& isRearMounted(critical);
if (equipment.isSpreadable()) {
Mounted m = spreadEquipment.get(equipment);
if (m != null) {
CriticalSlot criticalSlot = new CriticalSlot(
CriticalSlot.TYPE_EQUIPMENT, mech
.getEquipmentNum(m),
equipment.isHittable(), m);
mech.addCritical(location, criticalSlot);
if (criticalName