The World

The World ( ecs.World ) is the central data storage in Arche. It manages and stores entities ( ecs.Entity ), their components, as well as Resources. For the internal structure of the world, see chapter Architecture.

Here, we only deal with world creation. Most world functionality is covered in chapters Entities & Components and World Entity Access.

World creation

To create a world with default settings, use ecs.NewWorld :

1world := ecs.NewWorld()
2_ = world

A world can also be configured with a capacity increment, using an ecs.Config :

1config := ecs.NewConfig().WithCapacityIncrement(1024)
2world := ecs.NewWorld(config)
3_ = world

The capacity increment determines by how many entities an archetype grows when it reaches its capacity.

For archetypes with an Entity Relation, a separate capacity increment can be specified:

1config := ecs.NewConfig().
2	WithCapacityIncrement(1024).
3	WithRelationCapacityIncrement(128)
4
5world := ecs.NewWorld(config)
6_ = world

Reset the world

For systematic simulations, it is possible to reset a populated world for reuse:

1world := ecs.NewWorld()
2// ... do something with the world
3
4world.Reset()
5// ... start over again