Lutes internals

Manager

class lutes.Manager

Manager handles entities and their components.

add_component(entity, component)

Add a component to an entity

add_system(system)

Add system to the world

create_entity()

Create an entity in the world and return its identifier.

Return type:entity
dispatch_event(event, data)

Dispatch an event to all subscribers

Parameters:
  • event – event name as string
  • data – data that will be passed to subscribers
get_component(entity, component)

Get an entity’s component by its type Returns None if no component of given type was found

Return type:component or None
has_component(entity, component)

Check that given entity has component

init()

Initialize systems

remove_component(entity, component)

Remove a component from an entity

remove_entity(entity)

Remove an entity from the world

remove_system(system)

Remove a system from the world

subscribe(event, callback)

Subscribe a callback to an event

Parameters:
  • event – event name as string
  • callback – callable
update(delta)

Update every system

Parameters:delta – time elpased since last update

System

class lutes.System(priority=99)

A system handles a set of components. It is responsible for updating them.

entities = None

Entities handled by the system

handled_components = None

Components the system needs to update entites

init()

Initialize the system

priority = None

System priority, lower is updated first

update(delta)

Update entities

Parameters:delta – time elapsed since last update

Component

class lutes.Component(entity=None)

A component is a data bag attached to an entity

entity = None

Entity the component relates to