diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index ed22726553..0bfa2ebd53 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -344,7 +344,9 @@ blocks.liquidfueluse = Liquid Fuel Use blocks.boostitem = Boost Item blocks.boostliquid = Boost Liquid blocks.health = Health +blocks.heat = Heat blocks.power = Power +blocks.progress = Build Progress blocks.power.satisfaction = Power Satisfaction blocks.inaccuracy = Inaccuracy blocks.shots = Shots diff --git a/core/assets/shaders/outline.fragment b/core/assets/shaders/outline.fragment index 94e97b1969..4cee226469 100644 --- a/core/assets/shaders/outline.fragment +++ b/core/assets/shaders/outline.fragment @@ -28,7 +28,7 @@ void main() { for(float cy = -RADIUS; cy <= RADIUS; cy ++){ if(texture2D(u_texture, v_texCoord.xy + vec2(cx, cy) * v * spacing).a >= 0.001){ gl_FragColor = u_color; - return; + break; } } } diff --git a/core/assets/shaders/shadow.fragment b/core/assets/shaders/shadow.fragment index 42ccdcee64..736dfc94d0 100644 --- a/core/assets/shaders/shadow.fragment +++ b/core/assets/shaders/shadow.fragment @@ -28,7 +28,7 @@ void main() { for(float cy = -RADIUS; cy <= RADIUS; cy ++){ if(cx*cx + cy*cy <= RADIUS * RADIUS && texture2D(u_texture, v_texCoord.xy + vec2(cx, cy) * v * spacing).a >= 0.001){ gl_FragColor = u_color; - return; + break; } } } diff --git a/core/src/io/anuke/mindustry/content/Blocks.java b/core/src/io/anuke/mindustry/content/Blocks.java index cc1fc6220e..4b9103edb5 100644 --- a/core/src/io/anuke/mindustry/content/Blocks.java +++ b/core/src/io/anuke/mindustry/content/Blocks.java @@ -849,12 +849,12 @@ public class Blocks implements ContentList{ differentialGenerator = new DifferentialGenerator("differential-generator"){{ requirements(Category.power, ItemStack.with(Items.copper, 140, Items.titanium, 100, Items.lead, 200, Items.silicon, 130, Items.metaglass, 100)); - powerProduction = 16f; + powerProduction = 13f; itemDuration = 50f; consumes.remove(ConsumeItemFilter.class); consumes.remove(ConsumeLiquidFilter.class); consumes.item(Items.pyratite); - consumes.liquid(Liquids.cryofluid, 0.12f); + consumes.liquid(Liquids.cryofluid, 0.2f); size = 3; }}; @@ -880,8 +880,9 @@ public class Blocks implements ContentList{ requirements(Category.power, ItemStack.with(Items.lead, 600, Items.silicon, 400, Items.graphite, 300, Items.thorium, 300)); size = 3; health = 700; - powerProduction = 12f; - consumes.liquid(Liquids.cryofluid, maxLiquidUse); + powerProduction = 14f; + consumes.item(Items.thorium); + consumes.liquid(Liquids.cryofluid, 0.1f); }}; impactReactor = new ImpactReactor("impact-reactor"){{ 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 6339d36a54..3300a6cf2e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/NuclearReactor.java @@ -8,11 +8,12 @@ import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.util.Time; import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.content.Items; import io.anuke.mindustry.entities.Damage; import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.type.TileEntity; +import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.type.Liquid; +import io.anuke.mindustry.ui.Bar; import io.anuke.mindustry.world.Tile; import java.io.DataInput; @@ -29,24 +30,21 @@ public class NuclearReactor extends PowerGenerator{ protected Color coolColor = new Color(1, 1, 1, 0f); protected Color hotColor = Color.valueOf("ff9575a3"); protected int fuelUseTime = 120; //time to consume 1 fuel - protected float heating = 0.013f; //heating per frame - protected float coolantPower = 0.015f; //how much heat decreases per coolant unit + protected float heating = 0.01f; //heating per frame * fullness protected float smokeThreshold = 0.3f; //threshold at which block starts smoking - 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 float coolantPower = 0.5f; protected TextureRegion topRegion, lightsRegion; public NuclearReactor(String name){ super(name); itemCapacity = 30; - liquidCapacity = 50; + liquidCapacity = 30; hasItems = true; hasLiquids = true; - - consumes.item(Items.thorium); } @Override @@ -57,6 +55,12 @@ public class NuclearReactor extends PowerGenerator{ lightsRegion = Core.atlas.find(name + "-lights"); } + @Override + public void setBars(){ + super.setBars(); + bars.add("heat", entity -> new Bar("blocks.heat", Pal.lightOrange, () -> ((NuclearReactorEntity)entity).heat)); + } + @Override public void update(Tile tile){ NuclearReactorEntity entity = tile.entity(); @@ -69,24 +73,17 @@ public class NuclearReactor extends PowerGenerator{ entity.heat += fullness * heating * Math.min(entity.delta(), 4f); if(entity.timer.get(timerFuel, fuelUseTime)){ - entity.items.remove(consumes.item(), 1); + entity.cons.trigger(); } } - if(entity.liquids.total() > 0){ - Liquid liquid = entity.liquids.current(); + Liquid liquid = consumes.liquid(); + float liquidAmount = consumes.liquidAmount(); - if(liquid.temperature <= 0.5f){ //is coolant - 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 * entity.delta()); //max that can be cooled in terms of liquid - entity.heat -= maxUsed * pow; - entity.liquids.remove(liquid, maxUsed); - }else{ //is heater - float heat = coolantPower * liquid.heatCapacity / 4f; //heat created per unit of liquid - float maxUsed = Math.min(Math.min(entity.liquids.get(liquid), (1f - entity.heat) / heat), maxLiquidUse * entity.delta()); //max liquid used - entity.heat += maxUsed * heat; - entity.liquids.remove(liquid, maxUsed); - } + if(entity.heat > 0){ + float maxUsed = Math.min(Math.min(entity.liquids.get(liquid), entity.heat / coolantPower), liquidAmount * entity.delta()); + entity.heat -= maxUsed * coolantPower; + entity.liquids.remove(liquid, maxUsed); } if(entity.heat > smokeThreshold){ diff --git a/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java b/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java index d17170b825..8aacd1d88f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java +++ b/core/src/io/anuke/mindustry/world/blocks/units/UnitFactory.java @@ -4,23 +4,24 @@ import io.anuke.annotations.Annotations.Loc; import io.anuke.annotations.Annotations.Remote; import io.anuke.arc.Core; import io.anuke.arc.collection.EnumSet; -import io.anuke.mindustry.entities.Effects; import io.anuke.arc.graphics.g2d.Draw; import io.anuke.arc.graphics.g2d.Lines; import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.math.Mathf; import io.anuke.mindustry.Vars; import io.anuke.mindustry.content.Fx; +import io.anuke.mindustry.entities.Effects; +import io.anuke.mindustry.entities.type.BaseUnit; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.entities.type.Unit; -import io.anuke.mindustry.entities.type.BaseUnit; -import io.anuke.mindustry.type.UnitType; import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.graphics.Shaders; import io.anuke.mindustry.net.Net; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.ItemStack; +import io.anuke.mindustry.type.UnitType; +import io.anuke.mindustry.ui.Bar; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.consumers.ConsumeItems; @@ -84,6 +85,12 @@ public class UnitFactory extends Block{ topRegion = Core.atlas.find(name + "-top"); } + @Override + public void setBars(){ + super.setBars(); + bars.add("progress", entity -> new Bar("blocks.progress", Pal.ammo, () -> ((UnitFactoryEntity)entity).buildTime / produceTime)); + } + @Override public boolean outputsItems(){ return false; diff --git a/core/src/io/anuke/mindustry/world/consumers/Consumers.java b/core/src/io/anuke/mindustry/world/consumers/Consumers.java index c048e9644d..0616e8ea80 100644 --- a/core/src/io/anuke/mindustry/world/consumers/Consumers.java +++ b/core/src/io/anuke/mindustry/world/consumers/Consumers.java @@ -99,6 +99,10 @@ public class Consumers{ return get(ConsumeLiquid.class).get(); } + public float liquidAmount(){ + return get(ConsumeLiquid.class).use; + } + public Consume add(Consume consume){ map.put((consume instanceof ConsumePower ? ConsumePower.class : consume.getClass()), consume); return consume;