Skip to content

Commit 6db2350

Browse files
committed
new tests and ci fix
1 parent 5aa35ea commit 6db2350

File tree

5 files changed

+60
-8
lines changed

5 files changed

+60
-8
lines changed

.github/workflows/win_x64.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
key: ${{ runner.os }}-conan-cache
3636

3737
- name: Prepare Vulkan SDK
38-
uses: humbletim/setup-vulkan-sdk@v1.2.0
38+
uses: humbletim/setup-vulkan-sdk@main
3939
with:
4040
vulkan-query-version: 1.3.268.0
4141
vulkan-components: Vulkan-Headers, Vulkan-Loader
@@ -76,7 +76,7 @@ jobs:
7676
key: ${{ runner.os }}-conan-cache
7777

7878
- name: Prepare Vulkan SDK
79-
uses: humbletim/setup-vulkan-sdk@v1.2.0
79+
uses: humbletim/setup-vulkan-sdk@main
8080
with:
8181
vulkan-query-version: 1.3.268.0
8282
vulkan-components: Vulkan-Headers, Vulkan-Loader

Src/Engine/Engine/ECS/EntityManager.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,33 @@ const EntityManager::EntityInfo& EntityManager::GetEntityInfo(const uuids::uuid&
111111
static EntityInfo info{};
112112
return info;
113113
}
114+
115+
entt::entity EntityManager::GetEntity(const uuids::uuid& uuid)
116+
{
117+
if (const auto it = m_uuidToEntity.find(uuid); it != m_uuidToEntity.end())
118+
{
119+
return it->second;
120+
}
121+
122+
return {};
123+
}
124+
125+
bool EntityManager::Exists(entt::entity e)
126+
{
127+
if (const auto it = m_entities.find(e); it == m_entities.end())
128+
{
129+
return false;
130+
}
131+
return true;
132+
}
133+
134+
bool EntityManager::Exists(const uuids::uuid& uuid)
135+
{
136+
if (const auto it = m_uuidToEntity.find(uuid); it != m_uuidToEntity.end())
137+
{
138+
return Exists(it->second);
139+
}
140+
return false;
141+
}
142+
114143
} // engine::ecs

Src/Engine/Engine/ECS/EntityManager.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class ENGINE_API EntityManager : public core::NonCopyable
3737
const EntityInfo& GetEntityInfo(entt::entity e);
3838
const EntityInfo& GetEntityInfo(const uuids::uuid& uuid);
3939

40+
bool Exists(entt::entity e);
41+
bool Exists(const uuids::uuid& uuid);
42+
43+
entt::entity GetEntity(const uuids::uuid& uuid);
44+
4045
template<typename T>
4146
T* TryGetComponent(entt::entity e)
4247
{

Src/Engine/Engine/Tests/WorldTest.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <Engine/Engine.hpp>
44
#include <Engine/System/RenderSystem.hpp>
55

6-
TEST_CASE("Create entity and add component")
6+
TEST_CASE("Simple entity manipulations")
77
{
88
constexpr std::string_view C_TEST_ENTITY_NAME = "Test Entity";
99

@@ -12,9 +12,27 @@ TEST_CASE("Create entity and add component")
1212

1313
const auto uuid = em->CreateEntity(C_TEST_ENTITY_NAME);
1414
em->Update();
15+
const auto e = em->GetEntity(uuid);
1516

16-
em->AddComponent<engine::MeshComponent>(uuid, engine::MeshComponent());
17+
SUBCASE("Entity was created and component added")
18+
{
19+
em->AddComponent<engine::MeshComponent>(uuid, engine::MeshComponent());
1720

18-
CHECK_NE(em->TryGetComponent<engine::MeshComponent>(uuid), nullptr);
19-
CHECK_EQ(em->GetEntityInfo(uuid).m_name, C_TEST_ENTITY_NAME);
20-
}
21+
CHECK_EQ(em->GetEntityInfo(uuid).m_name, C_TEST_ENTITY_NAME);
22+
CHECK_NE(em->TryGetComponent<engine::MeshComponent>(uuid), nullptr);
23+
CHECK_NE(em->TryGetComponent<engine::MeshComponent>(e), nullptr);
24+
}
25+
26+
SUBCASE("MeshComponent was deleted")
27+
{
28+
em->RemoveComponent<engine::MeshComponent>(uuid);
29+
30+
CHECK_EQ(em->TryGetComponent<engine::MeshComponent>(uuid), nullptr);
31+
}
32+
33+
SUBCASE("Entity was deleted")
34+
{
35+
em->RemoveEntity(uuid);
36+
em->Update();
37+
}
38+
}

generate_solution.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@echo off
22

3-
python Scripts/generate_solution.py win-release-ut win-64
3+
python Scripts/generate_solution.py win-debug win-64

0 commit comments

Comments
 (0)