forked from Upstream/mmocore
More debug for waypoints
This commit is contained in:
parent
e41749135e
commit
5a2e05bb12
@ -157,7 +157,7 @@ public class WaypointViewer extends EditableInventory {
|
|||||||
Waypoint waypoint = inv.waypoints.get(inv.page * inv.getByFunction("waypoint").getSlots().size() + n);
|
Waypoint waypoint = inv.waypoints.get(inv.page * inv.getByFunction("waypoint").getSlots().size() + n);
|
||||||
holders.register("name", waypoint.getName());
|
holders.register("name", waypoint.getName());
|
||||||
if (!onlyName) {
|
if (!onlyName) {
|
||||||
holders.register("current_cost",inv.paths.get(waypoint).getCost());
|
holders.register("current_cost", inv.paths.get(waypoint).getCost());
|
||||||
holders.register("normal_cost", decimal.format(inv.paths.containsKey(waypoint) ? inv.paths.get(waypoint).getCost() : Double.POSITIVE_INFINITY));
|
holders.register("normal_cost", decimal.format(inv.paths.containsKey(waypoint) ? inv.paths.get(waypoint).getCost() : Double.POSITIVE_INFINITY));
|
||||||
holders.register("dynamic_cost", decimal.format(waypoint.getDynamicCost()));
|
holders.register("dynamic_cost", decimal.format(waypoint.getDynamicCost()));
|
||||||
holders.register("intermediary_waypoints", inv.paths.containsKey(waypoint) ? inv.paths.get(waypoint).displayIntermediaryWayPoints(inv.waypointCostType.equals(CostType.DYNAMIC_USE)) : "none");
|
holders.register("intermediary_waypoints", inv.paths.containsKey(waypoint) ? inv.paths.get(waypoint).displayIntermediaryWayPoints(inv.waypointCostType.equals(CostType.DYNAMIC_USE)) : "none");
|
||||||
@ -184,17 +184,20 @@ public class WaypointViewer extends EditableInventory {
|
|||||||
paths.put(pathInfo.getFinalWaypoint(), pathInfo);
|
paths.put(pathInfo.getFinalWaypoint(), pathInfo);
|
||||||
}
|
}
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
|
|
||||||
|
//Iterate through all the dynamic points and find all the points it is linked to and the path
|
||||||
|
HashMap<Waypoint, Double> dynamicPoints = new HashMap<>();
|
||||||
//We first check all the dynamic waypoints
|
//We first check all the dynamic waypoints
|
||||||
for (Waypoint waypoint : waypoints) {
|
for (Waypoint waypoint : waypoints) {
|
||||||
if (waypoint.canHaveDynamicUse(playerData.getPlayer()))
|
if (waypoint.canHaveDynamicUse(playerData.getPlayer())) {
|
||||||
paths.put(waypoint,new Waypoint.PathInfo(waypoint, waypoint.getDynamicCost()));
|
paths.put(waypoint, new Waypoint.PathInfo(waypoint, waypoint.getDynamicCost()));
|
||||||
|
dynamicPoints.put(waypoint, waypoint.getDynamicCost());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//Iterate through all the dynamic points and find all the points it is linked to and the path
|
for(Waypoint source: dynamicPoints.keySet()){
|
||||||
HashSet<Waypoint> waypointSet = new HashSet<>(paths.keySet());
|
|
||||||
for (Waypoint source : waypointSet) {
|
|
||||||
for (Waypoint.PathInfo target : source.getAllPath()) {
|
for (Waypoint.PathInfo target : source.getAllPath()) {
|
||||||
if (!paths.containsKey(target.getFinalWaypoint()) || paths.get(target.getFinalWaypoint()).getCost() > target.getCost()) {
|
if (!paths.containsKey(target.getFinalWaypoint()) || paths.get(target.getFinalWaypoint()).getCost() > target.getCost()+dynamicPoints.get(source)) {
|
||||||
paths.put(target.getFinalWaypoint(), target);
|
paths.put(target.getFinalWaypoint(), target.addCost(dynamicPoints.get(source)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ public class Waypoint implements Unlockable {
|
|||||||
|
|
||||||
public static class PathInfo {
|
public static class PathInfo {
|
||||||
private final ArrayList<Waypoint> waypoints;
|
private final ArrayList<Waypoint> waypoints;
|
||||||
private final double cost;
|
private double cost;
|
||||||
|
|
||||||
public ArrayList<Waypoint> getWaypoints() {
|
public ArrayList<Waypoint> getWaypoints() {
|
||||||
return waypoints;
|
return waypoints;
|
||||||
@ -261,6 +261,11 @@ public class Waypoint implements Unlockable {
|
|||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PathInfo addCost(double cost) {
|
||||||
|
this.cost+=cost;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<PathInfo> addInOrder(ArrayList<PathInfo> pathInfos) {
|
public ArrayList<PathInfo> addInOrder(ArrayList<PathInfo> pathInfos) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (index < pathInfos.size()) {
|
while (index < pathInfos.size()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user