Skip to content

Commit

Permalink
fix(core): remove obsolete system validations
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas7770 committed Jan 31, 2024
1 parent 58c8c82 commit 8d4a390
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 44 deletions.
2 changes: 1 addition & 1 deletion core/include/cubos/core/ecs/system/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace cubos::core::ecs
/// A system may be invalid, if, for example, it both reads and writes the same resource.
///
/// @return Whether the system is valid.
bool valid() const;
static bool valid();

/// @brief Checks if this system is compatible with another system.
///
Expand Down
15 changes: 1 addition & 14 deletions core/src/cubos/core/ecs/system/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,8 @@

using namespace cubos::core::ecs;

bool SystemInfo::valid() const
bool SystemInfo::valid()
{
if (this->usesWorld)
{
return !this->usesCommands && this->resourcesRead.empty() && this->resourcesWritten.empty();
}

for (const auto& rsc : this->resourcesRead)
{
if (this->resourcesWritten.contains(rsc))
{
return false;
}
}

return true;
}

Expand Down
29 changes: 0 additions & 29 deletions core/tests/ecs/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,6 @@ TEST_CASE("ecs::SystemInfo")
CHECK(infoA.valid());
}

SUBCASE("A is invalid")
{
SUBCASE("A reads and writes to the same resource")
{
infoA.resourcesRead.insert(typeid(int));
infoA.resourcesWritten.insert(typeid(int));
}

SUBCASE("A uses the world directly and reads a resource")
{
infoA.usesWorld = true;
infoA.resourcesRead.insert(typeid(int));
}

SUBCASE("A uses the world directly and writes a resource")
{
infoA.usesWorld = true;
infoA.resourcesWritten.insert(typeid(int));
}

SUBCASE("A uses the world directly and uses commands")
{
infoA.usesWorld = true;
infoA.usesCommands = true;
}

CHECK_FALSE(infoA.valid());
}

SUBCASE("A and B are compatible")
{
SUBCASE("both do nothing")
Expand Down

0 comments on commit 8d4a390

Please sign in to comment.