void Level::changeLevel(Position destination, Creature* c) { Vec2 oldPos = c->getPosition().getCoord(); if (model->changeLevel(destination, c)) { eraseCreature(c); getSafeSquare(oldPos)->removeCreature(); bucketMap->removeElement(oldPos, c); } }
void Level::changeLevel(StairKey key, Creature* c) { Vec2 oldPos = c->getPosition().getCoord(); Level* otherLevel = model->getLinkedLevel(this, key); if (otherLevel->landCreature(key, c)) eraseCreature(c, oldPos); else { Position otherPos = Random.choose(otherLevel->landingSquares.at(key)); if (Creature* other = otherPos.getCreature()) { if (!other->isPlayer() && c->getPosition().canEnterEmpty(other) && otherPos.canEnterEmpty(c)) { otherLevel->eraseCreature(other, otherPos.getCoord()); eraseCreature(c, oldPos); putCreature(oldPos, other); otherLevel->putCreature(otherPos.getCoord(), c); c->playerMessage("You switch levels with " + other->getName().a()); } } } }
void Level::killCreature(Creature* creature) { bucketMap->removeElement(creature->getPosition().getCoord(), creature); eraseCreature(creature); creature->getPosition().removeCreature(); }
void Level::changeLevel(Position destination, Creature* c) { Vec2 oldPos = c->getPosition().getCoord(); if (destination.isValid() && destination.getLevel()->landCreature({destination}, c)) eraseCreature(c, oldPos); }
void Level::killCreature(Creature* creature) { eraseCreature(creature, creature->getPosition().getCoord()); }