junkdog / artemis-odb

A continuation of the popular Artemis ECS framework
BSD 2-Clause "Simplified" License
776 stars 111 forks source link

[Question] Why does WorldSerializationManager need to be registered as a system? #598

Closed rhpenguins closed 3 years ago

rhpenguins commented 4 years ago

In the wiki on serializing an world instance to JSON using libGDX, it gives this following example:

final WorldSerializationManager manager = new WorldSerializationManager();
World world = new World(new WorldConfiguration().setSystem(manager));
manager.setSerializer(new JsonArtemisSerializer(world));

However, if the job of the manager is just to serialize the world when it is called, why does it need to be a base system? In the source code for it https://github.com/junkdog/artemis-odb/blob/develop/artemis-serialization/artemis-serializer/src/main/java/com/artemis/managers/WorldSerializationManager.java#L22, it leaves the overriden method processSystem() empty anyway.

Does anyone know why it needs to be registered as a system? The coupling has led to some messy code in my project, and it just doesn't seem logical to me.

DaanVanYperen commented 3 years ago

Ah the early-corona days! Hope you are doing ok in 2021.

It needs to be injected into other systems, which is why it is implemented this way. You are correct it is a bit of a wrinkle in the design but for backwards compatibility we've left managers like this.