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