esper
esper copied to clipboard
one to many relationship unit tests
Hello, I need to create relationships between my entities in my project. I have read this thread (https://github.com/benmoran56/esper/pull/62) and I would like to propose a way to build them using esper. The key idea is to add a same component instance (called a group) to many entities. This works already fine with esper but not any test assure it over the long-term. So this PR only adds unit tests.
Finally, I found another way to implement it which don't need to add the same instance of a component to many entities.
the first idea
item 1 | character | item 2 | ||
---|---|---|---|---|
Inventory | <-- | Hold | Inventory (the same instance) |
the new one
item 1 | character | item 2 | ||
---|---|---|---|---|
Belong | --> | Inventory | <-- | Belong |
for the farm/plant question (https://github.com/benmoran56/esper/issues/79)
plant 1 | farm | plant 2 | ||
---|---|---|---|---|
Rooted | --> | Plantation | <-- | Rooted |
The only oddity remaining is that a component has another component as an attribute. This allows to do not use an entity ID instead or to use a complex identifier system.