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

Method notifyCarryingStateChanged

source/rooms/RoomPrison.cpp:381–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381void RoomPrison::notifyCarryingStateChanged(Creature* carrier, GameEntity* carriedEntity)
382{
383 // The carrier has brought the enemy creature
384 if(carriedEntity->getObjectType() != GameEntityType::creature)
385 {
386 OD_LOG_ERR("room=" + getName() + ", entity=" + carriedEntity->getName());
387 return;
388 }
389
390 Creature* prisonerCreature = static_cast<Creature*>(carriedEntity);
391
392 // We check if we were waiting for this creature
393 // We release the pending prisoners before pushing the action room to make sure
394 // the place is free when we add the creature
395 auto it = std::find(mPendingPrisoners.begin(), mPendingPrisoners.end(), prisonerCreature);
396 if(it == mPendingPrisoners.end())
397 {
398 OD_LOG_ERR("room=" + getName() + ", unexpected creature=" + prisonerCreature->getName());
399 return;
400 }
401
402 mPendingPrisoners.erase(it);
403
404 prisonerCreature->clearActionQueue();
405 prisonerCreature->pushAction(Utils::make_unique<CreatureActionUseRoom>(*prisonerCreature, *this, true));
406 prisonerCreature->resetKoTurns();
407}
408
409uint32_t RoomPrison::countPrisoners()
410{

Callers

nothing calls this directly

Calls 4

clearActionQueueMethod · 0.80
pushActionMethod · 0.80
resetKoTurnsMethod · 0.80
getObjectTypeMethod · 0.45

Tested by

no test coverage detected