WIP pressure turbine

This commit is contained in:
Anuken
2021-10-27 18:25:58 -04:00
parent 7843785182
commit 3ee7ee7e79
10 changed files with 85 additions and 19 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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);

View File

@@ -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

View File

@@ -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;