diff --git a/.travis.yml b/.travis.yml index 06a66fa107..5e781b0f7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,13 +5,13 @@ jdk: android: components: - - android-26 + - android-27 # Additional components - extra-google-google_play_services - extra-google-m2repository - extra-android-m2repository - - addon-google_apis-google-26 + - addon-google_apis-google-27 script: - ./gradlew desktop:dist diff --git a/core/src/io/anuke/mindustry/content/Liquids.java b/core/src/io/anuke/mindustry/content/Liquids.java index 86adf3cf85..b29705bb32 100644 --- a/core/src/io/anuke/mindustry/content/Liquids.java +++ b/core/src/io/anuke/mindustry/content/Liquids.java @@ -41,8 +41,8 @@ public class Liquids implements ContentList { cryofluid = new Liquid("cryofluid", Color.SKY) { { - heatCapacity = 0.75f; - temperature = 0.4f; + heatCapacity = 0.9f; + temperature = 0.25f; tier = 1; effect = StatusEffects.freezing; } diff --git a/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java b/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java index ac9ce03f19..dd97e4a8b9 100644 --- a/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/CraftingBlocks.java @@ -121,7 +121,7 @@ public class CraftingBlocks extends BlockList implements ContentList { consumes.power(0.1f); consumes.item(Items.titanium); - consumes.liquid(Liquids.water, 0.2f); + consumes.liquid(Liquids.water, 0.3f); }}; blastMixer = new GenericCrafter("blast-mixer") {{ diff --git a/core/src/io/anuke/mindustry/content/blocks/LiquidBlocks.java b/core/src/io/anuke/mindustry/content/blocks/LiquidBlocks.java index c6330d2e09..621fca803a 100644 --- a/core/src/io/anuke/mindustry/content/blocks/LiquidBlocks.java +++ b/core/src/io/anuke/mindustry/content/blocks/LiquidBlocks.java @@ -22,6 +22,7 @@ public class LiquidBlocks extends BlockList implements ContentList{ pumpAmount = 0.25f; consumes.power(0.015f); liquidCapacity = 30f; + hasPower = true; size = 2; tier = 1; }}; diff --git a/core/src/io/anuke/mindustry/type/Liquid.java b/core/src/io/anuke/mindustry/type/Liquid.java index 85c65198aa..4672c529d4 100644 --- a/core/src/io/anuke/mindustry/type/Liquid.java +++ b/core/src/io/anuke/mindustry/type/Liquid.java @@ -10,9 +10,10 @@ import io.anuke.mindustry.ui.ContentDisplay; import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.util.Bundles; +import io.anuke.ucore.util.ThreadArray; public class Liquid implements UnlockableContent{ - private static final Array liquids = new Array<>(); + private static final Array liquids = new ThreadArray<>(); public final Color color; public final String name; diff --git a/core/src/io/anuke/mindustry/world/BaseBlock.java b/core/src/io/anuke/mindustry/world/BaseBlock.java index 68dbda64a5..875de327d1 100644 --- a/core/src/io/anuke/mindustry/world/BaseBlock.java +++ b/core/src/io/anuke/mindustry/world/BaseBlock.java @@ -20,6 +20,7 @@ public abstract class BaseBlock { public boolean hasLiquids; public boolean hasPower; + public boolean outputsLiquid = false; public boolean singleLiquid = true; public int itemCapacity; diff --git a/core/src/io/anuke/mindustry/world/blocks/LiquidBlock.java b/core/src/io/anuke/mindustry/world/blocks/LiquidBlock.java index 9feefc53b8..11b98f66b3 100644 --- a/core/src/io/anuke/mindustry/world/blocks/LiquidBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/LiquidBlock.java @@ -16,6 +16,7 @@ public class LiquidBlock extends Block{ solid = true; hasLiquids = true; group = BlockGroup.liquids; + outputsLiquid = true; } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java index 7aa7c3eac9..99b8fbfafc 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java @@ -40,14 +40,14 @@ public class Conduit extends LiquidBlock { ConduitEntity entity = tile.entity(); entity.blendbits = 0; - if(blends(tile, 1) && blends(tile, 2)) { + if(blends(tile, 2) && blends(tile, 1) && blends(tile, 3)) { + entity.blendbits = 3; + }else if(blends(tile, 1) && blends(tile, 2)) { entity.blendbits = 2; }else if(blends(tile, 3) && blends(tile, 2)) { entity.blendbits = 4; }else if(blends(tile, 0)){ - if(blends(tile, 2) && blends(tile, 1) && blends(tile, 3)) { - entity.blendbits = 3; - }else if(blends(tile, 1) && blends(tile, 3)) { + if(blends(tile, 1) && blends(tile, 3)) { entity.blendbits = 6; }else if(blends(tile, 1)) { entity.blendbits = 5; @@ -63,7 +63,9 @@ public class Conduit extends LiquidBlock { private boolean blends(Tile tile, int direction){ Tile other = tile.getNearby(Mathf.mod(tile.getRotation() - direction, 4)); - if(other == null || !(other.block().hasLiquids)) return false; + if(other != null) other = other.target(); + + if(other == null || !(other.block().hasLiquids) || !(other.block().outputsLiquid)) return false; return (tile.getNearby(tile.getRotation()) == other) || (!other.block().rotate || other.getNearby(other.getRotation()) == tile); } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java index a16c0b6b7f..8562b0735c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidBridge.java @@ -13,6 +13,7 @@ public class LiquidBridge extends ItemBridge { super(name); hasItems = false; hasLiquids = true; + outputsLiquid = true; } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidExtendingBridge.java b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidExtendingBridge.java index d8fc185adc..5076806347 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidExtendingBridge.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/LiquidExtendingBridge.java @@ -13,6 +13,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge { super(name); hasItems = false; hasLiquids = true; + outputsLiquid = true; } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java index e1973d64d2..872f03156e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ItemGenerator.java @@ -37,7 +37,7 @@ public abstract class ItemGenerator extends PowerGenerator { itemCapacity = 20; hasItems = true; - consumes.add(new ConsumeItemFilter(item -> getItemEfficiency(item) >= minItemEfficiency)).update(false); + consumes.add(new ConsumeItemFilter(item -> getItemEfficiency(item) >= minItemEfficiency)).update(false).optional(true); } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java b/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java index a5333f80be..9e1efada0d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ItemLiquidGenerator.java @@ -23,31 +23,39 @@ public abstract class ItemLiquidGenerator extends ItemGenerator { hasLiquids = true; liquidCapacity = 10f; - consumes.add(new ConsumeLiquidFilter(liquid -> getLiquidEfficiency(liquid) >= minLiquidEfficiency, 0.001f, true)).update(false); + consumes.add(new ConsumeLiquidFilter(liquid -> getLiquidEfficiency(liquid) >= minLiquidEfficiency, 0.001f, true)).update(false).optional(true); } @Override public void update(Tile tile){ ItemGeneratorEntity entity = tile.entity(); + Liquid liquid = null; + for (Liquid other : Liquid.all()){ + if(entity.liquids.get(other) >= 0.001f && getLiquidEfficiency(other) >= minLiquidEfficiency){ + liquid = other; + break; + } + } + //liquid takes priority over solids - if(entity.liquids.currentAmount() >= 0.001f && entity.cons.valid()){ - float powerPerLiquid = getLiquidEfficiency(entity.liquids.current())*this.powerPerLiquid; - float used = Math.min(entity.liquids.currentAmount(), maxLiquidGenerate * Timers.delta()); + if(liquid != null && entity.liquids.get(liquid) >= 0.001f && entity.cons.valid()){ + float powerPerLiquid = getLiquidEfficiency(liquid)*this.powerPerLiquid; + float used = Math.min(entity.liquids.get(liquid), maxLiquidGenerate * Timers.delta()); used = Math.min(used, (powerCapacity - entity.power.amount)/powerPerLiquid); - entity.liquids.remove(entity.liquids.current(), used); + entity.liquids.remove(liquid, used); entity.power.amount += used * powerPerLiquid; if(used > 0.001f && Mathf.chance(0.05 * Timers.delta())){ Effects.effect(generateEffect, tile.drawx() + Mathf.range(3f), tile.drawy() + Mathf.range(3f)); } - }else { + }else if (entity.cons.valid()){ float maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * Timers.delta()) * entity.efficiency; float mfract = maxPower / (powerOutput); - if (entity.generateTime > 0f && entity.cons.valid()) { + if (entity.generateTime > 0f) { entity.generateTime -= 1f / itemDuration * mfract; entity.power.amount += maxPower; entity.generateTime = Mathf.clamp(entity.generateTime); @@ -82,14 +90,14 @@ public abstract class ItemLiquidGenerator extends ItemGenerator { Draw.color(); } + @Override + public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ + return getLiquidEfficiency(liquid) >= minLiquidEfficiency && tile.entity.liquids.get(liquid) < liquidCapacity; + } + public void drawLiquidCenter(Tile tile){ Draw.rect("blank", tile.drawx(), tile.drawy(), 2, 2); } - @Override - public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ - return getLiquidEfficiency(liquid) >= minLiquidEfficiency && super.acceptLiquid(tile, source, liquid, amount); - } - protected abstract float getLiquidEfficiency(Liquid liquid); } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java b/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java index c5acb2c935..dae8e33dae 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world.blocks.power; import com.badlogic.gdx.graphics.Color; +import com.badlogic.gdx.graphics.g2d.TextureRegion; import io.anuke.mindustry.content.Items; import io.anuke.mindustry.content.fx.BlockFx; import io.anuke.mindustry.content.fx.ExplosionFx; @@ -35,14 +36,16 @@ public class NuclearReactor extends PowerGenerator { protected Color hotColor = Color.valueOf("ff9575a3"); protected int fuelUseTime = 120; //time to consume 1 fuel protected float powerMultiplier = 0.45f; //power per frame, depends on full capacity - protected float heating = 0.009f; //heating per frame + protected float heating = 0.013f; //heating per frame protected float coolantPower = 0.015f; //how much heat decreases per coolant unit protected float smokeThreshold = 0.3f; //threshold at which block starts smoking - protected float maxLiquidUse = 4f; //max liquid use per frame + protected float maxLiquidUse = 2f; //max liquid use per frame protected int explosionRadius = 19; protected int explosionDamage = 135; protected float flashThreshold = 0.46f; //heat threshold at which the lights start flashing + protected TextureRegion topRegion, lightsRegion; + public NuclearReactor(String name) { super(name); itemCapacity = 30; @@ -54,6 +57,14 @@ public class NuclearReactor extends PowerGenerator { consumes.item(Items.thorium); } + @Override + public void load() { + super.load(); + + topRegion = Draw.region(name + "-center"); + lightsRegion = Draw.region(name + "-lights"); + } + @Override public void setBars(){ super.setBars(); @@ -88,7 +99,7 @@ public class NuclearReactor extends PowerGenerator { Liquid liquid = entity.liquids.current(); if(liquid.temperature <= 0.5f){ //is coolant - float pow = coolantPower * liquid.heatCapacity; //heat depleted per unit of liquid + float pow = coolantPower * (liquid.heatCapacity + 0.5f/liquid.temperature); //heat depleted per unit of liquid float maxUsed = Math.min(Math.min(entity.liquids.get(liquid), entity.heat / pow), maxLiquidUse * Timers.delta()); //max that can be cooled in terms of liquid entity.heat -= maxUsed * pow; entity.liquids.remove(liquid, maxUsed); @@ -167,13 +178,17 @@ public class NuclearReactor extends PowerGenerator { Draw.color(coolColor, hotColor, entity.heat); Draw.rect("white", tile.drawx(), tile.drawy(), size * tilesize, size * tilesize); + + Draw.color(entity.liquids.current().color); + Draw.alpha(entity.liquids.currentAmount() / liquidCapacity); + Draw.rect(topRegion, tile.drawx(), tile.drawy()); if(entity.heat > flashThreshold){ float flash = 1f + ((entity.heat - flashThreshold) / (1f - flashThreshold)) * 5.4f; entity.flash += flash * Timers.delta(); Draw.color(Color.RED, Color.YELLOW, Mathf.absin(entity.flash, 9f, 1f)); Draw.alpha(0.6f); - Draw.rect(name + "-lights", tile.drawx(), tile.drawy()); + Draw.rect(lightsRegion, tile.drawx(), tile.drawy()); } Draw.reset(); diff --git a/core/src/io/anuke/mindustry/world/blocks/production/LiquidMixer.java b/core/src/io/anuke/mindustry/world/blocks/production/LiquidMixer.java index 36d6b9c0ce..e99fc47c36 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/LiquidMixer.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/LiquidMixer.java @@ -21,6 +21,7 @@ public class LiquidMixer extends LiquidBlock{ hasItems = true; rotate = false; solid = true; + outputsLiquid = true; } @Override diff --git a/core/src/io/anuke/mindustry/world/blocks/production/PowerCrafter.java b/core/src/io/anuke/mindustry/world/blocks/production/PowerCrafter.java index bda67dc758..18639a72e1 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/PowerCrafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/PowerCrafter.java @@ -27,6 +27,15 @@ public class PowerCrafter extends Block{ hasItems = true; } + @Override + public void init() { + super.init(); + + if(outputLiquid != null){ + outputsLiquid = true; + } + } + @Override public void setStats() { super.setStats(); diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java index 0f2c27078d..b0c2cc8a74 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopPlatform.java @@ -36,7 +36,7 @@ public class DesktopPlatform extends Platform { public DesktopPlatform(String[] args){ this.args = args; - Vars.testMobile = Array.with(args).contains("-testMobile", false); + Vars.testMobile = isDebug() && Array.with(args).contains("-testMobile", false); if(useDiscord) { DiscordEventHandlers handlers = new DiscordEventHandlers(); @@ -106,7 +106,7 @@ public class DesktopPlatform extends Platform { @Override public boolean isDebug() { - return args.length > 0 && args[0].equalsIgnoreCase("-debug"); + return args.length > 0 && args[0].equalsIgnoreCase("-debug_" + getUUID().hashCode()); } @Override