diff options
Diffstat (limited to 'src/world.hpp')
-rw-r--r-- | src/world.hpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/world.hpp b/src/world.hpp index 6781ee3c..5da700e3 100644 --- a/src/world.hpp +++ b/src/world.hpp @@ -37,7 +37,7 @@ private: explicit world(std::size_t capacity); - void do_make_entity(const std::shared_ptr<entity>& e, global_coords pos); + void do_make_entity(const std::shared_ptr<entity>& e, chunk& c, global_coords pos); void do_kill_entity(std::uint64_t id); friend struct entity; @@ -67,12 +67,12 @@ public: std::size_t collect_threshold() const noexcept { return _collect_every; } template<typename T, typename... Xs> - requires requires { T{std::uint64_t(), std::declval<world&>(), entity_type(), std::declval<Xs>()...}; } + requires requires(chunk& c) { T{std::uint64_t(), c, entity_type(), std::declval<Xs>()...}; } std::shared_ptr<T> make_entity(global_coords pos, Xs&&... xs) { static_assert(std::is_base_of_v<entity, T>); - auto ret = std::shared_ptr<T>(new T{++entity_counter, *this, entity_type_<T>::value, std::forward<Xs>(xs)...}); - do_make_entity(std::static_pointer_cast<entity>(ret), pos); + auto ret = std::shared_ptr<T>(new T{++entity_counter, operator[](pos.chunk()), entity_type_<T>::value, std::forward<Xs>(xs)...}); + do_make_entity(std::static_pointer_cast<entity>(ret), ret->c, pos); return ret; } |