diff options
-rw-r--r-- | editor/update.cpp | 3 | ||||
-rw-r--r-- | src/scenery.cpp | 13 | ||||
-rw-r--r-- | src/scenery.hpp | 3 |
3 files changed, 17 insertions, 2 deletions
diff --git a/editor/update.cpp b/editor/update.cpp index 9f347f0d..15d99d39 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -125,7 +125,8 @@ void app::update(float dt) do_camera(dt, keys, get_key_modifiers()); clear_non_repeated_keys(); - if (!_editor.current_tile_editor() && cursor.tile && find_clickable_scenery(*cursor.pixel)) + if (clickable_scenery* s; + !_editor.current_tile_editor() && cursor.tile && (s = find_clickable_scenery(*cursor.pixel)) && s->item.can_activate()) M->set_cursor(std::uint32_t(Cursor::Hand)); else M->set_cursor(std::uint32_t(Cursor::Arrow)); diff --git a/src/scenery.cpp b/src/scenery.cpp index 4eed262f..7c3001b0 100644 --- a/src/scenery.cpp +++ b/src/scenery.cpp @@ -54,6 +54,19 @@ scenery::scenery(float dt, frame_t frame, rotation r, bool passable, scenery_typ delta{dt}, frame{frame}, r{r}, passable{passable}, type{type} {} +bool scenery::can_activate() const noexcept +{ + switch (type) + { + default: + return false; + case scenery_type::door: + return !active; + case scenery_type::object: + return true; + } +} + void scenery::update(float dt, const anim_atlas& anim) { if (!active) diff --git a/src/scenery.hpp b/src/scenery.hpp index b6468ebe..aabf7315 100644 --- a/src/scenery.hpp +++ b/src/scenery.hpp @@ -13,7 +13,7 @@ enum class rotation : std::uint8_t { constexpr inline rotation rotation_COUNT = rotation{8}; enum class scenery_type : std::uint8_t { - none, generic, door, + none, generic, door, object, }; struct scenery final @@ -43,6 +43,7 @@ struct scenery final scenery(door_tag_t, rotation r, const anim_atlas& atlas, bool is_open = false); scenery(float dt, frame_t frame, rotation r, bool passable, scenery_type type); + bool can_activate() const noexcept; bool activate(const anim_atlas& atlas); void update(float dt, const anim_atlas& anim); }; |