| 202 | } |
| 203 | |
| 204 | bool MissileObject::computeDestination(const Ogre::Vector3& position, double moveDist, const Ogre::Vector3& direction, |
| 205 | Ogre::Vector3& destination, std::list<Tile*>& tiles) |
| 206 | { |
| 207 | destination = position + (moveDist * direction); |
| 208 | tiles = getGameMap()->tilesBetween(Helper::round(position.x), |
| 209 | Helper::round(position.y), Helper::round(destination.x), Helper::round(destination.y)); |
| 210 | if(tiles.empty()) |
| 211 | { |
| 212 | OD_LOG_ERR("missile=" + getName() + " has unexpected empty tiles destination"); |
| 213 | return false; |
| 214 | } |
| 215 | |
| 216 | // If we get out of the map, we take the last tile as the destination |
| 217 | if((direction.x > 0.0 && destination.x > static_cast<Ogre::Real>(getGameMap()->getMapSizeX() - 1)) || |
| 218 | (direction.x < 0.0 && destination.x < 0.0) || |
| 219 | (direction.y > 0 && destination.y > static_cast<Ogre::Real>(getGameMap()->getMapSizeY() - 1)) || |
| 220 | (direction.y < 0 && destination.y < 0)) |
| 221 | { |
| 222 | Tile* lastTile = tiles.back(); |
| 223 | destination.x = static_cast<Ogre::Real>(lastTile->getX()); |
| 224 | destination.y = static_cast<Ogre::Real>(lastTile->getY()); |
| 225 | |
| 226 | // We are in the last position, we can die |
| 227 | if(tiles.size() <= 1) |
| 228 | return false; |
| 229 | } |
| 230 | |
| 231 | return true; |
| 232 | } |
| 233 | |
| 234 | bool MissileObject::notifyDead(GameEntity* entity) |
| 235 | { |
nothing calls this directly
no test coverage detected