package me.hammerle.supersnuvi.tiles; import me.hammerle.supersnuvi.entity.Entity; import me.hammerle.supersnuvi.entity.EntityBuilder; import me.hammerle.supersnuvi.util.BlockDataStorage; import me.hammerle.supersnuvi.util.Face; import me.hammerle.supersnuvi.util.SoundUtils; import me.hammerle.supersnuvi.util.Utils; import me.hammerle.supersnuvi.gamelogic.Level; public class CrumblingStoneTile extends BaseMoveCollisionTile { private final BlockDataStorage states = new BlockDataStorage(); public CrumblingStoneTile() { super(0.1875f, 0.125f, 0.25f, 0.1875f, 0.0f, 0.0f, Tile.SIZE, Tile.SIZE * 0.6f); } @Override public boolean isColliding(float minX, float minY, float maxX, float maxY, int x, int y, Level l) { return !states.contains(x, y, l) && super.isColliding(minX, minY, maxX, maxY, x, y, l); } @Override public boolean isMoveColliding(float minX, float minY, float maxX, float maxY, int x, int y, Level l) { return !states.contains(x, y, l) && super.isMoveColliding(minX, minY, maxX, maxY, x, y, l); } @Override public void onEntityCollide(Entity ent, int x, int y, Face face, Level l) { if(face == Face.UP && !ent.getMovement().canMoveOnTiles() && states.add(x, y, l)) { l.getTileUpdater().add(l.getData().getBackgroundIndex(), x, y); l.spawnEntity(EntityBuilder.buildCrumblingStone(l, Utils.toCoord(x), Utils.toCoord(y))); SoundUtils.playSound(SoundUtils.Sound.STONE_CRUMBLING); } } @Override public boolean shouldRender(int x, int y, Level l) { return !states.contains(x, y, l); } @Override public void reset(Level l) { states.clear(l); } @Override public void reset(int x, int y, Level l) { states.clear(x, y, l); } }