0

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.

rafoo
  • 143
  • 1
  • 5
  • 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. – DMGregory Apr 27 '22 at 11:54

1 Answers1

2
  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".
Engineer
  • 29,455
  • 4
  • 72
  • 120
Mangata
  • 2,516
  • 1
  • 2
  • 9