Skip to content

Commit

Permalink
Merge pull request #5809 from SJuliez/ds-fov
Browse files Browse the repository at this point in the history
Use best hex for FoV highlighting for multi-hex units
  • Loading branch information
Sleet01 authored Jul 28, 2024
2 parents e86f08f + 8b06aec commit 63226af
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
15 changes: 15 additions & 0 deletions megamek/data/scenarios/Test Setups/DS_LOS.mms
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
MMSVersion: 2
name: Grounded DS Test
planet: None
description: A grounded DS on a small map for use in range/LOS/FoV testing

map: AGoAC Maps/16x17 Grassland 2.board

factions:
- name: Test Player

units:
- fullname: Intruder (3056)
at: [ 10, 9 ]
altitude: 0

Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ boolean draw(Graphics boardGraph, Coords c, int drawX, int drawY, boolean saveBo
Coords src;
boolean hasLoS = true;
// in movement phase, calc LOS based on selected hex, otherwise use selected Entity
if (this.boardView1.game.getPhase().isMovement() && this.boardView1.selected != null) {
src = this.boardView1.selected;
} else if (this.boardView1.getSelectedEntity() != null) {
src = this.boardView1.getSelectedEntity().getPosition();
if (boardView1.game.getPhase().isMovement() && this.boardView1.selected != null) {
src = boardView1.selected;
} else if (boardView1.getSelectedEntity() != null) {
Entity viewer = boardView1.getSelectedEntity();
src = viewer.getPosition();
// multi-hex units look from the hex closest to the target to avoid self-blocking
src = viewer.getSecondaryPositions().values().stream()
.min(Comparator.comparingInt(co -> co.distance(c))).orElse(src);
} else {
src = null;
}
Expand Down

0 comments on commit 63226af

Please sign in to comment.