Search in sources :

Example 11 with Aero

use of megamek.common.Aero 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)

Aggregations

Aero (megamek.common.Aero)11 BattleArmor (megamek.common.BattleArmor)9 Tank (megamek.common.Tank)8 Mech (megamek.common.Mech)7 Entity (megamek.common.Entity)6 Infantry (megamek.common.Infantry)6 File (java.io.File)4 SmallCraft (megamek.common.SmallCraft)4 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 DecimalFormat (java.text.DecimalFormat)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Vector (java.util.Vector)2 Collectors (java.util.stream.Collectors)2 JFrame (javax.swing.JFrame)2 JMenu (javax.swing.JMenu)2 JMenuItem (javax.swing.JMenuItem)2 JOptionPane (javax.swing.JOptionPane)2 AmmoType (megamek.common.AmmoType)2