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

Method doUpkeep

source/traps/Trap.cpp:113–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113void Trap::doUpkeep()
114{
115 Building::doUpkeep();
116
117 // We remove trap entities if we can
118 for(auto it = mTrapEntitiesWaitingRemove.begin(); it != mTrapEntitiesWaitingRemove.end();)
119 {
120 BuildingObject* trapEntity = *it;
121 if(!trapEntity->notifyRemoveAsked())
122 {
123 ++it;
124 continue;
125 }
126
127 removeBuildingObject(trapEntity);
128 it = mTrapEntitiesWaitingRemove.erase(it);
129 }
130
131 if (numCoveredTiles() <= 0)
132 return;
133
134 for(Tile* tile : mCoveredTiles)
135 {
136 // If the trap is deactivated, it cannot shoot
137 TrapTileData* trapTileData = static_cast<TrapTileData*>(mTileData[tile]);
138 if (!trapTileData->isActivated())
139 continue;
140
141 if(trapTileData->decreaseReloadTime())
142 continue;
143
144 if(shoot(tile))
145 {
146 trapTileData->setReloadTime(mReloadTime);
147 if(!trapTileData->decreaseShoot())
148 deactivate(tile);
149
150 const std::vector<Seat*>& seats = tile->getSeatsWithVision();
151 trapTileData->seatsSawTriggering(seats);
152
153 for(Seat* seat : trapTileData->mSeatsVision)
154 seat->setVisibleBuildingOnTile(this, tile);
155 }
156 }
157}
158
159int32_t Trap::getNbNeededCraftedTrap() const
160{

Callers 4

shootMethod · 0.45
shootMethod · 0.45
doMiscUpkeepMethod · 0.45
tryUseFightMethod · 0.45

Calls 7

decreaseReloadTimeMethod · 0.80
setReloadTimeMethod · 0.80
decreaseShootMethod · 0.80
seatsSawTriggeringMethod · 0.80
notifyRemoveAskedMethod · 0.45
isActivatedMethod · 0.45

Tested by

no test coverage detected