Skip to content

Commit 64e8793

Browse files
committed
fix: has component match order
1 parent 6658a13 commit 64e8793

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (FREYR_PROFILING)
2727
add_subdirectory(vendor/perfetto)
2828
endif (FREYR_PROFILING)
2929

30-
project(freyr LANGUAGES C CXX VERSION 0.19.7)
30+
project(freyr LANGUAGES C CXX VERSION 0.19.8)
3131

3232
if (FREYR_BUILD_EXAMPLES)
3333
add_subdirectory(examples)

include/Freyr/Containers/Archetype.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ namespace FREYR_NAMESPACE
9797
template <typename T>
9898
[[nodiscard]] bool HasComponent() const
9999
{
100-
return mRegisteredComponents.contains(GetComponentId<T>());
100+
thread_local static auto signature = MakeSignature<T>();
101+
return signature.Match(mSignature);
101102
}
102103

103104
template <typename... Ts>
104105
[[nodiscard]] bool HasComponents() const
105106
{
106107
thread_local static auto signature = MakeSignature<Ts...>();
107-
return mSignature.Match(signature);
108+
return signature.Match(mSignature);
108109
}
109110

110111
void StartTasks()

test/src/Builders/ArchetypeBuilderSpec.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ TEST_F(ArchetypeBuilderSpec, ArchetypeBuilderShouldRegisterComponent)
3939

4040
ASSERT_TRUE(archetype->HasComponent<PositionComponent>());
4141
ASSERT_TRUE(archetype->HasComponent<ModelComponent>());
42+
ASSERT_TRUE((archetype->HasComponents<PositionComponent, ModelComponent>()));
4243
}
4344

4445
TEST_F(ArchetypeBuilderSpec, ArchetypeBuilderShouldNotHaveUnregisteredComponent)
@@ -112,6 +113,9 @@ TEST_F(ArchetypeBuilderSpec, ArchetypeBuilder_ShouldAppendDefaultComponentsForAl
112113
.WithEntities(100)
113114
.Build();
114115

116+
auto firstHasPosition = archetype->HasComponent<PositionComponent>();
117+
auto firstHasName = archetype->HasComponent<NameComponent>();
118+
115119
const auto archetype2 =
116120
mScene->CreateArchetypeBuilder()
117121
.WithComponent(PositionComponent { .x = 200, .y = 200 })

0 commit comments

Comments
 (0)