light/modules/ecs/public/scene.hpp

59 lines
950 B
C++
Raw Normal View History

2025-07-05 13:28:41 +03:30
#pragma once
2025-07-11 01:16:52 +03:30
#include <ecs/components/transform.hpp>
#include <ecs/uuid.hpp>
2025-07-05 13:28:41 +03:30
#include <entt/entt.hpp>
#include <functional>
2025-07-05 13:28:41 +03:30
2025-07-11 00:05:48 +03:30
namespace lt {
2025-07-05 13:28:41 +03:30
class Entity;
class Framebuffer;
class Scene
{
public:
template<typename... T>
auto group()
{
return m_registry.group(entt::get<T...>);
}
2025-07-05 13:28:41 +03:30
2025-07-06 14:02:50 +03:30
auto create_entity(
2025-07-05 13:28:41 +03:30
const std::string &name,
const TransformComponent &transform = TransformComponent()
2025-07-06 14:02:50 +03:30
) -> Entity;
2025-07-05 13:28:41 +03:30
2025-07-06 14:02:50 +03:30
auto get_entity_by_tag(const std::string &tag) -> Entity;
2025-07-05 13:28:41 +03:30
auto get_entt_registry() -> entt::registry &
{
return m_registry;
}
2025-07-05 13:28:41 +03:30
private:
2025-07-05 16:07:51 +03:30
friend class Entity;
2025-07-06 14:02:50 +03:30
2025-07-05 16:07:51 +03:30
friend class SceneSerializer;
2025-07-06 14:02:50 +03:30
2025-07-05 16:07:51 +03:30
friend class SceneHierarchyPanel;
entt::registry m_registry;
2025-07-06 14:02:50 +03:30
auto create_entity_with_uuid(
2025-07-05 13:28:41 +03:30
const std::string &name,
UUID uuid,
const TransformComponent &transform = TransformComponent()
2025-07-06 14:02:50 +03:30
) -> Entity;
2025-07-05 13:28:41 +03:30
};
namespace ecs {
using Registry = Scene;
using Entity = ::lt::Entity;
} // namespace ecs
2025-07-11 00:05:48 +03:30
} // namespace lt