Skip to content

Commit

Permalink
Merge pull request #5706 from MegaMek/carry_objects
Browse files Browse the repository at this point in the history
Fix #2577, Fix #897, Fix #353
  • Loading branch information
NickAragua authored Jul 30, 2024
2 parents 9d4bccf + 6b48dd4 commit adae3a1
Show file tree
Hide file tree
Showing 40 changed files with 1,765 additions and 202 deletions.
Binary file added megamek/data/images/misc/cargo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions megamek/i18n/megamek/client/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,8 @@ DeployMinefieldDisplay.its_your_turn=It's your turn to deploy minefields.
DeployMinefieldDisplay.removeMines=Remove
DeployMinefieldDisplay.waitingForDeploymentPhase=Waiting to begin Deployment phase...
DeployMinefieldDisplay.waitingForDeployMinefieldPhase=Waiting to begin Deploy minefield phase...
DeployMinefieldDisplay.deployCarriable=Cargo({0})
DeployMinefieldDisplay.deployCarriableDialogHeader=Deploy Ground Object

#Expand Map Dialog
ExpandMapDialog.title=Expand map settings
Expand Down Expand Up @@ -2432,6 +2434,8 @@ MovementDisplay.butLoad=Load
MovementDisplay.butLand=Land
MovementDisplay.butJoin=Join
MovementDisplay.butManeuver=Maneuver
MovementDisplay.moveDropCargo=Drop Cargo
MovementDisplay.movePickupCargo=Pick Up Cargo
MovementDisplay.moveModeConvert=Convert Mode
MovementDisplay.moveModeLeg=Walk
MovementDisplay.moveModeTrack=Engage tracks
Expand Down Expand Up @@ -2876,6 +2880,7 @@ PlayerSettingsDialog.header.initMod=Initiative Modifier
PlayerSettingsDialog.header.minefields=Minefields
PlayerSettingsDialog.header.skills=Method for Rolling Pilot Skills
PlayerSettingsDialog.header.email=Round Report Email
PlayerSettingsDialog.header.GroundObjects=Carryable Ground Objects
PlayerSettingsDialog.botSettings=Bot Settings...
PlayerSettingsDialog.autoConfigFaction=Faction:
PlayerSettingsDialog.autoConfig=Autoconfig
Expand Down Expand Up @@ -3935,6 +3940,8 @@ WeaponAttackAction.BPodAtInf=B-Pod firing at infantry
WeaponAttackAction.BPodOnlyAtInf=B-Pods can't target non-infantry.
WeaponAttackAction.CantAimAndCallShots=you can't combine aimed shots and called shots.
WeaponAttackAction.CantClearMines=Weapon can't clear minefields.
WeaponAttackAction.CantFireWhileCarryingCargo=Carrying cargo prevents arm/torso weapon firing.
WeaponAttackAction.CantFireWhileLoadingUnloadingCargo=Cannot fire weapons while loading/unloading cargo.
WeaponAttackAction.CantFireWhileGrappled=Can only fire head and front torso weapons when grappled.
WeaponAttackAction.CantFireWithOtherWeapons=Already firing a weapon that can only be fired by itself! (%s)
WeaponAttackAction.CantFireArmsAndMainGun=Can't fire arm-mounted weapons and the main gun in the same turn.
Expand Down
11 changes: 11 additions & 0 deletions megamek/i18n/megamek/common/report-messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
2005=<newline><data> (<data>) flees the battlefield.
2010=It carries <data> (<data>) with it.
2015=It takes <data> (<data>) with it.
2016=It carries <data> with it.
2020=<newline><data> ejects from a <data> (<data>).
2025=<newline><data> (<data>) is abandoned by its crew.
2026=<newline><data> (<data>) is given the order to abandon ship.
Expand Down Expand Up @@ -254,6 +255,11 @@
2510=, <span class='warning'>Starts to flip.</span>
2511=, <span class='warning'>Capsizes and sinks.</span>
2512=<data> deploys a chaff pod.
2513=<data> loads <data> from <data>.
2514=<data> unloads <data> in <data>
2515=<data> is dropped to the ground. Needs <data>, rolls <data> : <msg:2516,2517>
2516=<span class='success'>success</span> - cargo remains intact.
2517=<span class='warning'>failure</span> - cargo destroyed!

3000=<newline><B>Weapon Attack Phase</B><newline>-------------------
3003=Inferno fire (bombs) started in hex <data>.
Expand Down Expand Up @@ -980,6 +986,11 @@
6700=Limb Blow off avoided due to armored actuator.
6710=Critical hit to <data> avoided due to armored component.

#cargo reports.
6720=<data> damaged by incoming attack. <data> tons remaining.
6721=<data> damaged by incoming attack and is completely destroyed.
6722=<data> is dropped to the ground due to the carrying unit falling.

