1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-19 04:17:50 +03:00

Removed puddle 'generation'

This commit is contained in:
Anuken 2021-08-04 18:31:36 -04:00
parent 3be5296572
commit dd738a0108
3 changed files with 11 additions and 12 deletions

View File

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

View File

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

View File

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