World
The World
is the heart of Ecstatic. All Entities
and Systems
are added to the World
instance, and its methods allow querying of Entities
.
#
Create a WorldTo create a World
instance, all you need to do is "new" one up.
#
Querying EntitiesA World
instance offers a good amount of methods that can be used to find the Entities
and Components
that you want to operate on.
To see all the methods that can be used to query with, check out the World API Docs.
Query methods can generally be grouped in a couple buckets:
get()
- If you know the entities' id, you can get it directly with get().find(), findAll()
- Use a predicate to "find" entities.locate(), locateAll()
- "locate" an entity or entities by whatComponents
are attached to it.grab(), grabAll(), grabBy()
- Similar tolocate
methods, but also "grabs" a component instance as well. Very handy if you know that you'll need to update a specific component on an entity.
#
Destroying /Shutting down a WorldIf you are going to get rid of a world instance, it can be a good idea to properly destroy all entities by calling their destroy()
methods, and running the systems one last time. This gives any Systems that monitor the entity "destroying" state a chance to clean up after themselves.