From dd738a01088a3a483295bee491647124e460e30e Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 4 Aug 2021 18:31:36 -0400 Subject: [PATCH] Removed puddle 'generation' --- .../src/main/resources/revisions/PuddleComp/1.json | 1 + core/src/mindustry/entities/Puddles.java | 11 +++++------ core/src/mindustry/entities/comp/PuddleComp.java | 11 +++++------ 3 files changed, 11 insertions(+), 12 deletions(-) create mode 100644 annotations/src/main/resources/revisions/PuddleComp/1.json diff --git a/annotations/src/main/resources/revisions/PuddleComp/1.json b/annotations/src/main/resources/revisions/PuddleComp/1.json new file mode 100644 index 0000000000..2e4c653aed --- /dev/null +++ b/annotations/src/main/resources/revisions/PuddleComp/1.json @@ -0,0 +1 @@ +{version:1,fields:[{name:amount,type:float},{name:liquid,type:mindustry.type.Liquid},{name:tile,type:mindustry.world.Tile},{name:x,type:float},{name:y,type:float}]} \ No newline at end of file diff --git a/core/src/mindustry/entities/Puddles.java b/core/src/mindustry/entities/Puddles.java index 183f64eacc..f0928db3ed 100644 --- a/core/src/mindustry/entities/Puddles.java +++ b/core/src/mindustry/entities/Puddles.java @@ -16,12 +16,12 @@ public class Puddles{ /** Deposits a Puddle between tile and source. */ public static void deposit(Tile tile, Tile source, Liquid liquid, float amount){ - deposit(tile, source, liquid, amount, 0); + deposit(tile, source, liquid, amount, true); } /** Deposits a Puddle at a tile. */ public static void deposit(Tile tile, Liquid liquid, float amount){ - deposit(tile, tile, liquid, amount, 0); + deposit(tile, tile, liquid, amount, true); } /** Returns the Puddle on the specified tile. May return null. */ @@ -29,7 +29,7 @@ public class Puddles{ return map.get(tile.pos()); } - public static void deposit(Tile tile, Tile source, Liquid liquid, float amount, int generation){ + public static void deposit(Tile tile, Tile source, Liquid liquid, float amount, boolean initial){ if(tile == null) return; if(tile.floor().isLiquid && !canStayOn(liquid, tile.floor().liquidDrop)){ @@ -38,7 +38,7 @@ public class Puddles{ Puddle p = map.get(tile.pos()); - if(generation == 0 && p != null && p.lastRipple <= Time.time - 40f){ + 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); p.lastRipple = Time.time; } @@ -55,14 +55,13 @@ public class Puddles{ puddle.tile = tile; puddle.liquid = liquid; puddle.amount = amount; - puddle.generation = generation; puddle.set((tile.worldx() + source.worldx()) / 2f, (tile.worldy() + source.worldy()) / 2f); puddle.add(); map.put(tile.pos(), puddle); }else if(p.liquid == liquid){ p.accepting = Math.max(amount, p.accepting); - if(generation == 0 && p.lastRipple <= Time.time - 40f && p.amount >= maxLiquid / 2f){ + 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); p.lastRipple = Time.time; } diff --git a/core/src/mindustry/entities/comp/PuddleComp.java b/core/src/mindustry/entities/comp/PuddleComp.java index 12f56fbaa4..68972714e7 100644 --- a/core/src/mindustry/entities/comp/PuddleComp.java +++ b/core/src/mindustry/entities/comp/PuddleComp.java @@ -20,7 +20,6 @@ import static mindustry.entities.Puddles.*; @EntityDef(value = {Puddlec.class}, pooled = true) @Component(base = true) abstract class PuddleComp implements Posc, Puddlec, Drawc{ - private static final int maxGeneration = 2; private static final Rect rect = new Rect(), rect2 = new Rect(); private static int seeds; @@ -29,7 +28,6 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{ transient float accepting, updateTime, lastRipple; float amount; - int generation; Tile tile; Liquid liquid; @@ -39,22 +37,23 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{ @Override public void update(){ - //update code float addSpeed = accepting > 0 ? 3f : 0f; amount -= Time.delta * (1f - liquid.viscosity) / (5f + addSpeed); amount += accepting; accepting = 0f; - if(amount >= maxLiquid / 1.5f && generation < maxGeneration){ + if(amount >= maxLiquid / 1.5f){ float deposited = Math.min((amount - maxLiquid / 1.5f) / 4f, 0.3f) * Time.delta; + int targets = 0; for(Point2 point : Geometry.d4){ Tile other = world.tile(tile.x + point.x, tile.y + point.y); if(other != null && other.block() == Blocks.air){ - Puddles.deposit(other, tile, liquid, deposited, generation + 1); - amount -= deposited / 2f; //tweak to speed up/slow down Puddle propagation + targets ++; + Puddles.deposit(other, tile, liquid, deposited, false); } } + amount -= deposited * targets; } amount = Mathf.clamp(amount, 0, maxLiquid);