xecs.Component#

class xecs.Component[source]#

Bases: object

A base class for components.

Methods

create_pool

Create a preallocated pool of components.

Attributes

component_ids

Maps each component type to a unique ID.

classmethod create_pool(capacity)[source]#

Create a preallocated pool of components.

Parameters:

capacity (int) – The maximum number of components the pool can hold.

Returns:

The component pool.

Return type:

ComponentPool[Self]

component_ids: ClassVar[dict[type[Component], ComponentId]] = {<class 'xecs._internal.entity_id.EntityId'>: 0, <class 'xecs._internal.transform2.Transform2'>: 1}#

Maps each component type to a unique ID. This is automatically populated by subclasses.