Genesis.Event (genesis v0.10.0)

Copy Markdown View Source

A struct representing an event that can be dispatched to entities.

Events are the primary mechanism for triggering behavior in Genesis. When an event is sent to an entity, it will be processed by the components attached that have been registered to handle that specific event.

Fields

  • :name - The unique event identifier
  • :entity - The target entity this event was sent to
  • :world - The world that dispatched the event
  • :timestamp - The event creation timestamp
  • :args - Additional event-specific data
  • :handlers - The list of modules that will handle the event

Summary

Functions

Processes a list of events by invoking their respective handlers in order. Each handler can choose to continue processing the event or halt further processing.

Types

t()

@type t() :: %Genesis.Event{
  args: map(),
  entity: Genesis.Entity.t(),
  handlers: [module()],
  name: atom(),
  timestamp: integer(),
  world: pid()
}

Functions

process(event)

Processes a list of events by invoking their respective handlers in order. Each handler can choose to continue processing the event or halt further processing.

NOTE: This function is mostly used internally to process entity events. Calling it directly should be avoided unless you need to bypass the default event dispatching mechanism.