Many campaign changes

This commit is contained in:
Anuken
2020-05-16 16:11:53 -04:00
parent d110fe5ea3
commit bdbc8ab6d2
12 changed files with 250 additions and 14 deletions

View File

@@ -1,5 +1,6 @@
package mindustry.maps.generators;
import arc.math.geom.*;
import arc.struct.*;
import mindustry.content.*;
import mindustry.game.*;
@@ -9,10 +10,40 @@ import mindustry.world.*;
public class BaseGenerator{
public void generate(Tiles tiles, Array<Tile> cores, Tile spawn, Team team, Sector sector){
//algorithm idea: make it spawn prefab turret setups and route resources to them with conveyors from chunks of ore drill setups
GridBits used = new GridBits(tiles.width, tiles.height);
Queue<Tile> frontier = new Queue<>();
for(Tile tile : cores){
frontier.add(tile);
}
int count = 2000;
int total = 0;
while(total++ < count){
Tile tile = frontier.removeFirst();
for(int i = 0; i < 4; i++){
int cx = tile.x + Geometry.d4x[i], cy = tile.y + Geometry.d4y[i];
if(tiles.in(cx, cy) && !used.get(cx, cy)){
Tile other = tiles.getn(cx, cy);
if(!other.solid()){
frontier.addLast(other);
}
used.set(cx, cy);
}
}
}
for(Tile tile : frontier){
tile.setBlock(Blocks.copperWall, team);
}
for(Tile tile : cores){
tile.clearOverlay();
tile.setBlock(Blocks.coreShard, team);
}