diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-08-16 22:49:54 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-08-16 22:49:54 +0200 |
commit | 889870345539cc4dd0f098b976ba555916f17aff (patch) | |
tree | 28dbd15ec0f97b2beda2b0174c1ac19a8742b113 /src | |
parent | 125cb3c0feb94e51b830957fb44ccc709b6afa61 (diff) |
editor: don't allow entities on top of one another
There are still workarounds for when this is actually desirable.
Diffstat (limited to 'src')
-rw-r--r-- | src/chunk-collision.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
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<collision_data>(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; }); |