From 90826b70640fdf287c08180a27fe25882604bd46 Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 19 Aug 2021 20:39:49 -0400 Subject: [PATCH] Boiling point implementation --- core/src/mindustry/content/Fx.java | 18 +++++++++++++++ core/src/mindustry/content/Liquids.java | 2 ++ core/src/mindustry/entities/Puddles.java | 7 ++++++ .../entities/bullet/LiquidBulletType.java | 22 ++++++++++++++++--- core/src/mindustry/type/Liquid.java | 11 ++++++++++ 5 files changed, 57 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/content/Fx.java b/core/src/mindustry/content/Fx.java index 3c96c0ee7d..1e51544749 100644 --- a/core/src/mindustry/content/Fx.java +++ b/core/src/mindustry/content/Fx.java @@ -900,6 +900,24 @@ public class Fx{ }); }), + vapor = new Effect(110f, e -> { + color(e.color); + alpha(e.fout()); + + randLenVectors(e.id, 3, 2f + e.finpow() * 11f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 0.6f + e.fin() * 5f); + }); + }), + + vaporSmall = new Effect(50f, e -> { + color(e.color); + alpha(e.fout()); + + randLenVectors(e.id, 4, 2f + e.finpow() * 5f, (x, y) -> { + Fill.circle(e.x + x, e.y + y, 1f + e.fin() * 4f); + }); + }), + fireballsmoke = new Effect(25f, e -> { color(Color.gray); diff --git a/core/src/mindustry/content/Liquids.java b/core/src/mindustry/content/Liquids.java index 5ab7820b70..9b725ec562 100644 --- a/core/src/mindustry/content/Liquids.java +++ b/core/src/mindustry/content/Liquids.java @@ -14,6 +14,8 @@ public class Liquids implements ContentList{ heatCapacity = 0.4f; alwaysUnlocked = true; effect = StatusEffects.wet; + boilPoint = 0.5f; + gasColor = Color.grays(0.9f); }}; slag = new Liquid("slag", Color.valueOf("ffa166")){{ diff --git a/core/src/mindustry/entities/Puddles.java b/core/src/mindustry/entities/Puddles.java index 8422329c6c..2b94f31b1e 100644 --- a/core/src/mindustry/entities/Puddles.java +++ b/core/src/mindustry/entities/Puddles.java @@ -32,6 +32,13 @@ public class Puddles{ public static void deposit(Tile tile, Tile source, Liquid liquid, float amount, boolean initial){ if(tile == null) return; + if(liquid.willBoil()){ + if(Mathf.chanceDelta(0.16f)){ + liquid.vaporEffect.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, liquid.gasColor); + } + return; + } + if(tile.floor().isLiquid && !canStayOn(liquid, tile.floor().liquidDrop)){ reactPuddle(tile.floor().liquidDrop, liquid, amount, tile, (tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); diff --git a/core/src/mindustry/entities/bullet/LiquidBulletType.java b/core/src/mindustry/entities/bullet/LiquidBulletType.java index 7a788f69c5..4363418094 100644 --- a/core/src/mindustry/entities/bullet/LiquidBulletType.java +++ b/core/src/mindustry/entities/bullet/LiquidBulletType.java @@ -2,6 +2,7 @@ package mindustry.entities.bullet; import arc.graphics.*; import arc.graphics.g2d.*; +import arc.math.*; import arc.math.geom.*; import arc.util.*; import mindustry.content.*; @@ -16,6 +17,7 @@ public class LiquidBulletType extends BulletType{ public Liquid liquid; public float puddleSize = 6f; public float orbSize = 3f; + public float boilTime = 15f; public LiquidBulletType(@Nullable Liquid liquid){ super(3.5f, 0); @@ -52,6 +54,12 @@ public class LiquidBulletType extends BulletType{ public void update(Bullet b){ super.update(b); + if(liquid.willBoil() && b.time >= Mathf.randomSeed(b.id, boilTime)){ + Fx.vaporSmall.at(b.x, b.y, liquid.gasColor); + b.remove(); + return; + } + if(liquid.canExtinguish()){ Tile tile = world.tileWorld(b.x, b.y); if(tile != null && Fires.has(tile.x, tile.y)){ @@ -65,8 +73,14 @@ public class LiquidBulletType extends BulletType{ @Override public void draw(Bullet b){ super.draw(b); - Draw.color(liquid.color, Color.white, b.fout() / 100f); - Fill.circle(b.x, b.y, orbSize); + if(liquid.willBoil()){ + Draw.color(liquid.color, Tmp.c3.set(liquid.gasColor).a(0.4f), b.time / Mathf.randomSeed(b.id, boilTime)); + Fill.circle(b.x, b.y, orbSize * (b.fin() * 1.1f + 1f)); + }else{ + Draw.color(liquid.color, Color.white, b.fout() / 100f); + Fill.circle(b.x, b.y, orbSize); + } + Draw.reset(); } @@ -75,7 +89,9 @@ public class LiquidBulletType extends BulletType{ super.despawned(b); //don't create liquids when the projectile despawns - hitEffect.at(b.x, b.y, b.rotation(), liquid.color); + if(!liquid.willBoil()){ + hitEffect.at(b.x, b.y, b.rotation(), liquid.color); + } } @Override diff --git a/core/src/mindustry/type/Liquid.java b/core/src/mindustry/type/Liquid.java index d1a0a89780..f306ef86ca 100644 --- a/core/src/mindustry/type/Liquid.java +++ b/core/src/mindustry/type/Liquid.java @@ -19,6 +19,8 @@ public class Liquid extends UnlockableContent{ /** Color used in pipes and on the ground. */ public Color color; + /** Color of this liquid in gas form. */ + public Color gasColor = Color.lightGray.cpy(); /** Color used in bars. */ public @Nullable Color barColor; /** Color used to draw lights. Note that the alpha channel is used to dictate brightness. */ @@ -39,6 +41,10 @@ public class Liquid extends UnlockableContent{ public Effect particleEffect = Fx.none; /** Particle effect rate spacing in ticks. */ public float particleSpacing = 60f; + /** Temperature at which this liquid vaporizes. This isn't just boiling. */ + public float boilPoint = 2f; + /** Effect when this liquid vaporizes. */ + public Effect vaporEffect = Fx.vapor; public Liquid(String name, Color color){ super(name); @@ -50,6 +56,11 @@ public class Liquid extends UnlockableContent{ this(name, new Color(Color.black)); } + /** @return true if this liquid will boil in this global environment. */ + public boolean willBoil(){ + return Attribute.heat.env() >= boilPoint; + } + public boolean canExtinguish(){ return flammability < 0.1f && temperature <= 0.5f; }