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

Method doUpkeep

source/rooms/RoomHatchery.cpp:145–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145void RoomHatchery::doUpkeep()
146{
147 Room::doUpkeep();
148
149 if(mCoveredTiles.empty())
150 return;
151
152 uint32_t nbChickens = getNbChickens();
153 if(nbChickens >= mNumActiveSpots)
154 return;
155
156 // Chickens have been eaten. We check when we will spawn another one
157 ++mSpawnChickenCooldown;
158 if(mSpawnChickenCooldown < ConfigManager::getSingleton().getRoomConfigUInt32("HatcheryChickenSpawnRate"))
159 return;
160
161 // We spawn 1 chicken per chicken coop (until chickens are maxed)
162 for(Tile* chickenCoopTile : mCentralActiveSpotTiles)
163 {
164 ChickenEntity* chicken = new ChickenEntity(getGameMap(), getName());
165 chicken->addToGameMap();
166 chicken->createMesh();
167 Ogre::Vector3 spawnPosition(static_cast<Ogre::Real>(chickenCoopTile->getX()),
168 static_cast<Ogre::Real>(chickenCoopTile->getY()), 0.0f);
169 chicken->setPosition(spawnPosition);
170 ++nbChickens;
171 if(nbChickens >= mNumActiveSpots)
172 break;
173 }
174
175 mSpawnChickenCooldown = 0;
176}
177
178bool RoomHatchery::hasOpenCreatureSpot(Creature* c)
179{

Callers

nothing calls this directly

Calls 6

getRoomConfigUInt32Method · 0.80
createMeshMethod · 0.80
addToGameMapMethod · 0.45
getXMethod · 0.45
getYMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected