1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-11 14:56:10 +03:00

Added tunnel conveyor, fixed generator bugs

This commit is contained in:
Anuken 2017-12-03 20:27:50 -05:00
parent 8481a3a5f3
commit dbb6673752
12 changed files with 211 additions and 133 deletions

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

View File

@ -105,6 +105,9 @@ public class Pathfind{
}
void findNode(Enemy enemy){
if(enemy.spawn >= Vars.control.getSpawnPoints().size){
enemy.spawn = 0;
}
if(Vars.control.getSpawnPoints().get(enemy.spawn).pathTiles == null){
return;

View File

@ -26,11 +26,11 @@ public enum Recipe{
poweredconveyor(distribution, DistributionBlocks.pulseconveyor, stack(Item.dirium, 1)),
router(distribution, DistributionBlocks.router, stack(Item.stone, 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)),
pulseconduit(distribution, DistributionBlocks.pulseconduit, stack(Item.titanium, 1), stack(Item.steel, 1)),
liquidrouter(distribution, DistributionBlocks.liquidrouter, 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)),
turret(weapon, WeaponBlocks.turret, stack(Item.stone, 4)),

View File

@ -63,6 +63,12 @@ public class DistributionBlocks{
+ "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"){{
formalName = "liquid junction";
description = "Serves as a liquid junction.";

View File

@ -32,7 +32,8 @@ public class PowerBooster extends Generator{
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
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();
}

View File

@ -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;
}
}

View File

@ -6,6 +6,8 @@ import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
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.world.Tile;
import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
@ -27,7 +29,7 @@ public class Generator extends PowerBlock{
public boolean hasLasers = true;
public boolean outputOnly = false;
public Generator(String name) {
public Generator(String 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)));
}else{
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);
}
}
@ -192,6 +194,13 @@ public class Generator extends PowerBlock{
if(target.block() instanceof Generator){
Generator other = (Generator) target.block();
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){
return true;
}

Binary file not shown.

Binary file not shown.