Simple enemy rebuilding AI + fleeing
This commit is contained in:
@@ -457,6 +457,23 @@ public class Units{
|
||||
nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons);
|
||||
}
|
||||
|
||||
/** @return whether there is an enemy in this rectangle. */
|
||||
public static boolean nearEnemy(Team team, float x, float y, float width, float height){
|
||||
Seq<TeamData> data = state.teams.present;
|
||||
for(int i = 0; i < data.size; i++){
|
||||
var other = data.items[i];
|
||||
if(other.team != team){
|
||||
if(other.tree().any(x, y, width, height)){
|
||||
return true;
|
||||
}
|
||||
if(other.turrets != null && other.turrets.any(x, y, width, height)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public interface Sortf{
|
||||
float cost(Unit unit, float x, float y);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ package mindustry.entities.units;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ai.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.Teams.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
Reference in New Issue
Block a user