Slight entity optimizations / Turret sprite fixes
This commit is contained in:
@@ -12,7 +12,7 @@ import io.anuke.mindustry.entities.traits.SolidTrait;
|
||||
|
||||
public class EntityCollisions{
|
||||
//range for tile collision scanning
|
||||
private static final int r = 2;
|
||||
private static final int r = 1;
|
||||
//move in 1-unit chunks
|
||||
private static final float seg = 1f;
|
||||
|
||||
|
||||
@@ -241,7 +241,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
}else{
|
||||
tile.airWeight -= dec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,7 @@ package io.anuke.mindustry.world;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.function.Consumer;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Geometry;
|
||||
import io.anuke.arc.math.geom.Point2;
|
||||
import io.anuke.arc.math.geom.Position;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.math.geom.*;
|
||||
import io.anuke.arc.util.Pack;
|
||||
import io.anuke.mindustry.content.Blocks;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
@@ -142,6 +139,11 @@ public class Tile implements Position, TargetTrait{
|
||||
return wall;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Block> T cblock(){
|
||||
return (T)wall;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Team getTeam(){
|
||||
return Team.all[target().team];
|
||||
@@ -327,6 +329,10 @@ public class Tile implements Position, TargetTrait{
|
||||
return link == null ? this : link;
|
||||
}
|
||||
|
||||
public Rectangle getHitbox(Rectangle rect){
|
||||
return rect.setSize(block().size * tilesize).setCenter(drawx(), drawy());
|
||||
}
|
||||
|
||||
public Tile getNearby(Point2 relative){
|
||||
return world.tile(x + relative.x, y + relative.y);
|
||||
}
|
||||
|
||||
@@ -8,9 +8,11 @@ import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.Lines;
|
||||
import io.anuke.arc.math.Angles;
|
||||
import io.anuke.arc.math.Mathf;
|
||||
import io.anuke.arc.math.geom.Intersector;
|
||||
import io.anuke.arc.math.geom.Vector2;
|
||||
import io.anuke.arc.util.Strings;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.arc.util.Tmp;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.mindustry.entities.type.TileEntity;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
@@ -224,19 +226,19 @@ public class PowerNode extends PowerBlock{
|
||||
}
|
||||
|
||||
protected boolean linkValid(Tile tile, Tile link, boolean checkMaxNodes){
|
||||
if(!(tile != link && link != null && link.block().hasPower) || tile.getTeamID() != link.getTeamID()) return false;
|
||||
if(tile == link || link == null || !link.block().hasPower || tile.getTeam() != link.getTeam()) return false;
|
||||
|
||||
if(link.block() instanceof PowerNode){
|
||||
TileEntity oe = link.entity();
|
||||
|
||||
return Mathf.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy()) <= Math.max(laserRange * tilesize,
|
||||
((PowerNode) link.block()).laserRange * tilesize)
|
||||
+ (link.block().size - 1) * tilesize / 2f + (tile.block().size - 1) * tilesize / 2f &&
|
||||
(!checkMaxNodes || (oe.power.links.size < ((PowerNode) link.block()).maxNodes || oe.power.links.contains(tile.pos())));
|
||||
}else{
|
||||
return Mathf.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy())
|
||||
<= laserRange * tilesize + (link.block().size - 1) * tilesize;
|
||||
if(overlaps(tile, link, laserRange*tilesize) || (link.block() instanceof PowerNode && overlaps(link, tile, link.<PowerNode>cblock().laserRange*tilesize))){
|
||||
if(checkMaxNodes && link.block() instanceof PowerNode){
|
||||
return link.entity.power.links.size < link.<PowerNode>cblock().maxNodes || link.entity.power.links.contains(tile.pos());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean overlaps(Tile src, Tile other, float range){
|
||||
return Intersector.overlaps(Tmp.cr1.set(src.drawx(), src.drawy(), range), other.getHitbox(Tmp.r1));
|
||||
}
|
||||
|
||||
protected void drawLaser(Tile tile, Tile target){
|
||||
|
||||
Reference in New Issue
Block a user