diff --git a/core/src/mindustry/ai/types/BuilderAI.java b/core/src/mindustry/ai/types/BuilderAI.java index e39765ba9a..8e3af71ce6 100644 --- a/core/src/mindustry/ai/types/BuilderAI.java +++ b/core/src/mindustry/ai/types/BuilderAI.java @@ -85,7 +85,7 @@ public class BuilderAI extends AIController{ if(player.isBuilder() && player.unit().activelyBuilding() && player.unit().buildPlan().samePos(req) && player.unit().buildPlan().breaking){ unit.plans.removeFirst(); //remove from list of plans - unit.team.data().blocks.remove(p -> p.x == req.x && p.y == req.y); + unit.team.data().plans.remove(p -> p.x == req.x && p.y == req.y); return; } } @@ -136,8 +136,8 @@ public class BuilderAI extends AIController{ float rebuildTime = (unit.team.rules().rtsAi ? 12f : 2f) * 60f; //find new plan - if(!unit.team.data().blocks.isEmpty() && following == null && timer.get(timerTarget3, rebuildTime)){ - Queue blocks = unit.team.data().blocks; + if(!unit.team.data().plans.isEmpty() && following == null && timer.get(timerTarget3, rebuildTime)){ + Queue blocks = unit.team.data().plans; BlockPlan block = blocks.first(); //check if it's already been placed diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index b926ee5e75..c6b9903e19 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -441,7 +441,7 @@ public class Control implements ApplicationListener, Loadable{ //if there's still an enemy base left, fix it if(state.rules.attackMode){ //replace all broken blocks - for(var plan : state.rules.waveTeam.data().blocks){ + for(var plan : state.rules.waveTeam.data().plans){ Tile tile = world.tile(plan.x, plan.y); if(tile != null){ tile.setBlock(content.block(plan.block), state.rules.waveTeam, plan.rotation); @@ -450,7 +450,7 @@ public class Control implements ApplicationListener, Loadable{ } } } - state.rules.waveTeam.data().blocks.clear(); + state.rules.waveTeam.data().plans.clear(); } //kill all units, since they should be dead anyway diff --git a/core/src/mindustry/core/Logic.java b/core/src/mindustry/core/Logic.java index 2584c4778b..5c1e84721c 100644 --- a/core/src/mindustry/core/Logic.java +++ b/core/src/mindustry/core/Logic.java @@ -45,7 +45,7 @@ public class Logic implements ApplicationListener{ Events.on(BlockBuildEndEvent.class, event -> { if(!event.breaking){ TeamData data = event.team.data(); - Iterator it = data.blocks.iterator(); + Iterator it = data.plans.iterator(); var bounds = event.tile.block().bounds(event.tile.x, event.tile.y, Tmp.r1); while(it.hasNext()){ BlockPlan b = it.next(); diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index e36d83eba9..40752efecc 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -290,16 +290,16 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, if(checkPrevious){ //remove existing blocks that have been placed here. //painful O(n) iteration + copy - for(int i = 0; i < data.blocks.size; i++){ - BlockPlan b = data.blocks.get(i); + for(int i = 0; i < data.plans.size; i++){ + BlockPlan b = data.plans.get(i); if(b.x == tile.x && b.y == tile.y){ - data.blocks.removeIndex(i); + data.plans.removeIndex(i); break; } } } - data.blocks.addFirst(new BlockPlan(tile.x, tile.y, (short)rotation, toAdd.id, overrideConfig == null ? config() : overrideConfig)); + data.plans.addFirst(new BlockPlan(tile.x, tile.y, (short)rotation, toAdd.id, overrideConfig == null ? config() : overrideConfig)); } public @Nullable Tile findClosestEdge(Position to, Boolf solid){ diff --git a/core/src/mindustry/game/Teams.java b/core/src/mindustry/game/Teams.java index dc927cd7d6..7710f599a4 100644 --- a/core/src/mindustry/game/Teams.java +++ b/core/src/mindustry/game/Teams.java @@ -247,7 +247,7 @@ public class Teams{ /** Enemies with cores or spawn points. */ public Team[] coreEnemies = {}; /** Planned blocks for drones. This is usually only blocks that have been broken. */ - public Queue blocks = new Queue<>(); + public Queue plans = new Queue<>(); /** Quadtree for all buildings of this team. Null if not active. */ public @Nullable QuadTree buildingTree; @@ -290,7 +290,7 @@ public class Teams{ } //no remaining blocks, cease building if applicable - blocks.clear(); + plans.clear(); //convert all team tiles to neutral, randomly killing them for(var b : builds){ diff --git a/core/src/mindustry/graphics/BlockRenderer.java b/core/src/mindustry/graphics/BlockRenderer.java index 7be03d5587..515c00a807 100644 --- a/core/src/mindustry/graphics/BlockRenderer.java +++ b/core/src/mindustry/graphics/BlockRenderer.java @@ -267,7 +267,7 @@ public class BlockRenderer{ } if(brokenFade > 0.001f){ - for(BlockPlan block : player.team().data().blocks){ + for(BlockPlan block : player.team().data().plans){ Block b = content.block(block.block); if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset, block.y * tilesize + b.offset))) continue; diff --git a/core/src/mindustry/input/InputHandler.java b/core/src/mindustry/input/InputHandler.java index 6e4b3fe53d..47ef52ae5e 100644 --- a/core/src/mindustry/input/InputHandler.java +++ b/core/src/mindustry/input/InputHandler.java @@ -187,7 +187,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ if(player == null) return; - var it = player.team().data().blocks.iterator(); + var it = player.team().data().plans.iterator(); //O(n^2) search here; no way around it outer: while(it.hasNext()){ @@ -1037,7 +1037,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } } - for(BlockPlan plan : player.team().data().blocks){ + for(BlockPlan plan : player.team().data().plans){ Block block = content.block(plan.block); if(block.bounds(plan.x, plan.y, Tmp.r2).overlaps(Tmp.r1)){ drawSelected(plan.x, plan.y, content.block(plan.block), Pal.remove); @@ -1187,7 +1187,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ removed.clear(); //remove blocks to rebuild - Iterator broken = player.team().data().blocks.iterator(); + Iterator broken = player.team().data().plans.iterator(); while(broken.hasNext()){ BlockPlan plan = broken.next(); Block block = content.block(plan.block); diff --git a/core/src/mindustry/io/SaveVersion.java b/core/src/mindustry/io/SaveVersion.java index e0cf4fbabf..6dffa264e7 100644 --- a/core/src/mindustry/io/SaveVersion.java +++ b/core/src/mindustry/io/SaveVersion.java @@ -342,8 +342,8 @@ public abstract class SaveVersion extends SaveFileReader{ stream.writeInt(data.size); for(TeamData team : data){ stream.writeInt(team.team.id); - stream.writeInt(team.blocks.size); - for(BlockPlan block : team.blocks){ + stream.writeInt(team.plans.size); + for(BlockPlan block : team.plans){ stream.writeShort(block.x); stream.writeShort(block.y); stream.writeShort(block.rotation); @@ -387,8 +387,8 @@ public abstract class SaveVersion extends SaveFileReader{ Team team = Team.get(stream.readInt()); TeamData data = team.data(); int blocks = stream.readInt(); - data.blocks.clear(); - data.blocks.ensureCapacity(Math.min(blocks, 1000)); + data.plans.clear(); + data.plans.ensureCapacity(Math.min(blocks, 1000)); var reads = Reads.get(stream); var set = new IntSet(); @@ -397,7 +397,7 @@ public abstract class SaveVersion extends SaveFileReader{ var obj = TypeIO.readObject(reads); //cannot have two in the same position if(set.add(Point2.pack(x, y))){ - data.blocks.addLast(new BlockPlan(x, y, rot, content.block(bid).id, obj)); + data.plans.addLast(new BlockPlan(x, y, rot, content.block(bid).id, obj)); } } } diff --git a/core/src/mindustry/io/versions/Save3.java b/core/src/mindustry/io/versions/Save3.java index 387d4130e2..51cd8bf4aa 100644 --- a/core/src/mindustry/io/versions/Save3.java +++ b/core/src/mindustry/io/versions/Save3.java @@ -21,7 +21,7 @@ public class Save3 extends LegacySaveVersion{ TeamData data = team.data(); int blocks = stream.readInt(); for(int j = 0; j < blocks; j++){ - data.blocks.addLast(new BlockPlan(stream.readShort(), stream.readShort(), stream.readShort(), content.block(stream.readShort()).id, stream.readInt())); + data.plans.addLast(new BlockPlan(stream.readShort(), stream.readShort(), stream.readShort(), content.block(stream.readShort()).id, stream.readInt())); } } diff --git a/core/src/mindustry/world/blocks/defense/BuildTurret.java b/core/src/mindustry/world/blocks/defense/BuildTurret.java index 64be3017e0..d4bb41ae0f 100644 --- a/core/src/mindustry/world/blocks/defense/BuildTurret.java +++ b/core/src/mindustry/world/blocks/defense/BuildTurret.java @@ -128,7 +128,7 @@ public class BuildTurret extends BaseTurret{ } }else if(unit.buildPlan() == null && timer(timerTarget, targetInterval)){ //search for new stuff - Queue blocks = team.data().blocks; + Queue blocks = team.data().plans; for(int i = 0; i < blocks.size; i++){ var block = blocks.get(i); if(within(block.x * tilesize, block.y * tilesize, range)){ @@ -169,7 +169,7 @@ public class BuildTurret extends BaseTurret{ if(player.isBuilder() && player.unit().activelyBuilding() && player.unit().buildPlan().samePos(req) && player.unit().buildPlan().breaking){ unit.plans().removeFirst(); //remove from list of plans - team.data().blocks.remove(p -> p.x == req.x && p.y == req.y); + team.data().plans.remove(p -> p.x == req.x && p.y == req.y); return; } }