Ashley ECS IteratingSystem 不处理实体系列

Ashley ECS IteratingSystem not processing entity family

不知怎么的,我无法让 IteratingSystem 工作。在更新中,我仔细检查是否有实体,它 returns 多于 0。但这应该意味着 processEntity 被调用,但它永远不会 运行s.

//...
import net.madmenyo.teststuff.AshleyTest.components.MovementComponent;
import net.madmenyo.teststuff.AshleyTest.components.PositionComponent;
//...

public class MovementSystem extends IteratingSystem {
    private ComponentMapper<PositionComponent> pm;
    private ComponentMapper<MovementComponent> mm;

    public MovementSystem () {
        super(Family.all(PositionComponent.class, MovementComponent.class).get());
        pm = ComponentMapper.getFor(PositionComponent.class);
        mm = ComponentMapper.getFor(MovementComponent.class);
    }

    @Override
    public void processEntity (Entity entity, float deltaTime) {
        System.out.println("Process moveSystem");
        PositionComponent position = pm.get(entity);
        MovementComponent movement = mm.get(entity);

        position.x += movement.velocityX * deltaTime;
        position.y += movement.velocityY * deltaTime;
    }

    @Override
    public void update(float deltaTime) {
        Engine engine = getEngine();

        int count = engine.getEntitiesFor(Family.all(PositionComponent.class, MovementComponent.class).get()).size();
    }
}

Afaik,对于更新方法中的每个计数,每次更新引擎时都应该 运行 ProcessEntity。由于更新被调用,引擎被更新,并且由于 count > 0 它应该处理实体,但它从未被调用。通过在 运行 时间内检查引擎,它还包含我定义的系列的多个实体。

processEntity(...) 由我未调用的父更新方法调用。再次查看后很容易修复,我只是把它留在这里以防万一。

@Override
public void update(float deltaTime) {
    super.update(deltaTime); // <-- call parent update
}