From 3ee7ee7e79593d7e6c35e8fba5a9e59b9bf4bed8 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 27 Oct 2021 18:25:58 -0400 Subject: [PATCH] WIP pressure turbine --- .../blocks/power/pressure-turbine-rotator.png | Bin 0 -> 1238 bytes .../sprites/blocks/power/pressure-turbine.png | Bin 0 -> 2005 bytes core/assets/icons/icons.properties | 1 + core/assets/logicids.dat | Bin 2927 -> 2945 bytes core/src/mindustry/content/Blocks.java | 22 ++++++++ core/src/mindustry/content/Fx.java | 11 ++++ .../src/mindustry/world/blocks/Autotiler.java | 16 +----- .../world/blocks/power/ThermalGenerator.java | 48 ++++++++++++++++-- core/src/mindustry/world/meta/Attribute.java | 4 +- tools/build.gradle | 2 +- 10 files changed, 85 insertions(+), 19 deletions(-) create mode 100644 core/assets-raw/sprites/blocks/power/pressure-turbine-rotator.png create mode 100644 core/assets-raw/sprites/blocks/power/pressure-turbine.png diff --git a/core/assets-raw/sprites/blocks/power/pressure-turbine-rotator.png b/core/assets-raw/sprites/blocks/power/pressure-turbine-rotator.png new file mode 100644 index 0000000000000000000000000000000000000000..76e45e92970a7d185b08c7a0f1931aa15405d365 GIT binary patch literal 1238 zcmV;{1S$K8P)Px(kV!;ARCt{2oWD;LK@`WoM=Yc@7MfTd6sKH8YXucV3$e5&R)kPnTwzU!m7%h* z1PTdM`cFtg1Eq=n2T*YqW@H@a$D7%CGqc?Lba(8{&VIi;GjHD81rP*55ClOG1VIo4 zK@bE%5CnDxwL6f)$NkS!+xKrb-}LT!de>o>_=>)n(5udd#8>pmgt^)sn04-zI+1?& zwt9!w=wp!)U``#>siY*e`p9m8>q1&Gp=KXh4G3L83ntX=BilT;w!SePE-Ya*8U~N0 z&bM3J6OtGo_9mqEV#MWI6Ie#T+WN*604^`iaDILnJif+Ah&?A)AF~^v#8ni9VnXg{h$Xagtpz&6g(Xs3dPtd)jH4Jy36;%ubHOqNQAPrVy%pf* zIDI7C98acuE8*iPBcWIO0KjhoY6<=rnCvB?Od~6qU z`&;<8=5)lJ6)lo-RVH*1UlB6FCB7oYgc2#~B4Oz1$>D$^{<}xl?0un5N2TfkMGGUo zh~(vu?*M@D@**BSy>C6H>lCEp8wu28UJi;^rfeoC@f9``sNyS9O(-coP^l=dn_!Bs z&`pRHUlD6UY4L%IPep8PPo^&M731Ya96fl}={!^uYKRY1ek|qd>sQ|Re)nnsTT#aq zv%7Y*Art0a)Da(O;JF}|3AMv~yQd#Rtk1UAmSi<=N26hyj%m11cj1R7MP_OeX_!)qZ`%gsUboVQ4BG^`Q#;lmRf()f3sgr7gTGV}o{+TODQi}36Vofk3Dw_#2 zSCpqbmg0kIf-9WWO_;gIQYcR;=P5O(;=cjyadjggg79c1iJL&Z(QgwIgP|a7t7ZBR)0C%H1aC4Z^wz zhdN&4&X4T_cOTiKAlC)7AiknzAB(-H?fcvUwffkc5I#88fZ8;(5t~(dbEhamqo7ZB zKhQ%10JjN!6JHPnK@bE%5ClOG1VIo4K@bY@8`2_q=o?>5l>h($07*qoM6N<$g5&Be A+5i9m literal 0 HcmV?d00001 diff --git a/core/assets-raw/sprites/blocks/power/pressure-turbine.png b/core/assets-raw/sprites/blocks/power/pressure-turbine.png new file mode 100644 index 0000000000000000000000000000000000000000..7322043c40a21b69a830e718a1d6f422786adc01 GIT binary patch literal 2005 zcmV;`2P*i9P)Px+k4Z#9RCt{2ojqtBM-a#72^Vr3R9JR!mOJA;hRk;WBn%V?)5H(i#kMEQs|g4|y3QDGKVz?Li3gRtfhe6i{W1AFbtC2K!B|}D zj4S~tO-V@I9aIJ^=GPV#Q>qkeNx3w=9RV5&7E2rA`sD-8ZY~Yyjlu5Z`IZ3W7DUG=s zDfB|y2^0gMIw~m$*in%{kQi)%;C>%zW@8JBzXYPnWZ^b z6GIGvdkRP)WC3vI$AP4}=oAD^#!dN5ey)Mpl$`Fbnkgbh1$O5n?5JHfepZmQ;+O$Fl)?T)xQzj|_ zB@ndccOec!P4fX1k01+#Uw-<6y5HwBEOII$d1M90a&E{MaG@f**u7sxzf~WbEOs$}4 zfl%9g0DvQ!lgGZFzS@M(J|91xdJ}r-%H^VtSr_8WkG~`D`mp~RzRI{D$;WH%Tfiih z1daKWH1h~V05s!xCLKbl`6wxbEC93*kxRwvSdlxiqngQroGXNc{c!CC{!?=7w zEgy;}XlN3hguVdxlFrMAP(>3oG>J}v`KVF|nkRs&Cmat-8VVDdB=b?PU%pB931SHM z|FFM`Fjc~m5n-rFG#{n;W?-G0tOhVG=A&vu7z5xjP84+*%tv`bh!+vu1JK1M$!S#x zL9|{_Ewvn!+o!Yv_94u5X+HP&VNE;K?TtI5PF_W{9F*Iqv?=xOT~N#6>3vW&03{z^ zS`JUI{cm$Bnx>jl3PRU|q9}Pz6mL3BmDAed5T4$=KpyK8gj6iI&MumlRcJa*l~VXQ zP79&s@N~|6R80s)b%17FO(}$y!_y_^qf!v8Hz;a0O*K;MX{s&&Fd^w^h*Ait%Dwdc z)6<(5;QjL*(JC(*UpTonLpAGarXEKUan0M3rZ2`MSzzSXPfwfEiRCg))v~Up1%kw2 z3xqfp4g&rzSud%{G}SneS`akGYR*l?KtYKA<{&hgrs}b-X05y0V(h>?YCjm+%Qcglv+cmbnKAl4jR<;P@2-5Te63ex)s!VT}?`q zS)~JlshBk8FD%WQVo(9-VqMKxo;zs73S-lnZ;hd7f<}vVHA6`<=K;ZLz9oj@2^vxe zH{Q*=uj^k!TU$fXdT;>zGWJa;Xw+O+v!%k=au7;3HVVZ8(7cANwXS9>Q8A?;U|u~S zB%7huci>^0Sz45(`sUT9=)C(MF1w~1w)3eQtz@4yvILYYuB};DQzOmXWbb_nFfXZ6 zUQ!Yc04QDA9Kd&7O#qvr-VkzmvO*XG;9)*~u<$aVM zfRY_Ftg%@kklWd!v=B?rT literal 0 HcmV?d00001 diff --git a/core/assets/icons/icons.properties b/core/assets/icons/icons.properties index d8453cd7eb..d5e212e9b9 100755 --- a/core/assets/icons/icons.properties +++ b/core/assets/icons/icons.properties @@ -410,3 +410,4 @@ 63298=core-bastion|block-core-bastion-ui 63297=plasma-bore|block-plasma-bore-ui 63296=steam-vent|block-steam-vent-ui +63295=pressure-turbine|block-pressure-turbine-ui diff --git a/core/assets/logicids.dat b/core/assets/logicids.dat index adb153965d62d6bf558091fdb25e28914a6b4f4b..e8366cab67c89bbd7ac9fef787998fbe80897826 100644 GIT binary patch delta 34 pcmaDa)+o-zuxuk!FsGnEK~ZXPacNPiZb@lTQf6N2<`7P4CIH3&3qk+@ delta 16 XcmZn^e=o+wuyi9+Fz4oUPAMh;EMo+d diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index bd989e8082..261be9b837 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -77,6 +77,7 @@ public class Blocks implements ContentList{ //power combustionGenerator, thermalGenerator, steamGenerator, differentialGenerator, rtgGenerator, solarPanel, largeSolarPanel, thoriumReactor, + pressureTurbine, impactReactor, battery, batteryLarge, powerNode, powerNodeLarge, surgeTower, diode, //production @@ -336,6 +337,7 @@ public class Blocks implements ContentList{ steamVent = new SteamVent("steam-vent"){{ parent = blendGroup = rhyolite; + attributes.set(Attribute.vent, 1f); }}; regolith = new Floor("regolith"){{ @@ -1490,6 +1492,26 @@ public class Blocks implements ContentList{ consumes.liquid(Liquids.cryofluid, 0.25f); }}; + //TODO work on sprite, green bits? + pressureTurbine = new ThermalGenerator("pressure-turbine"){{ + requirements(Category.power, with(Items.graphite, 35, Items.lead, 50, Items.beryllium, 25)); + attribute = Attribute.vent; + displayEfficiencyScale = 1f / 9f; + minEfficiency = 9f - 0.0001f; + powerProduction = 1f; + displayEfficiency = false; + generateEffect = Fx.turbinegenerate; + effectChance = 0.04f; + size = 3; + ambientSound = Sounds.hum; + ambientSoundVolume = 0.06f; + spinSpeed = 0.6f; + spinners = true; + hasLiquids = true; + liquidOutput = new LiquidStack(Liquids.water, 5f / 60f / 9f); + liquidCapacity = 20f; + }}; + //endregion power //region production diff --git a/core/src/mindustry/content/Fx.java b/core/src/mindustry/content/Fx.java index 7d9c1c5f7a..d91f3325e8 100644 --- a/core/src/mindustry/content/Fx.java +++ b/core/src/mindustry/content/Fx.java @@ -1632,6 +1632,17 @@ public class Fx{ } }).layer(Layer.bullet - 1f), + turbinegenerate = new Effect(100, e -> { + color(Pal.vent); + alpha(e.fslope() * 0.8f); + + rand.setSeed(e.id); + for(int i = 0; i < 3; i++){ + v.trns(rand.random(360f), rand.random(e.finpow() * 14f)).add(e.x, e.y); + Fill.circle(v.x, v.y, rand.random(1.4f, 3.4f)); + } + }).layer(Layer.bullet - 1f), + generatespark = new Effect(18, e -> { randLenVectors(e.id, 5, e.fin() * 8f, (x, y) -> { float len = e.fout() * 4f; diff --git a/core/src/mindustry/world/blocks/Autotiler.java b/core/src/mindustry/world/blocks/Autotiler.java index 44a69c13c5..3c5c1cb503 100644 --- a/core/src/mindustry/world/blocks/Autotiler.java +++ b/core/src/mindustry/world/blocks/Autotiler.java @@ -30,8 +30,6 @@ public interface Autotiler{ } /** - * Slices a texture region depending on the SliceMode paramater - * * @param input The TextureRegion to be sliced * @param mode The SliceMode to be applied * @return The sliced texture @@ -40,12 +38,7 @@ public interface Autotiler{ return mode == SliceMode.none ? input : mode == SliceMode.bottom ? botHalf(input) : topHalf(input); } - /** - * Get the top half of a texture - * - * @param input The TextureRegion to slice - * @return The top half of the texture - */ + /** @return The top half of the input */ default TextureRegion topHalf(TextureRegion input){ TextureRegion region = Tmp.tr1; region.set(input); @@ -53,12 +46,7 @@ public interface Autotiler{ return region; } - /** - * Get the buttom half of a texture - * - * @param input The TextureRegion to slice - * @return The buttom half of the texture - */ + /** @return The bottom half of the input */ default TextureRegion botHalf(TextureRegion input){ TextureRegion region = Tmp.tr1; region.set(input); diff --git a/core/src/mindustry/world/blocks/power/ThermalGenerator.java b/core/src/mindustry/world/blocks/power/ThermalGenerator.java index d0b979a29d..981ea3395a 100644 --- a/core/src/mindustry/world/blocks/power/ThermalGenerator.java +++ b/core/src/mindustry/world/blocks/power/ThermalGenerator.java @@ -2,25 +2,42 @@ package mindustry.world.blocks.power; import arc.*; import arc.graphics.*; +import arc.graphics.g2d.*; import arc.math.*; +import arc.util.*; +import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.entities.*; import mindustry.game.*; import mindustry.graphics.*; +import mindustry.type.*; import mindustry.world.*; import mindustry.world.meta.*; public class ThermalGenerator extends PowerGenerator{ public Effect generateEffect = Fx.none; public float effectChance = 0.05f; + public float minEfficiency = 0f; + public float spinSpeed = 1f; + public float displayEfficiencyScale = 1f; + public boolean spinners = false; + public boolean displayEfficiency = true; + public @Nullable LiquidStack liquidOutput; public Attribute attribute = Attribute.heat; + public @Load("@-rotator") TextureRegion rotatorRegion; + public @Load("@-rotator-blur") TextureRegion blurRegion; + public ThermalGenerator(String name){ super(name); } @Override public void init(){ + if(liquidOutput != null){ + outputsLiquid = true; + hasLiquids = true; + } super.init(); //proper light clipping clipSize = Math.max(clipSize, 45f * size * 2f * 2f); @@ -30,24 +47,32 @@ public class ThermalGenerator extends PowerGenerator{ public void setStats(){ super.setStats(); - stats.add(Stat.tiles, attribute, floating, size * size, false); + stats.add(Stat.tiles, attribute, floating, size * size * displayEfficiencyScale, !displayEfficiency); } @Override public void drawPlace(int x, int y, int rotation, boolean valid){ super.drawPlace(x, y, rotation, valid); - drawPlaceText(Core.bundle.formatFloat("bar.efficiency", sumAttribute(attribute, x, y) * 100, 1), x, y, valid); + if(displayEfficiency){ + drawPlaceText(Core.bundle.formatFloat("bar.efficiency", sumAttribute(attribute, x, y) * 100, 1), x, y, valid); + } } @Override public boolean canPlaceOn(Tile tile, Team team, int rotation){ //make sure there's heat at this location - return tile.getLinkedTilesAs(this, tempTiles).sumf(other -> other.floor().attributes.get(attribute)) > 0.01f; + return tile.getLinkedTilesAs(this, tempTiles).sumf(other -> other.floor().attributes.get(attribute)) > minEfficiency; + } + + @Override + public TextureRegion[] icons(){ + return spinners ? new TextureRegion[]{region, rotatorRegion} : super.makeIconRegions(); } public class ThermalGeneratorBuild extends GeneratorBuild{ public float sum; + public float spinRotation; @Override public void updateTile(){ @@ -56,6 +81,23 @@ public class ThermalGenerator extends PowerGenerator{ if(productionEfficiency > 0.1f && Mathf.chanceDelta(effectChance)){ generateEffect.at(x + Mathf.range(3f), y + Mathf.range(3f)); } + + spinRotation += productionEfficiency * spinSpeed; + + if(liquidOutput != null){ + float added = Math.min(productionEfficiency * delta() * liquidOutput.amount, liquidCapacity - liquids.get(liquidOutput.liquid)); + liquids.add(liquidOutput.liquid, added); + dumpLiquid(liquidOutput.liquid); + } + } + + @Override + public void draw(){ + super.draw(); + + if(spinners){ + Drawf.spinSprite(blurRegion.found() ? blurRegion : rotatorRegion, x, y, spinRotation); + } } @Override diff --git a/core/src/mindustry/world/meta/Attribute.java b/core/src/mindustry/world/meta/Attribute.java index a57dae4bb4..3b8554fd8e 100644 --- a/core/src/mindustry/world/meta/Attribute.java +++ b/core/src/mindustry/world/meta/Attribute.java @@ -19,7 +19,9 @@ public class Attribute{ /** Light coverage. Negative values decrease solar panel efficiency. */ light = add("light"), /** Silicate content. Used for sand extraction. */ - silicate = add("silicate"); + silicate = add("silicate"), + /** Used for erekir vents only. */ + vent = add("vent"); public final int id; public final String name; diff --git a/tools/build.gradle b/tools/build.gradle index 35b87b39ef..17872781a8 100644 --- a/tools/build.gradle +++ b/tools/build.gradle @@ -35,7 +35,7 @@ def transformColors = { List> list -> //TODO implementing this in gradle is a bad idea //d4816b -transformColors([["bf92f9", "8a73c6", "665c9f"], ["6e7080", "989aa4", "b0bac0"], ["bc5452", "ea8878", "feb380"], +transformColors([["4a4b53", "6e7080", "989aa4"], ["3a5651", "3a8f64", "92dd7e"], ["bf92f9", "8a73c6", "665c9f"], /*["6e7080", "989aa4", "b0bac0"],*/ ["bc5452", "ea8878", "feb380"], ["de9458", "f8c266", "ffe18f"], ["feb380", "ea8878", "bc5452"], ["d4816b", "eab678", "ffd37f"], ["ffffff", "dcc6c6", "9d7f7f"], ["df7646", "b23a4d", "752249"], ["3c3837", "515151", "646567"], ["5757c1", "6f80e8", "88a4ff"], ["8f665b", "b28768", "c9a58f"]])