From 8f389665a1506b3fd778911b54fb6f76be9d5966 Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 20 Aug 2021 11:42:27 -0400 Subject: [PATCH] Space 'puddles' --- core/src/mindustry/content/Bullets.java | 7 ++- core/src/mindustry/content/Liquids.java | 2 + core/src/mindustry/entities/Puddles.java | 21 +++++-- .../bullet/SpaceLiquidBulletType.java | 55 +++++++++++++++++++ 4 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 core/src/mindustry/entities/bullet/SpaceLiquidBulletType.java diff --git a/core/src/mindustry/content/Bullets.java b/core/src/mindustry/content/Bullets.java index d04f78d622..e2969bf16c 100644 --- a/core/src/mindustry/content/Bullets.java +++ b/core/src/mindustry/content/Bullets.java @@ -26,7 +26,7 @@ public class Bullets implements ContentList{ standardDenseBig, standardThoriumBig, standardIncendiaryBig, //liquid - waterShot, cryoShot, slagShot, oilShot, heavyWaterShot, heavyCryoShot, heavySlagShot, heavyOilShot, + waterShot, cryoShot, slagShot, oilShot, heavyWaterShot, heavyCryoShot, heavySlagShot, heavyOilShot, spaceLiquid, //environment, misc. damageLightning, damageLightningGround, fireball, basicFlame, pyraFlame; @@ -476,5 +476,10 @@ public class Bullets implements ContentList{ statusDuration = 60f * 4f; damage = 0.2f; }}; + + spaceLiquid = new SpaceLiquidBulletType(){{ + knockback = 0.7f; + drag = 0.01f; + }}; } } diff --git a/core/src/mindustry/content/Liquids.java b/core/src/mindustry/content/Liquids.java index 4f05f1a757..e07fd7e137 100644 --- a/core/src/mindustry/content/Liquids.java +++ b/core/src/mindustry/content/Liquids.java @@ -32,6 +32,8 @@ public class Liquids implements ContentList{ heatCapacity = 0.7f; barColor = Color.valueOf("6b675f"); effect = StatusEffects.tarred; + boilPoint = 0.65f; + gasColor = Color.grays(0.4f); }}; cryofluid = new Liquid("cryofluid", Color.valueOf("6ecdec")){{ diff --git a/core/src/mindustry/entities/Puddles.java b/core/src/mindustry/entities/Puddles.java index 2b94f31b1e..c1d05851a1 100644 --- a/core/src/mindustry/entities/Puddles.java +++ b/core/src/mindustry/entities/Puddles.java @@ -3,11 +3,13 @@ package mindustry.entities; import arc.math.*; import arc.struct.*; import arc.util.*; +import mindustry.*; import mindustry.content.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.type.*; import mindustry.world.*; +import mindustry.world.meta.*; public class Puddles{ private static final IntMap map = new IntMap<>(); @@ -32,21 +34,30 @@ public class Puddles{ public static void deposit(Tile tile, Tile source, Liquid liquid, float amount, boolean initial){ if(tile == null) return; + float ax = (tile.worldx() + source.worldx()) / 2f, ay = (tile.worldy() + source.worldy()) / 2f; + if(liquid.willBoil()){ if(Mathf.chanceDelta(0.16f)){ - liquid.vaporEffect.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, liquid.gasColor); + liquid.vaporEffect.at(ax, ay, liquid.gasColor); + } + return; + } + + if(Vars.state.rules.hasEnv(Env.space)){ + if(Mathf.chanceDelta(0.11f) && tile != source){ + Bullets.spaceLiquid.create(null, source.team(), ax, ay, source.angleTo(tile) + Mathf.range(50f), -1f, Mathf.random(0f, 0.2f), Mathf.random(0.6f, 1f), liquid); } 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); + ax, ay); Puddle p = map.get(tile.pos()); if(initial && p != null && p.lastRipple <= Time.time - 40f){ - Fx.ripple.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, 1f, tile.floor().liquidDrop.color); + Fx.ripple.at(ax, ay, 1f, tile.floor().liquidDrop.color); p.lastRipple = Time.time; } return; @@ -60,14 +71,14 @@ public class Puddles{ puddle.tile = tile; puddle.liquid = liquid; puddle.amount = amount; - puddle.set((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); + puddle.set(ax, ay); map.put(tile.pos(), puddle); puddle.add(); }else if(p.liquid == liquid){ p.accepting = Math.max(amount, p.accepting); if(initial && p.lastRipple <= Time.time - 40f && p.amount >= maxLiquid / 2f){ - Fx.ripple.at((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f, 1f, p.liquid.color); + Fx.ripple.at(ax, ay, 1f, p.liquid.color); p.lastRipple = Time.time; } }else{ diff --git a/core/src/mindustry/entities/bullet/SpaceLiquidBulletType.java b/core/src/mindustry/entities/bullet/SpaceLiquidBulletType.java new file mode 100644 index 0000000000..d68f225728 --- /dev/null +++ b/core/src/mindustry/entities/bullet/SpaceLiquidBulletType.java @@ -0,0 +1,55 @@ +package mindustry.entities.bullet; + +import arc.graphics.g2d.*; +import arc.math.*; +import mindustry.content.*; +import mindustry.gen.*; +import mindustry.type.*; + +//this should probably be an effect? +public class SpaceLiquidBulletType extends BulletType{ + public float orbSize = 5.5f; + + public SpaceLiquidBulletType(){ + super(3.5f, 0); + + collides = false; + lifetime = 90f; + despawnEffect = Fx.none; + hitEffect = Fx.none; + smokeEffect = Fx.none; + shootEffect = Fx.none; + drag = 0.001f; + } + + @Override + public float range(){ + return speed * lifetime / 2f; + } + + @Override + public void update(Bullet b){ + super.update(b); + + if(!(b.data instanceof Liquid liquid)) return; + } + + @Override + public void draw(Bullet b){ + super.draw(b); + + if(!(b.data instanceof Liquid liquid)) return; + + Draw.color(liquid.color); + Fill.circle(b.x, b.y, Interp.pow3Out.apply(b.fslope()) * orbSize); + + Draw.reset(); + } + + @Override + public void despawned(Bullet b){ + super.despawned(b); + + if(!(b.data instanceof Liquid liquid)) return; + } +}