From 4a88f64fa92b9e626f2f2f76c48c8092e0c202e8 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 20 Jun 2021 21:02:31 -0400 Subject: [PATCH] Asteroid ores (1) --- .../sprites/blocks/props/ferric-boulder1.png | Bin 0 -> 481 bytes .../sprites/blocks/props/ferric-boulder2.png | Bin 0 -> 486 bytes core/assets/icons/icons.properties | 1 + core/src/mindustry/content/Blocks.java | 8 ++- .../maps/generators/BasicGenerator.java | 50 ++++++++++++++++++ .../maps/planet/AsteroidGenerator.java | 26 +++++++-- .../world/blocks/campaign/LaunchPad.java | 4 -- gradle.properties | 2 +- 8 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 core/assets-raw/sprites/blocks/props/ferric-boulder1.png create mode 100644 core/assets-raw/sprites/blocks/props/ferric-boulder2.png diff --git a/core/assets-raw/sprites/blocks/props/ferric-boulder1.png b/core/assets-raw/sprites/blocks/props/ferric-boulder1.png new file mode 100644 index 0000000000000000000000000000000000000000..63685cbad5d8f19261a87c685622342a57ef5ea2 GIT binary patch literal 481 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}jKx9jP7LeL$-HD>V4Usg z;usRqdUTqhAG0Hm>whIJDU~jf1sq#s6v7uQJZmeUYyLp$PD>lNLSWE>z(t~(+mwWy zLRyqQWj*@X^Y$dyog5?UTmPS}e{1^T{KX6Xw`a36960&Z(AeIRn^~NaIl{HV3F;1yYsxo3c8al7+TgH zSJH`PkXiO*ktRFC8;1&6MS+vOM;d>85n1?pvq4;kQiDpIaQ6liXFi5mJFd1?#NIj_ zD=_(j)U@EN>N5;)L*7k@aqtS*r(TxGU}3xa+_h}K8u<f zeHZquqpGu$IXF*T;atg*ebCEqMX12_`WL^J$ba}yc5;>70>>V%37hw_JS=o%*)Xqw zN8M-r0=1ua?9s${2JF9E-M2Z#IAL?4$1$sNLtkhc9`+k1p=U;CB<0k#SsincIaczUm m;uj3I2ds7b8ULq$U|ito z;usRqdUo1IzrzLsZU0?nMof?}YS0R(V7k}Px^?}5o*Mz-%lLTqFmbOxaI1A9>qnM| zwMs@Q4ho@b5*ecVinpD=&he}N+t+{Rub;koz+RiV;dHn4<_+aBlNzn(_s8noy#6k8 zT9Vy--@qeH7RT~(xIEt7uBh7a_SW?3Z9BOSvFbA<{Jl7%^=onSv)qe}4XdIV4g{8J zJWL2p31H0SW4QWcx%{-O)}>LM3MMCN%zBw`Jey+1xO3+|rDAD@>oN21u`3B)6~CwU zNBgP6t(RMmtvXZ|azO0)m#E|rMJrD8sl1uzC&zd6{1soZ%e47qy1?zlN$d<$I`_K0 zEk0ALq%B}v`28;9Q{&}syLPaL+~t#+X4H3AS-Q4uqgSEcMj3{0{O8!VPn~P?C9|kn ziQ|B$UgHCkMT`qpJ;?Im`0M8Jt}!d9%28#ifO+Dn6MT*p_nD&>sue3H1xOvLTO_Jj zEPZIY%~GLNd4cohe6P}dsW;(NdA|h1IdO$X4$1EfL6g0DS2l}%OIsrzq)_wh{rbQ6 spM_kw!Sz)3PFtD5b|s<5YcHD5KJY3)?S{i)1_lNOPgg&ebxsLQ06bRIxc~qF literal 0 HcmV?d00001 diff --git a/core/assets/icons/icons.properties b/core/assets/icons/icons.properties index 7e7c3f434e..c2f12a72fb 100755 --- a/core/assets/icons/icons.properties +++ b/core/assets/icons/icons.properties @@ -386,3 +386,4 @@ 63347=ferric-stone|block-ferric-stone-ui 63346=ferric-stone-wall|block-ferric-stone-wall-ui 63345=ferric-craters|block-ferric-craters-ui +63344=ferric-boulder|block-ferric-boulder-ui diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 70a946a023..16831b009d 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -42,7 +42,8 @@ public class Blocks implements ContentList{ redweed, purbush, coralChunk, yellowCoral, regolithWall, yellowStoneWall, rhyoliteWall, carbonWall, redIceWall, ferricStoneWall, ferricStone, ferricCraters, graphiticStone, - iceSnow, sandWater, darksandWater, duneWall, sandWall, moss, sporeMoss, shale, shaleWall, shaleBoulder, sandBoulder, daciteBoulder, boulder, snowBoulder, basaltBoulder, grass, salt, + iceSnow, sandWater, darksandWater, duneWall, sandWall, moss, sporeMoss, shale, shaleWall, grass, salt, + shaleBoulder, sandBoulder, daciteBoulder, boulder, snowBoulder, basaltBoulder, ferricBoulder, metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor4, metalFloor5, basalt, magmarock, hotrock, snowWall, saltWall, darkPanel1, darkPanel2, darkPanel3, darkPanel4, darkPanel5, darkPanel6, darkMetal, pebbles, tendrils, @@ -477,6 +478,11 @@ public class Blocks implements ContentList{ variants = 2; }}; + ferricBoulder = new Prop("ferric-boulder"){{ + variants = 2; + ferricStone.asFloor().decoration = this; + }}; + moss = new Floor("moss"){{ variants = 3; attributes.set(Attribute.spores, 0.15f); diff --git a/core/src/mindustry/maps/generators/BasicGenerator.java b/core/src/mindustry/maps/generators/BasicGenerator.java index bee63cc9eb..6c6ea86e5c 100644 --- a/core/src/mindustry/maps/generators/BasicGenerator.java +++ b/core/src/mindustry/maps/generators/BasicGenerator.java @@ -83,6 +83,41 @@ public abstract class BasicGenerator implements WorldGenerator{ }); } + public void ore(Block dest, Block src, float i, float thresh){ + pass((x, y) -> { + if(floor != src) return; + + if(Math.abs(0.5f - noise(x, y + i*999, 2, 0.7, (40 + i * 2))) > 0.26f * thresh && + Math.abs(0.5f - noise(x, y - i*999, 1, 1, (30 + i * 4))) > 0.37f * thresh){ + ore = dest; + } + }); + } + + public void oreAround(Block ore, Block wall, int radius, float scl, float thresh){ + for(Tile tile : tiles){ + int x = tile.x, y = tile.y; + + if(tile.block() == Blocks.air && tile.floor().hasSurface() && noise(x, y + ore.id*999, scl, 1f) > thresh){ + boolean found = false; + + outer: + for(int dx = x-radius; dx <= x+radius; dx++){ + for(int dy = y-radius; dy <= y+radius; dy++){ + if(Mathf.within(dx, dy, x, y, radius + 0.001f) && tiles.in(dx, dy) && tiles.get(dx, dy).block() == wall){ + found = true; + break outer; + } + } + } + + if(found){ + tile.setOverlay(ore); + } + } + } + } + public void terrain(Block dst, float scl, float mag, float cmag){ pass((x, y) -> { double rocks = noise(x, y, 5, 0.5, scl) * mag @@ -245,6 +280,21 @@ public abstract class BasicGenerator implements WorldGenerator{ } } + public void decoration(float chance){ + pass((x, y) -> { + for(int i = 0; i < 4; i++){ + Tile near = world.tile(x + Geometry.d4[i].x, y + Geometry.d4[i].y); + if(near != null && near.block() != Blocks.air){ + return; + } + } + + if(rand.chance(chance) && floor.asFloor().hasSurface() && block == Blocks.air){ + block = floor.asFloor().decoration; + } + }); + } + public void brush(Seq path, int rad){ path.each(tile -> erase(tile.x, tile.y, rad)); } diff --git a/core/src/mindustry/maps/planet/AsteroidGenerator.java b/core/src/mindustry/maps/planet/AsteroidGenerator.java index 6b713a8095..eff010294c 100644 --- a/core/src/mindustry/maps/planet/AsteroidGenerator.java +++ b/core/src/mindustry/maps/planet/AsteroidGenerator.java @@ -6,26 +6,32 @@ import mindustry.content.*; import mindustry.game.*; import mindustry.maps.generators.*; import mindustry.type.*; +import mindustry.world.blocks.environment.*; import mindustry.world.meta.*; import static mindustry.Vars.*; public class AsteroidGenerator extends BlankPlanetGenerator{ + //TODO nonstatic public static int min = 20, max = 28, octaves = 2, foct = 3; - public static float radMin = 12f, radMax = 60f, persistence = 0.4f, scale = 30f, mag = 0.46f, thresh = 1f; - public static float fmag = 0.6f, fscl = 50f, fper = 0.6f; + public static float iceChance = 0.05f, carbonChance = 0.1f; Rand rand; int seed; void asteroid(int ax, int ay, int radius){ + Floor floor = ( + rand.chance(iceChance) ? Blocks.ice : + rand.chance(carbonChance) ? Blocks.graphiticStone : + Blocks.ferricStone + ).asFloor(); for(int x = ax - radius; x <= ax + radius; x++){ for(int y = ay - radius; y <= ay + radius; y++){ if(tiles.in(x, y) && Mathf.dst(x, y, ax, ay) / (radius) + Simplex.noise2d(seed, octaves, persistence, 1f / scale, x, y) * mag < thresh){ - tiles.getn(x, y).setFloor(Blocks.ferricStone.asFloor()); + tiles.getn(x, y).setFloor(floor); } } } @@ -41,6 +47,7 @@ public class AsteroidGenerator extends BlankPlanetGenerator{ floor = Blocks.space; }); + //spawn asteroids asteroid(sx, sy, rand.random(30, 50)); int amount = rand.random(min, max); @@ -50,7 +57,7 @@ public class AsteroidGenerator extends BlankPlanetGenerator{ asteroid((int)ax, (int)ay, (int)radius); } - //tiny asteroids. + //tiny asteroids int smalls = rand.random(min, max) * 3; for(int i = 0; i < smalls; i++){ float radius = rand.random(1, 8), ax = rand.random(radius, width - radius), ay = rand.random(radius, height - radius); @@ -58,6 +65,7 @@ public class AsteroidGenerator extends BlankPlanetGenerator{ asteroid((int)ax, (int)ay, (int)radius); } + //random noise stone pass((x, y) -> { if(floor != Blocks.space){ if(Ridged.noise2d(seed, x, y, foct, fper, 1f / fscl) > fmag){ @@ -66,6 +74,7 @@ public class AsteroidGenerator extends BlankPlanetGenerator{ } }); + //walls at insides pass((x, y) -> { if(floor == Blocks.space || Ridged.noise2d(seed + 1, x, y, 3, 0.5f, 1f / 60f) > 0.38f || Mathf.within(x, y, sx, sy, 20 + Ridged.noise2d(seed, x, y, 3, 0.5f, 1f / 30f) * 6f)) return; @@ -82,11 +91,20 @@ public class AsteroidGenerator extends BlankPlanetGenerator{ }); + //random craters pass((x, y) -> { if(floor == Blocks.ferricStone && rand.chance(0.02)) floor = Blocks.ferricCraters; if(floor == Blocks.stone && rand.chance(0.02)) floor = Blocks.craters; }); + decoration(0.013f); + + //lead generates around stone walls + oreAround(Blocks.oreLead, Blocks.stoneWall, 3, 69f, 0.6f); + + //copper only generates on ferric stone + ore(Blocks.oreCopper, Blocks.ferricStone, 5f, 0.8f); + Schematics.placeLaunchLoadout(sx, sy); state.rules.environment = Env.space; diff --git a/core/src/mindustry/world/blocks/campaign/LaunchPad.java b/core/src/mindustry/world/blocks/campaign/LaunchPad.java index 03f7343044..1f65097c47 100644 --- a/core/src/mindustry/world/blocks/campaign/LaunchPad.java +++ b/core/src/mindustry/world/blocks/campaign/LaunchPad.java @@ -115,10 +115,6 @@ public class LaunchPad extends Block{ Draw.reset(); } - float cooldown = Mathf.clamp(launchCounter / (90f)); - - Draw.mixcol(lightColor, 1f - cooldown); - Draw.rect(podRegion, x, y); Draw.reset(); diff --git a/gradle.properties b/gradle.properties index 1399d52bbd..7e78e05dc3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,4 +10,4 @@ kapt.include.compile.classpath=false kotlin.stdlib.default.dependency=false #needed for android compilation android.useAndroidX=true -archash=3de7a709fa1c0ba8cb0131f0fc6b02524e18016b +archash=b9d3067269d34c8f0cf3657c6b3919e327727f7e