snakia.core.ecs.system

Functions

cast(typ, val)

Cast a value to a type.

nolock()

overload(func)

Decorator for overloaded functions/methods.

Classes

Component(**data)

Iterable()

Processor()

A processor is a class that processes the system.

System()

A system is a collection of entities and components that can be processed by processors.

TypeVar(name, *constraints[, bound, ...])

Type variable.

count([start, step])

Return a count object whose .__next__() method returns consecutive values.

defaultdict

defaultdict(default_factory=None, /, [...]) --> dict with default factory

class snakia.core.ecs.system.System[source]

Bases: object

A system is a collection of entities and components that can be processed by processors.

__init__()[source]
add_component(entity, component)[source]

Adds a component to an entity.

Return type:

None

add_processor(proccessor)[source]

Adds a processor to the system.

Return type:

None

create_entity(*components)[source]

Creates an entity with the given components.

Return type:

int

delete_entity(entity, immediate=False)[source]

Deletes an entity.

Return type:

None

entity_exists(entity)[source]

Returns True if the entity exists.

Return type:

bool

full_reset()[source]

Resets the system to its initial state.

Return type:

None

get_component(component_type, /)[source]

Returns all entities with the given component.

Return type:

Iterable[tuple[int, TypeVar(C, bound= Component)]]

get_component_of_entity(entity, component_type, /, default=None)[source]

Returns the component of the given entity.

Return type:

Any

get_components(*component_types)[source]

Returns all entities with the given components.

Return type:

Iterable[tuple[int, tuple[Component, ...]]]

get_components_of_entity(entity, /, *component_types)[source]

Returns the components of the given entity.

Return type:

tuple[Any, ...]

get_processor(processor_type, /)[source]

Returns the first processor of the given type.

Return type:

Optional[TypeVar(P, bound= Processor)]

has_component(entity, component_type)[source]

Returns True if the entity has the given component.

Return type:

bool

has_components(entity, *component_types)[source]

Returns True if the entity has all the given components.

Return type:

bool

property is_running: bool

Returns True if the system is running.

remove_component(entity, component_type)[source]

Removes a component from an entity.

Return type:

Optional[TypeVar(C, bound= Component)]

remove_processor(processor_type)[source]

Removes a processor from the system.

Return type:

None

start()[source]

Starts the system.

Return type:

None

stop()[source]

Stops the system.

Return type:

None

update()[source]

Updates the system.

Return type:

None