This commit is contained in:
2023-10-27 21:55:31 -05:00
parent c63c5e6896
commit f002de704b
4 changed files with 27 additions and 8 deletions
@@ -20,6 +20,7 @@ import engine.gameManager.ChatManager;
import engine.gameManager.MovementManager;
import engine.gameManager.ZoneManager;
import engine.math.Bounds;
import engine.math.Vector3f;
import engine.math.Vector3fImmutable;
import engine.mobileAI.Threads.MobAIThread;
import engine.net.client.msg.MoveToPointMsg;
@@ -303,9 +304,23 @@ private static final int cellGap = 1;
if(character.region == null && Regions.getRegionAtLocation(goal) != null) {//mover not inside a building
Building building = BuildingManager.getBuildingAtLocation(goal);
for (Regions region : building.getBounds().getRegions())
ArrayList<Regions> entrances = new ArrayList<>();
for (Regions region : building.getBounds().getRegions()) {
if (region.exit && region.level == 0)
goal = new Vector3fImmutable(region.center.x, region.center.y, region.center.z);
entrances.add(region);
}
Regions cheapest = null;
for(Regions entrance : entrances){
if(cheapest == null) {
cheapest = entrance;
continue;
}
if(getCost(new Vector3fImmutable(entrance.center),character.loc,goal) < getCost(new Vector3fImmutable(cheapest.center),character.loc,goal))
cheapest = entrance;
}
goal = new Vector3fImmutable(cheapest.center.x, cheapest.center.y, cheapest.center.z);
}
ArrayList<Vector3fImmutable> path = getOptimizedPath(getPath(character.loc, goal), getPath(goal, character.loc));