예제 #1
0
  /**
   * Gets a collection of malfunctionable entities local to the given person.
   *
   * @return collection collection of malfunctionables.
   */
  public static Collection<Malfunctionable> getMalfunctionables(Person person) {

    Collection<Malfunctionable> entities = new ArrayList<Malfunctionable>();
    LocationSituation location = person.getLocationSituation();

    if (location == LocationSituation.IN_SETTLEMENT) {
      entities = getMalfunctionables(person.getSettlement());
    }

    if (location == LocationSituation.IN_VEHICLE) {
      entities = getMalfunctionables(person.getVehicle());
    }

    Collection<Unit> inventoryUnits = person.getInventory().getContainedUnits();
    if (inventoryUnits.size() > 0) {
      Iterator<Unit> i = inventoryUnits.iterator();
      while (i.hasNext()) {
        Unit unit = i.next();
        if ((unit instanceof Malfunctionable) && !entities.contains(unit)) {
          entities.add((Malfunctionable) unit);
        }
      }
    }

    return entities;
  }
예제 #2
0
  /**
   * Gets a local lab for scientific research.
   *
   * @param person the person checking for the lab.
   * @param science the science to research.
   * @return laboratory found or null if none.
   * @throws Exception if error getting a lab.
   */
  public static Lab getLocalLab(Person person, ScienceType science) {
    Lab result = null;

    LocationSituation location = person.getLocationSituation();
    if (location == LocationSituation.IN_SETTLEMENT) {
      result = getSettlementLab(person, science);
    } else if (location == LocationSituation.IN_VEHICLE) {
      result = getVehicleLab(person.getVehicle(), science);
    }

    return result;
  }
예제 #3
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;
  }