Added armored conduit / Lighting improvements / Moved liquid package

This commit is contained in:
Anuken
2019-11-17 13:51:36 -05:00
37 changed files with 3216 additions and 2988 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

@@ -963,6 +963,7 @@ block.fortress-factory.name = Fortress Mech Factory
block.revenant-factory.name = Revenant Fighter Factory block.revenant-factory.name = Revenant Fighter Factory
block.repair-point.name = Repair Point block.repair-point.name = Repair Point
block.pulse-conduit.name = Pulse Conduit block.pulse-conduit.name = Pulse Conduit
block.plated-conduit.name = Plated Conduit
block.phase-conduit.name = Phase Conduit block.phase-conduit.name = Phase Conduit
block.liquid-router.name = Liquid Router block.liquid-router.name = Liquid Router
block.liquid-tank.name = Liquid Tank block.liquid-tank.name = Liquid Tank
@@ -1131,6 +1132,7 @@ block.rotary-pump.description = An advanced pump. Pumps more liquid, but require
block.thermal-pump.description = The ultimate pump. block.thermal-pump.description = The ultimate pump.
block.conduit.description = Basic liquid transport block. Moves liquids forward. Used in conjunction with pumps and other conduits. block.conduit.description = Basic liquid transport block. Moves liquids forward. Used in conjunction with pumps and other conduits.
block.pulse-conduit.description = An advanced liquid transport block. Transports liquids faster and stores more than standard conduits. block.pulse-conduit.description = An advanced liquid transport block. Transports liquids faster and stores more than standard conduits.
block.plated-conduit.description = Moves liquids at the same rate as pulse conduits, but possesses more armor. Does not accept fluids from the sides by anything other than conduits.\nLeaks less.
block.liquid-router.description = Accepts liquids from one direction and outputs them to up to 3 other directions equally. Can also store a certain amount of liquid. Useful for splitting the liquids from one source to multiple targets. block.liquid-router.description = Accepts liquids from one direction and outputs them to up to 3 other directions equally. Can also store a certain amount of liquid. Useful for splitting the liquids from one source to multiple targets.
block.liquid-tank.description = Stores a large amount of liquids. Use for creating buffers in situations with non-constant demand of materials or as a safeguard for cooling vital blocks. block.liquid-tank.description = Stores a large amount of liquids. Use for creating buffers in situations with non-constant demand of materials or as a safeguard for cooling vital blocks.
block.liquid-junction.description = Acts as a bridge for two crossing conduits. Useful in situations with two different conduits carrying different liquids to different locations. block.liquid-junction.description = Acts as a bridge for two crossing conduits. Useful in situations with two different conduits carrying different liquids to different locations.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 742 B

After

Width:  |  Height:  |  Size: 745 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 736 KiB

After

Width:  |  Height:  |  Size: 740 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

After

Width:  |  Height:  |  Size: 261 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 897 KiB

After

Width:  |  Height:  |  Size: 905 KiB

View File

