From 88ce7837a6b70f326a507213cb284db0c7d55432 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 2 May 2019 08:56:29 -0400 Subject: [PATCH] Partial power usage / Drill ID priority / Liquid source deselect --- core/assets/bundles/bundle.properties | 2 +- core/src/io/anuke/mindustry/game/Version.java | 4 +++ .../io/anuke/mindustry/io/BundleLoader.java | 1 - core/src/io/anuke/mindustry/type/Item.java | 2 +- .../world/blocks/production/Drill.java | 2 -- .../world/blocks/sandbox/LiquidSource.java | 33 ++++++++++++------- .../world/consumers/ConsumePower.java | 2 +- .../mindustry/world/modules/LiquidModule.java | 6 ++++ 8 files changed, 34 insertions(+), 18 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 7feea8a29a..9ea86a2efc 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -1,7 +1,7 @@ credits.text = Created by [ROYAL]Anuken[] - [SKY]anukendev@gmail.com[] credits = Credits contributors = Translators and Contributors -discord = Join the mindustry discord! +discord = Join the Mindustry discord! link.discord.description = The official Mindustry discord chatroom link.github.description = Game source code link.dev-builds.description = Unstable development builds diff --git a/core/src/io/anuke/mindustry/game/Version.java b/core/src/io/anuke/mindustry/game/Version.java index 5349306321..77a14dac1a 100644 --- a/core/src/io/anuke/mindustry/game/Version.java +++ b/core/src/io/anuke/mindustry/game/Version.java @@ -19,8 +19,12 @@ public class Version{ public static int build = 0; /** Revision number. Used for hotfixes. Does not affect server compatibility. */ public static int revision = 0; + /** Whether version loading is enabled. */ + public static boolean enabled = true; public static void init(){ + if(!enabled) return; + try{ FileHandle file = Core.files.internal("version.properties"); diff --git a/core/src/io/anuke/mindustry/io/BundleLoader.java b/core/src/io/anuke/mindustry/io/BundleLoader.java index 14cb5e3e67..84f4f78965 100644 --- a/core/src/io/anuke/mindustry/io/BundleLoader.java +++ b/core/src/io/anuke/mindustry/io/BundleLoader.java @@ -57,7 +57,6 @@ public class BundleLoader{ Locale locale = getLocale(); Locale.setDefault(locale); - if(!headless) Log.info("Got locale: {0}", locale); Core.bundle = I18NBundle.createBundle(handle, locale); } diff --git a/core/src/io/anuke/mindustry/type/Item.java b/core/src/io/anuke/mindustry/type/Item.java index 9c03431759..2993908713 100644 --- a/core/src/io/anuke/mindustry/type/Item.java +++ b/core/src/io/anuke/mindustry/type/Item.java @@ -30,7 +30,7 @@ public class Item extends UnlockableContent implements Comparable{ * base material cost of this item, used for calculating place times * 1 cost = 1 tick added to build time */ - public float cost = 3f; + public float cost = 1f; /** If true, item is always unlocked. */ public boolean alwaysUnlocked = false; diff --git a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java index c34163b3b2..93d9857012 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/Drill.java @@ -180,8 +180,6 @@ public class Drill extends Block{ itemArray.sort((item1, item2) -> { int type = Boolean.compare(item1.type == ItemType.material, item2.type == ItemType.material); 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); }); diff --git a/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java b/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java index 7640d99945..35723aa00d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java +++ b/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java @@ -51,8 +51,12 @@ public class LiquidSource extends Block{ public void update(Tile tile){ LiquidSourceEntity entity = tile.entity(); - tile.entity.liquids.add(entity.source, liquidCapacity); - tryDumpLiquid(tile, entity.source); + if(entity.source == null){ + tile.entity.liquids.clear(); + }else{ + tile.entity.liquids.add(entity.source, liquidCapacity); + tryDumpLiquid(tile, entity.source); + } } @Override @@ -61,9 +65,11 @@ public class LiquidSource extends Block{ LiquidSourceEntity entity = tile.entity(); - Draw.color(entity.source.color); - Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f); - Draw.color(); + if(entity.source != null){ + Draw.color(entity.source.color); + Draw.rect("blank", tile.worldx(), tile.worldy(), 4f, 4f); + Draw.color(); + } } @Override @@ -73,17 +79,19 @@ public class LiquidSource extends Block{ Array items = content.liquids(); ButtonGroup group = new ButtonGroup<>(); + group.setMinCheckCount(0); Table cont = new Table(); for(int i = 0; i < items.size; i++){ final int f = i; - ImageButton button = cont.addImageButton("clear", "clear-toggle", 24, () -> { - Call.setLiquidSourceLiquid(null, tile, items.get(f)); + ImageButton button = cont.addImageButton("clear", "clear-toggle", 24, () -> control.input().frag.config.hideConfig()).size(38).group(group).get(); + button.changed(() -> { + Call.setLiquidSourceLiquid(null, tile, button.isChecked() ? items.get(f) : null); control.input().frag.config.hideConfig(); lastLiquid = items.get(f); - }).size(38).group(group).get(); + }); 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){ cont.row(); @@ -105,16 +113,17 @@ public class LiquidSource extends Block{ } class LiquidSourceEntity extends TileEntity{ - public Liquid source = Liquids.water; + public Liquid source = null; @Override public void writeConfig(DataOutput stream) throws IOException{ - stream.writeByte(source.id); + stream.writeByte(source == null ? -1 : source.id); } @Override public void readConfig(DataInput stream) throws IOException{ - source = content.liquid(stream.readByte()); + byte id = stream.readByte(); + source = id == -1 ? null : content.liquid(id); } } } diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java b/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java index 6aaf0da2a9..b5b1cf563f 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumePower.java @@ -47,7 +47,7 @@ public class ConsumePower extends Consume{ if(isBuffered){ return true; }else{ - return entity.power.satisfaction >= 0.9999f; + return entity.power.satisfaction > 0f; } } diff --git a/core/src/io/anuke/mindustry/world/modules/LiquidModule.java b/core/src/io/anuke/mindustry/world/modules/LiquidModule.java index 33b02b85a7..3eb50fc8e4 100644 --- a/core/src/io/anuke/mindustry/world/modules/LiquidModule.java +++ b/core/src/io/anuke/mindustry/world/modules/LiquidModule.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.world.modules; import io.anuke.mindustry.type.Liquid; import java.io.*; +import java.util.Arrays; import static io.anuke.mindustry.Vars.content; @@ -38,6 +39,11 @@ public class LiquidModule extends BlockModule{ return liquids[liquid.id]; } + public void clear(){ + total = 0; + Arrays.fill(liquids, 0); + } + public void add(Liquid liquid, float amount){ liquids[liquid.id] += amount; total += amount;