| 232 | } |
| 233 | |
| 234 | bool RoomWorkshop::addCreatureUsingRoom(Creature* creature) |
| 235 | { |
| 236 | if(!Room::addCreatureUsingRoom(creature)) |
| 237 | return false; |
| 238 | |
| 239 | int index = Random::Int(0, mUnusedSpots.size() - 1); |
| 240 | Tile* tileSpot = mUnusedSpots[index]; |
| 241 | mUnusedSpots.erase(mUnusedSpots.begin() + index); |
| 242 | mCreaturesSpots[creature] = tileSpot; |
| 243 | const Ogre::Vector3& creaturePosition = creature->getPosition(); |
| 244 | Ogre::Real wantedX = -1; |
| 245 | Ogre::Real wantedY = -1; |
| 246 | getCreatureWantedPos(creature, tileSpot, wantedX, wantedY); |
| 247 | if(creaturePosition.x != wantedX || |
| 248 | creaturePosition.y != wantedY) |
| 249 | { |
| 250 | // We move to the good tile |
| 251 | std::list<Tile*> pathToSpot = getGameMap()->path(creature, tileSpot); |
| 252 | if(pathToSpot.empty()) |
| 253 | { |
| 254 | OD_LOG_ERR("unexpected empty pathToSpot"); |
| 255 | return true; |
| 256 | } |
| 257 | |
| 258 | std::vector<Ogre::Vector3> path; |
| 259 | Creature::tileToVector3(pathToSpot, path, true, 0.0); |
| 260 | // We add the last step to take account of the offset |
| 261 | Ogre::Vector3 dest(wantedX, wantedY, 0.0); |
| 262 | path.push_back(dest); |
| 263 | creature->setWalkPath(EntityAnimation::walk_anim, EntityAnimation::idle_anim, true, true, path); |
| 264 | } |
| 265 | |
| 266 | return true; |
| 267 | } |
| 268 | |
| 269 | void RoomWorkshop::removeCreatureUsingRoom(Creature* c) |
| 270 | { |
nothing calls this directly
no test coverage detected