Method cleanup
This commit is contained in:
@@ -259,7 +259,7 @@ public class Damage{
|
||||
for(int dx = -trad; dx <= trad; dx++){
|
||||
for(int dy = -trad; dy <= trad; dy++){
|
||||
Tile tile = world.tile(Math.round(x / tilesize) + dx, Math.round(y / tilesize) + dy);
|
||||
if(tile != null && tile.entity != null && (team == null || state.teams.areEnemies(team, tile.getTeam())) && Mathf.dst(dx, dy) <= trad){
|
||||
if(tile != null && tile.entity != null && (team == null ||team.isEnemy(tile.getTeam())) && Mathf.dst(dx, dy) <= trad){
|
||||
tile.entity.damage(damage);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class Units{
|
||||
public static TileEntity findEnemyTile(Team team, float x, float y, float range, Boolf<Tile> pred){
|
||||
if(team == Team.derelict) return null;
|
||||
|
||||
for(Team enemy : state.teams.enemiesOf(team)){
|
||||
for(Team enemy : team.enemies()){
|
||||
TileEntity entity = indexer.findTile(enemy, x, y, range, pred, true);
|
||||
if(entity != null){
|
||||
return entity;
|
||||
@@ -195,13 +195,13 @@ public class Units{
|
||||
/** Iterates over all units that are enemies of this team. */
|
||||
public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons<Unit> cons){
|
||||
unitGroup.intersect(x, y, width, height, u -> {
|
||||
if(state.teams.areEnemies(team, u.getTeam())){
|
||||
if(team.isEnemy(u.getTeam())){
|
||||
cons.get(u);
|
||||
}
|
||||
});
|
||||
|
||||
playerGroup.intersect(x, y, width, height, player -> {
|
||||
if(state.teams.areEnemies(team, player.getTeam())){
|
||||
if(team.isEnemy(player.getTeam())){
|
||||
cons.get(player);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -88,7 +88,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
if(isDead()) return false;
|
||||
|
||||
if(other instanceof DamageTrait){
|
||||
return other instanceof TeamTrait && state.teams.areEnemies((((TeamTrait)other).getTeam()), team);
|
||||
return other instanceof TeamTrait && (((TeamTrait)other).getTeam()).isEnemy(team);
|
||||
}else{
|
||||
return other instanceof Unit && ((Unit)other).isFlying() == isFlying();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package mindustry.entities.type.base;
|
||||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.traits.*;
|
||||
import mindustry.entities.type.*;
|
||||
@@ -187,7 +186,7 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
||||
}
|
||||
|
||||
if(timer.get(timerTarget, 80) && Units.closestEnemy(getTeam(), x, y, 100f, u -> !(u instanceof BaseDrone)) == null && !isBuilding()){
|
||||
TeamData data = Vars.state.teams.get(team);
|
||||
TeamData data = team.data();
|
||||
if(!data.brokenBlocks.isEmpty()){
|
||||
BrokenBlock block = data.brokenBlocks.removeLast();
|
||||
if(Build.validPlace(getTeam(), block.x, block.y, content.block(block.block), block.rotation)){
|
||||
|
||||
@@ -237,15 +237,15 @@ public class GroundUnit extends BaseUnit{
|
||||
|
||||
protected void moveAwayFromCore(){
|
||||
Team enemy = null;
|
||||
for(Team team : Vars.state.teams.enemiesOf(team)){
|
||||
if(Vars.state.teams.isActive(team)){
|
||||
for(Team team : Vars.team.enemies()){
|
||||
if(team.active()){
|
||||
enemy = team;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(enemy == null){
|
||||
for(Team team : Vars.state.teams.enemiesOf(team)){
|
||||
for(Team team : Vars.team.enemies()){
|
||||
enemy = team;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user