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 0000000000..76e45e9297 Binary files /dev/null and b/core/assets-raw/sprites/blocks/power/pressure-turbine-rotator.png differ 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 0000000000..7322043c40 Binary files /dev/null and b/core/assets-raw/sprites/blocks/power/pressure-turbine.png differ 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 adb153965d..e8366cab67 100644 Binary files a/core/assets/logicids.dat and b/core/assets/logicids.dat differ 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"]])