refactor(mirror): adjust to new ecs
This commit is contained in:
parent
91d86545dc
commit
7266451b45
5 changed files with 20 additions and 19 deletions
|
@ -28,9 +28,9 @@ public:
|
|||
using Surface = lt::surface::SurfaceComponent;
|
||||
using Input = lt::input::InputComponent;
|
||||
|
||||
auto view = m_registry->get_entt_registry().view<Surface, Input>();
|
||||
|
||||
view.each([&](Surface &surface, Input &input) {});
|
||||
for (auto &[entity, surface, input] : m_registry->view<Surface, Input>())
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
auto tick() -> bool override
|
||||
|
@ -42,8 +42,8 @@ public:
|
|||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds { 10 });
|
||||
auto should_quit = false;
|
||||
auto view = m_registry->get_entt_registry().view<Surface, Input>();
|
||||
view.each([&](Surface &surface, Input &input) {
|
||||
for (auto &[entity, surface, input] : m_registry->view<Surface, Input>())
|
||||
{
|
||||
using State = lt::input::InputAction::State;
|
||||
const auto &[x, y] = surface.get_position();
|
||||
const auto &[width, height] = surface.get_resolution();
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
log_dbg("Deubg action 4");
|
||||
surface.push_request(surface::ModifyResolutionRequest({ width - 5, height - 5 }));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
timer.reset();
|
||||
return should_quit;
|
||||
|
@ -125,15 +125,18 @@ public:
|
|||
using lt::surface::SurfaceComponent;
|
||||
m_surface_system = create_ref<lt::surface::System>(m_editor_registry);
|
||||
|
||||
m_window = m_editor_registry->create_entity("Editor Window");
|
||||
m_window.add_component<SurfaceComponent>(SurfaceComponent::CreateInfo {
|
||||
.title = "Editor Window",
|
||||
.resolution = { 400u, 400u },
|
||||
.vsync = true,
|
||||
.visible = true,
|
||||
});
|
||||
m_window = m_editor_registry->create_entity();
|
||||
m_editor_registry->add<SurfaceComponent>(
|
||||
m_window,
|
||||
SurfaceComponent::CreateInfo {
|
||||
.title = "Editor Window",
|
||||
.resolution = { 400u, 400u },
|
||||
.vsync = true,
|
||||
.visible = true,
|
||||
}
|
||||
);
|
||||
|
||||
auto &input = m_window.add_component<InputComponent>();
|
||||
auto &input = m_editor_registry->add<InputComponent>(m_window, {});
|
||||
auto quit_action_key = input.add_action(
|
||||
input::InputAction {
|
||||
.name = "quit",
|
||||
|
@ -142,7 +145,6 @@ public:
|
|||
);
|
||||
|
||||
auto debug_action_keys = std::array<lt::input::InputAction::Key, 4> {};
|
||||
|
||||
debug_action_keys[0] = input.add_action(
|
||||
input::InputAction {
|
||||
.name = "debug_1",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <asset_manager/asset_manager.hpp>
|
||||
#include <camera/component.hpp>
|
||||
#include <ecs/components.hpp>
|
||||
#include <ecs/scene.hpp>
|
||||
#include <ecs/registry.hpp>
|
||||
#include <ecs/serializer.hpp>
|
||||
#include <input/input.hpp>
|
||||
#include <input/key_codes.hpp>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <asset_manager/asset_manager.hpp>
|
||||
#include <ecs/scene.hpp>
|
||||
#include <ecs/registry.hpp>
|
||||
#include <ecs/serializer.hpp>
|
||||
#include <imgui.h>
|
||||
#include <mirror/panels/asset_browser.hpp>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <ecs/components.hpp>
|
||||
#include <entt/entt.hpp>
|
||||
#include <imgui.h>
|
||||
#include <mirror/panels/properties.hpp>
|
||||
#include <mirror/panels/scene_hierarchy.hpp>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <ecs/entity.hpp>
|
||||
#include <ecs/scene.hpp>
|
||||
#include <ecs/registry.hpp>
|
||||
#include <mirror/panels/panel.hpp>
|
||||
|
||||
namespace lt {
|
||||
|
|
Loading…
Add table
Reference in a new issue