MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / useRoom

Method useRoom

source/rooms/RoomArena.cpp:242–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242bool RoomArena::useRoom(Creature& creature, bool forced)
243{
244 // If the creature is alone, it should wander in the room. If it is not, it should wait until there is one ready
245 if(mCreaturesFighting.size() < 2)
246 {
247 std::vector<Tile*> tiles = getCoveredTiles();
248 if(tiles.empty())
249 {
250 OD_LOG_ERR("room=" + getName() + ", creature=" + creature.getName());
251 return false;
252 }
253
254 uint32_t index = Random::Uint(0, tiles.size() - 1);
255 Tile* tile = tiles[index];
256 if(!creature.setDestination(tile))
257 {
258 OD_LOG_ERR("room=" + getName() + ", creature=" + creature.getName() + ", tile=" + Tile::displayAsString(tile));
259 return false;
260 }
261 return false;
262 }
263
264 // We do nothing while waiting
265 return false;
266}
267
268BuildingObject* RoomArena::notifyActiveSpotCreated(ActiveSpotPlace place, Tile* tile)
269{

Callers

nothing calls this directly

Calls 2

UintFunction · 0.85
setDestinationMethod · 0.80

Tested by

no test coverage detected