* Changes the destination the moving target is heading to. * @param dest Pointer to destination. */
| 94 | * @param dest Pointer to destination. |
| 95 | */ |
| 96 | void MovingTarget::setDestination(Target *dest) |
| 97 | { |
| 98 | // Remove moving target from old destination's followers |
| 99 | if (_dest != 0) |
| 100 | { |
| 101 | for (std::vector<Target*>::iterator i = _dest->getFollowers()->begin(); i != _dest->getFollowers()->end(); ++i) |
| 102 | { |
| 103 | if ((*i) == this) |
| 104 | { |
| 105 | _dest->getFollowers()->erase(i); |
| 106 | break; |
| 107 | } |
| 108 | } |
| 109 | } |
| 110 | _dest = dest; |
| 111 | // Add moving target to new destination's followers |
| 112 | if (_dest != 0) |
| 113 | { |
| 114 | _dest->getFollowers()->push_back(this); |
| 115 | } |
| 116 | calculateSpeed(); |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * Returns the speed of the moving target. |
nothing calls this directly
no test coverage detected