Added support for clearing map graph when map is disposed

Disposing maps was leaving invalid pathfinding results -- this fixes that
This commit is contained in:
Collin Smith
2019-12-04 23:49:20 -08:00
parent 5b6c0ed455
commit 1a7f6a95da
2 changed files with 5 additions and 0 deletions

View File

@ -365,6 +365,7 @@ public class Map implements Disposable {
zones.clear(); zones.clear();
for (DT1s dt1s : this.dt1s.values()) dt1s.clear(); for (DT1s dt1s : this.dt1s.values()) dt1s.clear();
dt1s.clear(); dt1s.clear();
mapGraph.clear();
} }
public Array<AssetDescriptor> getDependencies() { public Array<AssetDescriptor> getDependencies() {

View File

@ -24,6 +24,10 @@ public class MapGraph {
smoother = new PathSmoother<>(raycaster); smoother = new PathSmoother<>(raycaster);
} }
public void clear() {
identity.clear();
}
public Point2 getOrCreate(Vector2 src) { public Point2 getOrCreate(Vector2 src) {
return getOrCreate(tmpPoint.set(src)); return getOrCreate(tmpPoint.set(src));
} }