mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-04 15:27:19 +07:00
Better block hover info / Liquids source crash fix / Generator fix
This commit is contained in:
@ -326,12 +326,15 @@ blocks.liquidoutput = Liquid Output
|
||||
blocks.liquidoutputspeed = Liquid Output Speed
|
||||
blocks.liquiduse = Liquid Use
|
||||
blocks.coolant = Coolant
|
||||
blocks.liquid = Liquid
|
||||
blocks.coolantuse = Coolant Use
|
||||
blocks.inputliquidfuel = Fuel Liquid
|
||||
blocks.liquidfueluse = Liquid Fuel Use
|
||||
blocks.boostitem = Boost Item
|
||||
blocks.boostliquid = Boost Liquid
|
||||
blocks.health = Health
|
||||
blocks.power = Power
|
||||
blocks.power.satisfaction = Power Satisfaction
|
||||
blocks.inaccuracy = Inaccuracy
|
||||
blocks.shots = Shots
|
||||
blocks.reload = Shots/Second
|
||||
@ -575,6 +578,7 @@ block.battery.name = Battery
|
||||
block.battery-large.name = Large Battery
|
||||
block.combustion-generator.name = Combustion Generator
|
||||
block.turbine-generator.name = Turbine Generator
|
||||
block.differential-generator.name = Differential Generator
|
||||
block.mechanical-drill.name = Mechanical Drill
|
||||
block.pneumatic-drill.name = Pneumatic Drill
|
||||
block.laser-drill.name = Laser Drill
|
||||
|
@ -847,10 +847,10 @@ public class Blocks implements ContentList{
|
||||
size = 2;
|
||||
}};
|
||||
|
||||
differentialGenerator = new TurbineGenerator("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));
|
||||
powerProduction = 12f;
|
||||
itemDuration = 30f;
|
||||
itemDuration = 60f;
|
||||
consumes.remove(ConsumeItemFilter.class);
|
||||
consumes.remove(ConsumeLiquidFilter.class);
|
||||
consumes.item(Items.pyratite);
|
||||
|
@ -214,8 +214,10 @@ public class TechTree implements ContentList{
|
||||
node(turbineGenerator, () -> {
|
||||
node(thermalGenerator, () -> {
|
||||
node(rtgGenerator, () -> {
|
||||
node(thoriumReactor, () -> {
|
||||
node(differentialGenerator, () -> {
|
||||
node(thoriumReactor, () -> {
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -32,8 +32,10 @@ public class Bar extends Element{
|
||||
|
||||
public Bar(Supplier<String> name, Supplier<Color> color, FloatProvider fraction){
|
||||
this.fraction = fraction;
|
||||
lastValue = value = fraction.get();
|
||||
update(() -> {
|
||||
this.name = name.get();
|
||||
this.blinkColor.set(color.get());
|
||||
setColor(color.get());
|
||||
});
|
||||
}
|
||||
|
@ -496,7 +496,17 @@ public class Block extends BlockStorage{
|
||||
bars.row();
|
||||
|
||||
if(entity.liquids != null){
|
||||
bars.add(new Bar(() -> entity.liquids.current().localizedName(), () -> entity.liquids.current().color, () -> entity.liquids.total() / liquidCapacity)).growX();
|
||||
bars.add(new Bar(() -> entity.liquids.get(entity.liquids.current()) <= 0.001f ? Core.bundle.get("blocks.liquid") : entity.liquids.current().localizedName(), () -> entity.liquids.current().color, () -> entity.liquids.total() / liquidCapacity)).growX();
|
||||
bars.row();
|
||||
}
|
||||
|
||||
if(entity.power != null && consumes.has(ConsumePower.class) && consumes.get(ConsumePower.class).isBuffered){
|
||||
bars.add(new Bar("blocks.power", Palette.power, () -> entity.power.satisfaction)).growX();
|
||||
bars.row();
|
||||
}
|
||||
|
||||
if(entity.power != null && consumes.has(ConsumePower.class) && !consumes.get(ConsumePower.class).isBuffered){
|
||||
bars.add(new Bar("blocks.power.satisfaction", Palette.power, () -> entity.power.satisfaction)).growX();
|
||||
bars.row();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package io.anuke.mindustry.world.blocks.power;
|
||||
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeItem;
|
||||
import io.anuke.mindustry.world.consumers.ConsumeLiquid;
|
||||
|
||||
public class DifferentialGenerator extends TurbineGenerator{
|
||||
|
||||
public DifferentialGenerator(String name){
|
||||
super(name);
|
||||
|
||||
consumes.require(ConsumeItem.class);
|
||||
consumes.require(ConsumeLiquid.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return hasItems && consumes.item() == item && tile.entity.items.total() < itemCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
|
||||
return hasLiquids && consumes.liquid() == liquid && tile.entity.liquids.get(liquid) < liquidCapacity;
|
||||
}
|
||||
}
|
@ -79,6 +79,9 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
entity.heat = Mathf.lerpDelta(entity.heat, entity.generateTime >= 0.001f ? 1f : 0f, 0.05f);
|
||||
|
||||
//liquid takes priority over solids
|
||||
if(hasLiquids && liquid != null && entity.liquids.get(liquid) >= 0.001f){
|
||||
float baseLiquidEfficiency = getLiquidEfficiency(liquid);
|
||||
@ -131,17 +134,13 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
public void draw(Tile tile){
|
||||
super.draw(tile);
|
||||
|
||||
GeneratorEntity entity = tile.entity();
|
||||
ItemLiquidGeneratorEntity entity = tile.entity();
|
||||
|
||||
if(hasItems){
|
||||
if(entity.generateTime > 0){
|
||||
Draw.color(heatColor);
|
||||
float alpha = (entity.items.total() > 0 ? 1f : Mathf.clamp(entity.generateTime));
|
||||
alpha = alpha * 0.7f + Mathf.absin(Time.time(), 12f, 0.3f) * alpha;
|
||||
Draw.alpha(alpha);
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||
Draw.reset();
|
||||
}
|
||||
Draw.color(heatColor);
|
||||
Draw.alpha(entity.heat * 0.4f + Mathf.absin(Time.time(), 8f, 0.6f) * entity.heat);
|
||||
Draw.rect(topRegion, tile.drawx(), tile.drawy());
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
if(hasLiquids){
|
||||
@ -171,5 +170,6 @@ public class ItemLiquidGenerator extends PowerGenerator{
|
||||
|
||||
public static class ItemLiquidGeneratorEntity extends GeneratorEntity{
|
||||
public float explosiveness;
|
||||
public float heat;
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class PowerNode extends PowerBlock{
|
||||
|
||||
Draw.color(Palette.accent);
|
||||
|
||||
Lines.stroke(1f);
|
||||
Lines.stroke(1.5f);
|
||||
Lines.circle(tile.drawx(), tile.drawy(),
|
||||
tile.block().size * tilesize / 2f + 1f + Mathf.absin(Time.time(), 4f, 1f));
|
||||
|
||||
@ -171,8 +171,9 @@ public class PowerNode extends PowerBlock{
|
||||
link.block().size * tilesize / 2f + 1f + (linked ? 0f : Mathf.absin(Time.time(), 4f, 1f)));
|
||||
|
||||
if((entity.power.links.size >= maxNodes || (link.block() instanceof PowerNode && link.entity.power.links.size >= ((PowerNode) link.block()).maxNodes)) && !linked){
|
||||
Draw.color(Palette.breakInvalid);
|
||||
Lines.lineAngleCenter(link.drawx(), link.drawy(), 45, link.block().size * Mathf.sqrt2 * tilesize * 0.9f);
|
||||
Draw.color();
|
||||
Draw.rect("cross-" + link.block().size, link.drawx(), link.drawy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,22 +4,24 @@ import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.scene.style.TextureRegionDrawable;
|
||||
import io.anuke.arc.scene.ui.ButtonGroup;
|
||||
import io.anuke.arc.scene.ui.ImageButton;
|
||||
import io.anuke.arc.scene.ui.layout.Table;
|
||||
import io.anuke.mindustry.content.Liquids;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Vars.data;
|
||||
|
||||
public class LiquidSource extends Block{
|
||||
|
||||
@ -65,8 +67,9 @@ public class LiquidSource extends Block{
|
||||
if(!data.isUnlocked(items.get(i))) continue;
|
||||
|
||||
final int f = i;
|
||||
ImageButton button = cont.addImageButton("liquid-icon-" + items.get(i).name, "clear-toggle", 24,
|
||||
ImageButton button = cont.addImageButton("clear", "clear-toggle", 24,
|
||||
() -> Call.setLiquidSourceLiquid(null, tile, items.get(f))).size(38).group(group).get();
|
||||
button.getStyle().imageUp = new TextureRegionDrawable(items.get(i).iconRegion);
|
||||
button.setChecked(entity.source.id == f);
|
||||
|
||||
if(i % 4 == 3){
|
||||
|
Reference in New Issue
Block a user