MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / checkInLos

Method checkInLos

Engine/source/T3D/aiPlayer.cpp:1284–1333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1282}
1283
1284bool AIPlayer::checkInLos(GameBase* target, bool _useMuzzle, bool _checkEnabled)
1285{
1286 if (!isServerObject()) return false;
1287 if (!target)
1288 {
1289 target = mAimObject.getPointer();
1290 if (!target)
1291 return false;
1292 }
1293 if (_checkEnabled)
1294 {
1295 if (target->getTypeMask() & ShapeBaseObjectType)
1296 {
1297 ShapeBase *shapeBaseCheck = static_cast<ShapeBase *>(target);
1298 if (shapeBaseCheck)
1299 if (shapeBaseCheck->getDamageState() != Enabled) return false;
1300 }
1301 else
1302 return false;
1303 }
1304
1305 RayInfo ri;
1306
1307 disableCollision();
1308
1309 S32 mountCount = target->getMountedObjectCount();
1310 for (S32 i = 0; i < mountCount; i++)
1311 {
1312 target->getMountedObject(i)->disableCollision();
1313 }
1314
1315 Point3F checkPoint ;
1316 if (_useMuzzle)
1317 getMuzzlePointAI(0, &checkPoint );
1318 else
1319 {
1320 MatrixF eyeMat;
1321 getEyeTransform(&eyeMat);
1322 eyeMat.getColumn(3, &checkPoint );
1323 }
1324
1325 bool hit = !gServerContainer.castRay(checkPoint, target->getBoxCenter(), sAIPlayerLoSMask, &ri);
1326 enableCollision();
1327
1328 for (S32 i = 0; i < mountCount; i++)
1329 {
1330 target->getMountedObject(i)->enableCollision();
1331 }
1332 return hit;
1333}
1334
1335DefineEngineMethod(AIPlayer, checkInLos, bool, (ShapeBase* obj, bool useMuzzle, bool checkEnabled),(nullAsType<ShapeBase*>(), false, false),
1336 "@brief Check whether an object is in line of sight.\n"

Callers 1

aiPlayer.cppFile · 0.80

Calls 10

getTypeMaskMethod · 0.80
getMountedObjectCountMethod · 0.80
getMountedObjectMethod · 0.80
getColumnMethod · 0.80
getBoxCenterMethod · 0.80
getPointerMethod · 0.45
getDamageStateMethod · 0.45
disableCollisionMethod · 0.45
castRayMethod · 0.45
enableCollisionMethod · 0.45

Tested by

no test coverage detected