libgdx / ashley

A Java entity system inspired by Ash & Artemis.
Apache License 2.0
871 stars 144 forks source link

Is it possible to extend family? #267

Open xahon opened 6 years ago

xahon commented 6 years ago

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()
metaphore commented 6 years ago

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

xahon commented 6 years ago

@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