org.mars_sim.msp.simulation.person.ai.mission
Class MissionManager

java.lang.Object
  extended by org.mars_sim.msp.simulation.person.ai.mission.MissionManager
All Implemented Interfaces:
java.io.Serializable

public class MissionManager
extends java.lang.Object
implements java.io.Serializable

The MissionManager class keeps track of ongoing missions in the simulation. The simulation has only one mission manager.

See Also:
Serialized Form

Constructor Summary
MissionManager()
          Constructor
 
Method Summary
 void addListener(MissionManagerListener newListener)
          Add a listener
 void addMission(Mission newMission)
          Adds a new mission to the mission list.
 Mission getMission(Person person)
          Gets the mission a given person is a member of.
 Mission getMissionForVehicle(Vehicle vehicle)
          Gets a mission that the given vehicle is a part of.
 java.util.List<Mission> getMissions()
          Gets a list of current missions.
 java.util.List<Mission> getMissionsForSettlement(Settlement settlement)
          Gets all the active missions associated with a given settlement.
 Mission getNewMission(Person person)
          Gets a new mission for a person based on potential missions available.
 int getNumActiveMissions()
          Gets the number of currently active missions.
 double getTotalMissionProbability(Person person)
          Determines the total probability weight for available potential missions for a given person.
 void removeListener(MissionManagerListener oldListener)
          Remove a listener
 void timePassing(double time)
          Updates mission based on passing time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MissionManager

public MissionManager()
Constructor

Method Detail

addListener

public void addListener(MissionManagerListener newListener)
Add a listener

Parameters:
newListener - The listener to add.

removeListener

public void removeListener(MissionManagerListener oldListener)
Remove a listener

Parameters:
oldListener - the listener to remove.

getNumActiveMissions

public int getNumActiveMissions()
Gets the number of currently active missions.

Returns:
number of active missions

getMissions

public java.util.List<Mission> getMissions()
Gets a list of current missions.

Returns:
list of missions.

getMission

public Mission getMission(Person person)
Gets the mission a given person is a member of. If person is a member of no mission, return null.

Parameters:
person - the given person
Returns:
mission for that person

addMission

public void addMission(Mission newMission)
Adds a new mission to the mission list.

Parameters:
newMission - new mission to be added

getTotalMissionProbability

public double getTotalMissionProbability(Person person)
Determines the total probability weight for available potential missions for a given person.

Parameters:
person - the given person
Returns:
total probability weight

getNewMission

public Mission getNewMission(Person person)
Gets a new mission for a person based on potential missions available.

Parameters:
person - person to find the mission for
Returns:
new mission

getMissionsForSettlement

public java.util.List<Mission> getMissionsForSettlement(Settlement settlement)
Gets all the active missions associated with a given settlement.

Parameters:
settlement - the settlement to find missions.
Returns:
list of missions associated with the settlement.

getMissionForVehicle

public Mission getMissionForVehicle(Vehicle vehicle)
Gets a mission that the given vehicle is a part of.

Parameters:
vehicle - the vehicle to check for.
Returns:
mission or null if none.

timePassing

public void timePassing(double time)
                 throws java.lang.Exception
Updates mission based on passing time.

Parameters:
time - amount of time passing (millisols)
Throws:
java.lang.Exception - if error in updating missions