Class AINavigation

  • All Implemented Interfaces:
    com.badlogic.gdx.ai.steer.Limiter, com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>, com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>

    public class AINavigation
    extends Component
    implements com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
    Used to control NPCs with steerable for movement and state machines for behaviour
    • Constructor Detail

      • AINavigation

        public AINavigation()
        Creates a simple navigation component
    • Method Detail

      • setBehavior

        public void setBehavior​(com.badlogic.gdx.ai.steer.SteeringBehavior<com.badlogic.gdx.math.Vector2> behavior)
        Parameters:
        behavior - the behavior the AI will be set to
      • update

        public void update()
        Called once per frame. Apply the steering behaviour and sets the ship direction, so it faces the right way
        Overrides:
        update in class Component
      • stop

        public void stop()
        Stops all motion
      • getLinearVelocity

        public com.badlogic.gdx.math.Vector2 getLinearVelocity()
        Specified by:
        getLinearVelocity in interface com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
        Returns:
        the linear velocity of the rigid body this AI is attached to
      • getAngularVelocity

        public float getAngularVelocity()
        Specified by:
        getAngularVelocity in interface com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
        Returns:
        the angular velocity of the rigid body this AI is attached to
      • getBoundingRadius

        public float getBoundingRadius()
        Specified by:
        getBoundingRadius in interface com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
        Returns:
        the bounding radius of the AI's area
      • isTagged

        public boolean isTagged()
        Specified by:
        isTagged in interface com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
        Returns:
        whether the AI has been tagged
      • setTagged

        public void setTagged​(boolean tagged)
        Specified by:
        setTagged in interface com.badlogic.gdx.ai.steer.Steerable<com.badlogic.gdx.math.Vector2>
        Parameters:
        tagged - the boolean to set the tagged status to
      • getZeroLinearSpeedThreshold

        public float getZeroLinearSpeedThreshold()
        Specified by:
        getZeroLinearSpeedThreshold in interface com.badlogic.gdx.ai.steer.Limiter
        Returns:
        the Zero Linear Speed Threshold `unused`
      • setZeroLinearSpeedThreshold

        public void setZeroLinearSpeedThreshold​(float value)
        Specified by:
        setZeroLinearSpeedThreshold in interface com.badlogic.gdx.ai.steer.Limiter
        Parameters:
        value - the float to set the Zero Linear Speed Threshold to `unused`
      • getMaxLinearSpeed

        public float getMaxLinearSpeed()
        Specified by:
        getMaxLinearSpeed in interface com.badlogic.gdx.ai.steer.Limiter
        Returns:
        the maximum Linear Speed
      • setMaxLinearSpeed

        public void setMaxLinearSpeed​(float maxLinearSpeed)
        Specified by:
        setMaxLinearSpeed in interface com.badlogic.gdx.ai.steer.Limiter
        Parameters:
        maxLinearSpeed - the float to set the maximum Linear Speed to
      • getMaxLinearAcceleration

        public float getMaxLinearAcceleration()
        Specified by:
        getMaxLinearAcceleration in interface com.badlogic.gdx.ai.steer.Limiter
        Returns:
        the maximum Linear Acceleration
      • setMaxLinearAcceleration

        public void setMaxLinearAcceleration​(float maxLinearAcceleration)
        Specified by:
        setMaxLinearAcceleration in interface com.badlogic.gdx.ai.steer.Limiter
        Parameters:
        maxLinearAcceleration - the float to set the maximum Linear Acceleration to
      • getMaxAngularSpeed

        public float getMaxAngularSpeed()
        Specified by:
        getMaxAngularSpeed in interface com.badlogic.gdx.ai.steer.Limiter
        Returns:
        the maximum Angular Speed
      • setMaxAngularSpeed

        public void setMaxAngularSpeed​(float maxAngularSpeed)
        Specified by:
        setMaxAngularSpeed in interface com.badlogic.gdx.ai.steer.Limiter
        Parameters:
        maxAngularSpeed - the float to set the maximum Angular Speed to
      • getMaxAngularAcceleration

        public float getMaxAngularAcceleration()
        Specified by:
        getMaxAngularAcceleration in interface com.badlogic.gdx.ai.steer.Limiter
        Returns:
        the maximum Angular Acceleration
      • setMaxAngularAcceleration

        public void setMaxAngularAcceleration​(float maxAngularAcceleration)
        Specified by:
        setMaxAngularAcceleration in interface com.badlogic.gdx.ai.steer.Limiter
        Parameters:
        maxAngularAcceleration - the float to set the maximum Angular Acceleration to
      • getPosition

        public com.badlogic.gdx.math.Vector2 getPosition()
        Specified by:
        getPosition in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
        Returns:
        the position of the AI
      • getOrientation

        public float getOrientation()
        Specified by:
        getOrientation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
        Returns:
        the orientation of the AI
      • setOrientation

        public void setOrientation​(float orientation)
        Specified by:
        setOrientation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
        Parameters:
        orientation - the float to set the orientation to `unused`
      • vectorToAngle

        public float vectorToAngle​(com.badlogic.gdx.math.Vector2 vector)
        Specified by:
        vectorToAngle in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
        Parameters:
        vector - the vector to be converted
        Returns:
        the parsed vector as an angle
      • angleToVector

        public com.badlogic.gdx.math.Vector2 angleToVector​(com.badlogic.gdx.math.Vector2 outVector,
                                                           float angle)
        Specified by:
        angleToVector in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
        Parameters:
        angle - the angle to be converted
        Returns:
        the parsed angle as a vector
      • newLocation

        public com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2> newLocation()
        Specified by:
        newLocation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
        Returns:
        an empty location