An entity, component and systems library with universal unique ids peppered for distributed use.
Starts with a world:
from bec import World
w = World()
Then define your components:
from bec import World
from bec.meta import ComponentMeta, FieldMeta
w = World()
# define as many components as you want
w.define_component(ComponentMeta(
"Test Component",
"test_component",
[
FieldMeta("Field 1", "field1", str, "123")
]
))
Once you have defined a few components add them to your entities:
entity_id = w.add_entity("component1", "component2")
Currently the library will return entity ids. Future versions will return a class instance for ease of use.
Check if an entity has a particular component:
entity_id = w.add_entity("component1")
w.entity_has_component(entity_id, "component1") # True
w.entity_has_component(entity_id, "missing_component") # False
List components:
entity_id = w.add_entity("component1", "component2")
w.list_entity_components(entity_id) # ["component1", "component2"]
Get an entity component's instance
entity_id = w.add_entity("component1", "component2")
component = w.get_component(entity_id, "component1")
TODO: Add systems, systems tests and documentation