MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / updateVision

Method updateVision

game/state/battle/battle.cpp:1423–1453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1421}
1422
1423void 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
1455bool findLosBlockCenter(TileMap &map, BattleUnitType type,
1456 const BattleMapSector::LineOfSightBlock &lb, Vec3<int> center,

Callers 1

BattleViewMethod · 0.80

Calls 4

isConsciousMethod · 0.80
insertMethod · 0.80
refreshUnitVisionMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected