Added liquid bridge conduits

This commit is contained in:
Anuken
2018-04-11 21:39:54 -04:00
parent 2c769cad0b
commit a3a1e6d3a9
15 changed files with 337 additions and 249 deletions

View File

@@ -109,6 +109,7 @@ public class Recipes {
new Recipe(liquid, LiquidBlocks.liquidtank, stack(Items.steel, 2)),
new Recipe(liquid, LiquidBlocks.liquidjunction, stack(Items.steel, 2)),
new Recipe(liquid, LiquidBlocks.bridgeconduit, stack(Items.titanium, 2), stack(Items.steel, 2)),
new Recipe(liquid, LiquidBlocks.laserconduit, stack(Items.titanium, 2), stack(Items.steel, 2)),
new Recipe(liquid, LiquidBlocks.pump, stack(Items.steel, 10)),
new Recipe(liquid, LiquidBlocks.fluxpump, stack(Items.steel, 10), stack(Items.densealloy, 5)),

View File

@@ -36,8 +36,9 @@ public class LiquidBlocks {
liquidjunction = new LiquidJunction("liquidjunction"),
bridgeconduit = new LiquidBridge("bridgeconduit"){{
bridgeconduit = new LiquidExtendingBridge("bridgeconduit"){{
range = 3;
hasPower = false;
}},
laserconduit = new LiquidBridge("laserconduit"){{

View File

@@ -4,20 +4,13 @@ import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.ItemBuffer;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.graphics.CapStyle;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Mathf;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.world;
public class BufferedItemBridge extends ItemBridge {
public class BufferedItemBridge extends ExtendingItemBridge {
protected int timerAccept = timers ++;
protected float speed = 40f;
@@ -46,47 +39,6 @@ public class BufferedItemBridge extends ItemBridge {
}
}
@Override
public void drawLayer(Tile tile) {
BufferedItemBridgeEntity entity = tile.entity();
Tile other = world.tile(entity.link);
if(!linkValid(tile, other)) return;
int i = tile.absoluteRelativeTo(other.x, other.y);
float ex = other.worldx() - tile.worldx(),
ey = other.worldy() - tile.worldy();
ex *= entity.uptime;
ey *= entity.uptime;
Lines.stroke(8f);
Lines.line(Draw.region(name + "-bridge"),
tile.worldx(),
tile.worldy(),
tile.worldx() + ex,
tile.worldy() + ey, CapStyle.none, -tilesize/2f);
Draw.rect(name + "-end", tile.drawx(), tile.drawy(), i*90 + 90);
Draw.rect(name + "-end", tile.worldx() + ex, tile.worldy() + ey, i*90 + 270);
int dist = Math.max(Math.abs(other.x - tile.x), Math.abs(other.y - tile.y));
int arrows = (dist)*tilesize/6-1;
Draw.color();
for(int a = 0; a < arrows; a ++){
Draw.alpha(Mathf.absin(a/(float)arrows - entity.time/100f, 0.1f, 1f) * entity.uptime);
Draw.rect(name + "-arrow",
tile.worldx() + Geometry.d4[i].x*(tilesize/2f + a*6f + 2) * entity.uptime,
tile.worldy() + Geometry.d4[i].y*(tilesize/2f + a*6f + 2) * entity.uptime,
i*90f);
}
Draw.reset();
}
@Override
public TileEntity getEntity() {
return new BufferedItemBridgeEntity();

View File

@@ -0,0 +1,61 @@
package io.anuke.mindustry.world.blocks.types.distribution;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.graphics.CapStyle;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.world;
public class ExtendingItemBridge extends ItemBridge {
public ExtendingItemBridge(String name) {
super(name);
}
@Override
public void drawLayer(Tile tile) {
ItemBridgeEntity entity = tile.entity();
Tile other = world.tile(entity.link);
if(!linkValid(tile, other)) return;
int i = tile.absoluteRelativeTo(other.x, other.y);
float ex = other.worldx() - tile.worldx() - Geometry.d4[i].x*tilesize/2f,
ey = other.worldy() - tile.worldy() - Geometry.d4[i].y*tilesize/2f;
ex *= entity.uptime;
ey *= entity.uptime;
Lines.stroke(8f);
Lines.line(Draw.region(name + "-bridge"),
tile.worldx() + Geometry.d4[i].x*tilesize/2f,
tile.worldy() + Geometry.d4[i].y*tilesize/2f,
tile.worldx() + ex,
tile.worldy() + ey, CapStyle.none, 0f);
Draw.rect(name + "-end", tile.drawx(), tile.drawy(), i*90 + 90);
Draw.rect(name + "-end",
tile.worldx() + ex + Geometry.d4[i].x*tilesize/2f,
tile.worldy() + ey + Geometry.d4[i].y*tilesize/2f, i*90 + 270);
int dist = Math.max(Math.abs(other.x - tile.x), Math.abs(other.y - tile.y));
int arrows = (dist)*tilesize/6-1;
Draw.color();
for(int a = 0; a < arrows; a ++){
Draw.alpha(Mathf.absin(a/(float)arrows - entity.time/100f, 0.1f, 1f) * entity.uptime);
Draw.rect(name + "-arrow",
tile.worldx() + Geometry.d4[i].x*(tilesize/2f + a*6f + 2) * entity.uptime,
tile.worldy() + Geometry.d4[i].y*(tilesize/2f + a*6f + 2) * entity.uptime,
i*90f);
}
Draw.reset();
}
}

View File

@@ -8,7 +8,6 @@ import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.world;
public class LiquidBridge extends ItemBridge {
protected float transportSpeed = 0.5f;
public LiquidBridge(String name) {
super(name);

View File

@@ -0,0 +1,53 @@
package io.anuke.mindustry.world.blocks.types.distribution;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.world;
public class LiquidExtendingBridge extends ExtendingItemBridge {
public LiquidExtendingBridge(String name) {
super(name);
hasInventory = false;
hasLiquids = true;
}
@Override
public void update(Tile tile) {
ItemBridgeEntity entity = tile.entity();
entity.time += entity.cycleSpeed* Timers.delta();
entity.time2 += (entity.cycleSpeed-1f)*Timers.delta();
Tile other = world.tile(entity.link);
if(!linkValid(tile, other)){
tryDumpLiquid(tile);
}else{
float use = Math.min(powerCapacity, powerUse * Timers.delta());
if(!hasPower || entity.power.amount >= use){
entity.uptime = Mathf.lerpDelta(entity.uptime, 1f, 0.04f);
if(hasPower) entity.power.amount -= use;
}else{
entity.uptime = Mathf.lerpDelta(entity.uptime, 0f, 0.02f);
}
if(entity.uptime >= 0.5f){
if(tryMoveLiquid(tile, other) > 0.1f){
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 4f, 0.05f);
}else{
entity.cycleSpeed = Mathf.lerpDelta(entity.cycleSpeed, 1f, 0.01f);
}
}
}
}
@Override
public boolean acceptItem(Item item, Tile tile, Tile source) {
return false;
}
}