| 572 | } |
| 573 | |
| 574 | bool BattleUnit::calculateVisionToUnit(GameState &state, BattleUnit &u) |
| 575 | { |
| 576 | auto eyesPos = getEyeLocation(); |
| 577 | auto &map = *state.current_battle->map; |
| 578 | |
| 579 | // Unit unconscious, we own this unit or can't see it, skip |
| 580 | if (!u.isConscious() || u.owner == owner || !isWithinVision(u.position)) |
| 581 | { |
| 582 | return false; |
| 583 | } |
| 584 | auto target = u.tileObject->getCenter(); |
| 585 | if (u.isLarge()) |
| 586 | { |
| 587 | // Offset search for large units as they can get caught up in ground |
| 588 | // that is supposed to allow units to go through it but blocks LOS |
| 589 | auto targetvVectorDelta = glm::normalize(target - eyesPos) * 0.75f; |
| 590 | target -= targetvVectorDelta; |
| 591 | } |
| 592 | auto c = map.findCollision(eyesPos, target, mapPartSet, tileObject, true, false, |
| 593 | VIEW_DISTANCE / (u.isCloaked() ? 2 : 1)); |
| 594 | if (c || c.outOfRange) |
| 595 | { |
| 596 | return false; |
| 597 | } |
| 598 | return true; |
| 599 | } |
| 600 | |
| 601 | void BattleUnit::calculateVisionToUnits(GameState &state) |
| 602 | { |
nothing calls this directly
no test coverage detected