Interface of the warp drive of a spaceship that can only be read.

Implements

Constructors

Properties

defaultThrottle: number = 0.5

The default throttle value for the warp drive.

Methods

  • Disengages the warp drive: the ship will start to decelerate towards 0. The warp drive will be disabled when the ship reaches 0 speed.

    Returns void

  • Enables the warp drive: the ship will start to accelerate towards the target speed.

    Returns void

  • Returns the amount of fuel consumed by the warp drive to travel the given distance in light-years.

    Parameters

    • distanceLY: number

      The distance to travel in light-years.

    Returns number

  • Increases the target throttle by the given delta and clamps it between 0 and 1.

    Parameters

    • deltaThrottle: number

      The delta to apply to the target throttle.

    Returns void

  • Returns true if the warp drive is enabled and not disengaging. Returns false otherwise.

    Returns boolean

    True if the warp drive is enabled and not disengaging. Returns false otherwise.

  • Updates the warp drive based on the current speed of the ship, the distance to the closest body and the time elapsed since the last update.

    Parameters

    • currentForwardSpeed: number

      The current speed of the warp drive projected on the forward direction of the ship.

    • closestObjectDistance: number
    • closestObjectRadius: number
    • deltaSeconds: number

      The time elapsed since the last update in seconds.

    Returns void

  • Computes the target speed of the warp drive based on the distance to the closest body and the user throttle.

    Parameters

    • closestObjectDistance: number

      The distance to the closest body in m.

    • closestObjectRadius: number

    Returns number

    The computed target speed in m/s.