Raito 0.1
Loading...
Searching...
No Matches
Scene.h
Go to the documentation of this file.
1/*
2MIT License
3
4Copyright (c) 2023 Víctor Falcón Zaro
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in all
14copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22SOFTWARE.
23*/
24
25#pragma once
26#include <Raito/Core/UUID.h>
27#include "Entt/entt.hpp"
28
29
30namespace Editor
31{
32 class Hierarchy;
33}
34
35namespace Raito::ECS
36{
37 class Entity;
39 /*
40 * Holds all the entities and manages them
41 */
42 class Scene
43 {
44 public:
46 Scene() = default;
47
49 ~Scene() = default;
50
52
53
56 Entity CreateEntity(const std::string& name);
57
60 void DestroyEntity(Entity entity);
61
66
67 //
68 Entity FindEntityByName(std::string_view name);
70
73 template<typename... Components>
74 auto GetAllEntitiesWith() const
75 {
76 return m_Registry.view<Components...>();
77 }
78
79 private:
80 entt::registry m_Registry;
81 std::unordered_map<UUID, entt::entity> m_Entities{};
83 friend class Entity;
84 friend class Editor::Hierarchy;
85 };
86}
#define DEFAULT_MOVE_AND_COPY(T)
Definition Common.h:56
Definition Entity.h:33
Scene class.
Definition Scene.h:43
Entity GetEntityByUUID(UUID uuid)
Definition Scene.cpp:41
void DestroyEntity(Entity entity)
Definition Scene.cpp:23
Scene()=default
Default constructor.
friend class Editor::Hierarchy
Definition Scene.h:84
~Scene()=default
Default destructor.
Entity FindEntityByName(std::string_view name)
Definition Scene.cpp:30
Entity DuplicateEntity(Entity entity)
Definition Scene.cpp:26
Entity CreateEntity(const std::string &name)
Definition Scene.cpp:10
auto GetAllEntitiesWith() const
Definition Scene.h:74
Definition UUID.h:32
Definition Scene.h:31
Definition Components.h:33