diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-04-13 17:42:30 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-04-13 17:42:30 +0200 |
commit | 2260ab972100f1d6679690b730b6f0aa7409b014 (patch) | |
tree | 18386a59968c1e7933db702281fc13fe62ff9b1e /src/world.hpp | |
parent | cb13eb86db3593e723ce06c48a5cb2c94505d6ae (diff) |
instantiate scenery in a uniform manner
Now using world::make_scenery().
Add `std::monostate` to the `scenery_proto` variant to catch potential
bugs.
Diffstat (limited to 'src/world.hpp')
-rw-r--r-- | src/world.hpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/world.hpp b/src/world.hpp index e805ae1f..e92979db 100644 --- a/src/world.hpp +++ b/src/world.hpp @@ -9,11 +9,12 @@ namespace floormat { +template<typename T> struct shared_ptr_wrapper; struct object; struct critter; struct critter_proto; -template<typename T> struct object_type_; -template<typename T> struct shared_ptr_wrapper; +struct scenery; +struct scenery_proto; class world final { @@ -49,6 +50,7 @@ private: std::shared_ptr<object> find_object_(object_id id); [[noreturn]] static void throw_on_wrong_object_type(object_id id, object_type actual, object_type expected); + [[noreturn]] static void throw_on_empty_scenery_proto(object_id id, global_coords pos, Vector2b offset); friend struct object; @@ -87,7 +89,7 @@ public: do_make_object(std::static_pointer_cast<object>(ret), pos, sorted); return ret; } - + template<bool sorted = true> std::shared_ptr<scenery> make_scenery(object_id id, global_coords pos, scenery_proto&& proto); template<typename T = object> std::shared_ptr<T> find_object(object_id id); shared_ptr_wrapper<critter> ensure_player_character(object_id& id, critter_proto p); |