diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 1f91e6c36f..1c7f0dcea3 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -2445,8 +2445,11 @@ public class Blocks{ size = 3; ambientSound = Sounds.hum; ambientSoundVolume = 0.06f; - spinSpeed = 0.6f; - spinners = true; + + drawer = new DrawMulti(new DrawDefault(), new DrawBlurSpin("-rotator", 0.6f * 9f){{ + blurThresh = 0.01f; + }}); + hasLiquids = true; outputLiquid = new LiquidStack(Liquids.water, 5f / 60f / 9f); liquidCapacity = 20f; diff --git a/core/src/mindustry/world/blocks/defense/ShockwaveTower.java b/core/src/mindustry/world/blocks/defense/ShockwaveTower.java index ec93ed7de6..cc2733a9f5 100644 --- a/core/src/mindustry/world/blocks/defense/ShockwaveTower.java +++ b/core/src/mindustry/world/blocks/defense/ShockwaveTower.java @@ -31,6 +31,7 @@ public class ShockwaveTower extends Block{ public float cooldownMultiplier = 1f; public Effect waveEffect = Fx.pointShockwave; + //TODO switch to drawers eventually or something public float shapeRotateSpeed = 1f, shapeRadius = 6f; public int shapeSides = 4; diff --git a/core/src/mindustry/world/blocks/power/ConsumeGenerator.java b/core/src/mindustry/world/blocks/power/ConsumeGenerator.java index 8e59702727..16e213b3dc 100644 --- a/core/src/mindustry/world/blocks/power/ConsumeGenerator.java +++ b/core/src/mindustry/world/blocks/power/ConsumeGenerator.java @@ -17,6 +17,7 @@ public class ConsumeGenerator extends PowerGenerator{ /** The time in number of ticks during which a single item will produce power. */ public float itemDuration = 120f; + public float warmupSpeed = 0.05f; public float effectChance = 0.01f; public Effect generateEffect = Fx.none, consumeEffect = Fx.none; public float generateEffectRange = 3f; @@ -86,7 +87,7 @@ public class ConsumeGenerator extends PowerGenerator{ public void updateTile(){ boolean valid = efficiency > 0; - warmup = Mathf.lerpDelta(warmup, valid ? 1f : 0f, 0.05f); + warmup = Mathf.lerpDelta(warmup, valid ? 1f : 0f, warmupSpeed); productionEfficiency = efficiency * efficiencyMultiplier; totalTime += warmup * Time.delta; diff --git a/core/src/mindustry/world/blocks/power/ImpactReactor.java b/core/src/mindustry/world/blocks/power/ImpactReactor.java index 3a03595b34..30b988e97b 100644 --- a/core/src/mindustry/world/blocks/power/ImpactReactor.java +++ b/core/src/mindustry/world/blocks/power/ImpactReactor.java @@ -2,13 +2,10 @@ package mindustry.world.blocks.power; import arc.*; import arc.audio.*; -import arc.graphics.*; -import arc.graphics.g2d.*; import arc.math.*; import arc.struct.*; import arc.util.*; import arc.util.io.*; -import mindustry.annotations.Annotations.*; import mindustry.content.*; import mindustry.entities.*; import mindustry.game.EventType.*; @@ -16,6 +13,7 @@ import mindustry.gen.*; import mindustry.graphics.*; import mindustry.logic.*; import mindustry.ui.*; +import mindustry.world.draw.*; import mindustry.world.meta.*; import static mindustry.Vars.*; @@ -30,11 +28,6 @@ public class ImpactReactor extends PowerGenerator{ public Effect explodeEffect = Fx.impactReactorExplosion; public Sound explodeSound = Sounds.explosionbig; - public Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b"); - - public @Load("@-bottom") TextureRegion bottomRegion; - public @Load(value = "@-plasma-#", length = 4) TextureRegion[] plasmaRegions; - public ImpactReactor(String name){ super(name); hasPower = true; @@ -46,6 +39,8 @@ public class ImpactReactor extends PowerGenerator{ lightRadius = 115f; emitLight = true; envEnabled = Env.any; + + drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawPlasma(), new DrawDefault()); } @Override @@ -68,11 +63,6 @@ public class ImpactReactor extends PowerGenerator{ } } - @Override - public TextureRegion[] icons(){ - return new TextureRegion[]{bottomRegion, region}; - } - public class ImpactReactorBuild extends GeneratorBuild{ public float warmup, totalProgress; @@ -102,6 +92,11 @@ public class ImpactReactor extends PowerGenerator{ productionEfficiency = Mathf.pow(warmup, 5f); } + @Override + public float warmup(){ + return warmup; + } + @Override public float totalProgress(){ return totalProgress; @@ -111,29 +106,6 @@ public class ImpactReactor extends PowerGenerator{ public float ambientVolume(){ return warmup; } - - @Override - public void draw(){ - Draw.rect(bottomRegion, x, y); - - Draw.blend(Blending.additive); - for(int i = 0; i < plasmaRegions.length; i++){ - float r = ((float)plasmaRegions[i].width * Draw.scl - 3f + Mathf.absin(Time.time, 2f + i * 1f, 5f - i * 0.5f)); - - Draw.color(plasma1, plasma2, (float)i / plasmaRegions.length); - Draw.alpha((0.3f + Mathf.absin(Time.time, 2f + i * 2f, 0.3f + i * 0.05f)) * warmup); - Draw.rect(plasmaRegions[i], x, y, r, r, totalProgress * (12 + i * 6f)); - } - Draw.blend(); - - Draw.color(); - Draw.rect(region, x, y); - } - - @Override - public void drawLight(){ - Drawf.light(x, y, (110f + Mathf.absin(5, 5f)) * warmup, Tmp.c1.set(plasma2).lerp(plasma1, Mathf.absin(7f, 0.2f)), 0.8f * warmup); - } @Override public double sense(LAccess sensor){ diff --git a/core/src/mindustry/world/blocks/power/PowerGenerator.java b/core/src/mindustry/world/blocks/power/PowerGenerator.java index d534454e69..c3da8f2d85 100644 --- a/core/src/mindustry/world/blocks/power/PowerGenerator.java +++ b/core/src/mindustry/world/blocks/power/PowerGenerator.java @@ -76,6 +76,11 @@ public class PowerGenerator extends PowerDistributor{ drawer.draw(this); } + @Override + public float warmup(){ + return productionEfficiency; + } + @Override public void drawLight(){ super.drawLight(); diff --git a/core/src/mindustry/world/blocks/power/ThermalGenerator.java b/core/src/mindustry/world/blocks/power/ThermalGenerator.java index 6dfdcb1518..eb2eff6cee 100644 --- a/core/src/mindustry/world/blocks/power/ThermalGenerator.java +++ b/core/src/mindustry/world/blocks/power/ThermalGenerator.java @@ -2,10 +2,8 @@ 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.*; @@ -18,16 +16,11 @@ 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 outputLiquid; public Attribute attribute = Attribute.heat; - public @Load("@-rotator") TextureRegion rotatorRegion; - public @Load("@-rotator-blur") TextureRegion blurRegion; - public ThermalGenerator(String name){ super(name); noUpdateDisabled = true; @@ -72,13 +65,8 @@ public class ThermalGenerator extends PowerGenerator{ return tile.getLinkedTilesAs(this, tempTiles).sumf(other -> other.floor().attributes.get(attribute)) > minEfficiency; } - @Override - public TextureRegion[] icons(){ - return spinners ? new TextureRegion[]{region, rotatorRegion} : super.icons(); - } - public class ThermalGeneratorBuild extends GeneratorBuild{ - public float sum, spinRotation; + public float sum; @Override public void updateTile(){ @@ -88,8 +76,6 @@ public class ThermalGenerator extends PowerGenerator{ generateEffect.at(x + Mathf.range(3f), y + Mathf.range(3f)); } - spinRotation += productionEfficiency * spinSpeed; - if(outputLiquid != null){ float added = Math.min(productionEfficiency * delta() * outputLiquid.amount, liquidCapacity - liquids.get(outputLiquid.liquid)); liquids.add(outputLiquid.liquid, added); @@ -97,15 +83,6 @@ public class ThermalGenerator extends PowerGenerator{ } } - @Override - public void draw(){ - super.draw(); - - if(spinners){ - Drawf.spinSprite(blurRegion.found() && enabled && productionEfficiency > 0 ? blurRegion : rotatorRegion, x, y, spinRotation); - } - } - @Override public void drawLight(){ Drawf.light(x, y, (40f + Mathf.absin(10f, 5f)) * Math.min(productionEfficiency, 2f) * size, Color.scarlet, 0.4f); diff --git a/core/src/mindustry/world/draw/DrawPlasma.java b/core/src/mindustry/world/draw/DrawPlasma.java new file mode 100644 index 0000000000..2b5a47caeb --- /dev/null +++ b/core/src/mindustry/world/draw/DrawPlasma.java @@ -0,0 +1,45 @@ +package mindustry.world.draw; + +import arc.*; +import arc.graphics.*; +import arc.graphics.g2d.*; +import arc.math.*; +import arc.util.*; +import mindustry.gen.*; +import mindustry.graphics.*; +import mindustry.world.*; + +public class DrawPlasma extends DrawFlame{ + public TextureRegion[] regions; + public String suffix = "-plasma-"; + public int plasmas = 4; + + public Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b"); + + @Override + public void load(Block block){ + regions = new TextureRegion[plasmas]; + for(int i = 0; i < regions.length; i++){ + regions[i] = Core.atlas.find(block.name + suffix + i); + } + } + + @Override + public void drawLight(Building build){ + Drawf.light(build.x, build.y, (110f + Mathf.absin(5, 5f)) * build.warmup(), Tmp.c1.set(plasma2).lerp(plasma1, Mathf.absin(7f, 0.2f)), 0.8f * build.warmup()); + } + + @Override + public void draw(Building build){ + Draw.blend(Blending.additive); + for(int i = 0; i < regions.length; i++){ + float r = ((float)regions[i].width * Draw.scl - 3f + Mathf.absin(Time.time, 2f + i * 1f, 5f - i * 0.5f)); + + Draw.color(plasma1, plasma2, (float)i / regions.length); + Draw.alpha((0.3f + Mathf.absin(Time.time, 2f + i * 2f, 0.3f + i * 0.05f)) * build.warmup()); + Draw.rect(regions[i], build.x, build.y, r, r, build.totalProgress() * (12 + i * 6f)); + } + Draw.color(); + Draw.blend(); + } +}