diff --git a/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java b/core/src/ru/deadsoftware/cavedroid/game/mobs/FallingSand.java
index 7186b3a1ff13ee0af1375eb65fd6b2aba9cc202d..bce918e34fb811024815022970dd00ffa834e316 100644 (file)
package ru.deadsoftware.cavedroid.game.mobs;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
-import ru.deadsoftware.cavedroid.game.GameItems;
+import ru.deadsoftware.cavedroid.game.GameItemsHolder;
import ru.deadsoftware.cavedroid.game.world.GameWorld;
+import ru.deadsoftware.cavedroid.misc.Assets;
+
+import javax.annotation.CheckForNull;
/**
*/
public class FallingSand extends Mob {
+ private static final String TAG = "FallingSand";
+
/**
* Creates a FallingSand mob at coordinates
*
}
@Override
- public void ai(GameWorld gameWorld, float delta) {
+ public void ai(GameWorld gameWorld, GameItemsHolder gameItemsHolder, float delta) {
if (mVelocity.isZero()) {
- gameWorld.setForeMap(getMapX(), getMiddleMapY(), 10);
+ gameWorld.setForeMap(getMapX(), getMiddleMapY(), gameItemsHolder.getBlock("sand"));
kill();
}
}
@Override
public void draw(SpriteBatch spriteBatch, float x, float y, float delta) {
- spriteBatch.draw(GameItems.getBlockTex(10), x, y);
+ @CheckForNull final Texture texture = Assets.blockTextures.get("sand");
+
+ if (texture == null) {
+ Gdx.app.error(TAG, "Couldn't draw: texture not found");
+ kill();
+ return;
+ }
+
+ spriteBatch.draw(texture, x, y);
}
}