Package com.bergerkiller.bukkit.tc.pathfinding

Examples of com.bergerkiller.bukkit.tc.pathfinding.PathNode


    final String lastName = prop.getDestination();
    if (LogicUtil.nullOrEmpty(lastName)) {
      msg.append(" is not trying to reach a destination.");
    } else {
      msg.append(" is trying to reach ").green(lastName).newLine();
      final PathNode first = PathNode.get(prop.getLastPathNode());
      if (first == null) {
        msg.yellow("It has not yet visited a routing node, so no route is available yet.");
      } else {
        PathNode last = PathNode.get(lastName);
        if (last == null) {
          msg.red("The destination position to reach can not be found!");
        } else {
          // Calculate the exact route taken from first to last
          PathNode[] route = first.findRoute(last);
          msg.yellow("Route: ");
          if (route.length == 0) {
            msg.red(first.getDisplayName() + " /=/ " + last.getDisplayName() + " (not found)");
          } else {
            msg.setSeparator(ChatColor.YELLOW, " -> ");
            for (PathNode node : route) {
              msg.green(node.getDisplayName());
            }
View Full Code Here


      }
    }

    // Handle destination alternatively
    if (info.isAction(SignActionType.MEMBER_ENTER, SignActionType.GROUP_ENTER) && (facing || !info.isWatchedDirectionsDefined())) {
      PathNode node = PathNode.getOrCreate(info);
      if (node != null) {
        String destination = null;
        IProperties prop = null;
        if (doCart && info.hasMember()) {
          prop = info.getMember().getProperties();
        } else if (doTrain && info.hasGroup()) {
          prop = info.getGroup().getProperties();
        }
        if (prop != null) {
          destination = prop.getDestination();
          prop.setLastPathNode(node.getName());
        }
        // Continue with path finding if a valid destination is specified
        // If the current node denotes the destination - don't switch!
        if (!LogicUtil.nullOrEmpty(destination) && !node.containsName(destination)) {
          if (PathProvider.isProcessing()) {
            double currentForce = info.getGroup().getAverageForce();
            // Add an action to let the train wait until the node IS explored
            info.getGroup().getActions().addAction(new GroupActionWaitPathFinding(info, node, destination));
            info.getMember().getActions().addActionLaunch(info.getMember().getDirectionFrom(), 1.0, currentForce);
            info.getGroup().stop();
          } else {
            // Switch the rails to the right direction
            PathConnection conn = node.findConnection(destination);
            if (conn != null) {
              info.setRailsTo(conn.direction);
            }
          }
        }
View Full Code Here

  @Override
  public void destroy(SignActionEvent event) {
    // Remove the switcher name (location toString) from the available node names
    Block rails = event.getRails();
    if (rails != null) {
      PathNode node = PathNode.get(rails);
      if (node != null) {
        node.removeName(node.location.toString());
      }
    }
  }
View Full Code Here

      succ = handleBuild(event, Permission.BUILD_DESTINATION, "cart destination", "set a cart destination and the next destination to set once it is reached");
    } else if (event.isRCSign()) {
      succ = handleBuild(event, Permission.BUILD_DESTINATION, "train destination", "set the destination on a remote train");
    }
    if (succ && !event.getLine(2).isEmpty()) {
      PathNode node = PathNode.get(event.getLine(2));
      if (node != null) {
        Player p = event.getPlayer();
        p.sendMessage(ChatColor.RED + "Another destination with the same name already exists!");
        p.sendMessage(ChatColor.RED + "Please remove either sign and use /train reroute to fix");
View Full Code Here

  @Override
  public void destroy(SignActionEvent event) {
    String name = event.getLine(2);
    if (!LogicUtil.nullOrEmpty(name)) {
      PathNode node = PathNode.get(name);
      if (node != null) {
        node.removeName(name);
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.bergerkiller.bukkit.tc.pathfinding.PathNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.