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 TypeMethodDescriptionvoidcollectMetal(ResourceStatsComponent targetStats) Adds the collected metal to the worker inventory.voidcollectStone(ResourceStatsComponent targetStats) Adds the collected stone to the worker inventory.voidcollectWood(ResourceStatsComponent targetStats) Adds the collected wood to the worker inventory.voidcreate()Called when the entity is created and registered.getBase()Gets the base entity.voidloadToBase(ResourceStatsComponent baseStats) Loads the collected resources to the base.voidreturnToBase(Entity collector) Directs the worker to the base after resource collection and update the base resource statsvoidstartCollecting(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Called when collector starts collecting resources.voidCalled when collector stops collecting resources.voidupdate()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:ComponentCalled 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:ComponentCalled 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.
-