What have I been up to?
This week has been a bit slow, compared to the other weeks. It involved less writing code and more researching ways to do things.
So far, I’ve discovered a lot of things, a lot of which might not be relevant but I found out about them anyway.
Launching a new game
Whenever a new game is launched, a new GameManifest is created with game title, modules, and WorldInfo. After making the needed GameManifest object, the GameState is changed to StateLoading.
In StateLoading there are multiple processes with are added in either
Every process has a
step function which performs the actual process and returns true once done. If the function fails to return true, it is called again after some time. There are many processes, I only investigated some which I thought were relevant to my work.
WorldInfowhich was added to the
GameManifestwhile initialising the new game is now put to use. The WorldInfo is actually stored as a Map<String, WorldInfo> and this process simply gets the
TerasologyConstants.MAIN_WORLDwhose value is “main”. This made me understand that the world in which the player will spawn, it’s key should be “main” or
WorldGeneratorManageris fetched from the context, and a new generator is created, and seed is set for it.
- A new
StorageManageris instantiated to handle saving the game.
LocalChunkProvideris instantiated which in turn creates
ChunkGenerationPipelinewhere 8 threads are made for the loading of various chunks.
- This process, as the name suggests initialises all entities with the
- The entities are built in the
generateBlockTypeEntitymethod of the
BlockTypeEntityGeneratorclass. This method calls the
EntityBuilderclass. In this method, the entity is assigned a pool using the
PojoEntityManager, which maps entity ids to a
- All the world properties like tree density are accessed here and added to the newly created
- The worldEntity is created using a globalPool in the
PojoEntityManagerwhich I think is the only pool created and used throughout the game.
- This entity is created in a different way but just like the BlockType entities towards the end, the same build method is called which allots it to a pool. This pool is the same as the globalPool used to create the entity initially.
- A world generator is initialised and all the relevant entities associated with it are built and move them to the same pool being used till now. A large number of entities are built here.
The Chunk Generation Thread
EntityBuilderis now called by a large number of threads in completely random order creating chunks.
Apart from these processes, I’ve been looking at the way Sectors function as well. All the significant classes needed for the functioning are present in the engine but to put them in use, one needs to activate the TutorialSectors module.
The module makes use of the
createSectorEntity method in the
PojoEntityManager which in turn triggers the
create method of the
PojoSectorManager class. The
PojoSectorManager creates a new pool in its constructor which is then used to build the sectors entity. The entity is also given the relevant components needed for simulation.