| 992 | } |
| 993 | |
| 994 | bool 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 | |
| 1024 | DefineEngineMethod(AIPlayer, findCover, S32, (Point3F from, F32 radius),, |
| 1025 | "@brief Tells the AI to find cover nearby.\n\n" |
no test coverage detected