|
|
|
@ -134,10 +134,10 @@ bool TeleportCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
TriggerCell::TriggerCell(coordinate cell_x, coordinate cell_y, const std::vector<CellPtr> &cells_to_change, const sf::Color &color) :
|
|
|
|
|
TriggerCell::TriggerCell(std::vector<CellPtr> &&cells_to_change, coordinate cell_x, coordinate cell_y, const sf::Color &color) :
|
|
|
|
|
Cell(cell_x, cell_y, color)
|
|
|
|
|
{
|
|
|
|
|
cells.assign(std::move(cells_to_change));
|
|
|
|
|
cells = std::move(cells_to_change);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TriggerCell::~TriggerCell()
|
|
|
|
@ -150,11 +150,14 @@ bool TriggerCell::onMovingTo(HeroPtr &hero, LevelPtr &level)
|
|
|
|
|
Map &map = level->mapArray();
|
|
|
|
|
|
|
|
|
|
// We replace needed cells with the ones that the trigger provides.
|
|
|
|
|
for (const &cell : cells)
|
|
|
|
|
map[cell->x()][cell->y()].reset(cell.release());
|
|
|
|
|
|
|
|
|
|
// Trigger works only once.
|
|
|
|
|
cells.clear();
|
|
|
|
|
for (CellPtr &cell : cells)
|
|
|
|
|
{
|
|
|
|
|
const coordinate &y = cell->y();
|
|
|
|
|
const coordinate &x = cell->x();
|
|
|
|
|
|
|
|
|
|
map[x][y].release();
|
|
|
|
|
map[x][y] = std::move(cell);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// It's an impassable object, so player can't move to here.
|
|
|
|
|
return false;
|
|
|
|
|