Start of groundwork for dynamic bases
This commit is contained in:
@@ -1,7 +1,12 @@
|
|||||||
package io.anuke.mindustry.maps.generation;
|
package io.anuke.mindustry.maps.generation;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import com.badlogic.gdx.utils.Predicate;
|
||||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.blocks.production.Drill;
|
||||||
|
import io.anuke.mindustry.world.consumers.ConsumePower;
|
||||||
|
|
||||||
public class FortressGenerator{
|
public class FortressGenerator{
|
||||||
private final static int minCoreDst = 60;
|
private final static int minCoreDst = 60;
|
||||||
@@ -11,7 +16,6 @@ public class FortressGenerator{
|
|||||||
private Generation gen;
|
private Generation gen;
|
||||||
|
|
||||||
public void generate(Generation gen, Team team, int coreX, int coreY, int enemyX, int enemyY){
|
public void generate(Generation gen, Team team, int coreX, int coreY, int enemyX, int enemyY){
|
||||||
|
|
||||||
this.enemyX = enemyX;
|
this.enemyX = enemyX;
|
||||||
this.enemyY = enemyY;
|
this.enemyY = enemyY;
|
||||||
this.coreX = coreX;
|
this.coreX = coreX;
|
||||||
@@ -24,5 +28,24 @@ public class FortressGenerator{
|
|||||||
|
|
||||||
void gen(){
|
void gen(){
|
||||||
gen.tiles[enemyX][enemyY].setBlock(StorageBlocks.core, team);
|
gen.tiles[enemyX][enemyY].setBlock(StorageBlocks.core, team);
|
||||||
|
|
||||||
|
Array<Block> drills = find(b -> b instanceof Drill && !b.consumes.has(ConsumePower.class));
|
||||||
|
|
||||||
|
for(int x = 0; x < gen.width; x++){
|
||||||
|
for(int y = 0; y < gen.height; y++){
|
||||||
|
//TODO place valid drills
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Array<Block> find(Predicate<Block> pred){
|
||||||
|
Array<Block> out = new Array<>();
|
||||||
|
for(Block block : Block.all()){
|
||||||
|
if(pred.evaluate(block)){
|
||||||
|
out.add(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
package io.anuke.mindustry.maps.generation;
|
package io.anuke.mindustry.maps.generation;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.maps.Sector;
|
import io.anuke.mindustry.maps.Sector;
|
||||||
|
import io.anuke.mindustry.type.Item;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.mindustry.world.blocks.production.Drill;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.SeedRandom;
|
import io.anuke.ucore.util.SeedRandom;
|
||||||
|
|
||||||
public class Generation{
|
public class Generation{
|
||||||
@@ -17,4 +22,69 @@ public class Generation{
|
|||||||
this.height = height;
|
this.height = height;
|
||||||
this.random = random;
|
this.random = random;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO implement
|
||||||
|
Item drillItem(int x, int y, Drill block){
|
||||||
|
if(block.isMultiblock()){
|
||||||
|
Item result = null;
|
||||||
|
int offsetx = -(block.size - 1) / 2;
|
||||||
|
int offsety = -(block.size - 1) / 2;
|
||||||
|
|
||||||
|
for(int dx = 0; dx < block.size; dx++){
|
||||||
|
for(int dy = 0; dy < block.size; dy++){
|
||||||
|
int worldx = dx + offsetx + x;
|
||||||
|
int worldy = dy + offsety + y;
|
||||||
|
if(!Mathf.inBounds(worldx, worldy, tiles)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}else{
|
||||||
|
return tiles[x][y].floor().drops == null ? null : tiles[x][y].floor().drops.item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canPlace(int x, int y, Block block){
|
||||||
|
if(block.isMultiblock()){
|
||||||
|
int offsetx = -(block.size - 1) / 2;
|
||||||
|
int offsety = -(block.size - 1) / 2;
|
||||||
|
|
||||||
|
for(int dx = 0; dx < block.size; dx++){
|
||||||
|
for(int dy = 0; dy < block.size; dy++){
|
||||||
|
int worldx = dx + offsetx + x;
|
||||||
|
int worldy = dy + offsety + y;
|
||||||
|
if(!Mathf.inBounds(worldx, worldy, tiles) || !tiles[worldx][worldy].block().alwaysReplace){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return tiles[x][y].block().alwaysReplace;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlock(int x, int y, Block block, Team team){
|
||||||
|
tiles[x][y].setBlock(block, team);
|
||||||
|
if(block.isMultiblock()){
|
||||||
|
int offsetx = -(block.size - 1) / 2;
|
||||||
|
int offsety = -(block.size - 1) / 2;
|
||||||
|
|
||||||
|
for(int dx = 0; dx < block.size; dx++){
|
||||||
|
for(int dy = 0; dy < block.size; dy++){
|
||||||
|
int worldx = dx + offsetx + x;
|
||||||
|
int worldy = dy + offsety + y;
|
||||||
|
if(!(worldx == x && worldy == y) && Mathf.inBounds(worldx, worldy, tiles)){
|
||||||
|
Tile toplace = tiles[worldx][worldy];
|
||||||
|
if(toplace != null){
|
||||||
|
toplace.setLinked((byte) (dx + offsetx), (byte) (dy + offsety));
|
||||||
|
toplace.setTeam(team);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -192,6 +192,11 @@ public class BuildBlock extends Block{
|
|||||||
private float[] totalAccumulator;
|
private float[] totalAccumulator;
|
||||||
|
|
||||||
public void construct(Unit builder, TileEntity core, float amount){
|
public void construct(Unit builder, TileEntity core, float amount){
|
||||||
|
if(recipe == null){
|
||||||
|
damage(99999);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
float maxProgress = checkRequired(core.items, amount, false);
|
float maxProgress = checkRequired(core.items, amount, false);
|
||||||
|
|
||||||
for(int i = 0; i < recipe.requirements.length; i++){
|
for(int i = 0; i < recipe.requirements.length; i++){
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class MendProjector extends Block{
|
|||||||
if(other == null) continue;
|
if(other == null) continue;
|
||||||
other = other.target();
|
other = other.target();
|
||||||
|
|
||||||
if(!healed.contains(other.packedPosition()) && other.entity != null && other.entity.health < other.entity.maxHealth()){
|
if(other.getTeamID() == tile.getTeamID() && !healed.contains(other.packedPosition()) && other.entity != null && other.entity.health < other.entity.maxHealth()){
|
||||||
other.entity.healBy(other.entity.maxHealth() * (healPercent + entity.phaseHeat*phaseBoost)/100f);
|
other.entity.healBy(other.entity.maxHealth() * (healPercent + entity.phaseHeat*phaseBoost)/100f);
|
||||||
Effects.effect(BlockFx.healBlockFull, Hue.mix(color, phase, entity.phaseHeat), other.drawx(), other.drawy(), other.block().size);
|
Effects.effect(BlockFx.healBlockFull, Hue.mix(color, phase, entity.phaseHeat), other.drawx(), other.drawy(), other.block().size);
|
||||||
healed.add(other.packedPosition());
|
healed.add(other.packedPosition());
|
||||||
|
|||||||
@@ -12,4 +12,8 @@ public class Producers{
|
|||||||
public Content get(){
|
public Content get(){
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean is(Content content){
|
||||||
|
return content == output;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user