@@ -19,6 +19,8 @@ import io.anuke.mindustry.world.blocks.*;
import io.anuke.mindustry.world.blocks.defense.*; import io.anuke.mindustry.world.blocks.defense.*;
import io.anuke.mindustry.world.blocks.defense.turrets.*; import io.anuke.mindustry.world.blocks.defense.turrets.*;
import io.anuke.mindustry.world.blocks.distribution.*; import io.anuke.mindustry.world.blocks.distribution.*;
import io.anuke.mindustry.world.blocks.liquid.Conduit;
import io.anuke.mindustry.world.blocks.liquid.LiquidTank;
import io.anuke.mindustry.world.blocks.logic.*; import io.anuke.mindustry.world.blocks.logic.*;
import io.anuke.mindustry.world.blocks.power.*; import io.anuke.mindustry.world.blocks.power.*;
import io.anuke.mindustry.world.blocks.production.*; import io.anuke.mindustry.world.blocks.production.*;
@@ -59,7 +61,7 @@ public class Blocks implements ContentList{
conveyor, titaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router, overflowGate, massDriver, conveyor, titaniumConveyor, armoredConveyor, distributor, junction, itemBridge, phaseConveyor, sorter, invertedSorter, router, overflowGate, massDriver,
//liquids //liquids
mechanicalPump, rotaryPump, thermalPump, conduit, pulseConduit, liquidRouter, liquidTank, liquidJunction, bridgeConduit, phaseConduit, mechanicalPump, rotaryPump, thermalPump, conduit, pulseConduit, platedConduit, liquidRouter, liquidTank, liquidJunction, bridgeConduit, phaseConduit,
//power //power
combustionGenerator, thermalGenerator, turbineGenerator, differentialGenerator, rtgGenerator, solarPanel, largeSolarPanel, thoriumReactor, combustionGenerator, thermalGenerator, turbineGenerator, differentialGenerator, rtgGenerator, solarPanel, largeSolarPanel, thoriumReactor,
@@ -926,7 +928,7 @@ public class Blocks implements ContentList{
}}; }};
armoredConveyor = new ArmoredConveyor("armored-conveyor"){{ armoredConveyor = new ArmoredConveyor("armored-conveyor"){{
requirements(Category.distribution, ItemStack.with(Items.metaglass, 1, Items.thorium, 1)); requirements(Category.distribution, ItemStack.with(Items.plastanium, 1, Items.thorium, 1, Items.metaglass, 1));
health = 180; health = 180;
speed = 0.08f; speed = 0.08f;
}}; }};
@@ -1010,7 +1012,7 @@ public class Blocks implements ContentList{
size = 3; size = 3;
}}; }};
conduit = new Conduit("conduit"){{ conduit = new io.anuke.mindustry.world.blocks.liquid.Conduit("conduit"){{
requirements(Category.liquid, ItemStack.with(Items.metaglass, 1)); requirements(Category.liquid, ItemStack.with(Items.metaglass, 1));
health = 45; health = 45;
}}; }};
@@ -1022,7 +1024,14 @@ public class Blocks implements ContentList{
health = 90; health = 90;
}}; }};
liquidRouter = new LiquidRouter("liquid-router"){{ platedConduit = new io.anuke.mindustry.world.blocks.liquid.ArmoredConduit("plated-conduit"){{
requirements(Category.liquid, ItemStack.with(Items.thorium, 2, Items.metaglass, 1));
liquidCapacity = 16f;
liquidPressure = 1.025f;
health = 220;
}};
liquidRouter = new io.anuke.mindustry.world.blocks.liquid.LiquidRouter("liquid-router"){{
requirements(Category.liquid, ItemStack.with(Items.graphite, 4, Items.metaglass, 2)); requirements(Category.liquid, ItemStack.with(Items.graphite, 4, Items.metaglass, 2));
liquidCapacity = 20f; liquidCapacity = 20f;
}}; }};
@@ -1034,17 +1043,17 @@ public class Blocks implements ContentList{
health = 500; health = 500;
}}; }};
liquidJunction = new LiquidJunction("liquid-junction"){{ liquidJunction = new io.anuke.mindustry.world.blocks.liquid.LiquidJunction("liquid-junction"){{
requirements(Category.liquid, ItemStack.with(Items.graphite, 2, Items.metaglass, 2)); requirements(Category.liquid, ItemStack.with(Items.graphite, 2, Items.metaglass, 2));
}}; }};
bridgeConduit = new LiquidExtendingBridge("bridge-conduit"){{ bridgeConduit = new io.anuke.mindustry.world.blocks.liquid.LiquidExtendingBridge("bridge-conduit"){{
requirements(Category.liquid, ItemStack.with(Items.graphite, 4, Items.metaglass, 8)); requirements(Category.liquid, ItemStack.with(Items.graphite, 4, Items.metaglass, 8));
range = 4; range = 4;
hasPower = false; hasPower = false;
}}; }};
phaseConduit = new LiquidBridge("phase-conduit"){{ phaseConduit = new io.anuke.mindustry.world.blocks.liquid.LiquidBridge("phase-conduit"){{
requirements(Category.liquid, ItemStack.with(Items.phasefabric, 5, Items.silicon, 7, Items.metaglass, 20, Items.titanium, 10)); requirements(Category.liquid, ItemStack.with(Items.phasefabric, 5, Items.silicon, 7, Items.metaglass, 20, Items.titanium, 10));
range = 12; range = 12;
hasPower = true; hasPower = true;

View File

@@ -19,6 +19,7 @@ public class Liquids implements ContentList{
temperature = 1f; temperature = 1f;
viscosity = 0.8f; viscosity = 0.8f;
effect = StatusEffects.melting; effect = StatusEffects.melting;
lightColor = Color.valueOf("f0511d").a(0.4f);
}}; }};
oil = new Liquid("oil", Color.valueOf("313131")){{ oil = new Liquid("oil", Color.valueOf("313131")){{
@@ -34,6 +35,7 @@ public class Liquids implements ContentList{
heatCapacity = 0.9f; heatCapacity = 0.9f;
temperature = 0.25f; temperature = 0.25f;
effect = StatusEffects.freezing; effect = StatusEffects.freezing;
lightColor = Color.valueOf("0097f5").a(0.2f);
}}; }};
} }
} }

