MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / WhatIsVisible

Method WhatIsVisible

engine/Poseidon/World/Detection/Target.cpp:1310–1350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1308}
1309
1310void 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
1352VisibilityTracker::VisibilityTracker() = default;
1353

Callers 1

CreateTargetListMethod · 0.80

Calls 5

floatMaxFunction · 0.85
GetIRScanRangeMethod · 0.80
GetNearestEnemyDist2Method · 0.80
GetTypeFunction · 0.70
SquareFunction · 0.50

Tested by

no test coverage detected