Minor tweaks
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
package io.anuke.mindustry.maps.generation;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Predicate;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.blocks.production.Drill;
|
||||
import io.anuke.mindustry.world.consumers.ConsumePower;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.ItemTurret;
|
||||
import io.anuke.mindustry.world.blocks.defense.turrets.PowerTurret;
|
||||
|
||||
public class FortressGenerator{
|
||||
private final static int minCoreDst = 60;
|
||||
private final static int coreDst = 60;
|
||||
|
||||
private int enemyX, enemyY, coreX, coreY;
|
||||
private Team team;
|
||||
@@ -28,17 +32,31 @@ public class FortressGenerator{
|
||||
|
||||
void gen(){
|
||||
gen.tiles[enemyX][enemyY].setBlock(StorageBlocks.core, team);
|
||||
Item[] acceptedItems = {Items.copper, Items.densealloy, Items.silicon, Items.thorium};
|
||||
|
||||
Array<Block> drills = find(b -> b instanceof Drill && !b.consumes.has(ConsumePower.class));
|
||||
Array<Block> turrets = find(b -> (b instanceof ItemTurret && accepts(((ItemTurret) b).getAmmoTypes(), acceptedItems) || b instanceof PowerTurret));
|
||||
|
||||
for(int x = 0; x < gen.width; x++){
|
||||
for(int y = 0; y < gen.height; y++){
|
||||
//TODO place valid drills
|
||||
if(Vector2.dst(x, y, enemyX, enemyY) > coreDst){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
boolean accepts(AmmoType[] types, Item[] items){
|
||||
for(AmmoType type : types){
|
||||
for(Item item : items){
|
||||
if(type.item == item){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Array<Block> find(Predicate<Block> pred){
|
||||
Array<Block> out = new Array<>();
|
||||
for(Block block : Block.all()){
|
||||
|
||||
@@ -35,7 +35,15 @@ public class Generation{
|
||||
int worldx = dx + offsetx + x;
|
||||
int worldy = dy + offsety + y;
|
||||
if(!Mathf.inBounds(worldx, worldy, tiles)){
|
||||
continue;
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!block.isValid(tiles[worldx][worldy])) continue;
|
||||
|
||||
Item drop = tiles[worldx][worldy].floor().drops.item;
|
||||
|
||||
if(result == null || drop.id < result.id){
|
||||
result = drop;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,6 +54,8 @@ public class Generation{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean canPlace(int x, int y, Block block){
|
||||
if(block.isMultiblock()){
|
||||
int offsetx = -(block.size - 1) / 2;
|
||||
|
||||
@@ -233,7 +233,7 @@ public class Drill extends Block{
|
||||
return tile.floor().drops.item;
|
||||
}
|
||||
|
||||
protected boolean isValid(Tile tile){
|
||||
public boolean isValid(Tile tile){
|
||||
if(tile == null) return false;
|
||||
ItemStack drops = tile.floor().drops;
|
||||
return drops != null && drops.item.hardness <= tier;
|
||||
|
||||
Reference in New Issue
Block a user