Nuclear reactor fixes / Additional info bars

This commit is contained in:
Anuken
2019-02-26 14:47:05 -05:00
parent 964d1a0d87
commit 2fa32e5099
7 changed files with 41 additions and 30 deletions

View File

@@ -344,7 +344,9 @@ blocks.liquidfueluse = Liquid Fuel Use
blocks.boostitem = Boost Item blocks.boostitem = Boost Item
blocks.boostliquid = Boost Liquid blocks.boostliquid = Boost Liquid
blocks.health = Health blocks.health = Health
blocks.heat = Heat
blocks.power = Power blocks.power = Power
blocks.progress = Build Progress
blocks.power.satisfaction = Power Satisfaction blocks.power.satisfaction = Power Satisfaction
blocks.inaccuracy = Inaccuracy blocks.inaccuracy = Inaccuracy
blocks.shots = Shots blocks.shots = Shots

View File

@@ -28,7 +28,7 @@ void main() {
for(float cy = -RADIUS; cy <= RADIUS; cy ++){ for(float cy = -RADIUS; cy <= RADIUS; cy ++){
if(texture2D(u_texture, v_texCoord.xy + vec2(cx, cy) * v * spacing).a >= 0.001){ if(texture2D(u_texture, v_texCoord.xy + vec2(cx, cy) * v * spacing).a >= 0.001){
gl_FragColor = u_color; gl_FragColor = u_color;
return; break;
} }
} }
} }

View File

@@ -28,7 +28,7 @@ void main() {
for(float cy = -RADIUS; cy <= RADIUS; cy ++){ 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){ 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; gl_FragColor = u_color;
return; break;
} }
} }
} }

View File

@@ -849,12 +849,12 @@ public class Blocks implements ContentList{
differentialGenerator = new DifferentialGenerator("differential-generator"){{ 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)); 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; itemDuration = 50f;
consumes.remove(ConsumeItemFilter.class); consumes.remove(ConsumeItemFilter.class);
consumes.remove(ConsumeLiquidFilter.class); consumes.remove(ConsumeLiquidFilter.class);
consumes.item(Items.pyratite); consumes.item(Items.pyratite);
consumes.liquid(Liquids.cryofluid, 0.12f); consumes.liquid(Liquids.cryofluid, 0.2f);
size = 3; 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)); requirements(Category.power, ItemStack.with(Items.lead, 600, Items.silicon, 400, Items.graphite, 300, Items.thorium, 300));
size = 3; size = 3;
health = 700; health = 700;
powerProduction = 12f; powerProduction = 14f;
consumes.liquid(Liquids.cryofluid, maxLiquidUse); consumes.item(Items.thorium);
consumes.liquid(Liquids.cryofluid, 0.1f);
}}; }};
impactReactor = new ImpactReactor("impact-reactor"){{ impactReactor = new ImpactReactor("impact-reactor"){{

View File

@@ -8,11 +8,12 @@ import io.anuke.arc.math.Mathf;
import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.math.geom.Vector2;
import io.anuke.arc.util.Time; import io.anuke.arc.util.Time;
import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.content.Items;
import io.anuke.mindustry.entities.Damage; import io.anuke.mindustry.entities.Damage;
import io.anuke.mindustry.entities.Effects; import io.anuke.mindustry.entities.Effects;
import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.entities.type.TileEntity;
import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.ui.Bar;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import java.io.DataInput; import java.io.DataInput;
@@ -29,24 +30,21 @@ public class NuclearReactor extends PowerGenerator{
protected Color coolColor = new Color(1, 1, 1, 0f); protected Color coolColor = new Color(1, 1, 1, 0f);
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 heating = 0.013f; //heating per frame protected float heating = 0.01f; //heating per frame * fullness
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 = 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 float coolantPower = 0.5f;
protected TextureRegion topRegion, lightsRegion; protected TextureRegion topRegion, lightsRegion;
public NuclearReactor(String name){ public NuclearReactor(String name){
super(name); super(name);
itemCapacity = 30; itemCapacity = 30;
liquidCapacity = 50; liquidCapacity = 30;
hasItems = true; hasItems = true;
hasLiquids = true; hasLiquids = true;
consumes.item(Items.thorium);
} }
@Override @Override
@@ -57,6 +55,12 @@ public class NuclearReactor extends PowerGenerator{
lightsRegion = Core.atlas.find(name + "-lights"); 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 @Override
public void update(Tile tile){ public void update(Tile tile){
NuclearReactorEntity entity = tile.entity(); NuclearReactorEntity entity = tile.entity();
@@ -69,24 +73,17 @@ public class NuclearReactor extends PowerGenerator{
entity.heat += fullness * heating * Math.min(entity.delta(), 4f); entity.heat += fullness * heating * Math.min(entity.delta(), 4f);
if(entity.timer.get(timerFuel, fuelUseTime)){ if(entity.timer.get(timerFuel, fuelUseTime)){
entity.items.remove(consumes.item(), 1); entity.cons.trigger();
} }
} }
if(entity.liquids.total() > 0){ Liquid liquid = consumes.liquid();
Liquid liquid = entity.liquids.current(); float liquidAmount = consumes.liquidAmount();
if(liquid.temperature <= 0.5f){ //is coolant if(entity.heat > 0){
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 / coolantPower), liquidAmount * entity.delta());
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 * coolantPower;
entity.heat -= maxUsed * pow; entity.liquids.remove(liquid, maxUsed);
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 > smokeThreshold){ if(entity.heat > smokeThreshold){

View File

@@ -4,23 +4,24 @@ import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote; import io.anuke.annotations.Annotations.Remote;
import io.anuke.arc.Core; import io.anuke.arc.Core;
import io.anuke.arc.collection.EnumSet; 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.Draw;
import io.anuke.arc.graphics.g2d.Lines; import io.anuke.arc.graphics.g2d.Lines;
import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.arc.math.Mathf; import io.anuke.arc.math.Mathf;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.Fx; 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.TileEntity;
import io.anuke.mindustry.entities.type.Unit; 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.gen.Call;
import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.graphics.Pal;
import io.anuke.mindustry.graphics.Shaders; import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemStack; 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.Block;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.consumers.ConsumeItems; import io.anuke.mindustry.world.consumers.ConsumeItems;
@@ -84,6 +85,12 @@ public class UnitFactory extends Block{
topRegion = Core.atlas.find(name + "-top"); 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 @Override
public boolean outputsItems(){ public boolean outputsItems(){
return false; return false;

View File

@@ -99,6 +99,10 @@ public class Consumers{
return get(ConsumeLiquid.class).get(); return get(ConsumeLiquid.class).get();
} }
public float liquidAmount(){
return get(ConsumeLiquid.class).use;
}
public Consume add(Consume consume){ public Consume add(Consume consume){
map.put((consume instanceof ConsumePower ? ConsumePower.class : consume.getClass()), consume); map.put((consume instanceof ConsumePower ? ConsumePower.class : consume.getClass()), consume);
return consume; return consume;