lkn-core v0.3.0 Lkn.Core.Entity behaviour View Source

A behaviour module for implementing an Entity.

Note: An Entity can either be a Map or a Puppet. To actually implement an Entity, you should use either Lkn.Core.Puppet.defpuppet/2 or Lkn.Core.Map.defmap/2. In other words, if your code contains @behaviour Lkn.Core.Entity, you are doing it wrong. From a developer point of view, only the start_link/3 function is really useful.

Link to this section Summary

Types

The third argument of the start_link/3 function which is passed to the init_properties/1 callback

k()

A key to identify and reach an Entity, that is either a Lkn.Core.Puppet or a Lkn.Core.Map

A property of the Entity, e.g. its health point, its current speed, etc

A value associated to a given Entity’s property

Functions

Compute a digest which hopefully describes the entity

Retreive the current value of the given property, if it exists

Starts an Entity process linked to the current process

Stop the given Entity

Link to this section Types

Link to this type digest() View Source
digest() :: term
Link to this type init_args() View Source
init_args() :: any

The third argument of the start_link/3 function which is passed to the init_properties/1 callback.

A key to identify and reach an Entity, that is either a Lkn.Core.Puppet or a Lkn.Core.Map.

A property of the Entity, e.g. its health point, its current speed, etc.

Link to this type value() View Source
value() :: any

A value associated to a given Entity’s property.

Link to this section Functions

Link to this function digest(entity_key) View Source
digest(entity_key :: k) :: digest

Compute a digest which hopefully describes the entity

Retreive the current value of the given property, if it exists.

There is no write counterpart, because only a Component can modify it.

Link to this function start_link(module, key, args) View Source
start_link(module, k, init_args) :: Supervisor.on_start

Starts an Entity process linked to the current process.

Link to this function stop(key, reason \\ :normal) View Source

Stop the given Entity

This

Link to this section Callbacks

Link to this callback destroy(key, entity, reason) View Source
destroy(key :: k, entity :: %{optional(prop) => value}, reason :: term) :: any
Link to this callback digest(entity) View Source
digest(entity :: %{optional(prop) => value}) :: digest
Link to this callback init_properties(init_args) View Source
init_properties(init_args) :: %{optional(prop) => value}

Initializes the Entity’s map of properties.

This map is used by