diff options
| author | ilotterytea <iltsu@alright.party> | 2025-02-01 23:29:13 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-02-01 23:29:13 +0500 |
| commit | 8b515204de68d67f59410cc9c9c38855df7ce283 (patch) | |
| tree | f62ecf0ceba75abfc03dc703fe60a3fdcc55aa4a /src/floor.cpp | |
| parent | 91ffa8637cddddae07c42115788e5104a5faca7f (diff) | |
feat: tile replace
Diffstat (limited to 'src/floor.cpp')
| -rw-r--r-- | src/floor.cpp | 14 |
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}); } } |
