mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-27 06:51:30 -08:00
Slight puddle performance increase
This commit is contained in:
parent
b5db3ca6af
commit
0b6ff5c56d
4 changed files with 22 additions and 12 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package mindustry.entities;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
|
|
@ -11,9 +10,9 @@ import mindustry.type.*;
|
|||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
public class Puddles{
|
||||
private static final IntMap<Puddle> map = new IntMap<>();
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class Puddles{
|
||||
public static final float maxLiquid = 70f;
|
||||
|
||||
/** Deposits a Puddle between tile and source. */
|
||||
|
|
@ -28,7 +27,7 @@ public class Puddles{
|
|||
|
||||
/** Returns the Puddle on the specified tile. May return null. */
|
||||
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){
|
||||
|
|
@ -57,7 +56,7 @@ public class Puddles{
|
|||
if(tile.floor().isLiquid && !canStayOn(liquid, tile.floor().liquidDrop)){
|
||||
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){
|
||||
Fx.ripple.at(ax, ay, 1f, tile.floor().liquidDrop.color);
|
||||
|
|
@ -68,7 +67,7 @@ public class Puddles{
|
|||
|
||||
if(tile.floor().solid) return;
|
||||
|
||||
Puddle p = map.get(tile.pos());
|
||||
Puddle p = get(tile);
|
||||
if(p == null || p.liquid == null){
|
||||
if(!Vars.net.client()){
|
||||
//do not create puddles clientside as that destroys syncing
|
||||
|
|
@ -77,7 +76,7 @@ public class Puddles{
|
|||
puddle.liquid = liquid;
|
||||
puddle.amount = amount;
|
||||
puddle.set(ax, ay);
|
||||
map.put(tile.pos(), puddle);
|
||||
register(puddle);
|
||||
puddle.add();
|
||||
}
|
||||
}else if(p.liquid == liquid){
|
||||
|
|
@ -101,11 +100,11 @@ public class Puddles{
|
|||
public static void remove(Tile tile){
|
||||
if(tile == null) return;
|
||||
|
||||
map.remove(tile.pos());
|
||||
world.tiles.setPuddle(tile.array(), null);
|
||||
}
|
||||
|
||||
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. */
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ import static mindustry.entities.Puddles.*;
|
|||
/** Liquid that draws cells in its puddle. */
|
||||
public class CellLiquid extends Liquid{
|
||||
public Color colorFrom = Color.white.cpy(), colorTo = Color.white.cpy();
|
||||
public int cells = 8;
|
||||
public int cells = 6;
|
||||
|
||||
public @Nullable Liquid spreadTarget;
|
||||
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(
|
||||
vx + Mathf.sin(Time.time + i * 532, 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();
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import arc.func.*;
|
|||
import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
|
@ -12,11 +13,21 @@ public class Tiles implements Iterable<Tile>{
|
|||
public final int width, height;
|
||||
|
||||
final Tile[] array;
|
||||
final Puddle[] puddles;
|
||||
|
||||
public Tiles(int width, int height){
|
||||
this.array = new Tile[width * height];
|
||||
this.width = width;
|
||||
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){
|
||||
|
|
|
|||
|
|
@ -25,4 +25,4 @@ org.gradle.caching=true
|
|||
#used for slow jitpack builds; TODO see if this actually works
|
||||
org.gradle.internal.http.socketTimeout=100000
|
||||
org.gradle.internal.http.connectionTimeout=100000
|
||||
archash=8deb453b78
|
||||
archash=ea8fa3b50d
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue