From 1baa82a7c64dcee98abfb8ff6f36bb53fbb5be98 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 8 Jul 2021 16:16:44 -0400 Subject: [PATCH] Mostly-complete cliff crusher implementation --- .../blocks/drills/cliff-crusher-top.png | Bin 0 -> 354 bytes .../sprites/blocks/drills/cliff-crusher.png | Bin 0 -> 1232 bytes core/assets/icons/icons.properties | 1 + core/assets/logicids.dat | Bin 2858 -> 2873 bytes core/src/mindustry/content/Blocks.java | 6 +- core/src/mindustry/content/Fx.java | 7 +++ .../world/blocks/production/WallCrafter.java | 53 ++++++++++++++---- tools/build.gradle | 3 +- 8 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 core/assets-raw/sprites/blocks/drills/cliff-crusher-top.png create mode 100644 core/assets-raw/sprites/blocks/drills/cliff-crusher.png diff --git a/core/assets-raw/sprites/blocks/drills/cliff-crusher-top.png b/core/assets-raw/sprites/blocks/drills/cliff-crusher-top.png new file mode 100644 index 0000000000000000000000000000000000000000..051e61abfb3d95f2c23289b78db4de816a94faad GIT binary patch literal 354 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=jKx9jP7LeL$-D%zWjtLRLn`LH zy}6tBkby|+L*XM_B0UG$RtBXrWF7J7uwo7f-pH67V8HT)V}tDLXEC>*YfogjA75#~ z&;bDo z2G=dV+`aRCmK>uu&-~Lm4xERX-59+jX4)i`yVmQ$KK#ie$Hp80Ri@F)k*fQEOR6D!y9*~n$VEbTTlkh>u zfUj2kvrU3!2-jp~h3D*DOJ~kyTIyo3mu-r`!9V7X?*(7{W-wz-&~I4#isATSyNbUn utr!IQ0%{o)-g#s=ow@&12@EbZnb%+Q`}r|7e*!Sj7(8A5T-G@yGywn`CW&zX literal 0 HcmV?d00001 diff --git a/core/assets-raw/sprites/blocks/drills/cliff-crusher.png b/core/assets-raw/sprites/blocks/drills/cliff-crusher.png new file mode 100644 index 0000000000000000000000000000000000000000..a98246695cecb19d1f0fdaec9d8456469c9aacf5 GIT binary patch literal 1232 zcmV;>1TXuEP)Px(ib+I4RCt`-o6l<#K@`VdgO|352aPsTq`?$nZ;^^Uh`_-BY- zl^$wuh0y;%uo%27NK;a@&`M5H+8*m6zB-wGGxOfe+a>My6gE4P`F=7#-`kyd_x|Jg z%-k$+w6(F$y3f?|>YBJrmA_fb^Bx@SAE;N1iZPHMTBGLTKTenB9JC{M57G)lQ?g`zKx@ZFxQkJz?>psfv z3BF$K-3MSnmwA*4!EC4o1hbA92%#bE1;D8Qwbwr;8<+xtDl37&X?qX=06>3gK6uaM z!jkj57zn;H90=UWlLY|455Z?1C4s=X*9SqeaF&Vz*U0a^WxnIT?Ggs52BsmRTS$ue3=z}9KH(XQR0BexS7{DKe#-JgQ8r;q^ipn zQOsd>745fnjHIp%E$jX^gm4Y#$i zE{_PA#)qGuiOh2!zzQkLT9D_x5#xsG0weOsd*LvpLvuILQHJHS4J~69|Ryd5mFFR0wYveNotL>h2vx|Hny2Ipi=%mN2$};yV+f?C=1t+e zR7i~2|GWkSt??hKOKKj45WEjdb5CCO#HeZBlszBBnm6U$2gLM*vdr6cYnTUMJRgwf zJyuVcTv+-Sa{A6{Sgd}5ZoYzb7U1-R*q0u(U%Nr&d5`rX82dEngOK{hhc*PWtsw}a zcmM@K>vb0`2vi$=5X7l5^9Quw^+|=`>!mIT!FPsSiist1cba9^ZNC>8l^iXzfzo?X u+&0-gK@6a5^C@LwAcz1|Wj>{>6vAJncYw9`g4dV;0000prDZ2y= diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index bb156a6587..1f41ed08d5 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -395,6 +395,7 @@ public class Blocks implements ContentList{ duneWall = new StaticWall("dune-wall"){{ basalt.asFloor().wall = darksandWater.asFloor().wall = darksandTaintedWater.asFloor().wall = this; + attributes.set(Attribute.silicate, 2f); }}; regolithWall = new StaticWall("regolith-wall"){{ @@ -411,6 +412,7 @@ public class Blocks implements ContentList{ carbonWall = new StaticWall("carbon-wall"){{ carbonStone.asFloor().wall = this; + attributes.set(Attribute.silicate, 0.7f); }}; ferricStoneWall = new StaticWall("ferric-stone-wall"){{ @@ -429,6 +431,7 @@ public class Blocks implements ContentList{ sandWall = new StaticWall("sand-wall"){{ sandWater.asFloor().wall = water.asFloor().wall = deepwater.asFloor().wall = this; + attributes.set(Attribute.silicate, 2f); }}; saltWall = new StaticWall("salt-wall"); @@ -1515,8 +1518,9 @@ public class Blocks implements ContentList{ cliffCrusher = new WallCrafter("cliff-crusher"){{ requirements(Category.production, with(Items.copper, 10)); - consumes.power(0.2f); + consumes.power(0.9f); + drillTime = 110f; size = 2; attribute = Attribute.silicate; output = Items.sand; diff --git a/core/src/mindustry/content/Fx.java b/core/src/mindustry/content/Fx.java index caf2b37f6a..35f7cfe190 100644 --- a/core/src/mindustry/content/Fx.java +++ b/core/src/mindustry/content/Fx.java @@ -1689,6 +1689,13 @@ public class Fx{ Lines.spikes(e.x, e.y, e.fin() * 5f, 2, 8); }), + mineWallSmall = new Effect(50, e -> { + color(e.color, Color.darkGray, e.fin()); + randLenVectors(e.id, 2, e.fin() * 6f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, e.fout() + 0.5f); + }); + }), + mineSmall = new Effect(30, e -> { color(e.color, Color.lightGray, e.fin()); randLenVectors(e.id, 3, e.fin() * 5f, (x, y) -> { diff --git a/core/src/mindustry/world/blocks/production/WallCrafter.java b/core/src/mindustry/world/blocks/production/WallCrafter.java index 11943a010e..f4bf3d67c9 100644 --- a/core/src/mindustry/world/blocks/production/WallCrafter.java +++ b/core/src/mindustry/world/blocks/production/WallCrafter.java @@ -12,19 +12,27 @@ import mindustry.entities.*; import mindustry.entities.units.*; import mindustry.game.*; import mindustry.gen.*; +import mindustry.graphics.*; import mindustry.type.*; +import mindustry.ui.*; import mindustry.world.*; import mindustry.world.meta.*; import static mindustry.Vars.*; public class WallCrafter extends Block{ + static int idx = 0; + public @Load("@-top") TextureRegion topRegion; + public @Load("@-rotator-bottom") TextureRegion rotatorBottomRegion; + public @Load("@-rotator") TextureRegion rotatorRegion; /** Time to produce one item at 100% efficiency. */ - public float drillTime = 200f; + public float drillTime = 150f; /** Effect randomly played while drilling. */ - public Effect updateEffect = Fx.mineSmall; + public Effect updateEffect = Fx.mineWallSmall; + public float updateEffectChance = 0.02f; + public float rotateSpeed = 2f; /** Attribute to check for wall output. */ public Attribute attribute = Attribute.silicate; @@ -44,6 +52,9 @@ public class WallCrafter extends Block{ @Override public void setBars(){ super.setBars(); + + bars.add("drillspeed", (WallCrafterBuild e) -> + new Bar(() -> Core.bundle.format("bar.drillspeed", Strings.fixed(e.lastEfficiency * 60 / drillTime, 2)), () -> Pal.ammo, () -> e.warmup)); } @Override @@ -77,16 +88,16 @@ public class WallCrafter extends Block{ @Override public void drawPlace(int x, int y, int rotation, boolean valid){ - float eff = getEfficiency(x, y, rotation, null); + float eff = getEfficiency(x, y, rotation, null, null); drawPlaceText(Core.bundle.formatFloat("bar.drillspeed", 60f / drillTime * eff, 2), x, y, valid); } @Override public boolean canPlaceOn(Tile tile, Team team, int rotation){ - return getEfficiency(tile.x, tile.y, rotation, null) > 0; + return getEfficiency(tile.x, tile.y, rotation, null, null) > 0; } - float getEfficiency(int tx, int ty, int rotation, @Nullable Cons ctile){ + float getEfficiency(int tx, int ty, int rotation, @Nullable Cons ctile, @Nullable Intc2 cpos){ float eff = 0f; int cornerX = tx - (size-1)/2, cornerY = ty - (size-1)/2, s = size; @@ -112,6 +123,10 @@ public class WallCrafter extends Block{ } } + if(cpos != null){ + cpos.get(rx, ry); + } + Tile other = world.tile(rx, ry); if(other != null && other.solid()){ float at = other.block().attributes.get(attribute); @@ -125,8 +140,7 @@ public class WallCrafter extends Block{ } public class WallCrafterBuild extends Building{ - public float time; - public float warmup; + public float time, warmup, totalTime, lastEfficiency; @Override public void updateTile(){ @@ -139,20 +153,24 @@ public class WallCrafter extends Block{ float eff = getEfficiency(tile.x, tile.y, rotation, dest -> { //TODO make not chance based? - if(cons && Mathf.chanceDelta(0.05 * warmup)){ + if(cons && Mathf.chanceDelta(updateEffectChance * warmup)){ updateEffect.at( - dest.worldx() + Mathf.range(3f) - dx, - dest.worldy() + Mathf.range(3f) - dy, - output.color + dest.worldx() + Mathf.range(3f) - dx * tilesize, + dest.worldy() + Mathf.range(3f) - dy * tilesize, + Tmp.c1.set(dest.block().mapColor).mul(1f) ); } - }); + }, null); + + lastEfficiency = eff * timeScale * efficiency(); if(cons && (time += edelta() * eff) >= drillTime){ items.add(output, 1); time %= drillTime; } + totalTime += edelta() * warmup; + if(timer(timerDump, dumpTime)){ dump(); } @@ -168,6 +186,17 @@ public class WallCrafter extends Block{ //TODO draw spinner drill thingies Draw.rect(block.region, x, y); Draw.rect(topRegion, x, y, rotdeg()); + float ds = 0.6f, dx = Geometry.d4x(rotation) * ds, dy = Geometry.d4y(rotation) * ds; + + int bs = (rotation == 0 || rotation == 3) ? 1 : -1; + idx = 0; + getEfficiency(tile.x, tile.y, rotation, null, (cx, cy) -> { + int sign = idx++ >= size/2 && size % 2 == 0 ? -1 : 1; + float vx = (cx - dx) * tilesize, vy = (cy - dy) * tilesize; + Draw.z(Layer.blockOver); + Draw.rect(rotatorBottomRegion, vx, vy, totalTime * rotateSpeed * sign * bs); + Draw.rect(rotatorRegion, vx, vy); + }); } } } diff --git a/tools/build.gradle b/tools/build.gradle index c9985b1612..d3307d5707 100644 --- a/tools/build.gradle +++ b/tools/build.gradle @@ -37,7 +37,8 @@ def transformColors = { List> list -> //d4816b transformColors([["a387ea", "8a73c6", "5c5e9f"], ["6e7080", "989aa4", "b0bac0"], ["bc5452", "ea8878", "feb380"], ["de9458", "f8c266", "ffe18f"], ["feb380", "ea8878", "bc5452"], ["d4816b", "eab678", "ffd37f"], - ["ffffff", "dcc6c6", "9d7f7f"], ["df7646", "b23a4d", "752249"], ["3c3837", "515151", "646567"]]) + ["ffffff", "dcc6c6", "9d7f7f"], ["df7646", "b23a4d", "752249"], ["3c3837", "515151", "646567"], + ["5757c1", "6f80e8", "88a4ff"], ["8f665b", "b28768", "c9a58f"]]) def antialias = { File file -> if(!doAntialias) return