Added tunnel conveyor, fixed generator bugs
This commit is contained in:
BIN
core/assets-raw/sprites/blocks/conveyortunnel.png
Normal file
BIN
core/assets-raw/sprites/blocks/conveyortunnel.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 229 B |
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
@@ -105,6 +105,9 @@ public class Pathfind{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void findNode(Enemy enemy){
|
void findNode(Enemy enemy){
|
||||||
|
if(enemy.spawn >= Vars.control.getSpawnPoints().size){
|
||||||
|
enemy.spawn = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if(Vars.control.getSpawnPoints().get(enemy.spawn).pathTiles == null){
|
if(Vars.control.getSpawnPoints().get(enemy.spawn).pathTiles == null){
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -26,11 +26,11 @@ public enum Recipe{
|
|||||||
poweredconveyor(distribution, DistributionBlocks.pulseconveyor, stack(Item.dirium, 1)),
|
poweredconveyor(distribution, DistributionBlocks.pulseconveyor, stack(Item.dirium, 1)),
|
||||||
router(distribution, DistributionBlocks.router, stack(Item.stone, 2)),
|
router(distribution, DistributionBlocks.router, stack(Item.stone, 2)),
|
||||||
junction(distribution, DistributionBlocks.junction, stack(Item.iron, 2)),
|
junction(distribution, DistributionBlocks.junction, stack(Item.iron, 2)),
|
||||||
|
tunnel(distribution, DistributionBlocks.tunnel, stack(Item.iron, 2)),
|
||||||
conduit(distribution, DistributionBlocks.conduit, stack(Item.steel, 1)),
|
conduit(distribution, DistributionBlocks.conduit, stack(Item.steel, 1)),
|
||||||
pulseconduit(distribution, DistributionBlocks.pulseconduit, stack(Item.titanium, 1), stack(Item.steel, 1)),
|
pulseconduit(distribution, DistributionBlocks.pulseconduit, stack(Item.titanium, 1), stack(Item.steel, 1)),
|
||||||
liquidrouter(distribution, DistributionBlocks.liquidrouter, stack(Item.steel, 2)),
|
liquidrouter(distribution, DistributionBlocks.liquidrouter, stack(Item.steel, 2)),
|
||||||
liquidjunction(distribution, DistributionBlocks.liquidjunction, stack(Item.steel, 2)),
|
liquidjunction(distribution, DistributionBlocks.liquidjunction, stack(Item.steel, 2)),
|
||||||
liquiditemjunction(distribution, DistributionBlocks.liquiditemjunction, stack(Item.steel, 1), stack(Item.iron, 1)),
|
|
||||||
sorter(distribution, DistributionBlocks.sorter, stack(Item.steel, 2)),
|
sorter(distribution, DistributionBlocks.sorter, stack(Item.steel, 2)),
|
||||||
|
|
||||||
turret(weapon, WeaponBlocks.turret, stack(Item.stone, 4)),
|
turret(weapon, WeaponBlocks.turret, stack(Item.stone, 4)),
|
||||||
|
|||||||
@@ -63,6 +63,12 @@ public class DistributionBlocks{
|
|||||||
+ "two different conveyors carrying different materials to different locations.";
|
+ "two different conveyors carrying different materials to different locations.";
|
||||||
|
|
||||||
}},
|
}},
|
||||||
|
tunnel = new TunnelConveyor("conveyortunnel"){{
|
||||||
|
formalName = "conveyor tunnel";
|
||||||
|
description = "Transports items under blocks.";
|
||||||
|
fullDescription = "Transports item under blocks. "
|
||||||
|
+ "To use, place one tunnel leading into the block to be tunneled under, and one on the other side.";
|
||||||
|
}},
|
||||||
liquidjunction = new LiquidJunction("liquidjunction"){{
|
liquidjunction = new LiquidJunction("liquidjunction"){{
|
||||||
formalName = "liquid junction";
|
formalName = "liquid junction";
|
||||||
description = "Serves as a liquid junction.";
|
description = "Serves as a liquid junction.";
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ public class PowerBooster extends Generator{
|
|||||||
@Override
|
@Override
|
||||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||||
Draw.color("purple");
|
Draw.color("purple");
|
||||||
Draw.dashCircle(x * Vars.tilesize, y * Vars.tilesize, laserRange * Vars.tilesize);
|
Draw.thick(1f);
|
||||||
|
Draw.dashCircle(x * Vars.tilesize, y * Vars.tilesize, powerRange * Vars.tilesize);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks.types.distribution;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.core.Timers;
|
||||||
|
|
||||||
|
public class TunnelConveyor extends Block{
|
||||||
|
|
||||||
|
protected TunnelConveyor(String name) {
|
||||||
|
super(name);
|
||||||
|
rotate = true;
|
||||||
|
update = true;
|
||||||
|
solid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canReplace(Block other){
|
||||||
|
return other instanceof Conveyor || other instanceof Router || other instanceof Junction;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleItem(Item item, Tile tile, Tile source){
|
||||||
|
int dir = source.relativeTo(tile.x, tile.y);
|
||||||
|
Tile to = getOther(tile, dir, 3);
|
||||||
|
Tile inter = getOther(tile, dir, 2);
|
||||||
|
|
||||||
|
Timers.run(25, ()->{
|
||||||
|
if(to == null || to.entity == null) return;
|
||||||
|
to.block().handleItem(item, to, inter);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||||
|
int dir = source.relativeTo(dest.x, dest.y);
|
||||||
|
Tile to = getOther(dest, dir, 3);
|
||||||
|
Tile inter = getOther(dest, dir, 2);
|
||||||
|
return to != null && inter != null && source.getRotation() == (dest.getRotation() + 2)%4 && inter.block() instanceof TunnelConveyor
|
||||||
|
&& (inter.getRotation() + 2) % 4 == dest.getRotation() &&
|
||||||
|
to.block().acceptItem(item, to, inter);
|
||||||
|
}
|
||||||
|
|
||||||
|
Tile getOther(Tile tile, int dir, int amount){
|
||||||
|
for(int i = 0; i < amount; i ++){
|
||||||
|
if(tile == null) return null;
|
||||||
|
tile = tile.getNearby()[dir];
|
||||||
|
}
|
||||||
|
return tile;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,8 @@ import com.badlogic.gdx.math.Vector2;
|
|||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
|
import io.anuke.mindustry.core.GameState;
|
||||||
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.effect.Fx;
|
import io.anuke.mindustry.entities.effect.Fx;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
|
import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
|
||||||
@@ -27,7 +29,7 @@ public class Generator extends PowerBlock{
|
|||||||
public boolean hasLasers = true;
|
public boolean hasLasers = true;
|
||||||
public boolean outputOnly = false;
|
public boolean outputOnly = false;
|
||||||
|
|
||||||
public Generator(String name) {
|
public Generator(String name){
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +177,7 @@ public class Generator extends PowerBlock{
|
|||||||
Draw.tint(Hue.mix(Color.GRAY, Color.WHITE, 0.904f + Mathf.sin(Timers.time(), 1.7f, 0.06f)));
|
Draw.tint(Hue.mix(Color.GRAY, Color.WHITE, 0.904f + Mathf.sin(Timers.time(), 1.7f, 0.06f)));
|
||||||
}else{
|
}else{
|
||||||
Draw.tint(Hue.mix(Color.SCARLET, Color.WHITE, 0.902f + Mathf.sin(Timers.time(), 1.7f, 0.08f)));
|
Draw.tint(Hue.mix(Color.SCARLET, Color.WHITE, 0.902f + Mathf.sin(Timers.time(), 1.7f, 0.08f)));
|
||||||
if(Mathf.chance(Timers.delta() * 0.033)){
|
if(GameState.is(State.playing) && Mathf.chance(Timers.delta() * 0.033)){
|
||||||
Effects.effect(Fx.laserspark, target.worldx() - Tmp.v1.x, target.worldy() - Tmp.v1.y);
|
Effects.effect(Fx.laserspark, target.worldx() - Tmp.v1.x, target.worldy() - Tmp.v1.y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -192,6 +194,13 @@ public class Generator extends PowerBlock{
|
|||||||
if(target.block() instanceof Generator){
|
if(target.block() instanceof Generator){
|
||||||
Generator other = (Generator) target.block();
|
Generator other = (Generator) target.block();
|
||||||
int relrot = (rotation + 2) % 4;
|
int relrot = (rotation + 2) % 4;
|
||||||
|
if(other.hasLasers){
|
||||||
|
for(int i = 0; i < other.laserDirections; i ++){
|
||||||
|
if(target.getRotation() + i - other.laserDirections/2 == (target.getRotation() + 2) % 4){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if(other.hasLasers && Math.abs(target.getRotation() - relrot) <= other.laserDirections / 2){
|
if(other.hasLasers && Math.abs(target.getRotation() - relrot) <= other.laserDirections / 2){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user