| 1421 | } |
| 1422 | |
| 1423 | void Battle::updateVision(GameState &state) |
| 1424 | { |
| 1425 | std::set<sp<BattleUnit>> unitsToUpdate; |
| 1426 | for (auto &entry : units) |
| 1427 | { |
| 1428 | auto unit = entry.second; |
| 1429 | if (!unit->isConscious()) |
| 1430 | { |
| 1431 | continue; |
| 1432 | } |
| 1433 | for (auto &pos : tilesChangedForVision) |
| 1434 | { |
| 1435 | auto vec = pos - (Vec3<int>)unit->position; |
| 1436 | // Quick check it's to the right side of us and in range |
| 1437 | // FIXME: Should we check more thoroughly to save CPU time (probably)? |
| 1438 | if ((vec.x > 0 && unit->facing.x < 0) || (vec.y > 0 && unit->facing.y < 0) || |
| 1439 | (vec.x < 0 && unit->facing.x > 0) || (vec.y < 0 && unit->facing.y > 0) || |
| 1440 | (vec.x * vec.x + vec.y * vec.y + vec.z * vec.z > 400)) |
| 1441 | { |
| 1442 | continue; |
| 1443 | } |
| 1444 | unitsToUpdate.insert(unit); |
| 1445 | break; |
| 1446 | } |
| 1447 | } |
| 1448 | for (auto &unit : unitsToUpdate) |
| 1449 | { |
| 1450 | unit->refreshUnitVision(state); |
| 1451 | } |
| 1452 | tilesChangedForVision.clear(); |
| 1453 | } |
| 1454 | |
| 1455 | bool findLosBlockCenter(TileMap &map, BattleUnitType type, |
| 1456 | const BattleMapSector::LineOfSightBlock &lb, Vec3<int> center, |
no test coverage detected