* fix the ammo when it's added
*/
public void displayMech(Entity en) {
// Grab a copy of the game.
IGame game = client.getClient().game;
// update pointer to weapons
entity = en;
int currentHeatBuildup = en.heat // heat from last round
+ en.getEngineCritHeat() // heat engine crits will add
+ Math.min(15, en.heatFromExternal) // heat from external
// sources
+ en.heatBuildup; // heat we're building up this round
if (en instanceof Mech) {
if (en.infernos.isStillBurning()) { // hit with inferno ammo
currentHeatBuildup += en.infernos.getHeat();
}
if (!((Mech) en).hasLaserHeatSinks()) {
// extreme temperatures.
if (game.getPlanetaryConditions().getTemperature() > 0) {
currentHeatBuildup += game.getPlanetaryConditions()
.getTemperatureDifference(50, -30);
} else {
currentHeatBuildup -= game.getPlanetaryConditions()
.getTemperatureDifference(50, -30);
}
}
}
Coords position = entity.getPosition();
if (!en.isOffBoard() && (position != null)) {
IHex hex = game.getBoard().getHex(position);
if (hex.containsTerrain(Terrains.FIRE) && (hex.getFireTurn() > 0)) {
currentHeatBuildup += 5; // standing in fire
}
if (hex.terrainLevel(Terrains.MAGMA) == 1) {
currentHeatBuildup += 5;
} else if (hex.terrainLevel(Terrains.MAGMA) == 2) {
currentHeatBuildup += 10;
}
}
if ((en instanceof Mech)
&& (en.isStealthActive() || en.isNullSigActive() || en
.isVoidSigActive())) {
currentHeatBuildup += 10; // active stealth/nullsig/void sig
// heat
}
if ((en instanceof Mech) && en.isChameleonShieldActive()) {
currentHeatBuildup += 6;
}
for (Mounted m : entity.getEquipment()) {
int capHeat = 0;
if (m.hasChargedCapacitor()) {
capHeat += 5;
}
if (capHeat > 0) {
currentHeatBuildup += capHeat;
}
}
// update weapon list
weaponList.removeAll();
m_chAmmo.removeAll();
m_chAmmo.setEnabled(false);
m_chBayWeapon.removeAll();
m_chBayWeapon.setEnabled(false);
// on large craft we may need to take account of firing arcs
boolean[] usedFrontArc = new boolean[entity.locations()];
boolean[] usedRearArc = new boolean[entity.locations()];
for (int i = 0; i < entity.locations(); i++) {
usedFrontArc[i] = false;
usedRearArc[i] = false;
}
for (int i = 0; i < entity.getWeaponList().size(); i++) {
Mounted mounted = entity.getWeaponList().get(i);
WeaponType wtype = (WeaponType) mounted.getType();
StringBuffer wn = new StringBuffer(mounted.getDesc());
wn.append(" ["); //$NON-NLS-1$
wn.append(en.getLocationAbbr(mounted.getLocation()));
if (mounted.isSplit()) {
wn.append("/"); //$NON-NLS-1$
wn.append(en.getLocationAbbr(mounted.getSecondLocation()));
}
wn.append("]"); //$NON-NLS-1$
// determine shots left & total shots left
if ((wtype.getAmmoType() != AmmoType.T_NA)
&& !wtype.hasFlag(WeaponType.F_ONESHOT)) {
int shotsLeft = 0;
if ((mounted.getLinked() != null)
&& !mounted.getLinked().isDumping()) {
shotsLeft = mounted.getLinked().getShotsLeft();
}
EquipmentType typeUsed = null;
if (null != mounted.getLinked()) {
typeUsed = mounted.getLinked().getType();
}
int totalShotsLeft = entity
.getTotalMunitionsOfType(typeUsed);
wn.append(" ("); //$NON-NLS-1$
wn.append(shotsLeft);
wn.append("/"); //$NON-NLS-1$
wn.append(totalShotsLeft);
wn.append(")"); //$NON-NLS-1$
}
// MG rapidfire
if (mounted.isRapidfire()) {
wn.append(Messages.getString("MechDisplay.rapidFire")); //$NON-NLS-1$
}
// Hotloaded Missiles/Launchers
if (mounted.isHotLoaded()) {
wn.append(Messages.getString("MechDisplay.isHotLoaded")); //$NON-NLS-1$
}
// Fire Mode - lots of things have variable modes
if (wtype.hasModes()) {
wn.append(" ");
wn.append(mounted.curMode().getDisplayableName());
}
weaponList.add(wn.toString());
if (mounted.isUsedThisRound()
&& (game.getPhase() == mounted.usedInPhase())
&& (game.getPhase() == IGame.Phase.PHASE_FIRING)) {
// add heat from weapons fire to heat tracker
if (entity.usesWeaponBays()) {
// if using bay heat option then don't add total arc
if (game.getOptions().booleanOption("heat_by_bay")) {
for (int wId : mounted.getBayWeapons()) {
currentHeatBuildup += entity.getEquipment(wId)
.getCurrentHeat();
}
} else {
// check whether arc has fired
int loc = mounted.getLocation();
boolean rearMount = mounted.isRearMounted();
if (!rearMount) {
if (!usedFrontArc[loc]) {
currentHeatBuildup += entity.getHeatInArc(
loc, rearMount);
usedFrontArc[loc] = true;
}
} else {
if (!usedRearArc[loc]) {
currentHeatBuildup += entity.getHeatInArc(
loc, rearMount);
usedRearArc[loc] = true;
}
}
}
} else {
if (!mounted.isBombMounted()) {
currentHeatBuildup += mounted.getCurrentHeat();
}
}
}
}
// This code block copied from the MovementPanel class,
// bad coding practice (duplicate code).
int heatCap = en.getHeatCapacity();
int heatCapWater = en.getHeatCapacityWithWater();
String heatCapacityStr = Integer.toString(heatCap);
if (heatCap < heatCapWater) {
heatCapacityStr = heatCap + " [" + heatCapWater + "]"; //$NON-NLS-1$ //$NON-NLS-2$
}
// end duplicate block
String heatText = Integer.toString(currentHeatBuildup);
if (currentHeatBuildup > en.getHeatCapacityWithWater()) {
heatText += "*"; // overheat indication //$NON-NLS-1$
}
// check for negative values due to extreme temp
if (currentHeatBuildup < 0) {
currentHeatBuildup = 0;
}
currentHeatBuildupR
.setText(heatText + " (" + heatCapacityStr + ")"); //$NON-NLS-1$ //$NON-NLS-2$
// change what is visible based on type
if (entity.usesWeaponBays()) {
wArcHeatL.setVisible(true);
wArcHeatR.setVisible(true);
m_chBayWeapon.setVisible(true);
wBayWeapon.setVisible(true);
} else {
wArcHeatL.setVisible(false);
wArcHeatR.setVisible(false);
m_chBayWeapon.setVisible(false);
wBayWeapon.setVisible(false);
}
if (entity instanceof Aero) {
wAVL.setVisible(true);
wShortAVR.setVisible(true);
wMedAVR.setVisible(true);
wLongAVR.setVisible(true);
wExtAVR.setVisible(true);
wMinL.setVisible(false);
wMinR.setVisible(false);
} else {
wAVL.setVisible(false);
wShortAVR.setVisible(false);
wMedAVR.setVisible(false);
wLongAVR.setVisible(false);
wExtAVR.setVisible(false);
wMinL.setVisible(true);
wMinR.setVisible(true);
}
// If MaxTech range rules are in play, display the extreme range.
if (game.getOptions().booleanOption("tacops_range") || (entity instanceof Aero)) { //$NON-NLS-1$
wExtL.setVisible(true);
wExtR.setVisible(true);
} else {
wExtL.setVisible(false);
wExtR.setVisible(false);