From d410bc345c768b5097b24375dfa4c0ddc08aa119 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 27 Jan 2022 12:56:23 -0500 Subject: [PATCH] Guaranteed vent spawning --- .../mindustry/entities/comp/BuildingComp.java | 4 +- core/src/mindustry/input/MobileInput.java | 2 +- .../maps/planet/ErekirPlanetGenerator.java | 60 ++++++++++++++++++- core/src/mindustry/world/Block.java | 2 +- 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index ef9f4541d2..e70c6781b3 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -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){ diff --git a/core/src/mindustry/input/MobileInput.java b/core/src/mindustry/input/MobileInput.java index 13e864bc80..528829457d 100644 --- a/core/src/mindustry/input/MobileInput.java +++ b/core/src/mindustry/input/MobileInput.java @@ -52,7 +52,7 @@ public class MobileInput extends InputHandler implements GestureListener{ /** Place requests to be removed. */ public Seq 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; diff --git a/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java b/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java index 58b21ef21d..cf404ce7f5 100644 --- a/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java +++ b/core/src/mindustry/maps/planet/ErekirPlanetGenerator.java @@ -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); diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index f1128cc5ba..dbead695d1 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -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); }