Class ResourceCollectComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.worker.components.ResourceCollectComponent
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionResourceCollectComponent
(short targetLayer) Create a component which collects resources from entity on collision. -
Method Summary
Modifier and TypeMethodDescriptionvoid
collectMetal
(ResourceStatsComponent targetStats) Adds the collected metal to the worker inventory.void
collectStone
(ResourceStatsComponent targetStats) Adds the collected stone to the worker inventory.void
collectWood
(ResourceStatsComponent targetStats) Adds the collected wood to the worker inventory.void
create()
Called when the entity is created and registered.getBase()
Gets the base entity.void
loadToBase
(ResourceStatsComponent baseStats) Loads the collected resources to the base.void
returnToBase
(Entity collector) Directs the worker to the base after resource collection and update the base resource statsvoid
startCollecting
(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Called when collector starts collecting resources.void
Called when collector stops collecting resources.void
update()
Called once per frame of the game, and should be used for most component logic.Methods inherited from class com.deco2800.game.components.Component
dispose, earlyUpdate, getEntity, isAnimationRenderComponent, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Field Details
-
COLLECTION_TIME
public static final long COLLECTION_TIME- See Also:
-
-
Constructor Details
-
ResourceCollectComponent
public ResourceCollectComponent(short targetLayer) Create a component which collects resources from entity on collision.- Parameters:
targetLayer
- The physics layer of the target's collider.
-
-
Method Details
-
create
public void create()Description copied from class:Component
Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished. -
update
public void update()Description copied from class:Component
Called once per frame of the game, and should be used for most component logic. Not called if component is disabled. -
startCollecting
public void startCollecting(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Called when collector starts collecting resources.- Parameters:
me
- The entity's fixtureother
- The collided entity's fixture
-
stopCollecting
public void stopCollecting()Called when collector stops collecting resources. -
getBase
Gets the base entity.- Returns:
- The base entity.
-
returnToBase
Directs the worker to the base after resource collection and update the base resource stats -
collectStone
Adds the collected stone to the worker inventory.- Parameters:
targetStats
- The resource stats of the target.
-
collectMetal
Adds the collected metal to the worker inventory.- Parameters:
targetStats
- The resource stats of the target.
-
collectWood
Adds the collected wood to the worker inventory.- Parameters:
targetStats
- The resource stats of the target.
-
loadToBase
Loads the collected resources to the base.- Parameters:
baseStats
- The resource stats of the base.
-