| 69 | } |
| 70 | |
| 71 | void MissileObject::doUpkeep() |
| 72 | { |
| 73 | if(!getIsOnMap()) |
| 74 | return; |
| 75 | |
| 76 | if(!mIsMissileAlive) |
| 77 | { |
| 78 | if(!isMoving()) |
| 79 | { |
| 80 | removeFromGameMap(); |
| 81 | deleteYourself(); |
| 82 | } |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | Tile* tile = getPositionTile(); |
| 87 | if(tile == nullptr) |
| 88 | { |
| 89 | OD_LOG_ERR("entityName=" + getName()); |
| 90 | removeFromGameMap(); |
| 91 | deleteYourself(); |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | // We check if a creature is in our way. We start by taking the tile we will be on |
| 96 | Ogre::Vector3 position = getPosition(); |
| 97 | double moveDist = getMoveSpeed(); |
| 98 | Ogre::Vector3 destination; |
| 99 | std::list<Tile*> tiles; |
| 100 | mIsMissileAlive = computeDestination(position, moveDist, mDirection, destination, tiles); |
| 101 | |
| 102 | std::vector<Ogre::Vector3> path; |
| 103 | Tile* lastTile = nullptr; |
| 104 | while(!tiles.empty() && mIsMissileAlive) |
| 105 | { |
| 106 | Tile* tmpTile = tiles.front(); |
| 107 | tiles.pop_front(); |
| 108 | |
| 109 | if(tmpTile == nullptr) |
| 110 | { |
| 111 | OD_LOG_ERR("Unexpected null tile when reading missile path name=" + getName() + ", lastTile=" + (lastTile == nullptr ? std::string("nullptr") : Tile::displayAsString(lastTile))); |
| 112 | continue; |
| 113 | } |
| 114 | |
| 115 | if(tmpTile->getFullness() > 0.0) |
| 116 | { |
| 117 | Ogre::Vector3 nextDirection; |
| 118 | OD_LOG_INF("missile name=" + getName() + ", hit wall on tile=" + Tile::displayAsString(tmpTile)); |
| 119 | mIsMissileAlive = wallHitNextDirection(mDirection, lastTile, nextDirection); |
| 120 | if(!mIsMissileAlive) |
| 121 | { |
| 122 | destination.x = static_cast<Ogre::Real>(lastTile->getX()); |
| 123 | destination.y = static_cast<Ogre::Real>(lastTile->getY()); |
| 124 | break; |
| 125 | } |
| 126 | else |
| 127 | { |
| 128 | position.x = static_cast<Ogre::Real>(lastTile->getX()); |
nothing calls this directly
no test coverage detected