mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-21 01:37:13 +07:00
Renamed TeamData blocks -> plans
This commit is contained in:
parent
8f2e1163dd
commit
7885a46cd5
@ -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<BlockPlan> blocks = unit.team.data().blocks;
|
||||
if(!unit.team.data().plans.isEmpty() && following == null && timer.get(timerTarget3, rebuildTime)){
|
||||
Queue<BlockPlan> blocks = unit.team.data().plans;
|
||||
BlockPlan block = blocks.first();
|
||||
|
||||
//check if it's already been placed
|
||||
|
@ -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
|
||||
|
@ -45,7 +45,7 @@ public class Logic implements ApplicationListener{
|
||||
Events.on(BlockBuildEndEvent.class, event -> {
|
||||
if(!event.breaking){
|
||||
TeamData data = event.team.data();
|
||||
Iterator<BlockPlan> it = data.blocks.iterator();
|
||||
Iterator<BlockPlan> 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();
|
||||
|
@ -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<Tile> solid){
|
||||
|
@ -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<BlockPlan> blocks = new Queue<>();
|
||||
public Queue<BlockPlan> plans = new Queue<>();
|
||||
|
||||
/** Quadtree for all buildings of this team. Null if not active. */
|
||||
public @Nullable QuadTree<Building> 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){
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<BlockPlan> broken = player.team().data().blocks.iterator();
|
||||
Iterator<BlockPlan> broken = player.team().data().plans.iterator();
|
||||
while(broken.hasNext()){
|
||||
BlockPlan plan = broken.next();
|
||||
Block block = content.block(plan.block);
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class BuildTurret extends BaseTurret{
|
||||
}
|
||||
|
||||
}else if(unit.buildPlan() == null && timer(timerTarget, targetInterval)){ //search for new stuff
|
||||
Queue<BlockPlan> blocks = team.data().blocks;
|
||||
Queue<BlockPlan> 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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user