Class PhysicsMovementComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.physics.components.PhysicsMovementComponent
All Implemented Interfaces:
MovementController

public class PhysicsMovementComponent extends Component implements MovementController
Movement controller for a physics-based entity.
  • Constructor Details

    • PhysicsMovementComponent

      public PhysicsMovementComponent()
  • 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
    • applyKnockback

      public void applyKnockback(float duration)
      Applies knock-back to the entity by disabling its movement for a specified duration.
      Parameters:
      duration - The time (in seconds) for which the entity's movement will be disabled.
    • setMoving

      public void setMoving(boolean movementEnabled)
      Enable/disable movement for the controller. Disabling will immediately set velocity to 0.
      Specified by:
      setMoving in interface MovementController
      Parameters:
      movementEnabled - true to enable movement, false otherwise
    • getMoving

      public boolean getMoving()
      Specified by:
      getMoving in interface MovementController
      Returns:
      True when movement enabled, false when disabled
    • getTarget

      public com.badlogic.gdx.math.Vector2 getTarget()
      Specified by:
      getTarget in interface MovementController
      Returns:
      Target position in the world
    • setTarget

      public void setTarget(com.badlogic.gdx.math.Vector2 target)
      Set a target to move towards. The entity will be steered towards it in a straight line, not using pathfinding or avoiding other entities.
      Specified by:
      setTarget in interface MovementController
      Parameters:
      target - target position
    • setSpeed

      public void setSpeed(com.badlogic.gdx.math.Vector2 speed)
    • getSpeed

      public com.badlogic.gdx.math.Vector2 getSpeed()