View Source ECSx.Tag behaviour (ECSx v0.5.1)

A component type which does not require a value. This is useful when the mere presence or absence of a component is all the information we need.

For example, if we want a component type to model a boolean attribute, such as whether or not players may target a particular entity, we'll use a Tag:

defmodule MyApp.Components.Targetable do
  use ECSx.Tag
end

Then we can check for targetability with ...Targetable.exists?(entity) or get a list of all targetable entities with ...Targetable.get_all().

options

Options

  • :read_concurrency - when true, enables read concurrency for this component table. Only set this if you know what you're doing. Defaults to false

Link to this section Summary

Callbacks

Creates a new tag for a given entity.

Checks if an entity has this tag.

Gets a list of all entities with this tag.

Removes this component from an entity.

Link to this section Types

Link to this section Callbacks

@callback add(entity :: id()) :: :ok

Creates a new tag for a given entity.

@callback exists?(entity :: id()) :: boolean()

Checks if an entity has this tag.

@callback get_all() :: [id()]

Gets a list of all entities with this tag.

@callback remove(entity :: id()) :: :ok

Removes this component from an entity.