fix arrows drawing out of bounds

This commit is contained in:
Anthony Calosa
2024-11-16 19:50:09 +08:00
parent 95e3304948
commit 5597d0bf31

View File

@@ -466,22 +466,35 @@ public class MatchScreen extends FScreen {
final GameView game = MatchController.instance.getGameView(); final GameView game = MatchController.instance.getGameView();
try { try {
for (PlayerView p : game.getPlayers()) { for (PlayerView p : game.getPlayers()) {
if (p != null && playerPanelsList.contains(getPlayerPanel(p))) { if (p == null)
continue;
VPlayerPanel playerPanel = getPlayerPanel(p);
if (playerPanel != null && playerPanelsList.contains(playerPanel)) {
playerViewSet.add(p); playerViewSet.add(p);
if (p.getBattlefield() != null) { if (p.getBattlefield() != null) {
for (CardView c : p.getBattlefield()) { for (CardView c : p.getBattlefield()) {
endpoints.put(c.getId(), CardAreaPanel.get(c).getTargetingArrowOrigin()); CardAreaPanel panel = CardAreaPanel.get(c);
Vector2 origin = panel.getTargetingArrowOrigin();
//outside left bounds
if (origin.x < playerPanel.getField().getLeft())
continue;
//outside right bounds
if (origin.x > playerPanel.getField().getRight())
continue;
endpoints.put(c.getId(), origin);
cardsonBattlefield.add(c); cardsonBattlefield.add(c);
} }
} }
} }
} }
if (endpoints.isEmpty())
return;
//draw arrows for combat //draw arrows for combat
final CombatView combat = game.getCombat(); final CombatView combat = game.getCombat();
for (CardView c : cardsonBattlefield) { for (CardView c : cardsonBattlefield) {
TargetingOverlay.assembleArrows(g, c, endpoints, combat, playerViewSet); TargetingOverlay.assembleArrows(g, c, endpoints, combat, playerViewSet);
} }
} catch (Exception e) { } catch (Exception ignored) {
} }
} }