Search in sources :

Example 81 with Mounted

use of megamek.common.Mounted in project megameklab by MegaMek.

the class PrintMech method writeLocationCriticals.

private void writeLocationCriticals(int loc, SVGRectElement svgRect) {
    Rectangle2D bbox = getRectBBox(svgRect);
    Element canvas = (Element) ((Node) svgRect).getParentNode();
    int viewWidth = (int) bbox.getWidth();
    int viewHeight = (int) bbox.getHeight();
    int viewX = (int) bbox.getX();
    int viewY = (int) bbox.getY();
    double rollX = viewX;
    double critX = viewX + viewWidth * 0.11;
    double gap = 0;
    if (mech.getNumberOfCriticals(loc) > 6) {
        gap = viewHeight * 0.05;
    }
    double lineHeight = (viewHeight - gap) / mech.getNumberOfCriticals(loc);
    double currY = viewY;
    float fontSize = (float) lineHeight * 0.85f;
    Mounted startingMount = null;
    double startingMountY = 0;
    double endingMountY = 0;
    double connWidth = viewWidth * 0.02;
    double x = viewX + viewWidth * 0.075;
    x += addTextElement(canvas, x, viewY - 1, mech.getLocationName(loc), fontSize * 1.25f, "start", "bold");
    if (mech.isClan() && UnitUtil.hasAmmo(mech, loc) && !mech.hasCASEII(loc)) {
        addTextElement(canvas, x + fontSize / 2, viewY - 1, "(CASE)", fontSize, "start", "normal");
    }
    for (int slot = 0; slot < mech.getNumberOfCriticals(loc); slot++) {
        currY += lineHeight;
        if (slot == 6) {
            currY += gap;
        }
        addTextElement(canvas, rollX, currY, ((slot % 6) + 1) + ".", fontSize, "start", "bold");
        CriticalSlot crit = mech.getCritical(loc, slot);
        String style = "bold";
        String fill = "#000000";
        if ((null == crit) || ((crit.getType() == CriticalSlot.TYPE_EQUIPMENT) && (!crit.getMount().getType().isHittable()))) {
            style = "standard";
            fill = "#3f3f3f";
            addTextElement(canvas, critX, currY, formatCritName(crit), fontSize, "start", style, fill);
        } else if (crit.isArmored()) {
            Element pip = createPip(critX, currY - fontSize * 0.8, fontSize * 0.4, 0.7);
            canvas.appendChild(pip);
            addTextElement(canvas, critX + fontSize, currY, formatCritName(crit), fontSize, "start", style, fill);
        } else if ((crit.getType() == CriticalSlot.TYPE_EQUIPMENT) && (crit.getMount().getType() instanceof MiscType) && (crit.getMount().getType().hasFlag(MiscType.F_MODULAR_ARMOR))) {
            String critName = formatCritName(crit);
            addTextElement(canvas, critX, currY, critName, fontSize, "start", style, fill);
            x = critX + getTextLength(critName, fontSize);
            double remainingW = viewX + viewWidth - x;
            double spacing = remainingW / 6.0;
            double radius = spacing * 0.25;
            double y = currY - lineHeight + spacing;
            double y2 = currY - spacing;
            x += spacing;
            for (int i = 0; i < 10; i++) {
                if (i == 5) {
                    x -= spacing * 5.5;
                    y = y2;
                }
                Element pip = createPip(x, y, radius, 0.5);
                canvas.appendChild(pip);
                x += spacing;
            }
        } else {
            addTextElement(canvas, critX, currY, formatCritName(crit), fontSize, "start", style, fill);
        }
        Mounted m = null;
        if ((null != crit) && (crit.getType() == CriticalSlot.TYPE_EQUIPMENT) && (crit.getMount().getType().isHittable()) && (crit.getMount().getType().getCriticals(mech) > (mech.isSuperHeavy() ? 2 : 1))) {
            m = crit.getMount();
        }
        if ((startingMount != null) && (startingMount != m)) {
            connectSlots(canvas, critX - 1, startingMountY, connWidth, endingMountY - startingMountY);
        }
        if (m != startingMount) {
            startingMount = m;
            if (null != m) {
                startingMountY = currY - lineHeight * 0.6;
            }
        } else {
            endingMountY = currY;
        }
    }
    if ((null != startingMount) && (mech.getNumberOfCriticals(startingMount.getType(), loc) > 1)) {
        connectSlots(canvas, critX - 1, startingMountY, connWidth, endingMountY - startingMountY);
    }
}
Also used : Mounted(megamek.common.Mounted) CriticalSlot(megamek.common.CriticalSlot) SVGRectElement(org.w3c.dom.svg.SVGRectElement) Element(org.w3c.dom.Element) MiscType(megamek.common.MiscType) Rectangle2D(java.awt.geom.Rectangle2D)

