summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/floor.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/floor.cpp b/src/floor.cpp
index b8503ec..6632b6a 100644
--- a/src/floor.cpp
+++ b/src/floor.cpp
@@ -42,10 +42,18 @@ namespace silly::editor {
const sf::Vector2i &position,
const float &rotation) {
TileLayer &layer = this->layers.at(tile->type);
+ bool placed = false;
- if (!std::any_of(
- layer.tiles.begin(), layer.tiles.end(),
- [&position](const Tile &t) { return t.position == position; })) {
+ for (auto it = layer.tiles.begin(); it != layer.tiles.end(); ++it) {
+ if (it->position != position) continue;
+
+ it->rotation = rotation;
+ it->tile = tile;
+ placed = true;
+ break;
+ }
+
+ if (!placed) {
layer.tiles.push_back({tile, position, rotation});
}
}