xecs.World#

class xecs.World[source]#

Bases: object

Stores and manages all entities, components, and resources.

Methods

add_pool

Add a component pool to the world.

add_resource

Add a resource to the world.

get_resource

Get a resource.

get_view

Get a view of some components.

has_pool

Check if a pool for a given component type exists.

has_resource

Check if the world has a resource.

add_pool(pool)[source]#

Add a component pool to the world.

Parameters:

pool (ComponentPool[ComponentT]) – The component pool to add.

Return type:

None

add_resource(resource)[source]#

Add a resource to the world.

Parameters:

resource (Resource) – The resource to add.

Return type:

None

get_resource(resource)[source]#

Get a resource.

Parameters:

resource (type[ResourceT]) – The type of the resource.

Returns:

The resource.

Return type:

ResourceT

get_view(component, indices=None)[source]#

Get a view of some components.

Parameters:
  • component (type[ComponentT]) – The component which you want to view.

  • indices (ArrayViewIndices | None) – The indices specifying which entities in the component pool you want to view.

Returns:

A component view of your selected entities.

Return type:

ComponentT

has_pool(component)[source]#

Check if a pool for a given component type exists.

Returns:

Whether the pool exists.

Parameters:

component (type[Component]) –

Return type:

bool

has_resource(resource)[source]#

Check if the world has a resource.

Parameters:

resource (type[Resource]) – The type of the resource.

Returns:

Whether the world has the resource.

Return type:

bool