An entity system in Python.
Exceptions that may be raised.
Bases: exceptions.Exception
Error indicating that the system type already exists in the system manager.
Parameters: | system_type (type) – type of the system |
---|
Bases: exceptions.Exception
Error indicating that a component type does not exist for a certain entity.
Parameters: |
|
---|
Entity and System Managers.
Provide database-like access to components based on an entity key.
Add a component to the database and associates it with the given entity_id. entity_id can be an ecs.models.Entity object or a plain int.
Parameters: |
|
---|
Return the instance of component_type for the entity_id from the database.
Parameters: |
|
---|---|
Returns: | list of (entity_id, component_instance) tuples |
Return type: | tuple of (int, ecs.models.Component) |
Raises : | NonexistentComponentTypeForEntity when component_type does not exist on entity_instance |
Return a new entity instance with the current lowest GUID value. Does not store a reference to it, and does not make any entries in the database referencing it.
Returns: | the new entity |
---|---|
Return type: | ecs.models.Entity |
Get this manager’s database. Direct modification is not permitted.
Returns: | the database |
---|---|
Return type: | dict |
Return a list of (entity_id, component_instance) tuples for all entities in the database possessing a component of component_type. Return an empty list if there are no components of this type in the database. Can use in a loop like this, where Renderable is a component type:
for entity, renderable_component in entity_manager.pairs_for_type(Renderable):
pass # do something
Parameters: | component_type (type) – a type of created component |
---|---|
Returns: | list of (entity_id, component_instance) tuples |
Return type: | tuple of (int, ecs.models.Component) |
Remove the component of component_type associated with entity_id from the database. Doesn’t do any kind of data-teardown. It is up to the system calling this code to do that. In the future, a callback system may be used to implement type-specific destructors.
Parameters: |
|
---|
A container and manager for ecs.models.System objects.
Add a ecs.models.System instance to the manager.
Parameters: | system_instance (ecs.models.System) – instance of a system |
---|
Tell the manager to no longer run the system of this type.
Parameters: | system_type (type) – type of system to remove |
---|
Get this manager’s list of systems.
Returns: | system list |
---|---|
Return type: | list of ecs.models.System |
Entity, Component, and System classes.
Encapsulation of a GUID to use in the entity database.
Parameters: | guid (int) – globally unique identifier |
---|