View File

@@ -199,6 +199,10 @@ public class TechTree implements ContentList{
node(phaseConduit, () -> { node(phaseConduit, () -> {
}); });
node(platedConduit, () -> {
});
}); });
node(rotaryPump, () -> { node(rotaryPump, () -> {

View File

@@ -237,6 +237,12 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
seeds++; seeds++;
}); });
Draw.color(); Draw.color();
if(liquid.lightColor.a > 0.001f && f > 0){
Color color = liquid.lightColor;
float opacity = color.a * f;
renderer.lights.add(tile.drawx(), tile.drawy(), 30f * f, color, opacity * 0.8f);
}
} }
@Override @Override

View File

@@ -311,13 +311,17 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
loops.play(block.idleSound, this, block.idleSoundVolume); loops.play(block.idleSound, this, block.idleSoundVolume);
} }
Block previous = block;
block.update(tile); block.update(tile);
if(block == previous && cons != null){
if(liquids != null){
liquids.update();
}
if(cons != null){
cons.update(); cons.update();
} }
if(block == previous && power != null){ if(power != null){
power.graph.update(); power.graph.update();
} }
} }

View File

@@ -13,6 +13,7 @@ import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.game.Teams.*; import io.anuke.mindustry.game.Teams.*;
import io.anuke.mindustry.ui.*; import io.anuke.mindustry.ui.*;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.*;
import static io.anuke.arc.Core.camera; import static io.anuke.arc.Core.camera;
import static io.anuke.mindustry.Vars.*; import static io.anuke.mindustry.Vars.*;
@@ -218,7 +219,7 @@ public class BlockRenderer implements Disposable{
addRequest(tile, Layer.block); addRequest(tile, Layer.block);
} }
if(state.rules.lighting){ if(state.rules.lighting && tile.block().synthetic() && !(tile.block() instanceof BlockPart)){
addRequest(tile, Layer.lights); addRequest(tile, Layer.lights);
} }

View File

