diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-09 19:34:15 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-09 20:08:55 +0100 |
commit | d0395f8468b33817a79a0fd625ae52cdff06ae19 (patch) | |
tree | 1751e2e0771cb231fc143aebd7df3c1e72334beb /editor/vobj-editor.cpp | |
parent | d30921ac0b361639c10ae9d337cbf16cc3b7d359 (diff) |
loader: move vobj_cell to its own file
Diffstat (limited to 'editor/vobj-editor.cpp')
-rw-r--r-- | editor/vobj-editor.cpp | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/editor/vobj-editor.cpp b/editor/vobj-editor.cpp index ea9b8659..bfe88d71 100644 --- a/editor/vobj-editor.cpp +++ b/editor/vobj-editor.cpp @@ -1,7 +1,8 @@ #include "vobj-editor.hpp" -#include "loader/loader.hpp" #include "src/world.hpp" #include "src/light.hpp" +#include "loader/loader.hpp" +#include "loader/vobj-cell.hpp" #include "app.hpp" #include <array> #include <utility> @@ -68,23 +69,27 @@ start: while (auto id = a.get_object_colliding_with_cursor()) struct light_factory final : vobj_factory { - object_type type() const override { return object_type::light; } + object_type type() const override; + const vobj_cell& info() const override; + std::shared_ptr<object> make(world& w, object_id id, global_coords pos) const override; +}; - const vobj_info& info() const override - { - constexpr auto NAME = "light"_s; - static const vobj_info& ret = loader.vobj(NAME); - fm_debug_assert(ret.name == NAME); - fm_debug_assert(ret.atlas != nullptr); - return ret; - } +object_type light_factory::type() const { return object_type::light; } - std::shared_ptr<object> make(world& w, object_id id, global_coords pos) const override - { - auto ret = w.make_object<light>(id, pos, light_proto{}); - return ret; - } -}; +const vobj_cell& light_factory::info() const +{ + constexpr auto NAME = "light"_s; + static const vobj_cell& ret = loader.vobj(NAME); + fm_debug_assert(ret.name == NAME); + fm_debug_assert(ret.atlas != nullptr); + return ret; +} + +std::shared_ptr<object> light_factory::make(world& w, object_id id, global_coords pos) const +{ + auto ret = w.make_object<light>(id, pos, light_proto{}); + return ret; +} auto vobj_editor::make_vobj_type_map() -> std::map<StringView, vobj_> { |