Class WorkerInventoryComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.worker.components.WorkerInventoryComponent
- Direct Known Subclasses:
ResourceStatsComponent
A component intended to be used by the player to track their unit's inventory.
Currently only stores the stone and metal amount but can be extended for more
advanced functionality such as storing other items.
Can also be used as a more generic component for other entities.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMetal
(int metal) Adds to the player's metal.void
addStone
(int stone) Adds to the player's stone.void
addWood
(int wood) Adds to the player's wood.int
getMetal()
Returns the amount of metal in the inventoryint
getStone()
Returns the amount of stone in the inventoryint
getWood()
Returns the amount of wood in the inventoryhasMetal
(int metal) Returns if the entity has a certain amount of metal.hasStone
(int stone) Returns if the entity has a certain amount of stone.hasWood
(int wood) Returns if the entity has a certain amount of wood.void
setMetal
(int metal) Sets the player's metal.void
setStone
(int stone) Sets the player's stone.void
setWood
(int wood) Sets the player's wood.int
int
int
Methods inherited from class com.deco2800.game.components.Component
create, dispose, earlyUpdate, getEntity, isAnimationRenderComponent, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
WorkerInventoryComponent
public WorkerInventoryComponent() -
WorkerInventoryComponent
public WorkerInventoryComponent(int stone, int metal, int wood)
-
-
Method Details
-
getStone
public int getStone()Returns the amount of stone in the inventory- Returns:
- amount of the stone
-
getMetal
public int getMetal()Returns the amount of metal in the inventory- Returns:
- amount of the metal
-
getWood
public int getWood()Returns the amount of wood in the inventory- Returns:
- amount of the wood
-
hasStone
Returns if the entity has a certain amount of stone.- Parameters:
stone
- required amount of stone- Returns:
- player has greater than or equal to the required amount of stone
-
hasMetal
Returns if the entity has a certain amount of metal.- Parameters:
metal
- required amount of metal- Returns:
- player has greater than or equal to the required amount of metal
-
hasWood
Returns if the entity has a certain amount of wood.- Parameters:
wood
- required amount of wood- Returns:
- player has greater than or equal to the required amount of wood
-
setStone
public void setStone(int stone) Sets the player's stone. Stone has a minimum bound of 0.- Parameters:
stone
- stone
-
setMetal
public void setMetal(int metal) Sets the player's metal. Metal has a minimum bound of 0.- Parameters:
metal
- metal
-
setWood
public void setWood(int wood) Sets the player's wood. Wood h- Parameters:
wood
-
-
addStone
public void addStone(int stone) Adds to the player's stone. The amount added can be negative.- Parameters:
stone
- stone to add
-
addMetal
public void addMetal(int metal) Adds to the player's metal. The amount added can be negative.- Parameters:
metal
- metal to add
-
addWood
public void addWood(int wood) Adds to the player's wood. The amount added can be negative.- Parameters:
wood
- wood to add
-
unloadStone
public int unloadStone() -
unloadMetal
public int unloadMetal() -
unloadWood
public int unloadWood()
-