Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use best hex for FoV highlighting for multi-hex units #5809

Merged
merged 2 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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