From 889870345539cc4dd0f098b976ba555916f17aff Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 16 Aug 2023 22:49:54 +0200 Subject: editor: don't allow entities on top of one another There are still workarounds for when this is actually desirable. --- src/chunk-collision.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/chunk-collision.cpp b/src/chunk-collision.cpp index 7cf436a0..9810cee3 100644 --- a/src/chunk-collision.cpp +++ b/src/chunk-collision.cpp @@ -120,12 +120,22 @@ bool chunk::can_place_entity(const entity_proto& proto, local_coords pos) { (void)ensure_scenery_mesh(); + switch (proto.pass) + { + case pass_mode::blocked: + case pass_mode::see_through: + break; + case pass_mode::pass: + case pass_mode::shoot_through: + return true; + } + const auto center = Vector2(pos)*TILE_SIZE2 + Vector2(proto.offset) + Vector2(proto.bbox_offset), min = center - Vector2(proto.bbox_size/2), max = min + Vector2(proto.bbox_size); bool ret = true; _rtree.Search(min.data(), max.data(), [&](uint64_t data, const auto&) { [[maybe_unused]] auto x = std::bit_cast(data); - if (x.pass == (uint64_t)pass_mode::pass) + if (x.pass == (uint64_t)pass_mode::pass || x.pass == (uint64_t)pass_mode::shoot_through) return true; return ret = false; }); -- cgit v1.2.3