Skip to content

Inheritance #12

@HexDecimal

Description

@HexDecimal

I would like to add prefabs and inheritance. Something like this:

>>> world = tcod.ecs.World()
>>> world["orc"].components[("atk", int)] = 4
>>> monster = world["orc"].instantiate()  # New entity with is-a relation
>>> monster.components[("atk", int)]  # Takes atk from parent
4
>>> monster.components(traverse=())[("atk", int)]  # Missing when traversal is disabled
KeyError
>>> monster.components[("atk", int)] += 1  # Typical copy-on-write
>>> monster.components(traverse=())[("atk", int)]
5

I'm in the middle of refactoring queries, and once that is done I'll be able to add relationship traversal and then I can make an IsA sentinel value which will be the default traversal option for all queries and lookups.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions