use of megamek.common.loaders.EntityLoadingException in project megameklab by MegaMek.
the class DropTargetCriticalList method removeCrit.
public void removeCrit() {
CriticalSlot crit = getCrit();
Mounted mounted = getMounted();
if (mounted == null) {
return;
}
// mounted and be done
if (getUnit() instanceof BattleArmor) {
changeMountStatus(mounted, BattleArmor.MOUNT_LOC_NONE, false);
return;
}
UnitUtil.removeCriticals(getUnit(), mounted);
// Check linkings after you remove everything.
try {
MechFileParser.postLoadInit(getUnit());
} catch (EntityLoadingException ele) {
// do nothing.
} catch (Exception ex) {
ex.printStackTrace();
}
if ((crit != null) && (crit.getType() == CriticalSlot.TYPE_EQUIPMENT)) {
changeMountStatus(mounted, Entity.LOC_NONE, false);
}
}
use of megamek.common.loaders.EntityLoadingException in project megameklab by MegaMek.
the class DropTargetCriticalList method removeCrit.
private void removeCrit() {
CriticalSlot crit = getCrit();
Mounted mounted = getMounted();
if ((mounted == null)) {
return;
}
// Cannot remove a mast mount
if (mounted.getType().hasFlag(MiscType.F_MAST_MOUNT)) {
return;
}
UnitUtil.removeCriticals(getUnit(), mounted);
if ((crit != null) && (crit.getType() == CriticalSlot.TYPE_EQUIPMENT)) {
changeMountStatus(mounted, Entity.LOC_NONE, false);
}
UnitUtil.compactCriticals(getUnit());
// Check linkings after you remove everything.
try {
MechFileParser.postLoadInit(getUnit());
} catch (EntityLoadingException ele) {
// do nothing.
} catch (Exception ex) {
ex.printStackTrace();
}
}
use of megamek.common.loaders.EntityLoadingException in project megameklab by MegaMek.
the class DropTargetCriticalList method removeMount.
private void removeMount() {
Mounted mounted = getMounted();
if (mounted == null) {
return;
}
UnitUtil.removeMounted(getUnit(), mounted);
UnitUtil.compactCriticals(getUnit());
// Check linkings after you remove everything.
try {
MechFileParser.postLoadInit(getUnit());
} catch (EntityLoadingException ele) {
// do nothing.
} catch (Exception ex) {
ex.printStackTrace();
}
if (refresh != null) {
refresh.refreshAll();
}
}
use of megamek.common.loaders.EntityLoadingException in project megameklab by MegaMek.
the class DropTargetCriticalList method changeArmoring.
private void changeArmoring() {
CriticalSlot cs = getCrit();
if (cs != null) {
if (cs.getType() == CriticalSlot.TYPE_EQUIPMENT) {
Mounted mount = getMounted();
mount.setArmored(!cs.isArmored());
UnitUtil.updateCritsArmoredStatus(getUnit(), mount);
} else {
cs.setArmored(!cs.isArmored());
UnitUtil.updateCritsArmoredStatus(getUnit(), cs, getCritLocation());
}
}
// Check linkings after you remove everything.
try {
MechFileParser.postLoadInit(getUnit());
} catch (EntityLoadingException ele) {
// do nothing.
} catch (Exception ex) {
ex.printStackTrace();
}
if (refresh != null) {
refresh.refreshAll();
}
}
use of megamek.common.loaders.EntityLoadingException in project megameklab by MegaMek.
the class StructureTab method clearCrit.
/**
* Removes equipment placed in the given critical slot to clear the space for a system critical
*/
private void clearCrit(int loc, int slotNum) {
final CriticalSlot crit = getMech().getCritical(loc, slotNum);
Mounted mounted = null;
if (crit != null && crit.getType() == CriticalSlot.TYPE_EQUIPMENT) {
mounted = crit.getMount();
}
if (mounted == null) {
return;
}
UnitUtil.removeCriticals(getMech(), mounted);
if (crit.getMount2() != null) {
UnitUtil.removeCriticals(getMech(), crit.getMount2());
}
// Check linkings after you remove everything.
try {
MechFileParser.postLoadInit(getMech());
} catch (EntityLoadingException ele) {
// do nothing.
} catch (Exception ex) {
ex.printStackTrace();
}
if ((crit != null) && (crit.getType() == CriticalSlot.TYPE_EQUIPMENT)) {
UnitUtil.changeMountStatus(getMech(), mounted, Entity.LOC_NONE, Entity.LOC_NONE, false);
if (crit.getMount2() != null) {
UnitUtil.changeMountStatus(getMech(), crit.getMount2(), Entity.LOC_NONE, Entity.LOC_NONE, false);
}
}
}
Aggregations