Search in sources :

Example 6 with SimpleTechLevel

use of megamek.common.SimpleTechLevel 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_VTOL) {
        setEntity(new VTOL());
        getEntity().setTechLevel(TechConstants.T_INTRO_BOXSET);
        getEntity().setWeight(20);
        getEntity().setMovementMode(EntityMovementMode.VTOL);
    } else {
        if (entityType == Entity.ETYPE_SUPER_HEAVY_TANK) {
            setEntity(new SuperHeavyTank());
            getEntity().setTechLevel(TechConstants.T_IS_ADVANCED);
            getEntity().setWeight(51);
        } else {
            setEntity(new Tank());
            getEntity().setTechLevel(TechConstants.T_INTRO_BOXSET);
            getEntity().setWeight(20);
        }
        getEntity().setMovementMode(EntityMovementMode.HOVER);
    }
    Tank tank = (Tank) getEntity();
    tank.setYear(3145);
    tank.setEngine(new Engine(Math.max(10, (int) getEntity().getWeight() - tank.getSuspensionFactor()), Engine.NORMAL_ENGINE, Engine.TANK_ENGINE));
    tank.autoSetInternal();
    for (int loc = 0; loc < getEntity().locations(); loc++) {
        tank.initializeArmor(0, loc);
    }
    getEntity().setArmorType(EquipmentType.T_ARMOR_STANDARD);
    getEntity().setArmorTechLevel(TechConstants.T_INTRO_BOXSET);
    getEntity().setStructureType(EquipmentType.T_STRUCTURE_STANDARD);
    tank.setHasNoDualTurret(true);
    if (Entity.ETYPE_VTOL == entityType) {
        tank.setHasNoTurret(true);
    }
    if (null == oldEntity) {
        tank.setChassis("New");
        tank.setModel("Tank");
        tank.setYear(3145);
    } else {
        tank.setChassis(oldEntity.getChassis());
        tank.setModel(oldEntity.getModel());
        tank.setYear(Math.max(oldEntity.getYear(), tank.getConstructionTechAdvancement().getIntroductionDate()));
        tank.setSource(oldEntity.getSource());
        tank.setManualBV(oldEntity.getManualBV());
        SimpleTechLevel lvl = SimpleTechLevel.max(tank.getStaticTechLevel(), SimpleTechLevel.convertCompoundToSimple(oldEntity.getTechLevel()));
        tank.setTechLevel(lvl.getCompoundTechLevel(oldEntity.isClan()));
        tank.setMixedTech(oldEntity.isMixedTech());
        tank.setMovementMode(oldEntity.getMovementMode());
    }
    tank.setOriginalWalkMP((tank.getEngine().getRating() + tank.getSuspensionFactor()) / (int) tank.getWeight());
}
Also used : SimpleTechLevel(megamek.common.SimpleTechLevel) VTOL(megamek.common.VTOL) SuperHeavyTank(megamek.common.SuperHeavyTank) SuperHeavyTank(megamek.common.SuperHeavyTank) Tank(megamek.common.Tank) Engine(megamek.common.Engine)

Example 7 with SimpleTechLevel

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

SimpleTechLevel (megamek.common.SimpleTechLevel)7 Engine (megamek.common.Engine)3 Aero (megamek.common.Aero)1 BipedMech (megamek.common.BipedMech)1 ConvFighter (megamek.common.ConvFighter)1 Dropship (megamek.common.Dropship)1 LandAirMech (megamek.common.LandAirMech)1 Mech (megamek.common.Mech)1 QuadMech (megamek.common.QuadMech)1 QuadVee (megamek.common.QuadVee)1 SmallCraft (megamek.common.SmallCraft)1 SuperHeavyTank (megamek.common.SuperHeavyTank)1 Tank (megamek.common.Tank)1 TripodMech (megamek.common.TripodMech)1 VTOL (megamek.common.VTOL)1 MegaMekLabMainUI (megameklab.com.ui.MegaMekLabMainUI)1