/** * Gets the effective research time based on the person's science skill. * * @param time the real amount of time (millisol) for research. * @return the effective amount of time (millisol) for research. */ private double getEffectiveResearchTime(double time) { // Determine effective research time based on the science skill. double researchTime = time; int scienceSkill = getEffectiveSkillLevel(); if (scienceSkill == 0) { researchTime /= 2D; } else if (scienceSkill > 1) { researchTime += researchTime * (.2D * scienceSkill); } // Modify by tech level of laboratory. int techLevel = lab.getTechnologyLevel(); if (techLevel > 0) { researchTime *= techLevel; } // If research assistant, modify by assistant's effective skill. if (hasResearchAssistant()) { SkillManager manager = researchAssistant.getMind().getSkillManager(); int assistantSkill = manager.getEffectiveSkillLevel(science.getSkill()); if (scienceSkill > 0) { researchTime *= 1D + ((double) assistantSkill / (double) scienceSkill); } } return researchTime; }
/** * Gets an available lab in a vehicle. Returns null if no lab is currently available. * * @param vehicle the vehicle * @param science the science to research. * @return available lab */ private static Lab getVehicleLab(Vehicle vehicle, ScienceType science) { Lab result = null; if (vehicle instanceof Rover) { Rover rover = (Rover) vehicle; if (rover.hasLab()) { Lab lab = rover.getLab(); boolean availableSpace = (lab.getResearcherNum() < lab.getLaboratorySize()); boolean specialty = lab.hasSpecialty(science); boolean malfunction = (rover.getMalfunctionManager().hasMalfunction()); if (availableSpace && specialty && !malfunction) { result = lab; } } } return result; }
@Override public void endTask() { super.endTask(); // Remove person from lab so others can use it. try { if (lab != null) { lab.removeResearcher(); } } catch (Exception e) { } }
/** Adds a person to a lab. */ private void addPersonToLab() { try { LocationSituation location = person.getLocationSituation(); if (location == LocationSituation.IN_SETTLEMENT) { Building labBuilding = ((Research) lab).getBuilding(); // Walk to lab building. walkToActivitySpotInBuilding(labBuilding, false); lab.addResearcher(); malfunctions = labBuilding.getMalfunctionManager(); } else if (location == LocationSituation.IN_VEHICLE) { // Walk to lab internal location in rover. walkToLabActivitySpotInRover((Rover) person.getVehicle(), false); lab.addResearcher(); malfunctions = person.getVehicle().getMalfunctionManager(); } } catch (Exception e) { logger.severe("addPersonToLab(): " + e.getMessage()); } }