use of com.ilargia.games.logicbrick.gen.game.GameEntity 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);
}
use of com.ilargia.games.logicbrick.gen.game.GameEntity in project Entitas-Java by Rubentxu.
the class AnimatePositionSystem method execute.
@Override
public void execute(List<GameEntity> entities) {
for (GameEntity e : entities) {
Position pos = e.getPosition();
//e.getTextureView().body.setTransform(new Vector2(0, -12), new Vector2(pos.x, pos.y - 1), true);
moveFocused(new Vector2(pos.x, pos.y - 1), e.getTextureView().body);
}
}
use of com.ilargia.games.logicbrick.gen.game.GameEntity in project Entitas-Java by Rubentxu.
the class ProcessInputSystem method execute.
@Override
protected void execute(List<InputEntity> entities) {
InputEntity inputEntity = entities.get(0);
Input input = inputEntity.getInput();
Set<GameEntity> interactives = EntityIndexExtension.getEntitiesWithPosition(entitas.game, input.x, input.y).stream().filter(e -> e.isInteractive()).collect(Collectors.toSet());
for (GameEntity e : interactives) {
e.setDestroy(true);
}
}
use of com.ilargia.games.logicbrick.gen.game.GameEntity in project Entitas-Java by Rubentxu.
the class RemoveViewSystem method execute.
@Override
protected void execute(List<GameEntity> entities) {
for (GameEntity e : entities) {
destroyView(e.getTextureView());
e.removeTextureView();
}
}
use of com.ilargia.games.logicbrick.gen.game.GameEntity in project Entitas-Java by Rubentxu.
the class AddViewSystem method execute.
@Override
public void execute(List<GameEntity> entities) {
for (GameEntity e : entities) {
Texture texture = assetsManager.getTexture(String.format("assets/textures/%1$s.png", e.getAsset().name));
Body body = bodyBuilder.fixture(new FixtureDefBuilder().boxShape(0.5f, 0.5f)).type(BodyDef.BodyType.KinematicBody).build();
TextureRegion textureRegion = new TextureRegion(texture, 0, 0, texture.getWidth(), texture.getHeight());
e.addTextureView(e.getAsset().name, textureRegion, body);
//
if (e.hasPosition()) {
Position pos = e.getPosition();
body.setTransform(new Vector2(pos.x, pos.y + 1), 0);
}
}
}
Aggregations