Class StationMealComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.station.StationMealComponent
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStationMealComponent
(String type, List<String> acceptableItems) General constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Called on creation of the station to allow outside interaction within the station.getType()
Gets the type of stationvoid
handleInteraction
(InventoryComponent playerInventoryComponent, InventoryDisplay inventoryDisplay, String type) Handles any interaction with station, using current state of player and station inventory to determine intended interactionboolean
hasMeal()
Checks if there is a meal in the station inventory.boolean
Checks if the item can be acceptedpeek()
Gets a look at the current item being stored.void
stationGiveItem
(InventoryComponent playerInventoryComponent) Takes the item from the station, and returns the old itemvoid
stationReceiveItem
(ItemComponent item, InventoryComponent playerInventoryComponent) Takes the item from the player and stores in stationMethods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Field Details
-
type
-
inventoryComponent
-
acceptableItems
-
-
Constructor Details
-
StationMealComponent
General constructor- Parameters:
type
- - storing type of stationacceptableItems
- - HashMap, HashSet etc. of mappings for acceptable items based on station
-
-
Method Details
-
create
public void create()Called on creation of the station to allow outside interaction within the station. Adds the listener for set current item and for remove current item. -
getType
Gets the type of station- Returns:
- - station type
-
isItemAccepted
public boolean isItemAccepted()Checks if the item can be accepted- Returns:
- - true if it can be accepted, false otherwise.
-
handleInteraction
public void handleInteraction(InventoryComponent playerInventoryComponent, InventoryDisplay inventoryDisplay, String type) Handles any interaction with station, using current state of player and station inventory to determine intended interaction- Parameters:
playerInventoryComponent
- reference to player inventory componentinventoryDisplay
- reference to individual inventory displaytype
- the type of interaction attempt
-
peek
Gets a look at the current item being stored.- Returns:
- - current Item being stored
-
stationReceiveItem
Takes the item from the player and stores in station- Parameters:
item
- - valid item to be stored in the station inventory.playerInventoryComponent
- - reference to player inventory
-
stationGiveItem
Takes the item from the station, and returns the old item- Parameters:
playerInventoryComponent
- - reference to player inventory
-
hasMeal
public boolean hasMeal()Checks if there is a meal in the station inventory.- Returns:
- - true if there is a meal, false otherwise
-