Class BombTrackerComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.enemy.BombTrackerComponent
Tracks unexploded bombs spawned by the owner and handles their disposal.
When a bomb finishes (explodes) it emits "bomb:disposeRequested". This component handles bomb disposal on the
next update tick.
The dispose method for this component ensures that all tracked bombs are removed on level reset events.
Bombs must emit two events:
- "bomb:disposeRequested": The bomb is scheduled for disposal on next update
- "bomb:disposed": Fired by the bomb during its own disposal, the tracker removes it from the active list.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Methods inherited from class com.csse3200.game.components.Component
create, earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
BombTrackerComponent
public BombTrackerComponent()
-
-
Method Details
-
trackBomb
Register a newly spawned bomb for lifecycle management. Ignored if bomb is null or already tracked.- Parameters:
bomb- entity being to be tracked
-
update
public void update()Processes any pending disposal requests from bombs. Ensures that calls to bomb.dispose() occur outside the frame in which the request was raised. -
dispose
public void dispose()Dispose of all tracked bombs at once. -
getNumTracked
public int getNumTracked()Number of bombs currently tracked (unexploded)- Returns:
- int number of active bombs spawned by the entity
-