merge
This commit is contained in:
@@ -175,7 +175,6 @@ public class MapEditor{
|
|||||||
|
|
||||||
world.setBlock(tile(x, y), drawBlock, drawTeam);
|
world.setBlock(tile(x, y), drawBlock, drawTeam);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
|
boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air;
|
||||||
|
|
||||||
Consumer<Tile> drawer = tile -> {
|
Consumer<Tile> drawer = tile -> {
|
||||||
|
|||||||
@@ -16,8 +16,12 @@ public class Drawf{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void circles(float x, float y, float rad){
|
||||||
|
circles(x, y, rad, Pal.accent);
|
||||||
|
}
|
||||||
|
|
||||||
public static void circles(float x, float y, float rad, Color color){
|
public static void circles(float x, float y, float rad, Color color){
|
||||||
int vertices = 30;
|
int vertices = (int)(rad * 2);
|
||||||
Lines.stroke(3f, Pal.gray);
|
Lines.stroke(3f, Pal.gray);
|
||||||
Lines.poly(x, y, vertices, rad);
|
Lines.poly(x, y, vertices, rad);
|
||||||
Lines.stroke(1f, color);
|
Lines.stroke(1f, color);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import io.anuke.arc.graphics.*;
|
|||||||
import io.anuke.arc.graphics.g2d.*;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
import io.anuke.arc.graphics.g2d.TextureAtlas.*;
|
import io.anuke.arc.graphics.g2d.TextureAtlas.*;
|
||||||
import io.anuke.arc.math.*;
|
import io.anuke.arc.math.*;
|
||||||
|
import io.anuke.arc.math.geom.*;
|
||||||
import io.anuke.arc.scene.ui.layout.*;
|
import io.anuke.arc.scene.ui.layout.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.pooling.*;
|
import io.anuke.arc.util.pooling.*;
|
||||||
@@ -27,6 +28,7 @@ import io.anuke.mindustry.input.InputHandler.*;
|
|||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.ui.*;
|
import io.anuke.mindustry.ui.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
|
import io.anuke.mindustry.world.blocks.power.*;
|
||||||
import io.anuke.mindustry.world.consumers.*;
|
import io.anuke.mindustry.world.consumers.*;
|
||||||
import io.anuke.mindustry.world.meta.*;
|
import io.anuke.mindustry.world.meta.*;
|
||||||
|
|
||||||
@@ -266,7 +268,27 @@ public class Block extends BlockStorage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Called after the block is placed by this client. */
|
/** Called after the block is placed by this client. */
|
||||||
|
@CallSuper
|
||||||
public void playerPlaced(Tile tile){
|
public void playerPlaced(Tile tile){
|
||||||
|
|
||||||
|
if(consumesPower && !outputsPower){
|
||||||
|
int range = 10;
|
||||||
|
tempTiles.clear();
|
||||||
|
Geometry.circle(tile.x, tile.y, range, (x, y) -> {
|
||||||
|
Tile other = world.tile(x, y);
|
||||||
|
if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, tile)){
|
||||||
|
tempTiles.add(other);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile)));
|
||||||
|
if(!tempTiles.isEmpty()){
|
||||||
|
Call.linkPowerNodes(null, tempTiles.first(), tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(outputsPower && !consumesPower){
|
||||||
|
PowerNode.lastPlaced = tile.pos();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removed(Tile tile){
|
public void removed(Tile tile){
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import static io.anuke.mindustry.Vars.world;
|
|||||||
|
|
||||||
public class PowerNode extends PowerBlock{
|
public class PowerNode extends PowerBlock{
|
||||||
//last distribution block placed
|
//last distribution block placed
|
||||||
private static int lastPlaced = -1;
|
public static int lastPlaced = -1;
|
||||||
|
|
||||||
protected Vector2 t1 = new Vector2(), t2 = new Vector2();
|
protected Vector2 t1 = new Vector2(), t2 = new Vector2();
|
||||||
protected TextureRegion laser, laserEnd;
|
protected TextureRegion laser, laserEnd;
|
||||||
@@ -106,17 +106,13 @@ public class PowerNode extends PowerBlock{
|
|||||||
@Override
|
@Override
|
||||||
public void playerPlaced(Tile tile){
|
public void playerPlaced(Tile tile){
|
||||||
Tile before = world.tile(lastPlaced);
|
Tile before = world.tile(lastPlaced);
|
||||||
if(linkValid(tile, before) && before.block() instanceof PowerNode){
|
|
||||||
for(Tile near : before.entity.proximity()){
|
if(linkValid(tile, before) && !before.entity.proximity().contains(tile)){
|
||||||
if(near == tile){
|
|
||||||
lastPlaced = tile.pos();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Call.linkPowerNodes(null, tile, before);
|
Call.linkPowerNodes(null, tile, before);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastPlaced = tile.pos();
|
lastPlaced = tile.pos();
|
||||||
|
super.playerPlaced(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -170,7 +166,9 @@ public class PowerNode extends PowerBlock{
|
|||||||
Lines.circle(tile.drawx(), tile.drawy(),
|
Lines.circle(tile.drawx(), tile.drawy(),
|
||||||
tile.block().size * tilesize / 2f + 1f + Mathf.absin(Time.time(), 4f, 1f));
|
tile.block().size * tilesize / 2f + 1f + Mathf.absin(Time.time(), 4f, 1f));
|
||||||
|
|
||||||
Lines.poly(tile.drawx(), tile.drawy(), 50, laserRange * tilesize);
|
Drawf.circles(tile.drawx(), tile.drawy(), laserRange * tilesize);
|
||||||
|
|
||||||
|
Lines.stroke(1.5f);
|
||||||
|
|
||||||
for(int x = (int)(tile.x - laserRange - 1); x <= tile.x + laserRange + 1; x++){
|
for(int x = (int)(tile.x - laserRange - 1); x <= tile.x + laserRange + 1; x++){
|
||||||
for(int y = (int)(tile.y - laserRange - 1); y <= tile.y + laserRange + 1; y++){
|
for(int y = (int)(tile.y - laserRange - 1); y <= tile.y + laserRange + 1; y++){
|
||||||
@@ -199,7 +197,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||||
Lines.stroke(1f);
|
Lines.stroke(1f);
|
||||||
Draw.color(Pal.placing);
|
Draw.color(Pal.placing);
|
||||||
Lines.poly(x * tilesize + offset(), y * tilesize + offset(), 50, laserRange * tilesize);
|
Drawf.circles(x * tilesize + offset(), y * tilesize + offset(), laserRange * tilesize);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,11 +221,11 @@ public class PowerNode extends PowerBlock{
|
|||||||
return tile.entity.power.links.contains(other.pos());
|
return tile.entity.power.links.contains(other.pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean linkValid(Tile tile, Tile link){
|
public boolean linkValid(Tile tile, Tile link){
|
||||||
return linkValid(tile, link, true);
|
return linkValid(tile, link, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean linkValid(Tile tile, Tile link, boolean checkMaxNodes){
|
public boolean linkValid(Tile tile, Tile link, boolean checkMaxNodes){
|
||||||
if(tile == link || link == null || !link.block().hasPower || tile.getTeam() != link.getTeam()) return false;
|
if(tile == link || link == null || !link.block().hasPower || tile.getTeam() != link.getTeam()) return false;
|
||||||
|
|
||||||
if(overlaps(tile, link, laserRange * tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, link.<PowerNode>cblock().laserRange * tilesize))){
|
if(overlaps(tile, link, laserRange * tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, link.<PowerNode>cblock().laserRange * tilesize))){
|
||||||
|
|||||||
@@ -211,8 +211,10 @@ public class Drill extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
itemArray.sort((item1, item2) -> {
|
itemArray.sort((item1, item2) -> {
|
||||||
int type = Boolean.compare(item1.type == ItemType.material, item2.type == ItemType.material);
|
int type = Boolean.compare(item1 != Items.sand, item2 != Items.sand);
|
||||||
if(type != 0) return type;
|
if(type != 0) return type;
|
||||||
|
int amounts = Integer.compare(oreCount.get(item1, 0), oreCount.get(item2, 0));
|
||||||
|
if(amounts != 0) return amounts;
|
||||||
return Integer.compare(item1.id, item2.id);
|
return Integer.compare(item1.id, item2.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ import io.anuke.mindustry.gen.Call;
|
|||||||
import io.anuke.mindustry.graphics.Pal;
|
import io.anuke.mindustry.graphics.Pal;
|
||||||
import io.anuke.mindustry.graphics.Shaders;
|
import io.anuke.mindustry.graphics.Shaders;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.type.ItemType;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class CoreBlock extends StorageBlock{
|
public class CoreBlock extends StorageBlock{
|
||||||
|
protected Mech mech = Mechs.starter;
|
||||||
|
|
||||||
public CoreBlock(String name){
|
public CoreBlock(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -40,10 +40,10 @@ public class CoreBlock extends StorageBlock{
|
|||||||
CoreEntity entity = tile.entity();
|
CoreEntity entity = tile.entity();
|
||||||
Effects.effect(Fx.spawn, entity);
|
Effects.effect(Fx.spawn, entity);
|
||||||
entity.progress = 0;
|
entity.progress = 0;
|
||||||
entity.currentUnit = player;
|
entity.spawnPlayer = player;
|
||||||
entity.currentUnit.onRespawn(tile);
|
entity.spawnPlayer.onRespawn(tile);
|
||||||
entity.currentUnit.applyImpulse(0, 8f);
|
entity.spawnPlayer.applyImpulse(0, 8f);
|
||||||
entity.currentUnit = null;
|
entity.spawnPlayer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -94,8 +94,8 @@ public class CoreBlock extends StorageBlock{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entity.currentUnit != null){
|
if(entity.spawnPlayer != null){
|
||||||
Unit player = entity.currentUnit;
|
Unit player = entity.spawnPlayer;
|
||||||
|
|
||||||
TextureRegion region = player.getIconRegion();
|
TextureRegion region = player.getIconRegion();
|
||||||
|
|
||||||
@@ -129,19 +129,19 @@ public class CoreBlock extends StorageBlock{
|
|||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
CoreEntity entity = tile.entity();
|
CoreEntity entity = tile.entity();
|
||||||
|
|
||||||
if(entity.currentUnit != null){
|
if(entity.spawnPlayer != null){
|
||||||
if(!entity.currentUnit.isDead() || !entity.currentUnit.isAdded()){
|
if(!entity.spawnPlayer.isDead() || !entity.spawnPlayer.isAdded()){
|
||||||
entity.currentUnit = null;
|
entity.spawnPlayer = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.currentUnit.set(tile.drawx(), tile.drawy());
|
entity.spawnPlayer.set(tile.drawx(), tile.drawy());
|
||||||
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f);
|
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f);
|
||||||
entity.time += entity.delta();
|
entity.time += entity.delta();
|
||||||
entity.progress += 1f / state.rules.respawnTime * entity.delta();
|
entity.progress += 1f / state.rules.respawnTime * entity.delta();
|
||||||
|
|
||||||
if(entity.progress >= 1f){
|
if(entity.progress >= 1f){
|
||||||
Call.onUnitRespawn(tile, entity.currentUnit);
|
Call.onUnitRespawn(tile, entity.spawnPlayer);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.1f);
|
entity.heat = Mathf.lerpDelta(entity.heat, 0f, 0.1f);
|
||||||
@@ -154,17 +154,17 @@ public class CoreBlock extends StorageBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class CoreEntity extends TileEntity implements SpawnerTrait{
|
public class CoreEntity extends TileEntity implements SpawnerTrait{
|
||||||
public Player currentUnit;
|
public Player spawnPlayer;
|
||||||
float progress;
|
float progress;
|
||||||
float time;
|
float time;
|
||||||
float heat;
|
float heat;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateSpawning(Player player){
|
public void updateSpawning(Player player){
|
||||||
if(!netServer.isWaitingForPlayers() && currentUnit == null){
|
if(!netServer.isWaitingForPlayers() && spawnPlayer == null){
|
||||||
currentUnit = player;
|
spawnPlayer = player;
|
||||||
progress = 0f;
|
progress = 0f;
|
||||||
player.mech = Mechs.starter;
|
player.mech = mech;
|
||||||
player.beginRespawning(this);
|
player.beginRespawning(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user