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

Method findCover

Engine/source/T3D/aiPlayer.cpp:994–1022  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

992}
993
994bool AIPlayer::findCover(const Point3F &from, F32 radius)
995{
996 if(radius <= 0)
997 return false;
998
999 // Create a search state.
1000 CoverSearch s;
1001 s.loc = getPosition();
1002 s.dist = radius;
1003 // Direction we seek cover FROM.
1004 s.from = from;
1005
1006 // Find cover points.
1007 Box3F box(radius * 2.0f);
1008 box.setCenter(getPosition());
1009 getContainer()->findObjects(box, MarkerObjectType, findCoverCallback, &s);
1010
1011 // Go to cover!
1012 if(s.point)
1013 {
1014 // Calling setPathDestination clears cover...
1015 bool foundPath = setPathDestination(s.point->getPosition());
1016 // Now store the cover info.
1017 mCoverData.cover = s.point;
1018 s.point->setOccupied(true);
1019 return foundPath;
1020 }
1021 return false;
1022}
1023
1024DefineEngineMethod(AIPlayer, findCover, S32, (Point3F from, F32 radius),,
1025 "@brief Tells the AI to find cover nearby.\n\n"

Callers 1

aiPlayer.cppFile · 0.80

Calls 6

getPositionFunction · 0.85
setCenterMethod · 0.80
findObjectsMethod · 0.80
setOccupiedMethod · 0.80
getContainerFunction · 0.50
getPositionMethod · 0.45

Tested by

no test coverage detected