Slight puddle performance increase
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user