@@ -150,6 +150,7 @@ public class ContentParser{
"io.anuke.mindustry.world.blocks.defense", "io.anuke.mindustry.world.blocks.defense",
"io.anuke.mindustry.world.blocks.defense.turrets", "io.anuke.mindustry.world.blocks.defense.turrets",
"io.anuke.mindustry.world.blocks.distribution", "io.anuke.mindustry.world.blocks.distribution",
"io.anuke.mindustry.world.blocks.liquid",
"io.anuke.mindustry.world.blocks.logic", "io.anuke.mindustry.world.blocks.logic",
"io.anuke.mindustry.world.blocks.power", "io.anuke.mindustry.world.blocks.power",
"io.anuke.mindustry.world.blocks.production", "io.anuke.mindustry.world.blocks.production",

View File

@@ -13,6 +13,8 @@ public class Liquid extends UnlockableContent{
/** Color used in bars. */ /** Color used in bars. */
public @Nullable Color barColor; public @Nullable Color barColor;
/** Color used to draw lights. Note that the alpha channel is used to dictate brightness. */
public Color lightColor = Color.clear.cpy();
/** 0-1, 0 is completely inflammable, anything above that may catch fire when exposed to heat, 0.5+ is very flammable. */ /** 0-1, 0 is completely inflammable, anything above that may catch fire when exposed to heat, 0.5+ is very flammable. */
public float flammability; public float flammability;
/** temperature: 0.5 is 'room' temperature, 0 is very cold, 1 is molten hot */ /** temperature: 0.5 is 'room' temperature, 0 is very cold, 1 is molten hot */

View File

@@ -89,6 +89,8 @@ public class Block extends BlockStorage{
public boolean configurable; public boolean configurable;
/** Whether this block consumes touchDown events when tapped. */ /** Whether this block consumes touchDown events when tapped. */
public boolean consumesTap; public boolean consumesTap;
/** Whether to draw the glow of the liquid for this block, if it has one. */
public boolean drawLiquidLight = true;
/** Whether the config is positional and needs to be shifted. */ /** Whether the config is positional and needs to be shifted. */
public boolean posConfig; public boolean posConfig;
/** Whether this block uses conveyor-type placement mode.*/ /** Whether this block uses conveyor-type placement mode.*/
@@ -293,7 +295,20 @@ public class Block extends BlockStorage{
} }
public void drawLight(Tile tile){ public void drawLight(Tile tile){
if(hasLiquids && drawLiquidLight && tile.entity.liquids.current().lightColor.a > 0.001f){
drawLiquidLight(tile, tile.entity.liquids.current(), tile.entity.liquids.smoothAmount());
}
}
public void drawLiquidLight(Tile tile, Liquid liquid, float amount){
if(amount > 0.01f){
Color color = liquid.lightColor;
float fract = 1f;
float opacity = color.a * fract;
if(opacity > 0.001f){
renderer.lights.add(tile.drawx(), tile.drawy(), size * 30f * fract, color, opacity);
}
}
} }
public void drawTeam(Tile tile){ public void drawTeam(Tile tile){
@@ -610,7 +625,7 @@ public class Block extends BlockStorage{
if(hasLiquids){ if(hasLiquids){
tile.entity.liquids.forEach((liquid, amount) -> { tile.entity.liquids.each((liquid, amount) -> {
float splash = Mathf.clamp(amount / 4f, 0f, 10f); float splash = Mathf.clamp(amount / 4f, 0f, 10f);
for(int i = 0; i < Mathf.clamp(amount / 5, 0, 30); i++){ for(int i = 0; i < Mathf.clamp(amount / 5, 0, 30); i++){

View File

@@ -116,7 +116,7 @@ public abstract class BlockStorage extends UnlockableContent{
Tile other = proximity.get((i + dump) % proximity.size); Tile other = proximity.get((i + dump) % proximity.size);
Tile in = Edges.getFacingEdge(tile, other); Tile in = Edges.getFacingEdge(tile, other);
other = other.block().getLiquidDestination(other, in); other = other.block().getLiquidDestination(other, in, liquid);
if(other != null && other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.liquids != null){ if(other != null && other.getTeam() == tile.getTeam() && other.block().hasLiquids && canDumpLiquid(tile, other, liquid) && other.entity.liquids != null){
float ofract = other.entity.liquids.get(liquid) / other.block().liquidCapacity; float ofract = other.entity.liquids.get(liquid) / other.block().liquidCapacity;
@@ -142,10 +142,14 @@ public abstract class BlockStorage extends UnlockableContent{
} }
public float tryMoveLiquid(Tile tile, Tile next, boolean leak, Liquid liquid){ public float tryMoveLiquid(Tile tile, Tile next, boolean leak, Liquid liquid){
return tryMoveLiquid(tile, next, leak ? 1.5f : 100, liquid);
}
public float tryMoveLiquid(Tile tile, Tile next, float leakResistance, Liquid liquid){
if(next == null) return 0; if(next == null) return 0;
next = next.link(); next = next.link();
next = next.block().getLiquidDestination(next, tile); next = next.block().getLiquidDestination(next, tile, liquid);
if(next.getTeam() == tile.getTeam() && next.block().hasLiquids && tile.entity.liquids.get(liquid) > 0f){ if(next.getTeam() == tile.getTeam() && next.block().hasLiquids && tile.entity.liquids.get(liquid) > 0f){
@@ -175,15 +179,15 @@ public abstract class BlockStorage extends UnlockableContent{
} }
} }
} }
}else if(leak && !next.block().solid && !next.block().hasLiquids){ }else if(leakResistance != 100f && !next.block().solid && !next.block().hasLiquids){
float leakAmount = tile.entity.liquids.get(liquid) / 1.5f; float leakAmount = tile.entity.liquids.get(liquid) / leakResistance;
Puddle.deposit(next, tile, liquid, leakAmount); Puddle.deposit(next, tile, liquid, leakAmount);
tile.entity.liquids.remove(liquid, leakAmount); tile.entity.liquids.remove(liquid, leakAmount);
} }
return 0; return 0;
} }
public Tile getLiquidDestination(Tile tile, Tile from){ public Tile getLiquidDestination(Tile tile, Tile from, Liquid liquid){
return tile; return tile;
} }

View File

@@ -327,19 +327,19 @@ public class Tile implements Position, TargetTrait{
} }
// ▲ ▲ ▼ ▼ ◀ ▶ ◀ ▶ B A // ▲ ▲ ▼ ▼ ◀ ▶ ◀ ▶ B A
public Tile front(){ public @Nullable Tile front(){
return getNearbyLink((rotation + 4) % 4); return getNearbyLink((rotation + 4) % 4);
} }
public Tile right(){ public @Nullable Tile right(){
return getNearbyLink((rotation + 3) % 4); return getNearbyLink((rotation + 3) % 4);
} }
public Tile back(){ public @Nullable Tile back(){
return getNearbyLink((rotation + 2) % 4); return getNearbyLink((rotation + 2) % 4);
} }
public Tile left(){ public @Nullable Tile left(){
return getNearbyLink((rotation + 1) % 4); return getNearbyLink((rotation + 1) % 4);
} }

View File

@@ -87,6 +87,12 @@ public interface Autotiler{
return other != null && blends(tile, rotation, other.x, other.y, other.rotation(), other.block()); return other != null && blends(tile, rotation, other.x, other.y, other.rotation(), other.block());
} }
default boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
return (Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery)
|| ((!otherblock.rotate && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null &&
Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) || (otherblock.rotate && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y))));
}
default boolean lookingAt(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ default boolean lookingAt(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
return (Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery) return (Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery)
|| (!otherblock.rotate || Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y))); || (!otherblock.rotate || Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y)));

View File

@@ -1,6 +1,5 @@
package io.anuke.mindustry.world.blocks.distribution; package io.anuke.mindustry.world.blocks.distribution;
import io.anuke.arc.math.geom.*;
import io.anuke.mindustry.type.*; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
@@ -16,9 +15,7 @@ public class ArmoredConveyor extends Conveyor{
} }
@Override @Override
public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock) {
return otherblock.outputsItems() && (Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery) return otherblock.outputsItems() && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock);
|| ((!otherblock.rotate && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null &&
Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) || (otherblock.rotate && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y))));
} }
} }