6800=<data> (<data>) was not properly secured prior to takeoff.

7000=<newline><B>Victory!</B><newline>-------------------<newline>
Expand Down
16 changes: 16 additions & 0 deletions megamek/src/megamek/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,13 @@ public void sendAddSquadron(FighterSquadron fs, Collection<Integer> fighterIds)
public void sendDeployMinefields(Vector<Minefield> minefields) {
send(new Packet(PacketCommand.DEPLOY_MINEFIELDS, minefields));
}

/**
* Sends an updated state of ground objects (i.e. cargo etc)
*/
public void sendDeployGroundObjects(Map<Coords, List<ICarryable>> groundObjects) {
send(new Packet(PacketCommand.UPDATE_GROUND_OBJECTS, groundObjects));
}

/**
* Sends a "set Artillery Autohit Hexes" packet
Expand Down Expand Up @@ -576,6 +583,12 @@ protected void receiveEntityVisibilityIndicator(Packet packet) {
game.processGameEvent(new GameEntityChangeEvent(this, e));
}
}

@SuppressWarnings("unchecked")
protected void receiveUpdateGroundObjects(Packet packet) {
game.setGroundObjects((Map<Coords, List<ICarryable>>) packet.getObject(0));
game.processGameEvent(new GameBoardChangeEvent(this));
}

@SuppressWarnings("unchecked")
protected void receiveDeployMinefields(Packet packet) {
Expand Down Expand Up @@ -885,6 +898,9 @@ protected boolean handleGameSpecificPacket(Packet packet) {
case REMOVE_MINEFIELD:
receiveRemoveMinefield(packet);
break;
case UPDATE_GROUND_OBJECTS:
receiveUpdateGroundObjects(packet);
break;
case ADD_SMOKE_CLOUD:
SmokeCloud cloud = (SmokeCloud) packet.getObject(0);
game.addSmokeCloud(cloud);
Expand Down
17 changes: 14 additions & 3 deletions megamek/src/megamek/client/ui/swing/ClientGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ public class ClientGUI extends AbstractClientGUI implements BoardViewListener,
private MovementModifierSpriteHandler movementModifierSpriteHandler;
private SensorRangeSpriteHandler sensorRangeSpriteHandler;
private CollapseWarningSpriteHandler collapseWarningSpriteHandler;
private GroundObjectSpriteHandler groundObjectSpriteHandler;
private FiringSolutionSpriteHandler firingSolutionSpriteHandler;
private FiringArcSpriteHandler firingArcSpriteHandler;

Expand Down Expand Up @@ -490,12 +491,13 @@ private void initializeSpriteHandlers() {
FlareSpritesHandler flareSpritesHandler = new FlareSpritesHandler(bv, client.getGame());
sensorRangeSpriteHandler = new SensorRangeSpriteHandler(bv, client.getGame());
collapseWarningSpriteHandler = new CollapseWarningSpriteHandler(bv);
groundObjectSpriteHandler = new GroundObjectSpriteHandler(bv, client.getGame());
firingSolutionSpriteHandler = new FiringSolutionSpriteHandler(bv, client);
firingArcSpriteHandler = new FiringArcSpriteHandler(bv, this);

spriteHandlers.addAll(List.of(movementEnvelopeHandler, movementModifierSpriteHandler,
sensorRangeSpriteHandler, flareSpritesHandler, collapseWarningSpriteHandler,
firingSolutionSpriteHandler, firingArcSpriteHandler));
groundObjectSpriteHandler, firingSolutionSpriteHandler, firingArcSpriteHandler));
spriteHandlers.forEach(BoardViewSpriteHandler::initialize);
}

Expand Down Expand Up @@ -1177,7 +1179,7 @@ void switchPanel(GamePhase phase) {
// otherwise, hide the panel
panSecondary.setVisible(false);
}

// Set the new panel's listeners
if (curPanel instanceof BoardViewListener) {
bv.addBoardViewListener((BoardViewListener) curPanel);
Expand Down Expand Up @@ -2912,11 +2914,20 @@ public void showSensorRanges(Entity entity, Coords assumedPosition) {
/**
* Shows collapse warnings in the given list of Coords in the BoardView
*
* @param warnList The Coords to show the warning on
* @param warnList The list of coordinates to show the warning on
*/
public void showCollapseWarning(List<Coords> warnList) {
collapseWarningSpriteHandler.setCFWarningSprites(warnList);
}

/**
* Shows ground object icons in the given list of Coords in the BoardView
*
* @param groundObjectList The list of coordinates to show
*/
public void showGroundObjects(Map<Coords, List<ICarryable>> groundObjectList) {
groundObjectSpriteHandler.setGroundObjectSprites(groundObjectList);
}

/**
* Shows firing solutions from the viewpoint of the given entity on targets
Expand Down
Loading

0 comments on commit adae3a1

Please sign in to comment.