Search in sources :

Example 1 with EntityLoadingException

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);
    }
}
Also used : CriticalSlot(megamek.common.CriticalSlot) Mounted(megamek.common.Mounted) EntityLoadingException(megamek.common.loaders.EntityLoadingException) BattleArmor(megamek.common.BattleArmor) TestBattleArmor(megamek.common.verifier.TestBattleArmor) EntityLoadingException(megamek.common.loaders.EntityLoadingException)

Example 2 with EntityLoadingException

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();
    }
}
Also used : CriticalSlot(megamek.common.CriticalSlot) Mounted(megamek.common.Mounted) EntityLoadingException(megamek.common.loaders.EntityLoadingException) EntityLoadingException(megamek.common.loaders.EntityLoadingException)

Example 3 with EntityLoadingException

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();
    }
}
Also used : Mounted(megamek.common.Mounted) EntityLoadingException(megamek.common.loaders.EntityLoadingException) EntityLoadingException(megamek.common.loaders.EntityLoadingException)

Example 4 with EntityLoadingException

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();
    }
}
Also used : CriticalSlot(megamek.common.CriticalSlot) Mounted(megamek.common.Mounted) EntityLoadingException(megamek.common.loaders.EntityLoadingException) EntityLoadingException(megamek.common.loaders.EntityLoadingException)

Example 5 with EntityLoadingException

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);
        }
    }
}
Also used : CriticalSlot(megamek.common.CriticalSlot) Mounted(megamek.common.Mounted) EntityLoadingException(megamek.common.loaders.EntityLoadingException) LocationFullException(megamek.common.LocationFullException) EntityLoadingException(megamek.common.loaders.EntityLoadingException)

Aggregations

Mounted (megamek.common.Mounted)7 EntityLoadingException (megamek.common.loaders.EntityLoadingException)7 CriticalSlot (megamek.common.CriticalSlot)5 BattleArmor (megamek.common.BattleArmor)1 LocationFullException (megamek.common.LocationFullException)1 TestBattleArmor (megamek.common.verifier.TestBattleArmor)1