From a2f40a556529385f10931287be300c10e5927903 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 13 Oct 2021 19:35:04 -0400 Subject: [PATCH] Fixed #6148 --- core/src/mindustry/ai/Pathfinder.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/core/src/mindustry/ai/Pathfinder.java b/core/src/mindustry/ai/Pathfinder.java index 0d5a8af8d8..beae777c76 100644 --- a/core/src/mindustry/ai/Pathfinder.java +++ b/core/src/mindustry/ai/Pathfinder.java @@ -13,6 +13,7 @@ import mindustry.game.EventType.*; import mindustry.game.*; import mindustry.gen.*; import mindustry.world.*; +import mindustry.world.blocks.environment.*; import mindustry.world.blocks.storage.*; import mindustry.world.meta.*; @@ -40,7 +41,7 @@ public class Pathfinder implements Runnable{ public static final Seq costTypes = Seq.with( //ground - (team, tile) -> (PathTile.team(tile) == team.id || PathTile.team(tile) == 0) && PathTile.solid(tile) ? impassable : 1 + + (team, tile) -> (PathTile.allDeep(tile) || (PathTile.team(tile) == team.id || PathTile.team(tile) == 0) && PathTile.solid(tile)) ? impassable : 1 + PathTile.health(tile) * 5 + (PathTile.nearSolid(tile) ? 2 : 0) + (PathTile.nearLiquid(tile) ? 6 : 0) + @@ -108,14 +109,16 @@ public class Pathfinder implements Runnable{ /** Packs a tile into its internal representation. */ private int packTile(Tile tile){ - boolean nearLiquid = false, nearSolid = false, nearGround = false, solid = tile.solid(); + boolean nearLiquid = false, nearSolid = false, nearGround = false, solid = tile.solid(), allDeep = tile.floor().isDeep(); for(int i = 0; i < 4; i++){ Tile other = tile.nearby(i); if(other != null){ - if(other.floor().isLiquid) nearLiquid = true; + Floor floor = other.floor(); + if(floor.isLiquid) nearLiquid = true; if(other.solid()) nearSolid = true; - if(!other.floor().isLiquid) nearGround = true; + if(!floor.isLiquid) nearGround = true; + if(!floor.isDeep()) allDeep = false; } } @@ -131,7 +134,8 @@ public class Pathfinder implements Runnable{ nearGround, nearSolid, tile.floor().isDeep(), - tile.floor().damageTaken > 0.00001f + tile.floor().damageTaken > 0.00001f, + allDeep ); } @@ -494,5 +498,7 @@ public class Pathfinder implements Runnable{ boolean deep; //whether the floor damages boolean damages; + //whether all tiles nearby are deep + boolean allDeep; } }