Class ConsumableUseComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.items.ItemActionsComponent
com.csse3200.game.components.items.ConsumableUseComponent
Component responsible for handling the usage of consumable items.
When used, this component applies the effects of the consumable to the player entity and updates the inventory accordingly (either removing the item if it has been fully consumed, or decrementing its stack count).
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.csse3200.game.components.items.ItemActionsComponent
create
Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
ConsumableUseComponent
public ConsumableUseComponent()
-
-
Method Details
-
use
Uses the consumable item on the given player.If the consumable does not fire a projectile, all of its effects are applied to the player. The item is then consumed (removed or decremented) from the player's inventory.
- Specified by:
use
in classItemActionsComponent
- Parameters:
player
- the entity representing the player using the consumable
-