Beispiel #1
0
  private boolean buildingIsIsolated(Building position) {
    Graph graph = world.getPlatoonAgent().getPathPlanner().getGraph();

    for (Entrance entrance : world.getMrlBuilding(position.getID()).getEntrances()) {
      if (graph.getNodeBetweenAreas(position.getID(), entrance.getID(), null).isPassable()) {
        return false;
      }
    }
    return true;
  }
Beispiel #2
0
  /**
   * this method calculates the border entities, using entities and convexHull of the entities
   *
   * @param convex is the convex of all Entities
   * @param entities are the self entities
   * @param scale is the scale for making smaller convex hull
   */
  public Set<EntityID> getBorderEntities(ConvexHull convex, Set<EntityID> entities, double scale) {
    if (scale >= 1.0) {
      System.err.println(
          "scale should not be over 1.0! check it in border entities, border entities doesn't work now!");
      return null;
    }

    Building building;
    Polygon convexObject = convex.convex();
    Set<EntityID> borderEntities = new FastSet<EntityID>();

    if (convexObject.npoints
        == 0) { // I don't know why this happens, report me if this error writes usually! TODO check
      // this if something comes wrong here
      System.out.println("Something gone wrong in setting border entities for Firebrigade!!!");
      return null;
    }

    Polygon smallBorderPolygon = scalePolygon(convexObject, scale);
    //        Polygon bigBorderPolygon = scalePolygon(convexObject, 1.1);

    if (MRLConstants.LAUNCH_VIEWER) {
      //            MrlConvexHullLayer.BIG_Whole_BORDER_HULL = convex;
      //            MrlConvexHullLayer.SMALL_Whole_BORDER_HULL = smallBorderPolygon;
    }

    for (EntityID entityID : entities) {

      StandardEntity entity = world.getEntity(entityID);

      if (entity instanceof Refuge) continue;
      if (!(entity instanceof Building)) continue;
      building = (Building) entity;
      int vertexes[] = building.getApexList();
      for (int i = 0; i < vertexes.length; i += 2) {

        if ((convexObject.contains(vertexes[i], vertexes[i + 1]))
            && !(smallBorderPolygon.contains(vertexes[i], vertexes[i + 1]))) {
          borderEntities.add(building.getID());
          break;
        }
      }
    }

    return borderEntities;
  }