Custom spawn locations
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package io.anuke.mindustry.ai;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.Squad;
|
||||
import io.anuke.mindustry.game.EventType.WorldLoadEvent;
|
||||
@@ -25,6 +26,7 @@ public class WaveSpawner{
|
||||
private GridBits quadrants;
|
||||
|
||||
private Array<SpawnGroup> groups;
|
||||
private boolean dynamicSpawn;
|
||||
|
||||
private Array<FlyerSpawn> flySpawns = new Array<>();
|
||||
private Array<GroundSpawn> groundSpawns = new Array<>();
|
||||
@@ -81,10 +83,12 @@ public class WaveSpawner{
|
||||
int addGround = groundGroups - groundSpawns.size, addFly = flyGroups - flySpawns.size;
|
||||
|
||||
//add extra groups if the total exceeds it
|
||||
for(int i = 0; i < addGround; i++){
|
||||
GroundSpawn spawn = new GroundSpawn();
|
||||
findLocation(spawn);
|
||||
groundSpawns.add(spawn);
|
||||
if(!dynamicSpawn){
|
||||
for(int i = 0; i < addGround; i++){
|
||||
GroundSpawn spawn = new GroundSpawn();
|
||||
findLocation(spawn);
|
||||
groundSpawns.add(spawn);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < addFly; i++){
|
||||
@@ -117,9 +121,12 @@ public class WaveSpawner{
|
||||
flyCount++;
|
||||
}else{
|
||||
GroundSpawn spawn = groundSpawns.get(groundCount);
|
||||
checkQuadrant(spawn.x, spawn.y);
|
||||
if(!getQuad(spawn.x, spawn.y)){
|
||||
findLocation(spawn);
|
||||
|
||||
if(dynamicSpawn){
|
||||
checkQuadrant(spawn.x, spawn.y);
|
||||
if(!getQuad(spawn.x, spawn.y)){
|
||||
findLocation(spawn);
|
||||
}
|
||||
}
|
||||
|
||||
spawnX = spawn.x * quadsize * tilesize + quadsize * tilesize / 2f;
|
||||
@@ -165,6 +172,7 @@ public class WaveSpawner{
|
||||
}
|
||||
|
||||
private void reset(WorldLoadEvent event){
|
||||
dynamicSpawn = false;
|
||||
flySpawns.clear();
|
||||
groundSpawns.clear();
|
||||
quadrants = new GridBits(quadWidth(), quadHeight());
|
||||
@@ -174,6 +182,20 @@ public class WaveSpawner{
|
||||
}else{
|
||||
groups = world.getSector().spawns;
|
||||
}
|
||||
|
||||
dynamicSpawn = true;
|
||||
|
||||
for(int x = 0; x < world.width(); x++){
|
||||
for(int y = 0; y < world.height(); y++){
|
||||
if(world.tile(x, y).block() == Blocks.spawn){
|
||||
dynamicSpawn = false;
|
||||
GroundSpawn spawn = new GroundSpawn();
|
||||
spawn.x = x/quadsize;
|
||||
spawn.y = y/quadsize;
|
||||
groundSpawns.add(spawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getQuad(int quadx, int quady){
|
||||
|
||||
@@ -4,15 +4,19 @@ import com.badlogic.gdx.graphics.Color;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.Liquids;
|
||||
import io.anuke.mindustry.content.StatusEffects;
|
||||
import io.anuke.mindustry.graphics.CacheLayer;
|
||||
import io.anuke.mindustry.game.ContentList;
|
||||
import io.anuke.mindustry.graphics.CacheLayer;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class Blocks extends BlockList implements ContentList{
|
||||
public static Block air, blockpart, space, metalfloor, deepwater, water, lava, oil, stone, blackstone, dirt, sand, ice, snow, grass, shrub, rock, icerock, blackrock;
|
||||
public static Block air, blockpart, spawn, space, metalfloor, deepwater, water, lava, oil, stone, blackstone, dirt, sand, ice, snow, grass, shrub, rock, icerock, blackrock;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -23,19 +27,26 @@ public class Blocks extends BlockList implements ContentList{
|
||||
alwaysReplace = true;
|
||||
}
|
||||
|
||||
//don't draw
|
||||
public void draw(Tile tile){
|
||||
}
|
||||
|
||||
public void load(){
|
||||
}
|
||||
|
||||
public void init(){
|
||||
}
|
||||
public void draw(Tile tile){}
|
||||
public void load(){}
|
||||
public void init(){}
|
||||
};
|
||||
|
||||
blockpart = new BlockPart();
|
||||
|
||||
spawn = new Block("spawn"){
|
||||
{
|
||||
}
|
||||
|
||||
public void drawShadow(Tile tile){}
|
||||
|
||||
public void draw(Tile tile){
|
||||
Draw.color(Color.SCARLET);
|
||||
Lines.circle(tile.worldx(), tile.worldy(), 4f +Mathf.absin(Timers.time(), 6f, 6f));
|
||||
Draw.color();
|
||||
}
|
||||
};
|
||||
|
||||
for(int i = 1; i <= 6; i++){
|
||||
new BuildBlock("build" + i);
|
||||
}
|
||||
|
||||
@@ -84,6 +84,11 @@ public class MapIO{
|
||||
data.write(x, y, DataPosition.floor, block.floor.id);
|
||||
data.write(x, y, DataPosition.elevation, (byte)block.elevation);
|
||||
|
||||
//place spawn
|
||||
if(color == Color.rgba8888(Color.RED)){
|
||||
data.write(x, y, DataPosition.wall, Blocks.spawn.id);
|
||||
}
|
||||
|
||||
//place core
|
||||
if(color == Color.rgba8888(Color.GREEN)){
|
||||
for(int dx = 0; dx < 3; dx++){
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Drill extends Block{
|
||||
|
||||
@Override
|
||||
public TextureRegion[] getIcon(){
|
||||
return new TextureRegion[]{region, rotatorRegion, topRegion};
|
||||
return new TextureRegion[]{Draw.region(name), Draw.region(name + "-rotator"), Draw.region(name + "-top")};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user