From 8b515204de68d67f59410cc9c9c38855df7ce283 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sat, 1 Feb 2025 23:29:13 +0500 Subject: feat: tile replace --- src/floor.cpp | 14 +++++++++++--- 1 file 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}); } } -- cgit v1.2.3