Skip to content

Commit

Permalink
Dungeon: avoid building the same stream more than once (refactoring, …
Browse files Browse the repository at this point in the history
…CameraComponent)

see #1564 (comment)
  • Loading branch information
cagix committed Jul 1, 2024
1 parent 2e694e3 commit 3cd54b8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions game/src/core/systems/CameraSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ public static OrthographicCamera camera() {

@Override
public void execute() {
if (filteredEntityStream(CameraComponent.class, PositionComponent.class).findAny().isEmpty())
focus();
else filteredEntityStream().forEach(this::focus);
filteredEntityStream(CameraComponent.class, PositionComponent.class)
.findAny()
.ifPresentOrElse(this::focus, this::focus);

// Check if Gdx.graphics is null which happens when the game is run in headless mode (e.g.
// in tests)
if (Gdx.graphics != null) {
Expand Down

0 comments on commit 3cd54b8

Please sign in to comment.