Grease entities are useful as actionable, interactive game elements that are often visible to the player.
You might use entities to represent:
See an example entity class in the tutorial.
Base class for grease entities.
Entity objects themselves are merely identifiers within a grease.world.World. They also provide a facade for convenient entity-wise access of component data. However, they do not contain any data themselves other than an entity id.
Entities must be instantiated in the context of a world. To instantiate an entity, you must pass the world as the first argument to the constructor. Subclasses that implement the __init__() method, must accept the world as their first argument (after self). Other constructor arguments can be specified arbitarily by the subclass.
Return an EntityComponentAccessor for this entity for the component named.
Example:
my_entity.movement
Set the entity data in the named component for this entity. This sets the values of the component fields to the values of the matching attributes of the value provided. This value must have attributes for each of the component fields.
This allows you to easily copy component data from one entity to another.
Example:
my_entity.position = other_entity.position
Remove this entity and its data from the component.
Example:
del my_entity.renderable
Set of entities in a component, can be queried by component fields
A facade for accessing specific component data for a single entity. The implementation is lazy and does not actually access the component data until needed. If an attribute is set for a component that the entity is not yet a member of, it is automatically added to the component first.
Parameters: |
|
---|