Skip to content

Commit

Permalink
Dumper Equipment: Cargo link cleanup, data updates to affected units
Browse files Browse the repository at this point in the history
  • Loading branch information
SJuliez committed Jul 9, 2023
1 parent 68922a8 commit 32d4e90
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
1
</BlockVersion>

# Write the version number just in case...
##Write the version number just in case...
<Version>
MAM0
</Version>
Expand All @@ -16,9 +16,9 @@ LargeSupportTank
Brunel Dump Truck
</Name>

<model>
<Model>

</model>
</Model>

<mul id:>
3866
Expand All @@ -28,6 +28,10 @@ Brunel Dump Truck
2637
</year>

<originalBuildYear>
2637
</originalBuildYear>

<type>
IS Level 3
</type>
Expand All @@ -36,6 +40,9 @@ IS Level 3
Wheeled
</motion_type>

<transporters>
</transporters>

<cruiseMP>
3
</cruiseMP>
Expand All @@ -44,14 +51,6 @@ Wheeled
1
</engine_type>

<fuel>
4
</fuel>

<barrating>
6
</barrating>

<armor>
21
13
Expand All @@ -61,14 +60,6 @@ Wheeled
10
</armor>

<structural_tech_rating>
3
</structural_tech_rating>

<armor_tech_rating>
2
</armor_tech_rating>

<Body Equipment>
ISOffRoadChassis
</Body Equipment>
Expand All @@ -91,16 +82,42 @@ Backhoe

<Rear Equipment>
Dumper (Rear)
Cargo:SIZE:50.0
</Rear Equipment>

<tonnage>
150.0
</tonnage>
<barrating>
6
</barrating>

<source>
TRO: Vehicle Annex (Revised)
</source>
<structural_tech_rating>
3
</structural_tech_rating>

<engine_tech_rating>
3
</engine_tech_rating>

<armor_tech_rating>
2
</armor_tech_rating>

<history>
Armor is based on fluff. No Record Sheet available.
</history>

<source>
TRO: Vehicle Annex (Revised)
</source>

<tonnage>
150.0
</tonnage>

<fuel>
4.0
</fuel>

<fuelType>
PETROCHEMICALS
</fuelType>

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
1
</BlockVersion>

# Write the version number just in case...
##Write the version number just in case...
<Version>
MAM0
</Version>
Expand All @@ -16,9 +16,9 @@ SupportTank
Lesseps Dump Truck
</Name>

<model>
<Model>

</model>
</Model>

<mul id:>
4499
Expand All @@ -28,6 +28,10 @@ Lesseps Dump Truck
2523
</year>

<originalBuildYear>
2523
</originalBuildYear>

<type>
IS Level 3
</type>
Expand All @@ -36,6 +40,9 @@ IS Level 3
Wheeled
</motion_type>

<transporters>
</transporters>

<cruiseMP>
3
</cruiseMP>
Expand All @@ -44,25 +51,13 @@ Wheeled
11
</engine_type>

<fuel>
4
</fuel>

<armor>
28
19
19
12
</armor>

<barrating>
5
</barrating>

<structural_tech_rating>
3
</structural_tech_rating>

<Body Equipment>
ISOffRoadChassis
</Body Equipment>
Expand All @@ -79,11 +74,24 @@ Backhoe

<Rear Equipment>
Dumper (Rear)
Cargo:SIZE:20.0
</Rear Equipment>

<transporters>
cargobay:20:1
</transporters>
<barrating>
5
</barrating>

<structural_tech_rating>
3
</structural_tech_rating>

<engine_tech_rating>
3
</engine_tech_rating>

<armor_tech_rating>
3
</armor_tech_rating>

<source>
TRO: Vehicle Annex (Revised)
Expand All @@ -92,3 +100,8 @@ TRO: Vehicle Annex (Revised)
<tonnage>
50.0
</tonnage>

<fuel>
4.0
</fuel>

19 changes: 11 additions & 8 deletions megamek/src/megamek/common/MechFileParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -783,24 +783,27 @@ else if ((ent instanceof Infantry) && ((Infantry) ent).canMakeAntiMekAttacks())
}

/**
* Links Dumpers to Cargo equipment if there is one in the same location. Works only for variable size
* Cargo, {@link MiscType#createCargo()}, (but not Liquid Storage, Cargo containers/bays)
* Links each Dumper to the first (unlinked) Cargo equipment if there is one in the same location.
* Works only for variable size Cargo, {@link MiscType#createCargo()}, but not Liquid Storage,
* Cargo containers or bays.
*
* @param entity The entity to add links to
*/
static void linkDumpers(Entity entity) {
List<Mounted> dumpers = entity.getMisc().stream()
.filter(mounted -> mounted.getType().hasFlag(MiscType.F_DUMPER)).collect(Collectors.toList());

List<Mounted> cargos = entity.getMisc().stream()
.filter(mounted -> mounted.is(EquipmentTypeLookup.CARGO)).collect(Collectors.toList());
cargos.forEach(cargo -> cargo.setLinkedBy(null));

for (Mounted dumper : dumpers) {
if (dumper.getLinked() == null) {
for (Mounted cargo : cargos) {
if ((cargo.getLinkedBy() == null) && (cargo.getLocation() == dumper.getLocation())) {
dumper.setLinked(cargo);
break;
}
dumper.setLinked(null);
for (Mounted cargo : cargos) {
if ((cargo.getLinkedBy() == null) && (cargo.getLocation() == dumper.getLocation())) {
dumper.setLinked(cargo);
cargo.setLinkedBy(dumper);
break;
}
}
}
Expand Down

0 comments on commit 32d4e90

Please sign in to comment.