Skip to content

Commit 437b514

Browse files
authored
Merge pull request #7978 from psikomonkie/pr/transport-hhw-in-arms
2 parents 97d27d2 + a4da8c6 commit 437b514

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

MekHQ/resources/mekhq/resources/AssignForceToTransport.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ AssignForceToTransportMenu.DOCKING_COLLAR.text=Docking Collar
5757
AssignForceToTransportMenu.TANK_TRAILER_HITCH.text=Trailer Hitch
5858
AssignForceToTransportMenu.CARGO_BAY.text=Cargo Bay (Standard)
5959
AssignForceToTransportMenu.CARGO_CONTAINER.text=Cargo Container
60+
AssignForceToTransportMenu.MEK_ARMS.text=Mek Arms
61+
AssignForceToTransportMenu.LIFT_HOIST.text=Lift Hoist
62+
AssignForceToTransportMenu.ROOF_RACK.text=Roof Rack
6063
TOEMouseAdapter.unassign.TACTICAL_TRANSPORT.text=Unassign Force from Tactical Transport
6164
TOEMouseAdapter.unassign.SHIP_TRANSPORT.text=Unassign Force from Ship Transport
6265
TOEMouseAdapter.unassign.TOW_TRANSPORT.text=Unassign Force from Tractor

MekHQ/src/mekhq/campaign/unit/Unit.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5639,6 +5639,10 @@ public boolean isUnmannedTrailer() {
56395639
return false;
56405640
}
56415641

5642+
public boolean isHandheldWeapon() {
5643+
return entity instanceof HandheldWeapon;
5644+
}
5645+
56425646
public int getForceId() {
56435647
return forceId;
56445648
}
@@ -6676,7 +6680,8 @@ public Money getSparePartsCost() {
66766680
partsCost = partsCost.multipliedBy(2.0);
66776681
}
66786682

6679-
if (!(entity instanceof Infantry)) {
6683+
// No engines for infantry or HHW
6684+
if (!(entity instanceof Infantry) && !(entity instanceof HandheldWeapon)) {
66806685
if ((engine.getEngineType() == Engine.XL_ENGINE) || (engine.getEngineType() == Engine.XXL_ENGINE)) {
66816686
partsCost = partsCost.multipliedBy(2.5);
66826687
} else if (engine.getEngineType() == Engine.LIGHT_ENGINE) {

MekHQ/src/mekhq/campaign/utilities/CampaignTransportUtilities.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
import megamek.common.battleArmor.BattleArmor;
4444
import megamek.common.equipment.Cargo;
45+
import megamek.common.equipment.HandheldWeapon;
4546
import megamek.common.equipment.ICarryable;
4647
import megamek.common.units.*;
4748
import mekhq.campaign.enums.CampaignTransportType;
@@ -328,6 +329,28 @@ public EnumSet<TransporterType> getTransporterTypes(Cargo cargo,
328329
transporters.add(ROOF_RACK);
329330
}
330331

332+
return transporters;
333+
}
334+
},
335+
new Visitor<HandheldWeapon>() {
336+
@Override
337+
public boolean isInterestedIn(ICarryable entity) {
338+
return entity instanceof HandheldWeapon;
339+
}
340+
341+
@Override
342+
public EnumSet<TransporterType> getTransporterTypes(HandheldWeapon handheldWeapon,
343+
CampaignTransportType
344+
campaignTransportType) {
345+
EnumSet<TransporterType> transporters = EnumSet.noneOf(TransporterType.class);
346+
347+
//Ship transports can't use some transport types
348+
if (!(campaignTransportType.isShipTransport())) {
349+
// For now just MekArms. This should be expanded to include regular cargo bays and lift hoists
350+
// once those are supported for HHW in MHQ
351+
transporters.add(MEK_ARMS);
352+
}
353+
331354
return transporters;
332355
}
333356
});

MekHQ/src/mekhq/gui/adapter/TOEMouseAdapter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ protected Optional<JPopupMenu> createPopupMenu() {
10231023
// Only add units that have commanders
10241024
// Or Gun Emplacements!
10251025
// Or don't need a crew (trailers)
1026+
// Or HHWs
10261027
// TODO: Or Robotic Systems!
10271028
JMenu unsorted = new JMenu("Unsorted");
10281029

@@ -1044,7 +1045,9 @@ protected Optional<JPopupMenu> createPopupMenu() {
10441045
}
10451046
unitTypeMenus.get(type).setEnabled(true);
10461047
}
1047-
} else if ((u.getForceId() < 1) && (u.isPresent()) && (u.isUnmannedTrailer())) {
1048+
} else if ((u.getForceId() < 1) &&
1049+
(u.isPresent()) &&
1050+
(u.isUnmannedTrailer() || u.isHandheldWeapon())) {
10481051
JMenuItem menuItem0 = new JMenuItem(u.getName());
10491052
menuItem0.setActionCommand(TOEMouseAdapter.COMMAND_ADD_UNIT + u.getId() + '|' + forceIds);
10501053
menuItem0.addActionListener(this);

0 commit comments

Comments
 (0)