libgdx/ashley

Is it possible to extend family?

Opened this issue · 2 comments

xahon commented

I have these families:

val Placeable: Family = Family.all(
            NavigationComponent.Position::class.java,
            NavigationComponent.Rotation::class.java
).get()

val Movable: Family = Family.all(
            NavigationComponent.Position::class.java,
            NavigationComponent.Rotation::class.java,
            MovementComponent.MoveSpeed::class.java,
            MovementComponent.MoveInfo::class.java
).get()

is there any way to make Movable something like this?

val Movable: Family = Family.all(
            *Placeable.components,
            MovementComponent.MoveSpeed::class.java,
            MovementComponent.MoveInfo::class.java
).get()

I think this should be fairly easy to implement method that can merge a family into another instance.

xahon commented

@metaphore I have to create family wrapper class that makes that because you can't access to types you pass into all, one and exclude

UPD
I found that approach as ugly workaround to create wrapper class because in my case it returns Family class from which you can't build a new one for, e.g. Engine.getEntitiesFor because all, one, exclude are private fields
So I may be will have to create a bunch of narrow-case families for each particular system