X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=core%2Fsrc%2Fru%2Fdeadsoftware%2Fcavedroid%2Fgame%2FGameItems.java;h=f210baabf9abcb5658882331a00ea8842e6727bf;hb=f4d52e3e4a3712050532786fca0aded5ff8b5a03;hp=625938fd5fb76c07ce2cd1c56b24deca3cbe640c;hpb=59d48c1b28c570755327a8fb0827fa57e7fd3914;p=cavedroid.git diff --git a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java index 625938f..f210baa 100644 --- a/core/src/ru/deadsoftware/cavedroid/game/GameItems.java +++ b/core/src/ru/deadsoftware/cavedroid/game/GameItems.java @@ -19,82 +19,78 @@ public class GameItems { private static final ArrayMap blocks = new ArrayMap<>(); private static final ArrayMap items = new ArrayMap<>(); - static boolean isFluid(int id) { + public static boolean isFluid(int id) { return getBlock(id).isFluid(); } - static boolean isWater(int id) { + public static boolean isWater(int id) { return getBlock(id).getMeta().equals("water"); } - static boolean isLava(int id) { + public static boolean isLava(int id) { return getBlock(id).getMeta().equals("lava"); } - static boolean isSlab(int id) { + public static boolean isSlab(int id) { return getBlock(id).getMeta().equals("slab"); } - static boolean fluidCanFlowThere(int thisId, int thatId) { + public static boolean fluidCanFlowThere(int thisId, int thatId) { return thatId == 0 || (!getBlock(thatId).hasCollision() && !isFluid(thatId)) || (isWater(thisId) && isWater(thatId) && thisId < thatId) || (isLava(thisId) && isLava(thatId) && thisId < thatId); } - static Block getBlock(int id) { + public static Block getBlock(int id) { return blocks.getValueAt(id); } - static Item getItem(int id) { + public static Item getItem(int id) { return items.getValueAt(id); } - static Block getBlock(String key) { + public static Block getBlock(String key) { return blocks.getValueAt(blocksIds.get(key)); } - static Item getItem(String key) { + public static Item getItem(String key) { return items.getValueAt(itemsIds.get(key)); } - static int getBlockId(String key) { + public static int getBlockId(String key) { return blocksIds.get(key); } - static int getItemId(String key) { + public static int getItemId(String key) { return itemsIds.get(key); } - static String getBlockKey(int id) { + public static String getBlockKey(int id) { return blocks.getKeyAt(id); } - static String getItemKey(int id) { + public static String getItemKey(int id) { return items.getKeyAt(id); } - static int getBlockIdByItemId(int id) { + public static int getBlockIdByItemId(int id) { return getBlockId(items.getKeyAt(id)); } - static int getBlocksSize() { + public static int getBlocksSize() { return blocks.size; } - static int getItemsSize() { + public static int getItemsSize() { return items.size; } - static Sprite getBlockTex(int id) { - return getBlock(id).getTex(); + public static Sprite getBlockTex(int id) { + return getBlock(id).getTexture(); } - static Sprite getItemTex(int id) { - if (items.getValueAt(id).getType().equals("block")) { - return getBlockTex(id); - } else { - return getItem(id).getTex(); - } + public static Sprite getItemTex(int id) { + return items.getValueAt(id).getType().equals("block") ? getBlockTex(id) : getItem(id).getTexture(); } public static void load() {