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

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

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

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.

Types

id()

@type id() :: any()

Callbacks

add(entity)

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

Creates a new tag for a given entity.

exists?(entity)

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

Checks if an entity has this tag.

get_all()

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

Gets a list of all entities with this tag.

remove(entity)

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

Removes this component from an entity.