| 1308 | } |
| 1309 | |
| 1310 | void EntityAI::WhatIsVisible(TargetList& res, bool initialize) |
| 1311 | { |
| 1312 | if (initialize) |
| 1313 | { |
| 1314 | AddNewTargets(res, initialize); |
| 1315 | TrackTargets(res, initialize, 0); |
| 1316 | return; |
| 1317 | } |
| 1318 | |
| 1319 | AIUnit* unit = CommanderUnit(); |
| 1320 | if (!unit) |
| 1321 | { |
| 1322 | return; |
| 1323 | } |
| 1324 | |
| 1325 | float newTargetsPeriod = 1.0; |
| 1326 | float trackTargetsPeriod = 1.0; |
| 1327 | if (GetType()->_irScanRangeMax <= 0) |
| 1328 | { |
| 1329 | newTargetsPeriod = 5.0; |
| 1330 | } |
| 1331 | |
| 1332 | float trackRange = floatMax(GetType()->GetIRScanRange(), TACTICAL_VISIBILITY); |
| 1333 | float trackCoef = 1; |
| 1334 | if (unit->GetNearestEnemyDist2() > Square(trackRange)) |
| 1335 | { |
| 1336 | trackCoef = 5; |
| 1337 | } |
| 1338 | |
| 1339 | trackTargetsPeriod *= trackCoef; |
| 1340 | newTargetsPeriod *= trackCoef; |
| 1341 | |
| 1342 | if (Glob.time > _newTargetsTime + newTargetsPeriod) |
| 1343 | { |
| 1344 | AddNewTargets(res, initialize); |
| 1345 | } |
| 1346 | if (Glob.time > _trackTargetsTime + trackTargetsPeriod) |
| 1347 | { |
| 1348 | TrackTargets(res, initialize, trackTargetsPeriod); |
| 1349 | } |
| 1350 | } |
| 1351 | |
| 1352 | VisibilityTracker::VisibilityTracker() = default; |
| 1353 |
no test coverage detected