Merge remote-tracking branch 'origin/master'

# Conflicts:
#	core/src/io/anuke/mindustry/game/Version.java
This commit is contained in:
Anuken
2019-05-02 12:59:05 -04:00
7 changed files with 30 additions and 18 deletions

View File

@@ -19,7 +19,7 @@ public class Version{
public static int build = 0; public static int build = 0;
/** Revision number. Used for hotfixes. Does not affect server compatibility. */ /** Revision number. Used for hotfixes. Does not affect server compatibility. */
public static int revision = 0; public static int revision = 0;
/** Whether to load version info at all.*/ /** Whether version loading is enabled. */
public static boolean enabled = true; public static boolean enabled = true;
public static void init(){ public static void init(){

View File

@@ -57,7 +57,6 @@ public class BundleLoader{
Locale locale = getLocale(); Locale locale = getLocale();
Locale.setDefault(locale); Locale.setDefault(locale);
if(!headless) Log.info("Got locale: {0}", locale);
Core.bundle = I18NBundle.createBundle(handle, locale); Core.bundle = I18NBundle.createBundle(handle, locale);
} }
} }

View File

@@ -30,7 +30,7 @@ public class Item extends UnlockableContent implements Comparable<Item>{
* base material cost of this item, used for calculating place times * base material cost of this item, used for calculating place times
* 1 cost = 1 tick added to build time * 1 cost = 1 tick added to build time
*/ */
public float cost = 3f; public float cost = 1f;
/** If true, item is always unlocked. */ /** If true, item is always unlocked. */
public boolean alwaysUnlocked = false; public boolean alwaysUnlocked = false;

View File

@@ -180,8 +180,6 @@ public class Drill extends Block{
itemArray.sort((item1, item2) -> { itemArray.sort((item1, item2) -> {
int type = Boolean.compare(item1.type == ItemType.material, item2.type == ItemType.material); int type = Boolean.compare(item1.type == ItemType.material, item2.type == ItemType.material);
if(type != 0) return type; if(type != 0) return type;
int count = Integer.compare(oreCount.get(item1, 0), oreCount.get(item2, 0));
if(count != 0) return count;
return Integer.compare(item1.id, item2.id); return Integer.compare(item1.id, item2.id);
}); });

View File

@@ -51,8 +51,12 @@ public class LiquidSource extends Block{
public void update(Tile tile){ public void update(Tile tile){
LiquidSourceEntity entity = tile.entity(); LiquidSourceEntity entity = tile.entity();
tile.entity.liquids.add(entity.source, liquidCapacity); if(entity.source == null){
tryDumpLiquid(tile, entity.source); tile.entity.liquids.clear();
}else{
tile.entity.liquids.add(entity.source, liquidCapacity);
tryDumpLiquid(tile, entity.source);
}
} }
@Override @Override
@@ -61,9 +65,11 @@ public class LiquidSource extends Block{
LiquidSourceEntity entity = tile.entity(); LiquidSourceEntity entity = tile.entity();
Draw.color(entity.source.color); if(entity.source != null){
Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f); Draw.color(entity.source.color);
Draw.color(); Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f);
Draw.color();
}
} }
@Override @Override
@@ -73,17 +79,19 @@ public class LiquidSource extends Block{
Array<Liquid> items = content.liquids(); Array<Liquid> items = content.liquids();
ButtonGroup<ImageButton> group = new ButtonGroup<>(); ButtonGroup<ImageButton> group = new ButtonGroup<>();
group.setMinCheckCount(0);
Table cont = new Table(); Table cont = new Table();
for(int i = 0; i < items.size; i++){ for(int i = 0; i < items.size; i++){
final int f = i; final int f = i;
ImageButton button = cont.addImageButton("clear", "clear-toggle", 24, () -> { ImageButton button = cont.addImageButton("clear", "clear-toggle", 24, () -> control.input().frag.config.hideConfig()).size(38).group(group).get();
Call.setLiquidSourceLiquid(null, tile, items.get(f)); button.changed(() -> {
Call.setLiquidSourceLiquid(null, tile, button.isChecked() ? items.get(f) : null);
control.input().frag.config.hideConfig(); control.input().frag.config.hideConfig();
lastLiquid = items.get(f); lastLiquid = items.get(f);
}).size(38).group(group).get(); });
button.getStyle().imageUp = new TextureRegionDrawable(items.get(i).iconRegion); button.getStyle().imageUp = new TextureRegionDrawable(items.get(i).iconRegion);
button.setChecked(entity.source.id == f); button.setChecked(entity.source == items.get(i));
if(i % 4 == 3){ if(i % 4 == 3){
cont.row(); cont.row();
@@ -105,16 +113,17 @@ public class LiquidSource extends Block{
} }
class LiquidSourceEntity extends TileEntity{ class LiquidSourceEntity extends TileEntity{
public Liquid source = Liquids.water; public Liquid source = null;
@Override @Override
public void writeConfig(DataOutput stream) throws IOException{ public void writeConfig(DataOutput stream) throws IOException{
stream.writeByte(source.id); stream.writeByte(source == null ? -1 : source.id);
} }
@Override @Override
public void readConfig(DataInput stream) throws IOException{ public void readConfig(DataInput stream) throws IOException{
source = content.liquid(stream.readByte()); byte id = stream.readByte();
source = id == -1 ? null : content.liquid(id);
} }
} }
} }

View File

@@ -47,7 +47,7 @@ public class ConsumePower extends Consume{
if(isBuffered){ if(isBuffered){
return true; return true;
}else{ }else{
return entity.power.satisfaction >= 0.9999f; return entity.power.satisfaction > 0f;
} }
} }

View File

@@ -3,6 +3,7 @@ package io.anuke.mindustry.world.modules;
import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.type.Liquid;
import java.io.*; import java.io.*;
import java.util.Arrays;
import static io.anuke.mindustry.Vars.content; import static io.anuke.mindustry.Vars.content;
@@ -38,6 +39,11 @@ public class LiquidModule extends BlockModule{
return liquids[liquid.id]; return liquids[liquid.id];
} }
public void clear(){
total = 0;
Arrays.fill(liquids, 0);
}
public void add(Liquid liquid, float amount){ public void add(Liquid liquid, float amount){
liquids[liquid.id] += amount; liquids[liquid.id] += amount;
total += amount; total += amount;