View File

@@ -0,0 +1,45 @@
package io.anuke.mindustry.world.blocks.liquid;
import io.anuke.arc.Core;
import io.anuke.arc.graphics.g2d.Draw;
import io.anuke.arc.graphics.g2d.TextureRegion;
import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Edges;
import io.anuke.mindustry.world.Tile;
public class ArmoredConduit extends Conduit{
protected TextureRegion capRegion;
public ArmoredConduit(String name){
super(name);
leakResistance = 10f;
}
@Override
public void load(){
super.load();
capRegion = Core.atlas.find(name + "-cap");
}
@Override
public void draw(Tile tile){
super.draw(tile);
// draw the cap when a conduit would normally leak
Tile next = tile.front();
if(next != null && next.getTeam() == tile.getTeam() && next.block().hasLiquids) return;
Draw.rect(capRegion, tile.drawx(), tile.drawy(), tile.rotation() * 90);
}
@Override
public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){
return super.acceptLiquid(tile, source, liquid, amount) && (source.block() instanceof Conduit) || Edges.getFacingEdge(source, tile).relativeTo(tile) == tile.rotation();
}
@Override
public boolean blends(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
return otherblock.outputsLiquid && blendsArmored(tile, rotation, otherx, othery, otherrot, otherblock);
}
}

