From 9b06b294f48023653f9fd0fa9b82ffdacdb15622 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Sat, 28 Dec 2019 23:35:29 +0400 Subject: [PATCH] Removed ghost == null checks that are no longer necessary --- core/src/com/me/pacman/state/PlayState.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/core/src/com/me/pacman/state/PlayState.java b/core/src/com/me/pacman/state/PlayState.java index 957d5bd..6af6dad 100644 --- a/core/src/com/me/pacman/state/PlayState.java +++ b/core/src/com/me/pacman/state/PlayState.java @@ -106,7 +106,7 @@ public class PlayState extends LevelState { if (pacman.alive && newGameTimer <= 0) { for (Ghost ghost : ghosts) { - if (ghost == null || (pointsTimer > 0 && ghost == lastGhostCaptured)) { + if (pointsTimer > 0 && ghost == lastGhostCaptured) { continue; } ghost.render(game.batch, 0, 16); @@ -174,7 +174,7 @@ public class PlayState extends LevelState { frightTimer -= dt; if (frightTimer <= 0) { for (Ghost ghost : ghosts) { - if (ghost == null || ghost.currentBehaviour instanceof ReturnToBase) continue; + if (ghost.currentBehaviour instanceof ReturnToBase) continue; ghost.caught = false; ghost.currentBehaviour = ghost.chaseBehaviour; ghost.speed = Ghost.GHOST_SPEED; @@ -216,9 +216,6 @@ public class PlayState extends LevelState { if (!pacmanCaught) { for (Ghost ghost : ghosts) { - if (ghost == null) { - continue; - } ghost.update(dt); if (ghost.onSameTile(pacman)) { @@ -377,7 +374,7 @@ public class PlayState extends LevelState { public void eatPowerPellet(float x, float y) { pelletEaten(x, y); for (Ghost ghost : ghosts) { - if (ghost == null || ghost.currentBehaviour instanceof ReturnToBase) continue; + if (ghost.currentBehaviour instanceof ReturnToBase) continue; ghost.caught = false; ghost.currentBehaviour = ghost.frightBehaviour; ghost.currDirection = ghost.currDirection.getOpposite();