Renamed TeamData blocks -> plans
This commit is contained in:
@@ -85,7 +85,7 @@ public class BuilderAI extends AIController{
|
|||||||
if(player.isBuilder() && player.unit().activelyBuilding() && player.unit().buildPlan().samePos(req) && player.unit().buildPlan().breaking){
|
if(player.isBuilder() && player.unit().activelyBuilding() && player.unit().buildPlan().samePos(req) && player.unit().buildPlan().breaking){
|
||||||
unit.plans.removeFirst();
|
unit.plans.removeFirst();
|
||||||
//remove from list of plans
|
//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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -136,8 +136,8 @@ public class BuilderAI extends AIController{
|
|||||||
float rebuildTime = (unit.team.rules().rtsAi ? 12f : 2f) * 60f;
|
float rebuildTime = (unit.team.rules().rtsAi ? 12f : 2f) * 60f;
|
||||||
|
|
||||||
//find new plan
|
//find new plan
|
||||||
if(!unit.team.data().blocks.isEmpty() && following == null && timer.get(timerTarget3, rebuildTime)){
|
if(!unit.team.data().plans.isEmpty() && following == null && timer.get(timerTarget3, rebuildTime)){
|
||||||
Queue<BlockPlan> blocks = unit.team.data().blocks;
|
Queue<BlockPlan> blocks = unit.team.data().plans;
|
||||||
BlockPlan block = blocks.first();
|
BlockPlan block = blocks.first();
|
||||||
|
|
||||||
//check if it's already been placed
|
//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 there's still an enemy base left, fix it
|
||||||
if(state.rules.attackMode){
|
if(state.rules.attackMode){
|
||||||
//replace all broken blocks
|
//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);
|
Tile tile = world.tile(plan.x, plan.y);
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
tile.setBlock(content.block(plan.block), state.rules.waveTeam, plan.rotation);
|
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
|
//kill all units, since they should be dead anyway
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class Logic implements ApplicationListener{
|
|||||||
Events.on(BlockBuildEndEvent.class, event -> {
|
Events.on(BlockBuildEndEvent.class, event -> {
|
||||||
if(!event.breaking){
|
if(!event.breaking){
|
||||||
TeamData data = event.team.data();
|
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);
|
var bounds = event.tile.block().bounds(event.tile.x, event.tile.y, Tmp.r1);
|
||||||
while(it.hasNext()){
|
while(it.hasNext()){
|
||||||
BlockPlan b = it.next();
|
BlockPlan b = it.next();
|
||||||
|
|||||||
@@ -290,16 +290,16 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
if(checkPrevious){
|
if(checkPrevious){
|
||||||
//remove existing blocks that have been placed here.
|
//remove existing blocks that have been placed here.
|
||||||
//painful O(n) iteration + copy
|
//painful O(n) iteration + copy
|
||||||
for(int i = 0; i < data.blocks.size; i++){
|
for(int i = 0; i < data.plans.size; i++){
|
||||||
BlockPlan b = data.blocks.get(i);
|
BlockPlan b = data.plans.get(i);
|
||||||
if(b.x == tile.x && b.y == tile.y){
|
if(b.x == tile.x && b.y == tile.y){
|
||||||
data.blocks.removeIndex(i);
|
data.plans.removeIndex(i);
|
||||||
break;
|
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){
|
public @Nullable Tile findClosestEdge(Position to, Boolf<Tile> solid){
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ public class Teams{
|
|||||||
/** Enemies with cores or spawn points. */
|
/** Enemies with cores or spawn points. */
|
||||||
public Team[] coreEnemies = {};
|
public Team[] coreEnemies = {};
|
||||||
/** Planned blocks for drones. This is usually only blocks that have been broken. */
|
/** 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. */
|
/** Quadtree for all buildings of this team. Null if not active. */
|
||||||
public @Nullable QuadTree<Building> buildingTree;
|
public @Nullable QuadTree<Building> buildingTree;
|
||||||
@@ -290,7 +290,7 @@ public class Teams{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//no remaining blocks, cease building if applicable
|
//no remaining blocks, cease building if applicable
|
||||||
blocks.clear();
|
plans.clear();
|
||||||
|
|
||||||
//convert all team tiles to neutral, randomly killing them
|
//convert all team tiles to neutral, randomly killing them
|
||||||
for(var b : builds){
|
for(var b : builds){
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ public class BlockRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(brokenFade > 0.001f){
|
if(brokenFade > 0.001f){
|
||||||
for(BlockPlan block : player.team().data().blocks){
|
for(BlockPlan block : player.team().data().plans){
|
||||||
Block b = content.block(block.block);
|
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;
|
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;
|
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
|
//O(n^2) search here; no way around it
|
||||||
outer:
|
outer:
|
||||||
while(it.hasNext()){
|
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);
|
Block block = content.block(plan.block);
|
||||||
if(block.bounds(plan.x, plan.y, Tmp.r2).overlaps(Tmp.r1)){
|
if(block.bounds(plan.x, plan.y, Tmp.r2).overlaps(Tmp.r1)){
|
||||||
drawSelected(plan.x, plan.y, content.block(plan.block), Pal.remove);
|
drawSelected(plan.x, plan.y, content.block(plan.block), Pal.remove);
|
||||||
@@ -1187,7 +1187,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
removed.clear();
|
removed.clear();
|
||||||
|
|
||||||
//remove blocks to rebuild
|
//remove blocks to rebuild
|
||||||
Iterator<BlockPlan> broken = player.team().data().blocks.iterator();
|
Iterator<BlockPlan> broken = player.team().data().plans.iterator();
|
||||||
while(broken.hasNext()){
|
while(broken.hasNext()){
|
||||||
BlockPlan plan = broken.next();
|
BlockPlan plan = broken.next();
|
||||||
Block block = content.block(plan.block);
|
Block block = content.block(plan.block);
|
||||||
|
|||||||
@@ -342,8 +342,8 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
stream.writeInt(data.size);
|
stream.writeInt(data.size);
|
||||||
for(TeamData team : data){
|
for(TeamData team : data){
|
||||||
stream.writeInt(team.team.id);
|
stream.writeInt(team.team.id);
|
||||||
stream.writeInt(team.blocks.size);
|
stream.writeInt(team.plans.size);
|
||||||
for(BlockPlan block : team.blocks){
|
for(BlockPlan block : team.plans){
|
||||||
stream.writeShort(block.x);
|
stream.writeShort(block.x);
|
||||||
stream.writeShort(block.y);
|
stream.writeShort(block.y);
|
||||||
stream.writeShort(block.rotation);
|
stream.writeShort(block.rotation);
|
||||||
@@ -387,8 +387,8 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
Team team = Team.get(stream.readInt());
|
Team team = Team.get(stream.readInt());
|
||||||
TeamData data = team.data();
|
TeamData data = team.data();
|
||||||
int blocks = stream.readInt();
|
int blocks = stream.readInt();
|
||||||
data.blocks.clear();
|
data.plans.clear();
|
||||||
data.blocks.ensureCapacity(Math.min(blocks, 1000));
|
data.plans.ensureCapacity(Math.min(blocks, 1000));
|
||||||
var reads = Reads.get(stream);
|
var reads = Reads.get(stream);
|
||||||
var set = new IntSet();
|
var set = new IntSet();
|
||||||
|
|
||||||
@@ -397,7 +397,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
var obj = TypeIO.readObject(reads);
|
var obj = TypeIO.readObject(reads);
|
||||||
//cannot have two in the same position
|
//cannot have two in the same position
|
||||||
if(set.add(Point2.pack(x, y))){
|
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();
|
TeamData data = team.data();
|
||||||
int blocks = stream.readInt();
|
int blocks = stream.readInt();
|
||||||
for(int j = 0; j < blocks; j++){
|
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
|
}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++){
|
for(int i = 0; i < blocks.size; i++){
|
||||||
var block = blocks.get(i);
|
var block = blocks.get(i);
|
||||||
if(within(block.x * tilesize, block.y * tilesize, range)){
|
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){
|
if(player.isBuilder() && player.unit().activelyBuilding() && player.unit().buildPlan().samePos(req) && player.unit().buildPlan().breaking){
|
||||||
unit.plans().removeFirst();
|
unit.plans().removeFirst();
|
||||||
//remove from list of plans
|
//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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user