MovingBlocks/Terasology — pull request #1430 by flo (2014-12-07 19:49:32+00:00)
Title: For discussion: Init systems fix

I noticed that the Pathfinding module from @synopia is creating an entity in the initialize method of a system.

This works for newly generated worlds, but not for loaded worlds. The global store gets loaded after the system initialization and it contains necessary data for the entity manager to be able to work properly. For that reason it is currently clearing the entity manager.

The pull request splits the global store data loading. It loads first the data necessary for the entity manager to work properly from the global store, then it initializes the systems and then it restores the global entities.

However I am tending to thinking now that this is the wrong approach.
* A System should not create an entity, as for example adding components requires other systems to be ready
* systems don't see the global entiteis at their initialization.

So an alternative approach might be for now to just clear the entity manager after system initialization even if there is no global store to load (new game). That would be a minimal fix that might be enough for now. The important thing is that the developer notices it even on new worlds.

The Pathfinding module itself does not really need that entity it creates. I think another solution that doesn't use this entity might be even better.