Search in sources :

Example 16 with Engine

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

the class MainUI method createNewUnit.

@Override
public void createNewUnit(long entityType, boolean isPrimitive, boolean isIndustrial, Entity oldEntity) {
    if (entityType == Entity.ETYPE_AERO) {
        setEntity(new Aero());
        getEntity().setTechLevel(TechConstants.T_IS_TW_NON_BOX);
    } else if (entityType == Entity.ETYPE_CONV_FIGHTER) {
        setEntity(new ConvFighter());
        getEntity().setTechLevel(TechConstants.T_IS_TW_NON_BOX);
    } else {
        System.out.println("Aero.MainUI: Received incorrect entityType!");
        return;
    }
    Aero aero = (Aero) getEntity();
    aero.setYear(3145);
    aero.setWeight(25);
    aero.setEngine(new Engine(25, Engine.NORMAL_ENGINE, 0));
    if (isPrimitive) {
        aero.setCockpitType(Aero.COCKPIT_PRIMITIVE);
        aero.setArmorType(EquipmentType.T_ARMOR_PRIMITIVE_FIGHTER);
    } else {
        aero.setArmorType(EquipmentType.T_ARMOR_STANDARD);
    }
    aero.setArmorTechLevel(getEntity().getTechLevel());
    aero.setStructureType(EquipmentType.T_STRUCTURE_STANDARD);
    aero.setHeatSinks(10);
    aero.setHeatType(Aero.HEAT_SINGLE);
    aero.autoSetInternal();
    for (int loc = 0; loc < getEntity().locations(); loc++) {
        aero.initializeArmor(0, loc);
    }
    if (null == oldEntity) {
        getEntity().setChassis("New");
        getEntity().setModel("Aero");
    } else {
        aero.setChassis(oldEntity.getChassis());
        aero.setModel(oldEntity.getModel());
        aero.setYear(Math.max(oldEntity.getYear(), aero.getConstructionTechAdvancement().getIntroductionDate()));
        aero.setSource(oldEntity.getSource());
        aero.setManualBV(oldEntity.getManualBV());
        SimpleTechLevel lvl = SimpleTechLevel.max(aero.getStaticTechLevel(), SimpleTechLevel.convertCompoundToSimple(oldEntity.getTechLevel()));
        aero.setTechLevel(lvl.getCompoundTechLevel(oldEntity.isClan()));
        aero.setMixedTech(oldEntity.isMixedTech());
    }
}
Also used : SimpleTechLevel(megamek.common.SimpleTechLevel) ConvFighter(megamek.common.ConvFighter) Aero(megamek.common.Aero) Engine(megamek.common.Engine)

Example 17 with Engine

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

the class SummaryView method getEngineCrits.

private int getEngineCrits() {
    Engine engine = getTank().getEngine();
    int usedSlots = 0;
    if (engine.isFusion()) {
        if (engine.getEngineType() == Engine.LIGHT_ENGINE) {
            usedSlots++;
        }
        if (engine.getEngineType() == Engine.XL_ENGINE) {
            if (engine.hasFlag(Engine.CLAN_ENGINE)) {
                usedSlots++;
            } else {
                usedSlots += 2;
            }
        }
        if (engine.getEngineType() == Engine.XXL_ENGINE) {
            if (engine.hasFlag(Engine.CLAN_ENGINE)) {
                usedSlots += 2;
            } else {
                usedSlots += 4;
            }
        }
    }
    if (engine.hasFlag(Engine.LARGE_ENGINE)) {
        usedSlots++;
    }
    if (engine.getEngineType() == Engine.COMPACT_ENGINE) {
        usedSlots--;
    }
    return usedSlots;
}
Also used : Engine(megamek.common.Engine)

Aggregations

Engine (megamek.common.Engine)17 ArrayList (java.util.ArrayList)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)3 SimpleTechLevel (megamek.common.SimpleTechLevel)3 Aero (megamek.common.Aero)1 BipedMech (megamek.common.BipedMech)1 ConvFighter (megamek.common.ConvFighter)1 LandAirMech (megamek.common.LandAirMech)1 Mech (megamek.common.Mech)1 QuadMech (megamek.common.QuadMech)1 QuadVee (megamek.common.QuadVee)1 SuperHeavyTank (megamek.common.SuperHeavyTank)1 Tank (megamek.common.Tank)1 TripodMech (megamek.common.TripodMech)1 VTOL (megamek.common.VTOL)1