View File

@@ -1,4 +1,4 @@
package io.anuke.mindustry.world.blocks.distribution; package io.anuke.mindustry.world.blocks.liquid;
import io.anuke.arc.*; import io.anuke.arc.*;
import io.anuke.arc.collection.*; import io.anuke.arc.collection.*;
@@ -21,6 +21,8 @@ public class Conduit extends LiquidBlock implements Autotiler{
protected TextureRegion[] topRegions = new TextureRegion[7]; protected TextureRegion[] topRegions = new TextureRegion[7];
protected TextureRegion[] botRegions = new TextureRegion[7]; protected TextureRegion[] botRegions = new TextureRegion[7];
protected float leakResistance = 1.5f;
public Conduit(String name){ public Conduit(String name){
super(name); super(name);
rotate = true; rotate = true;
@@ -109,7 +111,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.liquids.total() / liquidCapacity, 0.05f); entity.smoothLiquid = Mathf.lerpDelta(entity.smoothLiquid, entity.liquids.total() / liquidCapacity, 0.05f);
if(tile.entity.liquids.total() > 0.001f && tile.entity.timer.get(timerFlow, 1)){ if(tile.entity.liquids.total() > 0.001f && tile.entity.timer.get(timerFlow, 1)){
tryMoveLiquid(tile, tile.getNearby(tile.rotation()), true, tile.entity.liquids.current()); tryMoveLiquid(tile, tile.getNearby(tile.rotation()), leakResistance, tile.entity.liquids.current());
entity.noSleep(); entity.noSleep();
}else{ }else{
entity.sleep(); entity.sleep();

View File

@@ -1,9 +1,10 @@
package io.anuke.mindustry.world.blocks.distribution; package io.anuke.mindustry.world.blocks.liquid;
import io.anuke.arc.math.*; import io.anuke.arc.math.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.mindustry.type.*; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.distribution.*;
import io.anuke.mindustry.world.meta.*; import io.anuke.mindustry.world.meta.*;
import static io.anuke.mindustry.Vars.world; import static io.anuke.mindustry.Vars.world;

View File

@@ -1,9 +1,10 @@
package io.anuke.mindustry.world.blocks.distribution; package io.anuke.mindustry.world.blocks.liquid;
import io.anuke.arc.math.*; import io.anuke.arc.math.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.mindustry.type.*; import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.distribution.*;
import io.anuke.mindustry.world.meta.*; import io.anuke.mindustry.world.meta.*;
import static io.anuke.mindustry.Vars.world; import static io.anuke.mindustry.Vars.world;

View File

@@ -1,7 +1,8 @@
package io.anuke.mindustry.world.blocks.distribution; package io.anuke.mindustry.world.blocks.liquid;
import io.anuke.arc.*; import io.anuke.arc.*;
import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.graphics.g2d.*;
import io.anuke.mindustry.type.*;
import io.anuke.mindustry.world.*; import io.anuke.mindustry.world.*;
import io.anuke.mindustry.world.blocks.*; import io.anuke.mindustry.world.blocks.*;
import io.anuke.mindustry.world.meta.*; import io.anuke.mindustry.world.meta.*;
@@ -35,10 +36,13 @@ public class LiquidJunction extends LiquidBlock{
} }
@Override @Override
public Tile getLiquidDestination(Tile tile, Tile source){ public Tile getLiquidDestination(Tile tile, Tile source, Liquid liquid){
int dir = source.relativeTo(tile.x, tile.y); int dir = source.relativeTo(tile.x, tile.y);
dir = (dir + 4) % 4; dir = (dir + 4) % 4;
Tile next = tile.getNearby(dir).link(); Tile next = tile.getNearby(dir).link();
return next.block().getLiquidDestination(next, tile); if(!next.block().acceptLiquid(next, tile, liquid, 0f) && !(next.block() instanceof LiquidJunction)){
return tile;
}
return next.block().getLiquidDestination(next, tile, liquid);
} }
} }

View File

@@ -1,4 +1,4 @@
package io.anuke.mindustry.world.blocks.distribution; package io.anuke.mindustry.world.blocks.liquid;
import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.type.Liquid;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;

View File

@@ -1,4 +1,4 @@
package io.anuke.mindustry.world.blocks.distribution; package io.anuke.mindustry.world.blocks.liquid;
public class LiquidTank extends LiquidRouter{ public class LiquidTank extends LiquidRouter{

View File

@@ -27,7 +27,7 @@ public class PowerDiode extends Block{
public void update(Tile tile){ public void update(Tile tile){
super.update(tile); super.update(tile);
if(!tile.back().block().hasPower || !tile.front().block().hasPower) return; if(tile.front() == null || tile.back() == null || !tile.back().block().hasPower || !tile.front().block().hasPower) return;
PowerGraph backGraph = tile.back().entity.power.graph; PowerGraph backGraph = tile.back().entity.power.graph;
PowerGraph frontGraph = tile.front().entity.power.graph; PowerGraph frontGraph = tile.front().entity.power.graph;

View File

@@ -32,6 +32,13 @@ public class LiquidConverter extends GenericCrafter{
stats.add(BlockStat.output, outputLiquid.liquid, outputLiquid.amount * craftTime, false); stats.add(BlockStat.output, outputLiquid.liquid, outputLiquid.amount * craftTime, false);
} }
@Override
public void drawLight(Tile tile){
if(hasLiquids && drawLiquidLight && outputLiquid.liquid.lightColor.a > 0.001f){
drawLiquidLight(tile, outputLiquid.liquid, tile.entity.liquids.get(outputLiquid.liquid));
}
}
@Override @Override
public void update(Tile tile){ public void update(Tile tile){
GenericCrafterEntity entity = tile.entity(); GenericCrafterEntity entity = tile.entity();

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.world.modules; package io.anuke.mindustry.world.modules;
import io.anuke.arc.math.*;
import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.type.Liquid;
import java.io.*; import java.io.*;
@@ -11,6 +12,15 @@ public class LiquidModule extends BlockModule{
private float[] liquids = new float[content.liquids().size]; private float[] liquids = new float[content.liquids().size];
private float total; private float total;
private Liquid current = content.liquid(0); private Liquid current = content.liquid(0);
private float smoothLiquid;
public void update(){
smoothLiquid = Mathf.lerpDelta(smoothLiquid, currentAmount(), 0.1f);
}
public float smoothAmount(){
return smoothLiquid;
}
/** Returns total amount of liquids. */ /** Returns total amount of liquids. */
public float total(){ public float total(){
@@ -54,7 +64,7 @@ public class LiquidModule extends BlockModule{
add(liquid, -amount); add(liquid, -amount);
} }
public void forEach(LiquidConsumer cons){ public void each(LiquidConsumer cons){
for(int i = 0; i < liquids.length; i++){ for(int i = 0; i < liquids.length; i++){
if(liquids[i] > 0){ if(liquids[i] > 0){
cons.accept(content.liquid(i), liquids[i]); cons.accept(content.liquid(i), liquids[i]);