|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.mars_sim.msp.core.Inventory
public class Inventory
The Inventory class represents what a unit contains in terms of resources and other units. It has methods for adding, removing and querying what the unit contains.
| Field Summary | |
|---|---|
static String |
INVENTORY_RESOURCE_EVENT
|
static String |
INVENTORY_RETRIEVING_UNIT_EVENT
|
static String |
INVENTORY_STORING_UNIT_EVENT
|
| Constructor Summary | |
|---|---|
Inventory(Unit owner)
Constructor |
|
| Method Summary | |
|---|---|
void |
addAmountResourcePhaseCapacity(Phase phase,
double capacity)
Adds capacity for a resource phase. |
void |
addAmountResourceTypeCapacity(AmountResource resource,
double capacity)
Adds capacity for a resource type. |
void |
addGeneralCapacity(double capacity)
Adds a capacity to general capacity. |
boolean |
canStoreUnit(Unit unit,
boolean allowDirty)
Checks if a unit can be stored. |
Inventory |
clone(Unit owner)
Creates a clone of this inventory (not including the inventory contents). |
boolean |
containsUnit(Unit unit)
Checks if a unit is in storage. |
boolean |
containsUnitClass(Class<? extends Unit> unitClass)
Checks if any of a given class of unit is in storage. |
void |
destroy()
Prepare object for garbage collection. |
Collection<Unit> |
findAllUnitsOfClass(Class<? extends Unit> unitClass)
Finds all of the units of a class in storage. |
int |
findNumEmptyUnitsOfClass(Class<? extends Unit> unitClass,
boolean allowDirty)
Finds the number of units of a class that are contained in storage and have an empty inventory. |
int |
findNumUnitsOfClass(Class<? extends Unit> unitClass)
Finds the number of units of a class that are contained in storage. |
Unit |
findUnitOfClass(Class<? extends Unit> unitClass)
Finds a unit of a given class in storage. |
Set<AmountResource> |
getAllAmountResourcesStored(boolean allowDirty)
Gets all of the amount resources stored. |
Set<ItemResource> |
getAllItemResourcesStored()
Gets a set of all the item resources in storage. |
double |
getAmountResourceCapacity(AmountResource resource,
boolean allowDirty)
Gets the storage capacity for a resource. |
double |
getAmountResourceRemainingCapacity(AmountResource resource,
boolean useContainedUnits,
boolean allowDirty)
Gets the remaining capacity available for a resource. |
double |
getAmountResourceStored(AmountResource resource,
boolean allowDirty)
Gets the amount of a resource stored. |
Collection<Unit> |
getContainedUnits()
Gets a collection of all the stored units. |
double |
getGeneralCapacity()
Gets the general capacity. |
double |
getGeneralStoredMass(boolean allowDirty)
Gets the mass stored in general capacity. |
int |
getItemResourceNum(ItemResource resource)
Gets the number of an item resource in storage. |
double |
getRemainingGeneralCapacity(boolean allowDirty)
Gets the remaining general capacity available. |
double |
getTotalInventoryMass(boolean allowDirty)
Gets the total mass stored in inventory. |
double |
getUnitTotalMass(boolean allowDirty)
Gets the total unit mass in storage. |
boolean |
hasAmountResourceCapacity(AmountResource resource,
boolean allowDirty)
Checks if storage has capacity for a resource. |
boolean |
hasAmountResourceCapacity(AmountResource resource,
double amount,
boolean allowDirty)
Checks if storage has capacity for an amount of a resource. |
boolean |
hasItemResource(ItemResource resource)
Checks if storage has an item resource. |
boolean |
isEmpty(boolean allowDirty)
Checks if inventory is empty. |
void |
removeAmountResourceTypeCapacity(AmountResource resource,
double capacity)
Removes capacity for a resource type. |
void |
retrieveAmountResource(AmountResource resource,
double amount)
Retrieves an amount of a resource from storage. |
void |
retrieveItemResources(ItemResource resource,
int number)
Retrieves item resources. |
void |
retrieveUnit(Unit unit)
Retrieves a unit from storage. |
void |
setCoordinates(Coordinates newLocation)
Sets the coordinates of all units in the inventory. |
void |
storeAmountResource(AmountResource resource,
double amount,
boolean useContainedUnits)
Store an amount of a resource. |
void |
storeItemResources(ItemResource resource,
int number)
Stores item resources. |
void |
storeUnit(Unit unit)
Stores a unit. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String INVENTORY_STORING_UNIT_EVENT
public static final String INVENTORY_RETRIEVING_UNIT_EVENT
public static final String INVENTORY_RESOURCE_EVENT
| Constructor Detail |
|---|
public Inventory(Unit owner)
owner - the unit that owns this inventory| Method Detail |
|---|
public void addAmountResourceTypeCapacity(AmountResource resource,
double capacity)
resource - the resource.capacity - the capacity amount (kg).
public void removeAmountResourceTypeCapacity(AmountResource resource,
double capacity)
resource - the resourcecapacity - the capacity amount (kg).
public void addAmountResourcePhaseCapacity(Phase phase,
double capacity)
phase - the phasecapacity - the capacity amount (kg).
public boolean hasAmountResourceCapacity(AmountResource resource,
boolean allowDirty)
resource - the resource.allowDirty - will allow dirty (possibly out of date) results.
public boolean hasAmountResourceCapacity(AmountResource resource,
double amount,
boolean allowDirty)
resource - the resource.amount - the amount (kg).allowDirty - will allow dirty (possibly out of date) results.
public double getAmountResourceCapacity(AmountResource resource,
boolean allowDirty)
resource - the resource.allowDirty - will allow dirty (possibly out of date) results.
public double getAmountResourceStored(AmountResource resource,
boolean allowDirty)
resource - the resource.allowDirty - will allow dirty (possibly out of date) results.
public Set<AmountResource> getAllAmountResourcesStored(boolean allowDirty)
allowDirty - will allow dirty (possibly out of date) results.
public double getAmountResourceRemainingCapacity(AmountResource resource,
boolean useContainedUnits,
boolean allowDirty)
resource - the resource.useContainedUnits - should the capacity of contained units be added?allowDirty - will allow dirty (possibly out of date) results.
public void storeAmountResource(AmountResource resource,
double amount,
boolean useContainedUnits)
resource - the resource.amount - the amount (kg).
public void retrieveAmountResource(AmountResource resource,
double amount)
resource - the resource.amount - the amount (kg).public void addGeneralCapacity(double capacity)
capacity - amount capacity (kg).public double getGeneralCapacity()
public double getGeneralStoredMass(boolean allowDirty)
allowDirty - will allow dirty (possibly out of date) results.
public double getRemainingGeneralCapacity(boolean allowDirty)
allowDirty - will allow dirty (possibly out of date) results.
public boolean hasItemResource(ItemResource resource)
resource - the resource.
public int getItemResourceNum(ItemResource resource)
resource - the resource.
public Set<ItemResource> getAllItemResourcesStored()
public void storeItemResources(ItemResource resource,
int number)
resource - the resource to store.number - the number of resources to store.
public void retrieveItemResources(ItemResource resource,
int number)
resource - the resource to retrieve.number - the number of resources to retrieve.public double getUnitTotalMass(boolean allowDirty)
allowDirty - will allow dirty (possibly out of date) results.
public Collection<Unit> getContainedUnits()
public boolean containsUnit(Unit unit)
unit - the unit.
public boolean containsUnitClass(Class<? extends Unit> unitClass)
unitClass - the unit class.
public Unit findUnitOfClass(Class<? extends Unit> unitClass)
unitClass - the unit class.
public Collection<Unit> findAllUnitsOfClass(Class<? extends Unit> unitClass)
unitClass - the unit class.
public int findNumUnitsOfClass(Class<? extends Unit> unitClass)
unitClass - the unit class.
public int findNumEmptyUnitsOfClass(Class<? extends Unit> unitClass,
boolean allowDirty)
unitClass - the unit class.allowDirty - will allow dirty (possibly out of date) results.
public boolean canStoreUnit(Unit unit,
boolean allowDirty)
unit - the unit.allowDirty - will allow dirty (possibly out of date) results.
public void storeUnit(Unit unit)
unit - the unitpublic void retrieveUnit(Unit unit)
unit - the unit.public void setCoordinates(Coordinates newLocation)
newLocation - the new coordinate locationpublic double getTotalInventoryMass(boolean allowDirty)
allowDirty - will allow dirty (possibly out of date) results.
public boolean isEmpty(boolean allowDirty)
allowDirty - will allow dirty (possibly out of date) results.
public Inventory clone(Unit owner)
owner - the unit owner of the inventory (or null).
public void destroy()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||