Class StationItemHandlerComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.station.StationItemHandlerComponent
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected InventoryComponent
protected final String
String type - storing type of station StationInventoryComponent inventorycomponent - instance of inventory for this station acceptableItems - ArrayList which contains all accepted items or it null -
Constructor Summary
Constructors -
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
isItemAccepted
(ItemComponent item) Checks if the item can be acceptedpeek()
void
stationGiveItem
(InventoryComponent playerInventoryComponent, InventoryDisplay inventoryDisplay) Takes the item from the station, and returns the old itemvoid
stationReceiveItem
(ItemComponent item, InventoryComponent playerInventoryComponent, InventoryDisplay inventoryDisplay) 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
String type - storing type of station StationInventoryComponent inventorycomponent - instance of inventory for this station acceptableItems - ArrayList which contains all accepted items or it null -
inventoryComponent
-
acceptableItems
-
-
Constructor Details
-
StationItemHandlerComponent
General constructor- Parameters:
type
- - storing type of 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
Checks if the item can be accepted- Parameters:
item
- to check if can be accepted- Returns:
- true if it can be acceptedd, 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
- Returns:
- current Item being stored
-
stationReceiveItem
public void stationReceiveItem(ItemComponent item, InventoryComponent playerInventoryComponent, InventoryDisplay inventoryDisplay) Takes the item from the player and stores in station- Parameters:
playerInventoryComponent
- reference to player inventoryinventoryDisplay
- reference to UI for inventory display
-
stationGiveItem
public void stationGiveItem(InventoryComponent playerInventoryComponent, InventoryDisplay inventoryDisplay) Takes the item from the station, and returns the old item- Parameters:
playerInventoryComponent
- reference to player inventoryinventoryDisplay
- reference to UI for inventory display
-