org.mars_sim.msp.simulation.structure
Class Settlement

java.lang.Object
  extended by org.mars_sim.msp.simulation.Unit
      extended by org.mars_sim.msp.simulation.structure.Structure
          extended by org.mars_sim.msp.simulation.structure.Settlement
All Implemented Interfaces:
java.io.Serializable, LifeSupport, Malfunctionable
Direct Known Subclasses:
MockSettlement

public class Settlement
extends Structure
implements LifeSupport

The Settlement class represents a settlement unit on virtual Mars. It contains information related to the state of the settlement.

See Also:
Serialized Form

Field Summary
static java.lang.String ADD_ASSOCIATED_PERSON_EVENT
           
protected  BuildingManager buildingManager
           
protected  GoodsManager goodsManager
           
protected  PowerGrid powerGrid
           
static java.lang.String REMOVE_ASSOCIATED_PERSON_EVENT
           
protected  ResupplyManager resupplyManager
           
 
Fields inherited from class org.mars_sim.msp.simulation.structure.Structure
malfunctionManager
 
Fields inherited from class org.mars_sim.msp.simulation.Unit
CONTAINER_UNIT_EVENT, DESCRIPTION_EVENT, LOCATION_EVENT, MASS_EVENT, NAME_EVENT
 
Constructor Summary
protected Settlement(java.lang.String name, Coordinates location)
          Constructor for subclass extension.
  Settlement(java.lang.String name, java.lang.String template, Coordinates location)
          Constructs a Settlement object at a given location
 
Method Summary
 java.util.Collection<Person> getAffectedPeople()
          Gets a collection of people affected by this entity.
 double getAirPressure()
          Gets the air pressure of the life support system.
 double getAirPressureModifier()
          Gets the air pressure modifier for this settlement.
 java.util.Collection<Person> getAllAssociatedPeople()
          Gets all people associated with this settlement, even if they are out on missions.
 java.util.Collection<Vehicle> getAllAssociatedVehicles()
          Gets all vehicles associated with this settlement, even if they are out on missions.
 Airlock getAvailableAirlock()
          Gets an available airlock for the settlement.
 int getAvailablePopulationCapacity()
          Gets the current available population capacity of the settlement
 BuildingManager getBuildingManager()
          Gets the settlement's building manager.
 int getCurrentPopulationNum()
          Gets the current population number of the settlement
 GoodsManager getGoodsManager()
          Gets the settlement's goods manager.
 Person[] getInhabitantArray()
          Gets an array of current inhabitants of the settlement
 java.util.Collection<Person> getInhabitants()
          Gets a collection of the inhabitants of the settlement.
 int getLifeSupportCapacity()
          Gets the number of people the life support can provide for.
 boolean getMissionCreationOverride()
          Gets the mission creation override flag.
 double getOxygenFlowModifier()
          Gets the oxygen flow modifier for this settlement.
 int getParkedVehicleNum()
          Gets the number of vehicles parked at the settlement.
 java.util.Collection<Vehicle> getParkedVehicles()
          Gets a collection of vehicles parked at the settlement.
 int getPopulationCapacity()
          Gets the population capacity of the settlement
 PowerGrid getPowerGrid()
          Gets the settlement's power grid.
 ResupplyManager getResupplyManager()
          Gets the settlement's resupply manager.
 double getTemperature()
          Gets the temperature of the life support system.
 double getTemperatureModifier()
          Gets the temperature modifier for this settlement.
 java.lang.String getTemplate()
          Gets the settlement template.
 double getWaterFlowModifier()
          Gets the water flow modifier for this settlement.
 boolean lifeSupportCheck()
          Returns true if life support is working properly and is not out of oxygen or water.
 double provideOxygen(double amountRequested)
          Gets oxygen from system.
 double provideWater(double amountRequested)
          Gets water from system.
 void setMissionCreationOverride(boolean missionCreationOverride)
          Sets the mission creation override flag.
 void timePassing(double time)
          Perform time-related processes
 
Methods inherited from class org.mars_sim.msp.simulation.structure.Structure
getMalfunctionManager
 
Methods inherited from class org.mars_sim.msp.simulation.Unit
addUnitListener, fireUnitUpdate, fireUnitUpdate, getBaseMass, getContainerUnit, getCoordinates, getDescription, getInventory, getMass, getName, getTopContainerUnit, getUnitManager, removeUnitListener, setBaseMass, setContainerUnit, setCoordinates, setDescription, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mars_sim.msp.simulation.malfunction.Malfunctionable
getInventory, getName
 

Field Detail

ADD_ASSOCIATED_PERSON_EVENT

public static final java.lang.String ADD_ASSOCIATED_PERSON_EVENT
See Also:
Constant Field Values

REMOVE_ASSOCIATED_PERSON_EVENT

public static final java.lang.String REMOVE_ASSOCIATED_PERSON_EVENT
See Also:
Constant Field Values

buildingManager

protected BuildingManager buildingManager

resupplyManager

protected ResupplyManager resupplyManager

goodsManager

protected GoodsManager goodsManager

powerGrid

protected PowerGrid powerGrid
Constructor Detail

Settlement

protected Settlement(java.lang.String name,
                     Coordinates location)
Constructor for subclass extension.

Parameters:
name - the settlement's name
location - the settlement's location

Settlement

public Settlement(java.lang.String name,
                  java.lang.String template,
                  Coordinates location)
           throws java.lang.Exception
Constructs a Settlement object at a given location

Parameters:
name - the settlement's name
template - for the settlement
location - the settlement's location
Throws:
java.lang.Exception - if settlement cannot be constructed.
Method Detail

getPopulationCapacity

public int getPopulationCapacity()
Gets the population capacity of the settlement

Returns:
the population capacity

getCurrentPopulationNum

public int getCurrentPopulationNum()
Gets the current population number of the settlement

Returns:
the number of inhabitants

getInhabitants

public java.util.Collection<Person> getInhabitants()
Gets a collection of the inhabitants of the settlement.

Returns:
Collection of inhabitants

getAvailablePopulationCapacity

public int getAvailablePopulationCapacity()
Gets the current available population capacity of the settlement

Returns:
the available population capacity

getInhabitantArray

public Person[] getInhabitantArray()
Gets an array of current inhabitants of the settlement

Returns:
array of inhabitants

getParkedVehicles

public java.util.Collection<Vehicle> getParkedVehicles()
Gets a collection of vehicles parked at the settlement.

Returns:
Collection of parked vehicles

getParkedVehicleNum

public int getParkedVehicleNum()
Gets the number of vehicles parked at the settlement.

Returns:
parked vehicles number

lifeSupportCheck

public boolean lifeSupportCheck()
                         throws java.lang.Exception
Returns true if life support is working properly and is not out of oxygen or water.

Specified by:
lifeSupportCheck in interface LifeSupport
Returns:
true if life support is OK
Throws:
java.lang.Exception - if error checking life support.

getLifeSupportCapacity

public int getLifeSupportCapacity()
Gets the number of people the life support can provide for.

Specified by:
getLifeSupportCapacity in interface LifeSupport
Returns:
the capacity of the life support system

provideOxygen

public double provideOxygen(double amountRequested)
                     throws java.lang.Exception
Gets oxygen from system.

Specified by:
provideOxygen in interface LifeSupport
Parameters:
amountRequested - the amount of oxygen requested from system (kg)
Returns:
the amount of oxgyen actually received from system (kg)
Throws:
java.lang.Exception - if error providing oxygen.

getOxygenFlowModifier

public double getOxygenFlowModifier()
Gets the oxygen flow modifier for this settlement.

Returns:
oxygen flow modifier

provideWater

public double provideWater(double amountRequested)
                    throws java.lang.Exception
Gets water from system.

Specified by:
provideWater in interface LifeSupport
Parameters:
amountRequested - the amount of water requested from system (kg)
Returns:
the amount of water actually received from system (kg)
Throws:
java.lang.Exception - if error providing water.

getWaterFlowModifier

public double getWaterFlowModifier()
Gets the water flow modifier for this settlement.

Returns:
water flow modifier

getAirPressure

public double getAirPressure()
Gets the air pressure of the life support system.

Specified by:
getAirPressure in interface LifeSupport
Returns:
air pressure (atm)

getAirPressureModifier

public double getAirPressureModifier()
Gets the air pressure modifier for this settlement.

Returns:
air pressure flow modifier

getTemperature

public double getTemperature()
Gets the temperature of the life support system.

Specified by:
getTemperature in interface LifeSupport
Returns:
temperature (degrees C)

getTemperatureModifier

public double getTemperatureModifier()
Gets the temperature modifier for this settlement.

Returns:
temperature flow modifier

timePassing

public void timePassing(double time)
                 throws java.lang.Exception
Perform time-related processes

Overrides:
timePassing in class Unit
Parameters:
time - the amount of time passing (in millisols)
Throws:
java.lang.Exception - if error during time passing.

getAffectedPeople

public java.util.Collection<Person> getAffectedPeople()
Gets a collection of people affected by this entity.

Specified by:
getAffectedPeople in interface Malfunctionable
Returns:
person collection

getBuildingManager

public BuildingManager getBuildingManager()
Gets the settlement's building manager.

Returns:
building manager

getResupplyManager

public ResupplyManager getResupplyManager()
Gets the settlement's resupply manager.

Returns:
resupply manager

getGoodsManager

public GoodsManager getGoodsManager()
Gets the settlement's goods manager.

Returns:
goods manager

getAvailableAirlock

public Airlock getAvailableAirlock()
Gets an available airlock for the settlement.

Returns:
airlock or null if none available.

getPowerGrid

public PowerGrid getPowerGrid()
Gets the settlement's power grid.

Returns:
the power grid.

getTemplate

public java.lang.String getTemplate()
Gets the settlement template.

Returns:
template as string.

getAllAssociatedPeople

public java.util.Collection<Person> getAllAssociatedPeople()
Gets all people associated with this settlement, even if they are out on missions.

Returns:
collection of associated people.

getAllAssociatedVehicles

public java.util.Collection<Vehicle> getAllAssociatedVehicles()
Gets all vehicles associated with this settlement, even if they are out on missions.

Returns:
collection of associated vehicles.

setMissionCreationOverride

public void setMissionCreationOverride(boolean missionCreationOverride)
Sets the mission creation override flag.

Parameters:
missionCreationOverride - override for settlement mission creation.

getMissionCreationOverride

public boolean getMissionCreationOverride()
Gets the mission creation override flag.

Returns:
override for settlement mission creation.