mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-26 22:42:41 -08:00
Null checks & cleanup of upgrade pathing
This commit is contained in:
parent
6c67dc1266
commit
a18e1854ab
4 changed files with 14 additions and 17 deletions
|
|
@ -38,9 +38,9 @@ public class Puddles{
|
|||
|
||||
Puddle p = map.get(tile.pos());
|
||||
|
||||
if(generation == 0 && p != null && p.lastRipple() <= Time.time - 40f){
|
||||
if(generation == 0 && 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);
|
||||
p.lastRipple = Time.time;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -62,9 +62,9 @@ public class Puddles{
|
|||
}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(generation == 0 && 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);
|
||||
p.lastRipple = Time.time;
|
||||
}
|
||||
}else{
|
||||
p.amount(p.amount() + reactPuddle(p.liquid(), liquid, amount, p.tile(), (p.x() + source.worldx())/2f, (p.y() + source.worldy())/2f));
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ abstract class PuddleComp implements Posc, Puddlec, Drawc{
|
|||
|
||||
@Import float x, y;
|
||||
|
||||
transient float accepting, updateTime;
|
||||
transient float accepting, updateTime, lastRipple;
|
||||
float amount;
|
||||
int generation;
|
||||
Tile tile;
|
||||
|
|
|
|||
|
|
@ -1162,11 +1162,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||
}
|
||||
|
||||
if(diagonal){
|
||||
Tile start = world.tile(startX, startY);
|
||||
Tile end = world.tile(endX, endY);
|
||||
if(block != null && block instanceof Autotiler
|
||||
&& start.build instanceof ChainedBuilding && end.build instanceof ChainedBuilding
|
||||
&& block.canReplace(end.build.block) && block.canReplace(start.build.block)){
|
||||
var start = world.build(startX, startY);
|
||||
var end = world.build(endX, endY);
|
||||
if(block != null && start instanceof ChainedBuilding && end instanceof ChainedBuilding
|
||||
&& block.canReplace(end.block) && block.canReplace(start.block)){
|
||||
points = Placement.upgradeLine(startX, startY, endX, endY);
|
||||
}else{
|
||||
points = Placement.pathfindLine(block != null && block.conveyorPlacement, startX, startY, endX, endY);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import arc.math.*;
|
|||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
|
||||
|
|
@ -58,13 +57,12 @@ public class Placement{
|
|||
public static Seq<Point2> upgradeLine(int startX, int startY, int endX, int endY){
|
||||
Pools.freeAll(points);
|
||||
points.clear();
|
||||
Building building = world.tile(startX, startY).build;
|
||||
var build = world.build(startX, startY);
|
||||
points.add(Pools.obtain(Point2.class, Point2::new).set(startX, startY));
|
||||
while(building.tile.x != endX || building.tile.y != endY){
|
||||
ChainedBuilding chained = (ChainedBuilding)building;
|
||||
if(chained.next() == null) return pathfindLine(true, startX, startY, endX, endY);
|
||||
building = chained.next();
|
||||
points.add(Pools.obtain(Point2.class, Point2::new).set(building.tile.x, building.tile.y));
|
||||
while(build instanceof ChainedBuilding chain && (build.tile.x != endX || build.tile.y != endY)){
|
||||
if(chain.next() == null) return pathfindLine(true, startX, startY, endX, endY);
|
||||
build = chain.next();
|
||||
points.add(Pools.obtain(Point2.class, Point2::new).set(build.tile.x, build.tile.y));
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue