You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using relations in a query you can query for a specific target:
constresults=world.query(Contains(gold))
Or a wildcard, which matches any entity targeted by that relation:
constresults=world.query(Contains('*'))
The feature request is to extend this by passing traits which filters by any entity that is a target of the relation and also has the matching traits.
constresults=world.query(Contains(IsActive))
Challenges: We are currently using the same API for both adding relations as traits and querying entities. This mixes concerns in a way that feels unsafe. Either strong typing needs to address this or there needs to be some symmetry between adding relations and querying them.
The text was updated successfully, but these errors were encountered:
My preferred approach would be to go for symmetry and enable bulk operations in all contexts. Examples:
isGold=trait();// ------------------------------------------------------------------// adding with `...trait[]` argmyEntity.add(Contains(isGold));// translates toworld.query(isGold).forEach(goldEntity=>myEntity.add(Contains(goldEntity)))// ------------------------------------------------------------------// removing with `...trait[]` argmyEntity.remove(Contains(isGold));// translates toworld.query(isGold).forEach(goldEntity=>myEntity.remove(Contains(goldEntity)))// ------------------------------------------------------------------// querying for a relation with `...trait[]` argworld.query(A,Contains(isGold))// translates to (pseudo code implementation)containsGold=world.query(Contains(isGold))world.query(A,Contains("*")).filter(e=>containsGold.some(e2=>e2===e.targetFor(Contains)))
When using relations in a query you can query for a specific target:
Or a wildcard, which matches any entity targeted by that relation:
The feature request is to extend this by passing traits which filters by any entity that is a target of the relation and also has the matching traits.
Challenges: We are currently using the same API for both adding relations as traits and querying entities. This mixes concerns in a way that feels unsafe. Either strong typing needs to address this or there needs to be some symmetry between adding relations and querying them.
The text was updated successfully, but these errors were encountered: