0
\$\begingroup\$

I am searching about "sub-systems" in ECS but I don't find any article speaking on that. Considers this simple example:

struct Engine
{
    MoveSystem move_system;
    CollisionSystem collision_system;
    RenderSystem render_system;

    void PhysicsSystem::update()
    {
        move_system.update();
        collision_system.update();
        render_system.update();
    }
}

We can make a physics_system which will be the aggregation of the physics_system and the collision_system.

void Engine::update()
{
    physics_system.update();
    render_system.update(); // No change
}

struct PhysicsSystem
{
    MoveSystem move_system;
    CollisionSystem collision_system;

    void PhysicsSystem::update()
    {
        move_system.update();
        collision_system.update();
    }
}

Is it a bad practice? I could not see any drawback since it looks like just a pure change-big-class-into-many-smalls refactoring without logical changes.

\$\endgroup\$
1
  • \$\begingroup\$ As a general rule, I'd work under the assumption that everything is permitted until you encounter a specific prohibition or problem. Then ask about that specific problem once you've demonstrated it. \$\endgroup\$
    – DMGregory
    Apr 27 at 11:54

1 Answer 1

2
\$\begingroup\$
  1. Yes, you can. ECS is just like a "guiding methodology",There is no mandatory rule. You can make your own implementation as needed.
  2. Is it a bad practice? Maybe. PhysicsSystem is not characterized as a system. It does not focus on entities with certain properties. It is only used to organize some other systems. So maybe PhysicsSystem is a System Group instead of system. System Group is a common concept in ecs system, usually used to organize the update order. You can search it with "system groups" as key-word instead of "sub-systems".
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .