Guaranteed vent spawning
This commit is contained in:
@@ -1374,14 +1374,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
table.setPosition(pos.x, pos.y, Align.top);
|
||||
}
|
||||
|
||||
/** Returns whether or not a hand cursor should be shown over this block. */
|
||||
/** Returns whether a hand cursor should be shown over this block. */
|
||||
public Cursor getCursor(){
|
||||
return block.configurable && interactable(player.team()) ? SystemCursor.hand : SystemCursor.arrow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when another tile is tapped while this block is selected.
|
||||
* @return whether or not this block should be deselected.
|
||||
* @return whether this block should be deselected.
|
||||
*/
|
||||
public boolean onConfigureTileTapped(Building other){
|
||||
if(block.clearOnDoubleTap){
|
||||
|
||||
@@ -52,7 +52,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
|
||||
/** Place requests to be removed. */
|
||||
public Seq<BuildPlan> removals = new Seq<>();
|
||||
/** Whether or not the player is currently shifting all placed tiles. */
|
||||
/** Whether the player is currently shifting all placed tiles. */
|
||||
public boolean selecting;
|
||||
/** Whether the player is currently in line-place mode. */
|
||||
public boolean lineMode, schematicMode;
|
||||
|
||||
@@ -316,21 +316,26 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
trimDark();
|
||||
|
||||
//TODO vents everywhere! rhyolite patches? or different vents?
|
||||
int minVents = rand.random(4, 8);
|
||||
int ventCount = 0;
|
||||
|
||||
//TODO vents everywhere! rhyolite patches
|
||||
//vents
|
||||
outer:
|
||||
for(Tile tile : tiles){
|
||||
if(floor == Blocks.rhyolite && rand.chance(0.0016)){
|
||||
var floor = tile.floor();
|
||||
if((floor == Blocks.rhyolite || floor == Blocks.roughRhyolite) && rand.chance(0.002)){
|
||||
int radius = 2;
|
||||
for(int x = -radius; x <= radius; x++){
|
||||
for(int y = -radius; y <= radius; y++){
|
||||
Tile other = tiles.get(x + tile.x, y + tile.y);
|
||||
if(other == null || other.floor() != Blocks.rhyolite || other.block().solid){
|
||||
if(other == null || (other.floor() != Blocks.rhyolite && other.floor() != Blocks.roughRhyolite) || other.block().solid){
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ventCount ++;
|
||||
for(var pos : SteamVent.offsets){
|
||||
Tile other = tiles.get(pos.x + tile.x + 1, pos.y + tile.y + 1);
|
||||
other.setFloor(Blocks.steamVent.asFloor());
|
||||
@@ -338,6 +343,55 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
int iterations = 0;
|
||||
int maxIterations = 5;
|
||||
|
||||
//try to add additional vents, but only several times to prevent infinite loops in bad maps
|
||||
while(ventCount < minVents && iterations++ < maxIterations){
|
||||
outer:
|
||||
for(Tile tile : tiles){
|
||||
if(rand.chance(0.0003)){
|
||||
int radius = 1;
|
||||
for(int x = -radius; x <= radius; x++){
|
||||
for(int y = -radius; y <= radius; y++){
|
||||
Tile other = tiles.get(x + tile.x, y + tile.y);
|
||||
//skip solids / other vents / arkycite / slag
|
||||
if(other == null || other.block().solid || other.floor() == Blocks.steamVent || other.floor() == Blocks.slag || other.floor() == Blocks.arkyciteFloor){
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ventCount ++;
|
||||
for(var pos : SteamVent.offsets){
|
||||
Tile other = tiles.get(pos.x + tile.x + 1, pos.y + tile.y + 1);
|
||||
other.setFloor(Blocks.steamVent.asFloor());
|
||||
}
|
||||
|
||||
//"circle" for blending
|
||||
//TODO should it replace akrycite? slag?
|
||||
int crad = rand.random(6, 14), crad2 = crad * crad;
|
||||
for(int cx = -crad; cx <= crad; cx++){
|
||||
for(int cy = -crad; cy <= crad; cy++){
|
||||
int rx = cx + tile.x, ry = cy + tile.y;
|
||||
//skew circle Y
|
||||
float rcy = cy + cx*0.9f;
|
||||
if(cx*cx + rcy*rcy <= crad2 - noise(rx, ry + rx*2f, 2, 0.7f, 8f, crad2 * 1.1f)){
|
||||
Tile dest = tiles.get(rx, ry);
|
||||
if(dest != null && dest.floor() != Blocks.steamVent && dest.floor() != Blocks.roughRhyolite && dest.floor() != Blocks.arkyciteFloor && dest.floor() != Blocks.slag){
|
||||
dest.setFloor(rand.chance(0.08) ? Blocks.rhyoliteCrater.asFloor() : Blocks.rhyolite.asFloor());
|
||||
if(dest.block().isStatic()){
|
||||
dest.setBlock(Blocks.rhyoliteWall);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(Tile tile : tiles){
|
||||
if(tile.overlay().needsSurface && !tile.floor().hasSurface()){
|
||||
tile.setOverlay(Blocks.air);
|
||||
|
||||
@@ -417,7 +417,7 @@ public class Block extends UnlockableContent{
|
||||
return hasItems;
|
||||
}
|
||||
|
||||
/** Returns whether or not this block can be place on the specified */
|
||||
/** Returns whether this block can be place on the specified */
|
||||
public boolean canPlaceOn(Tile tile, Team team, int rotation){
|
||||
return canPlaceOn(tile, team);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user