diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-16 12:26:01 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-17 23:23:11 +0100 |
| commit | 489db3043caa82942ef7dc5a6d4b1ee30fd56b9d (patch) | |
| tree | 4f5ba8567141bf4955c886d53ceab3907b9502f2 /editor/scenery-editor.cpp | |
| parent | d7ea52c8c86e607dc3e7557c96d07910d21be1f4 (diff) | |
a
Diffstat (limited to 'editor/scenery-editor.cpp')
| -rw-r--r-- | editor/scenery-editor.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/editor/scenery-editor.cpp b/editor/scenery-editor.cpp index 73705056..1165219d 100644 --- a/editor/scenery-editor.cpp +++ b/editor/scenery-editor.cpp @@ -79,8 +79,27 @@ bool scenery_editor::is_anything_selected() const void scenery_editor::place_tile(world& w, global_coords pos, const scenery_& s) { auto [c, t] = w[pos]; - // todo check collision at pos - auto sc = w.make_entity<scenery>(pos, s.proto); + if (!s) + { + // don't regen colliders + const auto px = Vector2(pos.local()) * TILE_SIZE2; + const auto es = c.entities(); + for (auto i = es.size()-1; i != (std::size_t)-1; i--) + { + const auto& e = *es[i]; + if (e.type != entity_type::scenery) + continue; + auto center = Vector2(e.coord.local())*TILE_SIZE2 + Vector2(e.offset) + Vector2(e.bbox_offset), + min = center - Vector2(e.bbox_size/2), max = min + Vector2(e.bbox_size); + if (px >= min && px <= max) + c.remove_entity(i); + } + } + else + { + // todo check collision at pos + w.make_entity<scenery>(pos, s.proto); + } c.mark_scenery_modified(); } |
