Class DeflectingComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.npc.DeflectingComponent

public class DeflectingComponent extends Component
A component that deflects incoming projectiles a set amount of projectile collision events. The target layer to be deflected is flexible, meaning it can deflect other entities as well, including but not limited to it's own target layer.

This class assumes the projectile has only a TrajectTask. If there are multiple tasks, the other tasks will be disposed.

  • Constructor Details

    • DeflectingComponent

      public DeflectingComponent(short targetLayer, short dmgLayer, int deflectLimitAmount)
      Initialise a Deflecting component that deflects projectile, reversing the incoming direcition of the entity. Any effects, such as damage, will be negated when deflected. The projectile's damage target layer will also be changed.
      Parameters:
      targetLayer - Target layer to deflect on
      dmgLayer - Target layer for the projectile to hit.
      deflectLimitAmount - Amount of deflections to occur for the disabling of this component.
  • 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