1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-11 03:31:19 +03:00

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:
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

View File

@ -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;
}

View File

@ -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") {{

View File

@ -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;
}};

View File

@ -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<Liquid> liquids = new Array<>();
private static final Array<Liquid> liquids = new ThreadArray<>();
public final Color color;
public final String name;

View File

@ -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;

View File

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

View File

@ -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);
}

View File

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

View File

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

View File

@ -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

View File

@ -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);
}

View File

@ -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();

View File

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

View File

@ -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();

View File

@ -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