Example #1
0
  public DeathInfo(Robot robot) {

    // Initialize data members
    timeOfDeath = Simulation.instance().getMasterClock().getMarsClock().getDateTimeStamp();
    /*
            Complaint serious = person.getPhysicalCondition().getMostSerious();
            if (serious != null) illness = serious.getName();

            if (person.getLocationSituation() == LocationSituation.OUTSIDE) placeOfDeath = "Outside";
            else {
                containerUnit = person.getContainerUnit();
                placeOfDeath = containerUnit.getName();
            }

            locationOfDeath = person.getCoordinates();
    */
    BotMind botMind = robot.getBotMind();

    robotJob = botMind.getRobotJob();
    /*
            if (mind.getMission() != null) {
                mission = mind.getMission().getName();
                missionPhase = mind.getMission().getPhaseDescription();
            }
    */
    TaskManager taskMgr = botMind.getTaskManager();
    if (taskMgr.hasTask()) {
      task = taskMgr.getTaskName();
      TaskPhase phase = taskMgr.getPhase();
      if (phase != null) {
        taskPhase = phase.getName();
      } else {
        taskPhase = "";
      }
    }

    Iterator<Malfunctionable> i = MalfunctionFactory.getMalfunctionables(robot).iterator();
    Malfunction mostSerious = null;
    int severity = 0;
    while (i.hasNext()) {
      Malfunctionable entity = i.next();
      MalfunctionManager malfunctionMgr = entity.getMalfunctionManager();
      if (malfunctionMgr.hasEmergencyMalfunction()) {
        Malfunction m = malfunctionMgr.getMostSeriousEmergencyMalfunction();
        if (m.getSeverity() > severity) {
          mostSerious = m;
          severity = m.getSeverity();
        }
      }
    }
    if (mostSerious != null) malfunction = mostSerious.getName();

    this.robotType = robot.getRobotType();
  }
  /**
   * Performs the researching phase.
   *
   * @param time the amount of time (millisols) to perform the phase.
   * @return the amount of time (millisols) left over after performing the phase.
   */
  protected double researchingPhase(double time) {

    // If person is incapacitated, end task.
    if (person.getPerformanceRating() == 0D) {
      endTask();
    }

    // Check for laboratory malfunction.
    if (malfunctions.hasMalfunction()) endTask();

    // Check if research in study is completed.
    boolean isPrimary = study.getPrimaryResearcher().equals(person);
    if (isPrimary) {
      if (study.isPrimaryResearchCompleted()) {
        endTask();
      }
    } else {
      if (study.isCollaborativeResearchCompleted(person)) {
        endTask();
      }
    }

    // Check if person is in a moving rover.
    if (inMovingRover(person)) {
      endTask();
    }

    if (isDone()) {
      return time;
    }

    // Add research work time to study.
    double researchTime = getEffectiveResearchTime(time);
    if (isPrimary) {
      study.addPrimaryResearchWorkTime(researchTime);
    } else {
      study.addCollaborativeResearchWorkTime(person, researchTime);
    }

    // Add experience
    addExperience(time);

    // Check for lab accident.
    checkForAccident(time);

    return 0D;
  }