Example 82 with Mounted

use of megamek.common.Mounted in project megameklab by MegaMek.

the class WSStatusBar method calculateTotalHeat.

public double calculateTotalHeat() {
    double heat = 0;
    for (Mounted mounted : getJumpship().getWeaponList()) {
        WeaponType wtype = (WeaponType) mounted.getType();
        double weaponHeat = wtype.getHeat();
        // only count non-damaged equipment
        if (mounted.isMissing() || mounted.isHit() || mounted.isDestroyed() || mounted.isBreached()) {
            continue;
        }
        // one shot weapons count 1/4
        if ((wtype.getAmmoType() == AmmoType.T_ROCKET_LAUNCHER) || wtype.hasFlag(WeaponType.F_ONESHOT)) {
            weaponHeat *= 0.25;
        }
        // double heat for ultras
        if ((wtype.getAmmoType() == AmmoType.T_AC_ULTRA) || (wtype.getAmmoType() == AmmoType.T_AC_ULTRA_THB)) {
            weaponHeat *= 2;
        }
        // Six times heat for RAC
        if (wtype.getAmmoType() == AmmoType.T_AC_ROTARY) {
            weaponHeat *= 6;
        }
        // half heat for streaks
        if ((wtype.getAmmoType() == AmmoType.T_SRM_STREAK) || (wtype.getAmmoType() == AmmoType.T_LRM_STREAK)) {
            weaponHeat *= 0.5;
        }
        heat += weaponHeat;
    }
    for (Mounted m : getJumpship().getMisc()) {
        heat += m.getType().getHeat();
    }
    return heat;
}
Also used : Mounted(megamek.common.Mounted) WeaponType(megamek.common.WeaponType)

Example 83 with Mounted

use of megamek.common.Mounted in project megameklab by MegaMek.

the class BMBuildTab method resetCrits.

private void resetCrits() {
    for (Mounted mounted : getMech().getEquipment()) {
        if (!UnitUtil.isFixedLocationSpreadEquipment(mounted.getType())) {
            UnitUtil.removeCriticals(getMech(), mounted);
            BMUtils.clearMountedLocationAndLinked(mounted);
        }
    }
    refresh.refreshAll();
}
Also used : Mounted(megamek.common.Mounted)

Example 84 with Mounted

use of megamek.common.Mounted in project megameklab by MegaMek.

the class DSStatusBar method calculateTotalHeat.

public double calculateTotalHeat() {
    double heat = 0;
    for (Mounted mounted : getSmallCraft().getWeaponList()) {
        WeaponType wtype = (WeaponType) mounted.getType();
        double weaponHeat = wtype.getHeat();
        // only count non-damaged equipment
        if (mounted.isMissing() || mounted.isHit() || mounted.isDestroyed() || mounted.isBreached()) {
            continue;
        }
        // one shot weapons count 1/4
        if ((wtype.getAmmoType() == AmmoType.T_ROCKET_LAUNCHER) || wtype.hasFlag(WeaponType.F_ONESHOT)) {
            weaponHeat *= 0.25;
        }
        // double heat for ultras
        if ((wtype.getAmmoType() == AmmoType.T_AC_ULTRA) || (wtype.getAmmoType() == AmmoType.T_AC_ULTRA_THB)) {
            weaponHeat *= 2;
        }
        // Six times heat for RAC
        if (wtype.getAmmoType() == AmmoType.T_AC_ROTARY) {
            weaponHeat *= 6;
        }
        // half heat for streaks
        if ((wtype.getAmmoType() == AmmoType.T_SRM_STREAK) || (wtype.getAmmoType() == AmmoType.T_LRM_STREAK)) {
            weaponHeat *= 0.5;
        }
        heat += weaponHeat;
    }
    for (Mounted m : getSmallCraft().getMisc()) {
        heat += m.getType().getHeat();
    }
    return heat;
}
Also used : Mounted(megamek.common.Mounted) WeaponType(megamek.common.WeaponType)

