summaryrefslogtreecommitdiffhomepage
path: root/src/world.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-04-14 08:53:35 +0200
committerStanislaw Halik <sthalik@misaki.pl>2024-04-14 09:22:54 +0200
commit9d35200ea54a0729d489dc2c76823a2a13cdcac4 (patch)
treeafe10e017dcc226750c0023d0787df912927e6cd /src/world.hpp
parentc8ae1f808a16d664ec229ca3a2237ac39bf1164d (diff)
add find_object specialization for scenery subtypes
Diffstat (limited to 'src/world.hpp')
-rw-r--r--src/world.hpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/world.hpp b/src/world.hpp
index e92979db..52cb1f64 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -1,8 +1,10 @@
#pragma once
#include "compat/safe-ptr.hpp"
+#include "compat/base-of.hpp"
#include "chunk.hpp"
#include "global-coords.hpp"
#include "object-type.hpp"
+#include "scenery-type.hpp"
#include "loader/policy.hpp"
#include <memory>
#include <unordered_map>
@@ -50,6 +52,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_wrong_scenery_type(object_id id, scenery_type actual, scenery_type expected);
[[noreturn]] static void throw_on_empty_scenery_proto(object_id id, global_coords pos, Vector2b offset);
friend struct object;
@@ -91,6 +94,7 @@ public:
}
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);
+ template<typename T> requires is_strict_base_of<scenery, T> std::shared_ptr<T> find_object(object_id id);
shared_ptr_wrapper<critter> ensure_player_character(object_id& id, critter_proto p);
shared_ptr_wrapper<critter> ensure_player_character(object_id& id);