Reactor balancing / Fixed generators / Fixed pump crash / Travis update

This commit is contained in:
Anuken
2018-07-12 10:20:38 -04:00
parent 6375862a71
commit f41e426b69
16 changed files with 71 additions and 30 deletions

View File

@@ -5,13 +5,13 @@ jdk:
android: android:
components: components:
- android-26 - android-27
# Additional components # Additional components
- extra-google-google_play_services - extra-google-google_play_services
- extra-google-m2repository - extra-google-m2repository
- extra-android-m2repository - extra-android-m2repository
- addon-google_apis-google-26 - addon-google_apis-google-27
script: script:
- ./gradlew desktop:dist - ./gradlew desktop:dist

View File

@@ -41,8 +41,8 @@ public class Liquids implements ContentList {
cryofluid = new Liquid("cryofluid", Color.SKY) { cryofluid = new Liquid("cryofluid", Color.SKY) {
{ {
heatCapacity = 0.75f; heatCapacity = 0.9f;
temperature = 0.4f; temperature = 0.25f;
tier = 1; tier = 1;
effect = StatusEffects.freezing; effect = StatusEffects.freezing;
} }

View File

@@ -121,7 +121,7 @@ public class CraftingBlocks extends BlockList implements ContentList {
consumes.power(0.1f); consumes.power(0.1f);
consumes.item(Items.titanium); consumes.item(Items.titanium);
consumes.liquid(Liquids.water, 0.2f); consumes.liquid(Liquids.water, 0.3f);
}}; }};
blastMixer = new GenericCrafter("blast-mixer") {{ blastMixer = new GenericCrafter("blast-mixer") {{

View File

@@ -22,6 +22,7 @@ public class LiquidBlocks extends BlockList implements ContentList{
pumpAmount = 0.25f; pumpAmount = 0.25f;
consumes.power(0.015f); consumes.power(0.015f);
liquidCapacity = 30f; liquidCapacity = 30f;
hasPower = true;
size = 2; size = 2;
tier = 1; tier = 1;
}}; }};

View File

@@ -10,9 +10,10 @@ import io.anuke.mindustry.ui.ContentDisplay;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Bundles; import io.anuke.ucore.util.Bundles;
import io.anuke.ucore.util.ThreadArray;
public class Liquid implements UnlockableContent{ public class Liquid implements UnlockableContent{
private static final Array<Liquid> liquids = new Array<>(); private static final Array<Liquid> liquids = new ThreadArray<>();
public final Color color; public final Color color;
public final String name; public final String name;

View File

@@ -20,6 +20,7 @@ public abstract class BaseBlock {
public boolean hasLiquids; public boolean hasLiquids;
public boolean hasPower; public boolean hasPower;
public boolean outputsLiquid = false;
public boolean singleLiquid = true; public boolean singleLiquid = true;
public int itemCapacity; public int itemCapacity;

View File

@@ -16,6 +16,7 @@ public class LiquidBlock extends Block{
solid = true; solid = true;
hasLiquids = true; hasLiquids = true;
group = BlockGroup.liquids; group = BlockGroup.liquids;
outputsLiquid = true;
} }
@Override @Override

View File

@@ -40,14 +40,14 @@ public class Conduit extends LiquidBlock {
ConduitEntity entity = tile.entity(); ConduitEntity entity = tile.entity();
entity.blendbits = 0; 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; entity.blendbits = 2;
}else if(blends(tile, 3) && blends(tile, 2)) { }else if(blends(tile, 3) && blends(tile, 2)) {
entity.blendbits = 4; entity.blendbits = 4;
}else if(blends(tile, 0)){ }else if(blends(tile, 0)){
if(blends(tile, 2) && blends(tile, 1) && blends(tile, 3)) { if(blends(tile, 1) && blends(tile, 3)) {
entity.blendbits = 3;
}else if(blends(tile, 1) && blends(tile, 3)) {
entity.blendbits = 6; entity.blendbits = 6;
}else if(blends(tile, 1)) { }else if(blends(tile, 1)) {
entity.blendbits = 5; entity.blendbits = 5;
@@ -63,7 +63,9 @@ public class Conduit extends LiquidBlock {
private boolean blends(Tile tile, int direction){ private boolean blends(Tile tile, int direction){
Tile other = tile.getNearby(Mathf.mod(tile.getRotation() - direction, 4)); 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) return (tile.getNearby(tile.getRotation()) == other)
|| (!other.block().rotate || other.getNearby(other.getRotation()) == tile); || (!other.block().rotate || other.getNearby(other.getRotation()) == tile);
} }

View File

@@ -13,6 +13,7 @@ public class LiquidBridge extends ItemBridge {
super(name); super(name);
hasItems = false; hasItems = false;
hasLiquids = true; hasLiquids = true;
outputsLiquid = true;
} }
@Override @Override

View File

@@ -13,6 +13,7 @@ public class LiquidExtendingBridge extends ExtendingItemBridge {
super(name); super(name);
hasItems = false; hasItems = false;
hasLiquids = true; hasLiquids = true;
outputsLiquid = true;
} }
@Override @Override

View File

@@ -37,7 +37,7 @@ public abstract class ItemGenerator extends PowerGenerator {
itemCapacity = 20; itemCapacity = 20;
hasItems = true; 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 @Override

View File

@@ -23,31 +23,39 @@ public abstract class ItemLiquidGenerator extends ItemGenerator {
hasLiquids = true; hasLiquids = true;
liquidCapacity = 10f; 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 @Override
public void update(Tile tile){ public void update(Tile tile){
ItemGeneratorEntity entity = tile.entity(); 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 //liquid takes priority over solids
if(entity.liquids.currentAmount() >= 0.001f && entity.cons.valid()){ if(liquid != null && entity.liquids.get(liquid) >= 0.001f && entity.cons.valid()){
float powerPerLiquid = getLiquidEfficiency(entity.liquids.current())*this.powerPerLiquid; float powerPerLiquid = getLiquidEfficiency(liquid)*this.powerPerLiquid;
float used = Math.min(entity.liquids.currentAmount(), maxLiquidGenerate * Timers.delta()); float used = Math.min(entity.liquids.get(liquid), maxLiquidGenerate * Timers.delta());
used = Math.min(used, (powerCapacity - entity.power.amount)/powerPerLiquid); 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; entity.power.amount += used * powerPerLiquid;
if(used > 0.001f && Mathf.chance(0.05 * Timers.delta())){ if(used > 0.001f && Mathf.chance(0.05 * Timers.delta())){
Effects.effect(generateEffect, tile.drawx() + Mathf.range(3f), tile.drawy() + Mathf.range(3f)); 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 maxPower = Math.min(powerCapacity - entity.power.amount, powerOutput * Timers.delta()) * entity.efficiency;
float mfract = maxPower / (powerOutput); float mfract = maxPower / (powerOutput);
if (entity.generateTime > 0f && entity.cons.valid()) { if (entity.generateTime > 0f) {
entity.generateTime -= 1f / itemDuration * mfract; entity.generateTime -= 1f / itemDuration * mfract;
entity.power.amount += maxPower; entity.power.amount += maxPower;
entity.generateTime = Mathf.clamp(entity.generateTime); entity.generateTime = Mathf.clamp(entity.generateTime);
@@ -82,14 +90,14 @@ public abstract class ItemLiquidGenerator extends ItemGenerator {
Draw.color(); 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){ public void drawLiquidCenter(Tile tile){
Draw.rect("blank", tile.drawx(), tile.drawy(), 2, 2); 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); protected abstract float getLiquidEfficiency(Liquid liquid);
} }

View File

@@ -1,6 +1,7 @@
package io.anuke.mindustry.world.blocks.power; package io.anuke.mindustry.world.blocks.power;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.content.Items; import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.content.fx.BlockFx; import io.anuke.mindustry.content.fx.BlockFx;
import io.anuke.mindustry.content.fx.ExplosionFx; import io.anuke.mindustry.content.fx.ExplosionFx;
@@ -35,14 +36,16 @@ public class NuclearReactor extends PowerGenerator {
protected Color hotColor = Color.valueOf("ff9575a3"); protected Color hotColor = Color.valueOf("ff9575a3");
protected int fuelUseTime = 120; //time to consume 1 fuel protected int fuelUseTime = 120; //time to consume 1 fuel
protected float powerMultiplier = 0.45f; //power per frame, depends on full capacity 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 coolantPower = 0.015f; //how much heat decreases per coolant unit
protected float smokeThreshold = 0.3f; //threshold at which block starts smoking 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 explosionRadius = 19;
protected int explosionDamage = 135; protected int explosionDamage = 135;
protected float flashThreshold = 0.46f; //heat threshold at which the lights start flashing protected float flashThreshold = 0.46f; //heat threshold at which the lights start flashing
protected TextureRegion topRegion, lightsRegion;
public NuclearReactor(String name) { public NuclearReactor(String name) {
super(name); super(name);
itemCapacity = 30; itemCapacity = 30;
@@ -54,6 +57,14 @@ public class NuclearReactor extends PowerGenerator {
consumes.item(Items.thorium); consumes.item(Items.thorium);
} }
@Override
public void load() {
super.load();
topRegion = Draw.region(name + "-center");
lightsRegion = Draw.region(name + "-lights");
}
@Override @Override
public void setBars(){ public void setBars(){
super.setBars(); super.setBars();
@@ -88,7 +99,7 @@ public class NuclearReactor extends PowerGenerator {
Liquid liquid = entity.liquids.current(); Liquid liquid = entity.liquids.current();
if(liquid.temperature <= 0.5f){ //is coolant 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 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.heat -= maxUsed * pow;
entity.liquids.remove(liquid, maxUsed); entity.liquids.remove(liquid, maxUsed);
@@ -168,12 +179,16 @@ public class NuclearReactor extends PowerGenerator {
Draw.color(coolColor, hotColor, entity.heat); Draw.color(coolColor, hotColor, entity.heat);
Draw.rect("white", tile.drawx(), tile.drawy(), size * tilesize, size * tilesize); 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){ if(entity.heat > flashThreshold){
float flash = 1f + ((entity.heat - flashThreshold) / (1f - flashThreshold)) * 5.4f; float flash = 1f + ((entity.heat - flashThreshold) / (1f - flashThreshold)) * 5.4f;
entity.flash += flash * Timers.delta(); entity.flash += flash * Timers.delta();
Draw.color(Color.RED, Color.YELLOW, Mathf.absin(entity.flash, 9f, 1f)); Draw.color(Color.RED, Color.YELLOW, Mathf.absin(entity.flash, 9f, 1f));
Draw.alpha(0.6f); Draw.alpha(0.6f);
Draw.rect(name + "-lights", tile.drawx(), tile.drawy()); Draw.rect(lightsRegion, tile.drawx(), tile.drawy());
} }
Draw.reset(); Draw.reset();

View File

@@ -21,6 +21,7 @@ public class LiquidMixer extends LiquidBlock{
hasItems = true; hasItems = true;
rotate = false; rotate = false;
solid = true; solid = true;
outputsLiquid = true;
} }
@Override @Override

View File

@@ -27,6 +27,15 @@ public class PowerCrafter extends Block{
hasItems = true; hasItems = true;
} }
@Override
public void init() {
super.init();
if(outputLiquid != null){
outputsLiquid = true;
}
}
@Override @Override
public void setStats() { public void setStats() {
super.setStats(); super.setStats();

View File

@@ -36,7 +36,7 @@ public class DesktopPlatform extends Platform {
public DesktopPlatform(String[] args){ public DesktopPlatform(String[] args){
this.args = args; this.args = args;
Vars.testMobile = Array.with(args).contains("-testMobile", false); Vars.testMobile = isDebug() && Array.with(args).contains("-testMobile", false);
if(useDiscord) { if(useDiscord) {
DiscordEventHandlers handlers = new DiscordEventHandlers(); DiscordEventHandlers handlers = new DiscordEventHandlers();
@@ -106,7 +106,7 @@ public class DesktopPlatform extends Platform {
@Override @Override
public boolean isDebug() { public boolean isDebug() {
return args.length > 0 && args[0].equalsIgnoreCase("-debug"); return args.length > 0 && args[0].equalsIgnoreCase("-debug_" + getUUID().hashCode());
} }
@Override @Override