EntityManager is a 'world' for Entities. When an Entity is created it is added to an EntityManager. the responsibilities of the manager are: (1) updating the entities (the time between updates is stored in the managers class variable dt). (2) checking for collisions using an instance of SpatialHashing and sending the .collision msg to the entities. You can add to it 3 types of entities: free, static and mobile. When adding a free Entity the manager doesn't include it when checking for collisions. Mobile entities are checked against each other and with static ones while static are not checked against each other. This saves processing time by reducing the number of checks while the spatial hashing index becomes more efficient by registering the static entities one time only, at the time of creation.
On instantiation we need to pass in the spatial index.
This is the method that is used inside a game loop to set the world in motion. Examine the internal of the methods if you want to know how the rest of the class is working. The update method is expected to be called inside a loop/routine with a wait time of the current dt. An example of usage can be found in the GameLoop class.
Swap the index for a new one.
Clear just the entities.
Check for collisions between the relevant objects.
Clear all walls currently registered with the manager.
Add a wall to the manager.
Remove a wall from the manager.
Clear all entities and walls (Does not affect the camera).
Get all mobile entities.
Get all free entities.
Get static entities.
Get all entities in a List.
Get the walls in a List.