From 0b49bd19852226a225d66bc38961452a40e4039e Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 4 Jun 2019 17:10:45 -0400 Subject: [PATCH] Pathfinding tweak / Doors now update pathfinding --- core/src/io/anuke/mindustry/ai/Pathfinder.java | 8 ++++++++ .../src/io/anuke/mindustry/world/blocks/defense/Door.java | 3 +++ 2 files changed, 11 insertions(+) diff --git a/core/src/io/anuke/mindustry/ai/Pathfinder.java b/core/src/io/anuke/mindustry/ai/Pathfinder.java index fbf9cd3c57..026cdbe0e7 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfinder.java +++ b/core/src/io/anuke/mindustry/ai/Pathfinder.java @@ -39,6 +39,10 @@ public class Pathfinder{ }); } + public void updateSolid(Tile tile){ + update(tile, tile.getTeam()); + } + public void update(){ if(Net.client() || paths == null) return; @@ -94,6 +98,10 @@ public class Pathfinder{ if(paths != null && paths[team.ordinal()] != null && paths[team.ordinal()].weights != null){ PathData path = paths[team.ordinal()]; + if(!path.frontier.isEmpty()){ + return; + } + //impassable tiles have a weight of float.max if(!passable(tile, team)){ path.weights[tile.x][tile.y] = Float.MAX_VALUE; diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/Door.java b/core/src/io/anuke/mindustry/world/blocks/defense/Door.java index 07454f6849..04da951cff 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/Door.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/Door.java @@ -16,6 +16,8 @@ import io.anuke.mindustry.world.Tile; import java.io.*; +import static io.anuke.mindustry.Vars.world; + public class Door extends Wall{ protected final Rectangle rect = new Rectangle(); @@ -68,6 +70,7 @@ public class Door extends Wall{ } entity.open = !entity.open; + world.pathfinder.updateSolid(tile); if(!entity.open){ Effects.effect(closefx, tile.drawx(), tile.drawy()); }else{