diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 1ac28ece7a..25704f57f4 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -34,6 +34,8 @@ public class Vars{ public static final float wavespace = 60 * 60 * 1.5f; //set ridiculously high for now public static final float coreBuildRange = 800999f; + + public static final float enemyCoreBuildRange = 400f; //discord group URL public static final String discordURL = "https://discord.gg/BKADYds"; public static final String releasesURL = "https://api.github.com/repos/Anuken/Mindustry/releases"; diff --git a/core/src/io/anuke/mindustry/ai/BlockIndexer.java b/core/src/io/anuke/mindustry/ai/BlockIndexer.java index ae21cd4e13..ba0bd7a31d 100644 --- a/core/src/io/anuke/mindustry/ai/BlockIndexer.java +++ b/core/src/io/anuke/mindustry/ai/BlockIndexer.java @@ -142,7 +142,7 @@ public class BlockIndexer{ for(int ty = ry * structQuadrantSize; ty < (ry + 1) * structQuadrantSize && ty < world.height(); ty++){ Tile other = world.tile(tx, ty); - if(other == null || other.entity == null || !pred.test(other)) continue; + if(other == null || other.entity == null || other.getTeam() != team || !pred.test(other)) continue; TileEntity e = other.entity; diff --git a/core/src/io/anuke/mindustry/entities/Predict.java b/core/src/io/anuke/mindustry/entities/Predict.java index 06f86b540c..ec3385a852 100644 --- a/core/src/io/anuke/mindustry/entities/Predict.java +++ b/core/src/io/anuke/mindustry/entities/Predict.java @@ -53,6 +53,9 @@ public class Predict{ * See {@link #intercept(float, float, float, float, float, float, float)}. */ public static Vector2 intercept(TargetTrait src, TargetTrait dst, float v){ + if(vec.set(dst.getVelocity().sub(src.getVelocity())).isZero()){ + return vresult.set(dst.getX(), dst.getY()); + } return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), dst.getVelocity().x - src.getVelocity().x, dst.getVelocity().x - src.getVelocity().y, v); } diff --git a/core/src/io/anuke/mindustry/entities/Units.java b/core/src/io/anuke/mindustry/entities/Units.java index 1b9fcb27f2..7afd5b28b6 100644 --- a/core/src/io/anuke/mindustry/entities/Units.java +++ b/core/src/io/anuke/mindustry/entities/Units.java @@ -147,11 +147,14 @@ public class Units{ } } - /** - * Returns the closest target enemy. First, units are checked, then tile entities. - */ + /**Returns the closest target enemy. First, units are checked, then tile entities.*/ public static TargetTrait getClosestTarget(Team team, float x, float y, float range){ - Unit unit = getClosestEnemy(team, x, y, range, u -> true); + return getClosestTarget(team, x, y, range, u -> true); + } + + /**Returns the closest target enemy. First, units are checked, then tile entities.*/ + public static TargetTrait getClosestTarget(Team team, float x, float y, float range, Predicate unitPred){ + Unit unit = getClosestEnemy(team, x, y, range, unitPred); if(unit != null){ return unit; }else{ diff --git a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java index 2b8d7afd71..ba3942d9b4 100644 --- a/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/OverlayRenderer.java @@ -24,6 +24,7 @@ import io.anuke.ucore.util.Mathf; import static io.anuke.mindustry.Vars.*; public class OverlayRenderer{ + private float buildFadeTime; public void drawBottom(){ for(Player player : players){ @@ -58,6 +59,24 @@ public class OverlayRenderer{ input.drawTop(); + buildFadeTime = Mathf.lerpDelta(buildFadeTime, input.isPlacing() ? 1f : 0f, 0.06f); + + Draw.reset(); + Lines.stroke(buildFadeTime*2f); + + if(buildFadeTime > 0.005f){ + for(TeamData data : state.teams.enemyDataOf(player.getTeam())){ + for(Tile core : data.cores){ + float dst = Vector2.dst(player.x, player.y, core.drawx(), core.drawy()); + if(dst < enemyCoreBuildRange * 1.5f){ + Draw.color(Color.DARK_GRAY); + Lines.poly(core.drawx(), core.drawy() - 2, 200, enemyCoreBuildRange); + Draw.color(Palette.accent, data.team.color, 0.5f + Mathf.absin(Timers.time(), 10f, 0.5f)); + Lines.poly(core.drawx(), core.drawy(), 200, enemyCoreBuildRange); + } + } + } + } Draw.reset(); //draw selected block bars and info diff --git a/core/src/io/anuke/mindustry/maps/generation/WorldGenerator.java b/core/src/io/anuke/mindustry/maps/generation/WorldGenerator.java index 854cbfb90c..5a5b379141 100644 --- a/core/src/io/anuke/mindustry/maps/generation/WorldGenerator.java +++ b/core/src/io/anuke/mindustry/maps/generation/WorldGenerator.java @@ -242,7 +242,7 @@ public class WorldGenerator{ int x = sectorX * sectorSize + localX + Short.MAX_VALUE; int y = sectorY * sectorSize + localY + Short.MAX_VALUE; - Block floor = Blocks.stone; + Block floor; Block wall = Blocks.air; double ridge = rid.getValue(x, y, 1f / 400f); @@ -285,6 +285,8 @@ public class WorldGenerator{ } }else if(minDst > lerpDst/1.5f){ floor = Blocks.lava; + }else{ + floor = Blocks.blackstone; } if(temp < 0.6f){ diff --git a/core/src/io/anuke/mindustry/world/Build.java b/core/src/io/anuke/mindustry/world/Build.java index 6b0f226cac..a08e0ae067 100644 --- a/core/src/io/anuke/mindustry/world/Build.java +++ b/core/src/io/anuke/mindustry/world/Build.java @@ -1,10 +1,12 @@ package io.anuke.mindustry.world; import com.badlogic.gdx.math.Rectangle; +import com.badlogic.gdx.math.Vector2; import io.anuke.mindustry.content.blocks.Blocks; import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.game.EventType.BlockBuildEvent; import io.anuke.mindustry.game.Team; +import io.anuke.mindustry.game.TeamInfo.TeamData; import io.anuke.mindustry.type.Recipe; import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity; import io.anuke.ucore.core.Events; @@ -135,6 +137,15 @@ public class Build{ } } + //check for enemy cores + for(TeamData data : state.teams.enemyDataOf(team)){ + for(Tile core : data.cores){ + if(Vector2.dst(x*tilesize + type.offset(), y*tilesize + type.offset(), core.drawx(), core.drawy()) < enemyCoreBuildRange + type.size*tilesize/2f){ + return false; + } + } + } + Tile tile = world.tile(x, y); if(tile == null) return false; diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java index 2fc3ffe9b7..edff051533 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java @@ -7,10 +7,10 @@ import com.badlogic.gdx.utils.Array; import io.anuke.mindustry.content.fx.Fx; import io.anuke.mindustry.entities.Predict; import io.anuke.mindustry.entities.TileEntity; -import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.entities.Units; import io.anuke.mindustry.entities.bullet.Bullet; import io.anuke.mindustry.entities.bullet.BulletType; +import io.anuke.mindustry.entities.traits.TargetTrait; import io.anuke.mindustry.graphics.Layer; import io.anuke.mindustry.graphics.Palette; import io.anuke.mindustry.type.AmmoEntry; @@ -37,7 +37,7 @@ import java.io.IOException; import static io.anuke.mindustry.Vars.tilesize; public abstract class Turret extends Block{ - protected static final int targetInterval = 15; + protected static final int targetInterval = 20; protected final int timerTarget = timers++; @@ -188,11 +188,11 @@ public abstract class Turret extends Block{ if(hasAmmo(tile)){ if(entity.timer.get(timerTarget, targetInterval)){ - entity.target = Units.getClosestEnemy(tile.getTeam(), + entity.target = Units.getClosestTarget(tile.getTeam(), tile.drawx(), tile.drawy(), range, e -> !e.isDead() && (!e.isFlying() || targetAir)); } - if(entity.target != null){ + if(!Units.invalidateTarget(entity.target, tile.getTeam(), tile.drawx(), tile.drawy())){ AmmoType type = peekAmmo(tile); float speed = type.bullet.speed; if(speed < 0.1f) speed = 9999999f; @@ -322,7 +322,7 @@ public abstract class Turret extends Block{ public float recoil = 0f; public float heat; public int shots; - public Unit target; + public TargetTrait target; @Override public void write(DataOutputStream stream) throws IOException{