ecsalt_component (ecsalt v2.0.0)

View Source

Put, remove, and query named data on entities.

Summary

Functions

Fold a function over all entities matching a given set of components, accumulating a result.

For each entity with the specified Component, apply fun(EntityID, Values).

Return all entities matching a given set of components. Returns empty list if there are no matches.

Associate a component defined as the tuple {key,value} with an entity. If the component already exists, it will be replaced with the new value. Returns the opaque world() type.

Remove a component from a given entity. This function will always succeed even if the component does not exist.

Update a component's value by applying a function to it. The component must already exist on the entity.

Types

component()

-type component() :: {term(), term()}.

entity()

-type entity() :: {term(), [component()]}.

id()

-type id() :: identifier().

world()

-opaque world()

Functions

fold(ComponentList, Fun, Acc0, World)

-spec fold([term()], fun((id(), [component()], Acc) -> Acc), Acc, world()) -> Acc.

Fold a function over all entities matching a given set of components, accumulating a result.

foreach(ComponentList, Fun, World)

-spec foreach([term()], fun((id(), [component()]) -> any()), world()) -> ok.

For each entity with the specified Component, apply fun(EntityID, Values).

match(ComponentList, World)

-spec match([term()], world()) -> [entity()].

Return all entities matching a given set of components. Returns empty list if there are no matches.

put(Components, EntityID, World)

-spec put([{term(), term()}], id(), world()) -> world().

Associate a component defined as the tuple {key,value} with an entity. If the component already exists, it will be replaced with the new value. Returns the opaque world() type.

remove(Components, EntityID, World)

-spec remove([term()], id(), world()) -> world().

Remove a component from a given entity. This function will always succeed even if the component does not exist.

update(Name, Fun, EntityID, World)

-spec update(term(), fun((term()) -> term()), id(), world()) -> world().

Update a component's value by applying a function to it. The component must already exist on the entity.