Skip to content

Commit

Permalink
Removed static armor weight methods for BA and protos from EquipmentT…
Browse files Browse the repository at this point in the history
…ype.
  • Loading branch information
neoancient committed Jan 28, 2024
1 parent 253d1d4 commit e3cc82f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import javax.swing.UIManager;

import megamek.common.*;
import megamek.common.equipment.ArmorType;
import megamek.common.verifier.TestSupportVehicle;
import megameklab.ui.generalUnit.ArmorLocationView.ArmorLocationListener;
import megameklab.ui.listeners.ArmorAllocationListener;
Expand Down Expand Up @@ -261,8 +262,7 @@ public void setFromEntity(Entity en) {
txtPointsPerTon.setToolTipText(resourceMap.getString("ArmorAllocationView.txtKgPerPoint.tooltip"));
} else if (en instanceof Protomech) {
txtPointsPerTon.setText(String.format("%d",
(int) (EquipmentType.getProtomechArmorWeightPerPoint(en.getArmorType(Protomech.LOC_BODY))
* 1000)));
(int) (ArmorType.forEntity(en).getWeightPerPoint() * 1000)));
lblPointsPerTon.setText(resourceMap.getString("ArmorAllocationView.txtKgPerPoint.text"));
txtPointsPerTon.setToolTipText(resourceMap.getString("ArmorAllocationView.txtKgPerPoint.tooltip"));
} else {
Expand Down
7 changes: 3 additions & 4 deletions megameklab/src/megameklab/ui/protoMek/PMStructureTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import megamek.codeUtilities.MathUtility;
import megamek.common.*;
import megamek.common.equipment.ArmorType;
import megamek.common.verifier.TestEntity;
import megamek.common.verifier.TestProtomech;
import megamek.common.verifier.TestProtomech.ProtomechArmor;
Expand Down Expand Up @@ -459,9 +460,7 @@ public void armorTypeChanged(EquipmentType armor) {

@Override
public void armorFactorChanged(int points) {
double tonnage = EquipmentType.getProtomechArmorWeightPerPoint(
getProtomech().getArmorType(Protomech.LOC_TORSO))
* points;
double tonnage = ArmorType.forEntity(getProtomech()).getWeightPerPoint() * points;
getProtomech().setArmorTonnage(tonnage);
panArmorAllocation.setFromEntity(getProtomech());
panSummary.refresh();
Expand Down Expand Up @@ -493,7 +492,7 @@ public void useRemainingTonnageArmor() {
totalTonnage - currentTonnage, TestEntity.Ceil.KILO);
// We can only use remaining tonnage equal to whole points of armor.
remainingTonnage = (int) UnitUtil.getRawArmorPoints(getProtomech(), remainingTonnage)
* EquipmentType.getProtomechArmorWeightPerPoint(getProtomech().getArmorType(Protomech.LOC_TORSO));
* ArmorType.forEntity(getProtomech()).getWeightPerPoint();
double maxArmor = MathUtility.clamp(getProtomech().getLabArmorTonnage() + remainingTonnage, 0,
UnitUtil.getMaximumArmorTonnage(getProtomech()));
getProtomech().setArmorTonnage(maxArmor);
Expand Down
3 changes: 1 addition & 2 deletions megameklab/src/megameklab/util/UnitUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,7 @@ public static double getMaximumArmorTonnage(Entity unit) {
*/
public static double getRawArmorPoints(Entity unit, double armorTons) {
if (unit.hasETypeFlag(Entity.ETYPE_PROTOMECH)) {
return Math.round(armorTons /
EquipmentType.getProtomechArmorWeightPerPoint(unit.getArmorType(Protomech.LOC_TORSO)));
return Math.round(armorTons / ArmorType.forEntity(unit).getWeightPerPoint());
} else if (unit.isSupportVehicle()) {
return Math.floor(armorTons / TestSupportVehicle.armorWeightPerPoint(unit));
} else if ((unit instanceof Jumpship)
Expand Down

0 comments on commit e3cc82f

Please sign in to comment.