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());
}
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());
}
}
Aggregations