mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-20 09:17:19 +07:00
Make closestEnemyCore find the actual closest core (#6676)
* Make closestEnemyCore find the actual closest core this function should return the closest core of all of `team`’s enemies, but it instead returns the closest core of the first enemy team that has a core * Glenn method
This commit is contained in:
parent
47b8e8d9fa
commit
7faa0f119e
@ -36,11 +36,19 @@ public class Teams{
|
||||
|
||||
@Nullable
|
||||
public CoreBuild closestEnemyCore(float x, float y, Team team){
|
||||
CoreBuild closest = null;
|
||||
float closestDst = Float.MAX_VALUE;
|
||||
|
||||
for(Team enemy : team.data().coreEnemies){
|
||||
CoreBuild tile = Geometry.findClosest(x, y, enemy.cores());
|
||||
if(tile != null) return tile;
|
||||
for(CoreBuild core : enemy.cores()){
|
||||
float dst = Mathf.dst2(x, y, core.getX(), core.getY());
|
||||
if(closestDst > dst){
|
||||
closest = core;
|
||||
closestDst = dst;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return closest;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -368,4 +376,4 @@ public class Teams{
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user