Class ResourceCollectComponent

java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.worker.components.ResourceCollectComponent

public class ResourceCollectComponent extends Component
  • Field Details

  • 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.
      Overrides:
      create in class Component
    • 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.
      Overrides:
      update in class Component
    • 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 fixture
      other - The collided entity's fixture
    • stopCollecting

      public void stopCollecting()
      Called when collector stops collecting resources.
    • getBase

      public Entity getBase()
      Gets the base entity.
      Returns:
      The base entity.
    • returnToBase

      public void returnToBase(Entity collector)
      Directs the worker to the base after resource collection and update the base resource stats
    • collectStone

      public void collectStone(ResourceStatsComponent targetStats)
      Adds the collected stone to the worker inventory.
      Parameters:
      targetStats - The resource stats of the target.
    • collectMetal

      public void collectMetal(ResourceStatsComponent targetStats)
      Adds the collected metal to the worker inventory.
      Parameters:
      targetStats - The resource stats of the target.
    • collectWood

      public void collectWood(ResourceStatsComponent targetStats)
      Adds the collected wood to the worker inventory.
      Parameters:
      targetStats - The resource stats of the target.
    • loadToBase

      public void loadToBase(ResourceStatsComponent baseStats)
      Loads the collected resources to the base.
      Parameters:
      baseStats - The resource stats of the base.