Removed liquid storage

This commit is contained in:
Anuken
2018-04-14 21:13:10 -04:00
parent b715e0d34e
commit 458d4378f0
5 changed files with 18 additions and 37 deletions

View File

@@ -1,7 +1,7 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Sat Apr 14 20:37:32 EDT 2018 #Sat Apr 14 21:02:06 EDT 2018
version=release version=release
androidBuildCode=920 androidBuildCode=922
name=Mindustry name=Mindustry
code=3.5 code=3.5
build=custom build build=custom build

View File

@@ -4,7 +4,7 @@ import io.anuke.mindustry.resource.*;
public class UnitInventory { public class UnitInventory {
private final AmmoEntry ammo = new AmmoEntry(AmmoType.getByID(0), 0); private final AmmoEntry ammo = new AmmoEntry(AmmoType.getByID(0), 0);
private CarryItem item; private ItemStack item;
private int capacity; private int capacity;
public UnitInventory(int capacity) { public UnitInventory(int capacity) {
@@ -15,32 +15,28 @@ public class UnitInventory {
return capacity; return capacity;
} }
public boolean isEmpty(){
return item == null;
}
public int itemCapacityUsed(Item type){ public int itemCapacityUsed(Item type){
if(canAcceptItem(type)){ if(canAcceptItem(type)){
return !hasItem() ? capacity : (capacity - getItem().amount); return !hasItem() ? capacity : (capacity - item.amount);
}else{ }else{
return capacity; return capacity;
} }
} }
public boolean canAcceptItem(Item type){ public boolean canAcceptItem(Item type){
return !hasItem() || (getItem().item == type && capacity - getItem().amount > 0); return !hasItem() || (item.item == type && capacity - item.amount > 0);
} }
public void clear(){ public void clear(){
item = null; item = null;
} }
public boolean hasAnything(){
return item != null;
}
public boolean hasLiquid(){
return item instanceof LiquidStack;
}
public boolean hasItem(){ public boolean hasItem(){
return item instanceof ItemStack; return item != null;
} }
public void addItem(Item item, int amount){ public void addItem(Item item, int amount){
@@ -52,22 +48,9 @@ public class UnitInventory {
} }
} }
public void addLiquid(Liquid liquid, float amount){
if(hasItem()){
getLiquid().liquid = liquid;
getLiquid().amount = amount;
}else{
this.item = new LiquidStack(liquid, amount);
}
}
public ItemStack getItem(){ public ItemStack getItem(){
if(!hasItem()) throw new RuntimeException("This inventory has no item! Check hasItem() first."); if(!hasItem()) throw new RuntimeException("This inventory has no item! Check hasItem() first.");
return (ItemStack)item; return item;
}
public LiquidStack getLiquid(){
if(!hasItem()) throw new RuntimeException("This inventory has no item! Check hasItem() first.");
return (LiquidStack)item;
} }
} }

View File

@@ -47,7 +47,7 @@ public class DesktopInput extends InputHandler{
boolean canBeginShoot = Inputs.keyTap("select") && canShoot(); boolean canBeginShoot = Inputs.keyTap("select") && canShoot();
if(Inputs.keyTap("select") && recipe == null && player.inventory.hasAnything()){ if(Inputs.keyTap("select") && recipe == null && player.inventory.hasItem()){
Vector2 vec = Graphics.screen(player.x, player.y); Vector2 vec = Graphics.screen(player.x, player.y);
if(vec.dst(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY()) <= playerSelectRange){ if(vec.dst(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY()) <= playerSelectRange){
canBeginShoot = false; canBeginShoot = false;
@@ -112,11 +112,11 @@ public class DesktopInput extends InputHandler{
Tile target = cursor == null ? null : cursor.target(); Tile target = cursor == null ? null : cursor.target();
boolean showCursor = false; boolean showCursor = false;
if(droppingItem && Inputs.keyRelease("select") && player.inventory.hasAnything() && target != null){ if(droppingItem && Inputs.keyRelease("select") && !player.inventory.isEmpty() && target != null){
dropItem(target, player.inventory.getItem()); dropItem(target, player.inventory.getItem());
} }
if(droppingItem && (!Inputs.keyDown("select") || !player.inventory.hasAnything())){ if(droppingItem && (!Inputs.keyDown("select") || player.inventory.isEmpty())){
droppingItem = false; droppingItem = false;
} }

View File

@@ -1,13 +1,11 @@
package io.anuke.mindustry.ui.fragments; package io.anuke.mindustry.ui.fragments;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.IntSet; import com.badlogic.gdx.utils.IntSet;
import io.anuke.mindustry.content.Liquids;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.resource.Item; import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.ui.ItemImage; import io.anuke.mindustry.ui.ItemImage;
@@ -18,7 +16,6 @@ import io.anuke.ucore.core.Inputs;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.function.BooleanProvider; import io.anuke.ucore.function.BooleanProvider;
import io.anuke.ucore.function.Callable; import io.anuke.ucore.function.Callable;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.actions.Actions; import io.anuke.ucore.scene.actions.Actions;
import io.anuke.ucore.scene.event.HandCursorListener; import io.anuke.ucore.scene.event.HandCursorListener;
import io.anuke.ucore.scene.event.Touchable; import io.anuke.ucore.scene.event.Touchable;
@@ -82,6 +79,7 @@ public class BlockInventoryFragment implements Fragment {
table.margin(3f); table.margin(3f);
table.defaults().size(16 * 2).space(6f); table.defaults().size(16 * 2).space(6f);
/*
if(tile.block().hasPower){ if(tile.block().hasPower){
table.add(new ItemImage(Draw.region("icon-power"), () -> round(tile.entity.power.amount), Colors.get("power"))); table.add(new ItemImage(Draw.region("icon-power"), () -> round(tile.entity.power.amount), Colors.get("power")));
@@ -101,13 +99,13 @@ public class BlockInventoryFragment implements Fragment {
int amount = Inputs.keyDown("item_withdraw") ? items[f] : 1; int amount = Inputs.keyDown("item_withdraw") ? items[f] : 1;
items[f] -= amount; items[f] -= amount;
move(item.region, image, () -> player.inventory.addItem(item, amount), Color.WHITE);*/ move(item.region, image, () -> player.inventory.addItem(item, amount), Color.WHITE);
} }
}); });
table.add(image); table.add(image);
if (row++ % cols == cols - 1) table.row(); if (row++ % cols == cols - 1) table.row();
} }*/
if(tile.block().hasInventory) { if(tile.block().hasInventory) {
int[] items = tile.entity.inventory.items; int[] items = tile.entity.inventory.items;

View File

@@ -194,7 +194,7 @@ public class Block extends BaseBlock {
public void update(Tile tile){} public void update(Tile tile){}
public boolean isAccessible(){ public boolean isAccessible(){
return (hasInventory && itemCapacity > 0) || hasLiquids || hasPower; return (hasInventory && itemCapacity > 0);
} }
public void onDestroyed(Tile tile){ public void onDestroyed(Tile tile){