コード例 #1
0
  /**
   * Gets all malfunctionables associated with a settlement.
   *
   * @param settlement the settlement.
   * @return collection of malfunctionables.
   */
  public static Collection<Malfunctionable> getAssociatedMalfunctionables(Settlement settlement) {

    // Add settlement, buildings and all other malfunctionables in settlement inventory.
    Collection<Malfunctionable> entities = getMalfunctionables(settlement);

    // Add all associated rovers out on missions and their inventories.
    Iterator<Mission> i =
        Simulation.instance().getMissionManager().getMissionsForSettlement(settlement).iterator();
    while (i.hasNext()) {
      Mission mission = i.next();
      if (mission instanceof VehicleMission) {
        Vehicle vehicle = ((VehicleMission) mission).getVehicle();
        if ((vehicle != null) && !settlement.equals(vehicle.getSettlement()))
          entities.addAll(getMalfunctionables(vehicle));
      }
    }

    // Get entities carried by robots
    Iterator<Robot> jj = settlement.getAllAssociatedRobots().iterator();
    while (jj.hasNext()) {
      Robot robot = jj.next();
      if (robot.getLocationSituation() == LocationSituation.OUTSIDE)
        entities.addAll(getMalfunctionables(robot));
    }

    // TODO: how to ask robots first and only ask people if robots are not available so that the
    // tasks are not duplicated ?
    // Get entities carried by people on EVA.
    Iterator<Person> j = settlement.getAllAssociatedPeople().iterator();
    while (j.hasNext()) {
      Person person = j.next();
      if (person.getLocationSituation() == LocationSituation.OUTSIDE)
        entities.addAll(getMalfunctionables(person));
    }

    return entities;
  }
コード例 #2
0
  /**
   * Checks if the person is in a moving vehicle.
   *
   * @param person the person.
   * @return true if person is in a moving vehicle.
   */
  public static boolean inMovingRover(Person person) {

    boolean result = false;

    if (person.getLocationSituation() == LocationSituation.IN_VEHICLE) {
      Vehicle vehicle = person.getVehicle();
      if (vehicle.getStatus().equals(Vehicle.MOVING)) {
        result = true;
      } else if (vehicle.getStatus().equals(Vehicle.TOWED)) {
        Vehicle towingVehicle = vehicle.getTowingVehicle();
        if (towingVehicle.getStatus().equals(Vehicle.MOVING)
            || towingVehicle.getStatus().equals(Vehicle.TOWED)) {
          result = false;
        }
      }
    }

    return result;
  }