Awful enemy base generation

This commit is contained in:
Anuken
2020-06-02 22:09:41 -04:00
parent 789cc3cdb9
commit 5e7d9f8119
16 changed files with 528 additions and 176 deletions
+18 -3
View File
@@ -91,7 +91,7 @@ public class Build{
}
//TODO should water blocks be placeable here?
if(/*!type.requiresWater && */!contactsGround(tile.x, tile.y, type)){
if(/*!type.requiresWater && */!contactsShallows(tile.x, tile.y, type)){
return false;
}
@@ -118,7 +118,7 @@ public class Build{
return true;
}else{
return tile.interactable(team)
&& contactsGround(tile.x, tile.y, type)
&& contactsShallows(tile.x, tile.y, type)
&& (!tile.floor().isDeep() || type.floating || type.requiresWater)
&& tile.floor().placeableOn
&& (!type.requiresWater || tile.floor().liquidDrop == Liquids.water)
@@ -128,7 +128,22 @@ public class Build{
}
}
private static boolean contactsGround(int x, int y, Block block){
public static boolean contactsGround(int x, int y, Block block){
if(block.isMultiblock()){
for(Point2 point : Edges.getEdges(block.size)){
Tile tile = world.tile(x + point.x, y + point.y);
if(tile != null && !tile.floor().isLiquid) return true;
}
}else{
for(Point2 point : Geometry.d4){
Tile tile = world.tile(x + point.x, y + point.y);
if(tile != null && !tile.floor().isLiquid) return true;
}
}
return false;
}
public static boolean contactsShallows(int x, int y, Block block){
if(block.isMultiblock()){
for(Point2 point : Edges.getInsideEdges(block.size)){
Tile tile = world.tile(x + point.x, y + point.y);
+9
View File
@@ -246,6 +246,15 @@ public class Tile implements Position, QuadTreeObject{
setOverlay(overlay);
}
/** Sets the block to air. */
public void setAir(){
setBlock(Blocks.air);
}
public void circle(int radius, Intc2 cons){
Geometry.circle(x, y, world.width(), world.height(), radius, cons);
}
public void recache(){
if(!headless && !world.isGenerating()){
renderer.blocks.floor.recacheTile(this);
@@ -1,5 +1,7 @@
package mindustry.world.blocks.campaign;
import arc.Graphics.*;
import arc.Graphics.Cursor.*;
import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.*;
@@ -11,7 +13,7 @@ import mindustry.graphics.*;
import mindustry.ui.*;
import mindustry.world.*;
import static mindustry.Vars.state;
import static mindustry.Vars.*;
public class CoreLauncher extends Block{
public int range = 1;
@@ -38,18 +40,23 @@ public class CoreLauncher extends Block{
if(state.isCampaign() && consValid()){
Vars.ui.planet.show(state.rules.sector, range, this);
cons.trigger();
}
return false;
}
@Override
public Cursor getCursor(){
return consValid() ? SystemCursor.hand : SystemCursor.arrow;
}
public void launch(){
LaunchCorec ent = LaunchCoreEntity.create();
ent.set(this);
ent.block(Blocks.coreShard);
ent.lifetime(Vars.launchDuration);
ent.add();
cons.trigger();
}
}
@@ -116,11 +123,5 @@ public class CoreLauncher extends Block{
Fx.rocketSmokeLarge.at(cx() + Mathf.range(r), cy() + Mathf.range(r), fin());
}
}
@Override
public void remove(){
//TODO something
}
}
}
@@ -124,26 +124,7 @@ public class BlockForge extends PayloadAcceptor{
Draw.rect(outRegion, x, y, rotdeg());
if(recipe != null){
Draw.draw(Layer.blockOver, () -> {
TextureRegion region = recipe.icon(Cicon.full);
Shaders.build.region = region;
Shaders.build.progress = progress / recipe.buildCost;
Shaders.build.color.set(Pal.accent);
Shaders.build.color.a = heat;
Shaders.build.time = -time / 20f;
Draw.shader(Shaders.build);
Draw.rect(region, x, y);
Draw.shader();
Draw.color(Pal.accent);
Draw.alpha(heat);
Lines.lineAngleCenter(x + Mathf.sin(time, 20f, Vars.tilesize / 2f * size - 2f), y, 90, size * Vars.tilesize - 4f);
Draw.reset();
});
Draw.draw(Layer.blockOver, () -> Drawf.construct(this, recipe, 0, progress / recipe.buildCost, heat, time));
}
drawPayload();