-
-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Milestone
Description
Hello,
Is it a bug or am I doing something wrong?
I add Component (name = BComponent) to Entity and in System class itterating over entities with BComponent is running.
I can check if Entity has a BComponent: entity.has(BComponent) = true
But if I call entity.get(BComponent), it will stops with FleksNoSuchEntityComponentException.
I suppose if "entity.has(BComponent)" is true, then "entity.get(BComponent)" should be not null or Exception.
Output in my console:
CmpSystem One onTickEntity
CmpSystem Two onTickEntity
entity.has(BComponent) = true
Exception in thread "main" com.github.quillraven.fleks.FleksNoSuchEntityComponentException: Entity 'Entity(id=0, version=0)' has no component of type 'BComponent'.
class MOneTest : KtxGame<KtxScreen>() {
override fun create() {
addScreen(GameScreen())
setScreen<GameScreen>()
}
override fun render() {
currentScreen.render(Gdx.graphics.deltaTime)
}
}
class GameScreen() : KtxScreen {
private val eWorld = configureWorld {
systems {
add(CmpSystemOne())
add(CmpSystemTwo())
}
}
init {
eWorld.entity {
it += AComponent
}
}
override fun render(delta: Float) {
eWorld.update(delta)
}
}
class AComponent() : Component<AComponent> {
override fun type() = AComponent
companion object : ComponentType<AComponent>()
}
class BComponent() : Component<BComponent> {
override fun type() = BComponent
companion object : ComponentType<BComponent>()
}
class CmpSystemOne() : IteratingSystem(World.family { all(AComponent) }) {
override fun onTickEntity(entity: Entity) {
println("CmpSystem One onTickEntity")
entity.configure {
it += BComponent
}
}
}
class CmpSystemTwo() : IteratingSystem(World.family { all(BComponent) }) {
override fun onTickEntity(entity: Entity) {
println("CmpSystem Two onTickEntity")
println("entity.has(BComponent) = " + entity.has(BComponent))
val bCmp = entity.get(BComponent)
}
}
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed