X-Git-Url: https://deadsoftware.ru/gitweb?a=blobdiff_plain;ds=sidebyside;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2Fworld%2FGameWorld.java;h=32fef769bed2b89c4e1d71e55d68c2eb37cd04eb;hb=8b34480aaaf0112671d319accff573030079c7b6;hp=91793c845a23406745876c1fc0cad8ffb013a615;hpb=6da6f8b40b6945e0b4e8376f506c43e548918df4;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorld.java b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorld.java index 91793c8..32fef76 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/world/GameWorld.java +++ b/core/src/ru/deadsoftware/cavedroid/game/world/GameWorld.java @@ -114,6 +114,15 @@ public class GameWorld { } } + private boolean isSameSlab(Block slab1, Block slab2) { + if (!(slab1 instanceof Block.Slab) || !(slab2 instanceof Block.Slab)) { + return false; + } + + return slab1.getParams().getKey().equals(((Block.Slab) slab2).getOtherPartBlockKey()) + || slab1.getParams().getKey().equals(slab2.getParams().getKey()); + } + public boolean hasForeAt(int x, int y) { return getMap(x, y, 0) != mGameItemsHolder.getFallbackBlock(); } @@ -145,7 +154,7 @@ public class GameWorld { public void placeToForeground(int x, int y, Block value) { if (!hasForeAt(x, y) || value == mGameItemsHolder.getFallbackBlock() || !getForeMap(x, y).hasCollision()) { setForeMap(x, y, value); - } else if (value instanceof Block.Slab && getForeMap(x, y) == value) { + } else if (value instanceof Block.Slab && isSameSlab(value, getForeMap(x, y))) { setForeMap(x, y, mGameItemsHolder.getBlock(((Block.Slab) value).getFullBlockKey())); } }