Class CollectableComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.collectables.CollectableComponent
- Direct Known Subclasses:
KeyComponent
,UpgradesComponent
Abstract component for collectable items in the game world.
Handles collision detection with the player and invokes
onCollect(Entity)
when picked up. Subclasses define what happens on collection
(e.g., adding to inventory, increasing score).-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
CollectableComponent
public CollectableComponent()
-
-
Method Details
-
create
public void create()Registers a listener for"onCollisionStart"
events to trigger collection logic. -
onCollect
Called when this collectable is picked up by the player.- Parameters:
collector
- the player entity collecting this item- Returns:
- true if collection succeeded (and the item should be removed), false otherwise
-