uncategorized replayReader - wxyz-abcd/node-haxball GitHub Wiki

ReplayReader

This is a special structure that is returned from the function Replay.read.

1. Properties

  • state: An object containing all information about the current room state.
  • gameState: An object containing the game state information. Returns null if game is not active.
  • currentPlayerId: This is a read-only property that always returns -1. It is only added for compatibility with renderers. (And it is only used in the initialization code of renderers.)

2. Functions

  • length(): number

    Returns the length of replay content.

    Parameters: None.

    Return value: The length of replay content in milliseconds.

  • getTime(): number

    Returns the current time.

    Parameters: None.

    Return value: The current time in milliseconds.

  • setTime(destinationTime: number): void

    Plays the replay until the destinationTime or end of replay is reached. Note that it may take some time to reach the destination time(especially if you are trying to rewind time), because the game state data is generated on the fly and not stored in memory. (It would probably use huge amounts of RAM.)

    Parameters: The desired time in milliseconds.

    Return value: void.

  • getCurrentFrameNo(): number

    Returns the current frame number.

    Parameters: None.

    Return value: The current frame number.

  • setCurrentFrameNo(destinationFrameNo: number): void

    Plays the replay until the destinationFrameNo or end of replay is reached. Note that it may take some time to reach the destination frame number(especially if you are trying to rewind time), because the game state data is generated on the fly and not stored in memory. (It would probably use huge amounts of RAM.)

    Parameters: The desired frame number.

    Return value: void.

  • getSpeed(): number

    Returns the current speed coefficient of this replay reader object.

    Parameters: None.

    Return value: The current speed coefficient of this replay reader object.

  • setSpeed(coefficient: number): void

    Changes the speed coefficient of this replay reader object.

    Parameters:

    • coefficient: number: The desired speed coefficient. Must be a real number >=0. Meaning of possible value ranges is as follows:
      • value = 0 : stop replay.
      • 0 < value < 1 : slow-motion replay.
      • value = 1 : normal speed replay.
      • value > 1 : fast-motion replay.

    Return value: void.

  • destroy(): void

    Releases the resources that are used by this object.

    Parameters: None.

    Return value: void.

3. Callbacks

  • onDestinationTimeReached(): void

    Called when the destination time or frame number has been reached, which only happens some time after a call to setTime(destinationTime) or setCurrentFrameNo(destinationFrameNo).

    Parameters: None.

    Return value: void.

  • onEnd(): void

    Called when the end of replay data has been reached.

    Parameters: None.

    Return value: void.

⚠️ **GitHub.com Fallback** ⚠️