[Fluid] Convenient entity matching
See original GitHub issueQuick notes. Sorry for mess!
(From a jam perspective) aspects are currently a quite laborious aspect of ODB. it’s a pain writing out the predicates for a system or queries to the subscription manager. There’s some areas we could improve things:
Query singletons
Believe there are opportunities to solve the following query in a more succinct manner.
E(world.getAspectSubscriptionManager().get(Aspect.all(BathroomLevel.class)).getEntities().get(0))
Don’t know about others but having to inspect or alter a singleton that falls outside the scope of my system aspects is a fairly common thing. Delegating to a specialized passive system might be the proper way to do it, but the verbosity of resolving the singleton remains.
Something like E(BathroomLevel.class)
could do the trick.
Query + iterating lists
Same with this query:
IntBag actives = world.getAspectSubscriptionManager().get(Aspect.all(Hammer.class)).getEntities();
int[] ids = actives.getData();
for (int i = 0, s = actives.size(); s > i; i++) {
We could follow a jQuery
style batch-operations All(Hammer.class).visible(true).do(myOperation)
or perhaps the more practical for(E e : All(Hammer))
, can’t really weigh the performance costs of having an iterator. I guess a per-composition iterator wouldn’t be too costly or limiting?
Constructors
Will not do.
IntellIJ quick-creating a constructor forcefully maps the Aspect.Builder as a parameter.
public class MyExampleSystem extends BaseEntitySystem {
public MyExampleSystem(Aspect.Builder aspect) {
super(aspect);
}
}
Bit of a hack but I’ve been using a no-arg constructor (with Aspect.all()
) in the hierarchy to save time in this regard.
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (6 by maintainers)
Top GitHub Comments
To keep things extensible and easy to grok settled on:
Group
If anyone has a better naming suggestion i’m all for it. was considering
E.group(..)
,E.allWithGroup(..)
, perhapsE.entitiesWithGroup(..)
sinceE
tends to get statically imported.Tag
Subscription
edit 1&2: Added tag, subscription
High value ticket for me, I’d love a convenient and fast API to retrieve by tag/group/composition and operate on sets.