Ground units: Avoid stepping onto dangerous/deep floor

This commit is contained in:
Anuken
2021-01-17 09:21:11 -05:00
parent 02ef633529
commit f9adcfeed1
2 changed files with 6 additions and 1 deletions

View File

@@ -292,7 +292,7 @@ public class Pathfinder implements Runnable{
}
}
if(current == null || tl == impassable) return tile;
if(current == null || tl == impassable || (path.cost == costTypes.items[costGround] && current.dangerous() && !tile.dangerous())) return tile;
return current;
}

View File

@@ -378,6 +378,11 @@ public class Tile implements Position, QuadTreeObject, Displayable{
return block.destructible || block.breakable || block.update;
}
/** @return whether the floor on this tile deals damage or can be drowned on. */
public boolean dangerous(){
return !block.solid && (floor.isDeep() || floor.damageTaken > 0);
}
/**
* Iterates through the list of all tiles linked to this multiblock, or just itself if it's not a multiblock.
* The result contains all linked tiles, including this tile itself.