Search in sources :

Example 1 with EntityIndex

use of com.ilargia.games.entitas.index.EntityIndex in project Entitas-Java by Rubentxu.

the class EntityIndexExtension method addEntityIndices.

public static void addEntityIndices(Entitas contexts) {
    EntityIndex<GameEntity, Integer> positionIndex = new EntityIndex(contexts.game.getGroup(GameMatcher.Position()), (e, c) -> {
        Position positionComponent = (Position) c;
        return positionComponent != null ? (positionComponent.x << shiftX) + positionComponent.y : (((GameEntity) e).getPosition().x << shiftX) + ((GameEntity) e).getPosition().y;
    });
    contexts.game.addEntityIndex(PositionKey, positionIndex);
}
Also used : GameEntity(com.ilargia.games.logicbrick.gen.game.GameEntity) Position(com.ilargia.games.logicbrick.component.game.Position) EntityIndex(com.ilargia.games.entitas.index.EntityIndex)

Aggregations

EntityIndex (com.ilargia.games.entitas.index.EntityIndex)1 Position (com.ilargia.games.logicbrick.component.game.Position)1 GameEntity (com.ilargia.games.logicbrick.gen.game.GameEntity)1