Slight puddle performance increase
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package mindustry.entities;
|
package mindustry.entities;
|
||||||
|
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.struct.*;
|
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
@@ -11,9 +10,9 @@ import mindustry.type.*;
|
|||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
|
|
||||||
public class Puddles{
|
import static mindustry.Vars.*;
|
||||||
private static final IntMap<Puddle> map = new IntMap<>();
|
|
||||||
|
|
||||||
|
public class Puddles{
|
||||||
public static final float maxLiquid = 70f;
|
public static final float maxLiquid = 70f;
|
||||||
|
|
||||||
/** Deposits a Puddle between tile and source. */
|
/** Deposits a Puddle between tile and source. */
|
||||||
@@ -28,7 +27,7 @@ public class Puddles{
|
|||||||
|
|
||||||
/** Returns the Puddle on the specified tile. May return null. */
|
/** Returns the Puddle on the specified tile. May return null. */
|
||||||
public static Puddle get(Tile tile){
|
public static Puddle get(Tile tile){
|
||||||
return map.get(tile.pos());
|
return world.tiles.puddle(tile.array());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void deposit(Tile tile, Tile source, Liquid liquid, float amount, boolean initial){
|
public static void deposit(Tile tile, Tile source, Liquid liquid, float amount, boolean initial){
|
||||||
@@ -57,7 +56,7 @@ public class Puddles{
|
|||||||
if(tile.floor().isLiquid && !canStayOn(liquid, tile.floor().liquidDrop)){
|
if(tile.floor().isLiquid && !canStayOn(liquid, tile.floor().liquidDrop)){
|
||||||
reactPuddle(tile.floor().liquidDrop, liquid, amount, tile, ax, ay);
|
reactPuddle(tile.floor().liquidDrop, liquid, amount, tile, ax, ay);
|
||||||
|
|
||||||
Puddle p = map.get(tile.pos());
|
Puddle p = get(tile);
|
||||||
|
|
||||||
if(initial && p != null && p.lastRipple <= Time.time - 40f){
|
if(initial && p != null && p.lastRipple <= Time.time - 40f){
|
||||||
Fx.ripple.at(ax, ay, 1f, tile.floor().liquidDrop.color);
|
Fx.ripple.at(ax, ay, 1f, tile.floor().liquidDrop.color);
|
||||||
@@ -68,7 +67,7 @@ public class Puddles{
|
|||||||
|
|
||||||
if(tile.floor().solid) return;
|
if(tile.floor().solid) return;
|
||||||
|
|
||||||
Puddle p = map.get(tile.pos());
|
Puddle p = get(tile);
|
||||||
if(p == null || p.liquid == null){
|
if(p == null || p.liquid == null){
|
||||||
if(!Vars.net.client()){
|
if(!Vars.net.client()){
|
||||||
//do not create puddles clientside as that destroys syncing
|
//do not create puddles clientside as that destroys syncing
|
||||||
@@ -77,7 +76,7 @@ public class Puddles{
|
|||||||
puddle.liquid = liquid;
|
puddle.liquid = liquid;
|
||||||
puddle.amount = amount;
|
puddle.amount = amount;
|
||||||
puddle.set(ax, ay);
|
puddle.set(ax, ay);
|
||||||
map.put(tile.pos(), puddle);
|
register(puddle);
|
||||||
puddle.add();
|
puddle.add();
|
||||||
}
|
}
|
||||||
}else if(p.liquid == liquid){
|
}else if(p.liquid == liquid){
|
||||||
@@ -101,11 +100,11 @@ public class Puddles{
|
|||||||
public static void remove(Tile tile){
|
public static void remove(Tile tile){
|
||||||
if(tile == null) return;
|
if(tile == null) return;
|
||||||
|
|
||||||
map.remove(tile.pos());
|
world.tiles.setPuddle(tile.array(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void register(Puddle puddle){
|
public static void register(Puddle puddle){
|
||||||
map.put(puddle.tile().pos(), puddle);
|
world.tiles.setPuddle(puddle.tile().array(), puddle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reacts two liquids together at a location. */
|
/** Reacts two liquids together at a location. */
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import static mindustry.entities.Puddles.*;
|
|||||||
/** Liquid that draws cells in its puddle. */
|
/** Liquid that draws cells in its puddle. */
|
||||||
public class CellLiquid extends Liquid{
|
public class CellLiquid extends Liquid{
|
||||||
public Color colorFrom = Color.white.cpy(), colorTo = Color.white.cpy();
|
public Color colorFrom = Color.white.cpy(), colorTo = Color.white.cpy();
|
||||||
public int cells = 8;
|
public int cells = 6;
|
||||||
|
|
||||||
public @Nullable Liquid spreadTarget;
|
public @Nullable Liquid spreadTarget;
|
||||||
public float maxSpread = 0.75f, spreadConversion = 1.2f, spreadDamage = 0.11f, removeScaling = 0.25f;
|
public float maxSpread = 0.75f, spreadConversion = 1.2f, spreadDamage = 0.11f, removeScaling = 0.25f;
|
||||||
@@ -122,7 +122,7 @@ public class CellLiquid extends Liquid{
|
|||||||
Fill.circle(
|
Fill.circle(
|
||||||
vx + Mathf.sin(Time.time + i * 532, sscl, smag),
|
vx + Mathf.sin(Time.time + i * 532, sscl, smag),
|
||||||
vy + Mathf.sin(Time.time + i * 53, sscl, smag),
|
vy + Mathf.sin(Time.time + i * 53, sscl, smag),
|
||||||
f * 3.8f * rand.random(0.2f, 1f) * Mathf.absin(Time.time + ((i + id) % 60) * 54, 75f * rand.random(1f, 2f), 1f));
|
f * 3.8f * rand.random(0.35f, 1f) * Mathf.absin(Time.time + ((i + id) % 60) * 54, 75f * rand.random(1f, 2f), 1f));
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.color();
|
Draw.color();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import arc.func.*;
|
|||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
import arc.math.geom.*;
|
import arc.math.geom.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@@ -12,11 +13,21 @@ public class Tiles implements Iterable<Tile>{
|
|||||||
public final int width, height;
|
public final int width, height;
|
||||||
|
|
||||||
final Tile[] array;
|
final Tile[] array;
|
||||||
|
final Puddle[] puddles;
|
||||||
|
|
||||||
public Tiles(int width, int height){
|
public Tiles(int width, int height){
|
||||||
this.array = new Tile[width * height];
|
this.array = new Tile[width * height];
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
this.puddles = new Puddle[width * height];
|
||||||
|
}
|
||||||
|
|
||||||
|
public Puddle puddle(int pos){
|
||||||
|
return puddles[pos];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPuddle(int pos, Puddle p){
|
||||||
|
puddles[pos] = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void each(Intc2 cons){
|
public void each(Intc2 cons){
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ org.gradle.caching=true
|
|||||||
#used for slow jitpack builds; TODO see if this actually works
|
#used for slow jitpack builds; TODO see if this actually works
|
||||||
org.gradle.internal.http.socketTimeout=100000
|
org.gradle.internal.http.socketTimeout=100000
|
||||||
org.gradle.internal.http.connectionTimeout=100000
|
org.gradle.internal.http.connectionTimeout=100000
|
||||||
archash=8deb453b78
|
archash=ea8fa3b50d
|
||||||
|
|||||||
Reference in New Issue
Block a user