Specs specify how to retrieve and update components and singletons. They are initialized using the Ecs.ComponentsN and Ecs.SingletonsN modules.
type alias Specs =
{ allComponents : AllComponentsSpec EntityId Components
, position : ComponentSpec EntityId Position Components
, velocity : ComponentSpec EntityId Velocity Components
, nextEntityId : SingletonSpec EntityId Singletons
}
specs : Specs
specs =
Specs |> Ecs.Components2.specs |> Ecs.Singletons1.specsUsed for operations on a single component type.
Used for operations on a single singleton type.
The world contains all your entities, components and singletons.
The world that contains all you data.
Create an empty world without entities or components. Singletons need an intial value.
Determine if the world is empty, without entities or components.
Get all entity ids in the world.
Determine the total number of entities in the world.
Determine the total number of components in the world.
Entities are represented by an id.
An entity id can be any comparable type.
Operations on entities usually apply to the active entity in the world. You can make an entity active with the onEntiy function. Also when you insert a new entity that entity will be active.
Add a new entity id to the world and make the entity active.
Make an entity active if it is part of the world, otherwise no entity will be active.
Remove the active entity from the world. All component associated with the entity will also be removed.
Remove all components of the active entity. The entity will remain part of the world.
Determine if there is an active entity.
Get the active entity id.
Components contain all the entity data in the world. Every component is associated with an entity.
Insert a component with the specified component type in the active entity.
Update a component with the specified component type in the active entity.
Remove a component with the specified component type from the active entity.
Determine if the active entity has the specified component type.
Get a component with the specified component type of the active entity.
Get all entities that contain the specified component type.
Determine the total number of components of the specified component type.
Replace all components for the specified component type. All provided entities are added to the world.
Clear all components for the specified component type.
Get all components for the specified component type.
Singletons contain data where there should only be one instance of. Singletons are optional. They are added to the package for convenience and to create a consistent way to deal with data (singletons and components). You can also just keep the singleton data in your model next to the ecs world just like you do in any Elm program.
Set the data for the specified singleton type.
Update the data for the specified singleton type.
Get the data for the specified singleton type.
Used for operations on multiple component types.