use of megamek.common.Engine in project megameklab by MegaMek.
the class FighterChassisView method getAvailableEngines.
public List<Engine> getAvailableEngines() {
if (isPrimitive()) {
return Collections.singletonList(new Engine(getEngineRating(), Engine.NORMAL_ENGINE, 0));
}
List<Engine> retVal = new ArrayList<>();
boolean isMixed = techManager.useMixedTech();
int flags = 0;
if (techManager.useClanTechBase()) {
flags |= Engine.CLAN_ENGINE;
}
if (getEngineRating() > 400) {
flags |= Engine.LARGE_ENGINE;
}
int altFlags = flags ^ Engine.CLAN_ENGINE;
// Non-superheavies can use non-fusion engines under experimental rules
for (int i : ENGINE_TYPES) {
Engine e = new Engine(getEngineRating(), i, flags);
if (e.engineValid && (e.isFusion() || conventional) && techManager.isLegal(e)) {
retVal.add(e);
}
// Only add the opposite tech base if the engine is different.
if (isMixed && e.getSideTorsoCriticalSlots().length > 0) {
e = new Engine(getEngineRating(), i, altFlags);
if (e.engineValid && (e.isFusion() || conventional) && techManager.isLegal(e)) {
retVal.add(e);
}
}
}
return retVal;
}
use of megamek.common.Engine in project megameklab by MegaMek.
the class MekChassisView method setEngine.
/**
* Select the first engine in the list that matches engine type and flags,
* ignoring any flags other than Clan.
*/
public void setEngine(Engine engine) {
if (null != engine) {
int type = engine.getEngineType();
int flags = engine.getFlags() & Engine.CLAN_ENGINE;
for (int i = 0; i < cbEngine.getModel().getSize(); i++) {
final Engine e = cbEngine.getItemAt(i);
if ((e.getEngineType() == type) && ((e.getFlags() & Engine.CLAN_ENGINE) == flags)) {
cbEngine.setSelectedIndex(i);
return;
}
}
}
}
use of megamek.common.Engine in project megameklab by MegaMek.
the class MekChassisView method refreshEngine.
private void refreshEngine() {
cbEngine.removeActionListener(this);
Engine prevEngine = (Engine) cbEngine.getSelectedItem();
cbEngine.removeAllItems();
for (Engine e : getAvailableEngines()) {
cbEngine.addItem(e);
}
setEngine(prevEngine);
cbEngine.addActionListener(this);
if (cbEngine.getSelectedIndex() < 0) {
cbEngine.setSelectedIndex(0);
}
}
use of megamek.common.Engine in project megameklab by MegaMek.
the class MekChassisView method getEngine.
public Engine getEngine() {
Engine e = (Engine) cbEngine.getSelectedItem();
if (null == e) {
return null;
}
// Clan and large flags are specific to the engine. the superheavy flag depends on the mech
// and may have changed since the last refresh.
int flags = e.getFlags() & (Engine.CLAN_ENGINE | Engine.LARGE_ENGINE);
if (isSuperheavy()) {
flags |= Engine.SUPERHEAVY_ENGINE;
}
return new Engine(getEngineRating(), e.getEngineType(), flags);
}
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_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());
}
Aggregations