Example 85 with Mounted

use of megamek.common.Mounted in project megameklab by MegaMek.

the class PMBuildView method loadEquipmentTable.

private void loadEquipmentTable() {
    equipmentList.removeAllCrits();
    masterEquipmentList.clear();
    for (Mounted mount : getProtoMek().getMisc()) {
        if (mount.getLocation() == Entity.LOC_NONE) {
            masterEquipmentList.add(mount);
        }
    }
    for (Mounted mount : getProtoMek().getWeaponList()) {
        if (mount.getLocation() == Entity.LOC_NONE) {
            masterEquipmentList.add(mount);
        }
    }
    for (Mounted mount : getProtoMek().getAmmo()) {
        if ((mount.getLocation() == Entity.LOC_NONE) && !mount.isOneShotAmmo()) {
            masterEquipmentList.add(mount);
        }
    }
    Collections.sort(masterEquipmentList, StringUtils.mountedComparator());
    // Time to Sort
    // weapons and ammo
    Vector<Mounted> weaponsNAmmoList = new Vector<Mounted>(10, 1);
    for (int pos = 0; pos < masterEquipmentList.size(); pos++) {
        if ((masterEquipmentList.get(pos).getType() instanceof Weapon) || (masterEquipmentList.get(pos).getType() instanceof AmmoType)) {
            weaponsNAmmoList.add(masterEquipmentList.get(pos));
            masterEquipmentList.remove(pos);
            pos--;
        }
    }
    Collections.sort(weaponsNAmmoList, StringUtils.mountedComparator());
    for (Mounted mount : weaponsNAmmoList) {
        equipmentList.addCrit(mount);
    }
    // Equipment
    for (int pos = 0; pos < masterEquipmentList.size(); pos++) {
        if ((masterEquipmentList.get(pos).getType() instanceof MiscType) && UnitUtil.isArmor(masterEquipmentList.get(pos).getType())) {
            equipmentList.addCrit(masterEquipmentList.get(pos));
            masterEquipmentList.remove(pos);
            pos--;
        }
    }
    // everything else
    for (int pos = 0; pos < masterEquipmentList.size(); pos++) {
        equipmentList.addCrit(masterEquipmentList.get(pos));
    }
}
Also used : AmmoType(megamek.common.AmmoType) Mounted(megamek.common.Mounted) MiscType(megamek.common.MiscType) Vector(java.util.Vector) Weapon(megamek.common.weapons.Weapon)

Aggregations

Mounted (megamek.common.Mounted)162 MiscType (megamek.common.MiscType)50 LocationFullException (megamek.common.LocationFullException)39 AmmoType (megamek.common.AmmoType)36 EquipmentType (megamek.common.EquipmentType)34 CriticalSlot (megamek.common.CriticalSlot)31 ArrayList (java.util.ArrayList)30 WeaponType (megamek.common.WeaponType)29 Vector (java.util.Vector)25 EntityLoadingException (megamek.common.loaders.EntityLoadingException)21 Font (java.awt.Font)14 Entity (megamek.common.Entity)13 List (java.util.List)12 Dimension (java.awt.Dimension)11 JLabel (javax.swing.JLabel)11 JMenuItem (javax.swing.JMenuItem)11 JPopupMenu (javax.swing.JPopupMenu)11 BattleArmor (megamek.common.BattleArmor)11 ActionEvent (java.awt.event.ActionEvent)10 Weapon (megamek.common.weapons.Weapon)10