refactor(mirror): adjust to new ecs

This commit is contained in:
light7734 2025-09-20 15:40:05 +03:30
parent 91d86545dc
commit 7266451b45
Signed by: light7734
GPG key ID: 8C30176798F1A6BA
5 changed files with 20 additions and 19 deletions

View file

@ -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",

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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 {