interfaces impl - wxyz-abcd/node-haxball GitHub Wiki

Impl

Implementation of Haxball's inner classes. Some important classes are exported through this object.

The explanations will be cut short, vague and sometimes partially ambiguous here; and only some of the properties of classes will be explored due to the potentially harmful nature of explaining these in detail.

The classes are put into 3 categories for now:

1. Core

Some important core classes used inside Haxball.

1.1. Point

The Point class that is used internally inside the game's physics engine.

1.1.1. Properties

  • x: number: The x coordinate of the point.
  • y: number: The y coordinate of the point.

1.2. TeamColors

The class that defines the colors of a team.

1.2.1. Properties

  • angle: number: The angle of stripes rendered inside a player.
  • text: int: The numeric color of the avatar text rendered inside a player.
  • inner: int[]: The numeric colors of each stripe rendered inside a player.

1.3. Team

The class that defines the properties of a team.

1.3.1. Static objects

  • spec: Team: The static spectators team.
  • red: Team: The static red team.
  • blue: Team: The static blue team.
  • byId: Team[]: A static array to get all teams using their ids. Its definition is Team.byId = [Team.spec, Team.red, Team.blue].

1.3.2. Properties

  • id: int: The id of current Team object.
  • color: int: The numeric color value of current Team object.

2. Stream

These classes are used to read/write data from/to replay files and/or network/WebRTC stream.

2.1. Reader

StreamReader class

2.2. Writer

StreamWriter class

3. Stadium

All Stadium-related classes.

3.1. Vertex

A class that defines a vertex.

3.1.1. Properties

  • id: int: The id(index) of this Vertex.
  • cGroup: int: The collision group of this Vertex.
  • cMask: int: The collision mask of this Vertex.
  • bCoef: number: The bouncing coefficient of this Vertex.
  • pos: Point: The position of this Vertex.

3.2. Segment

A class that defines a segment.

3.2.1. Properties

  • v0: Vertex: The first Vertex of this Segment.
  • v1: Vertex: The second Vertex of this Segment.
  • curveF: number: The curving angle of this Segment. (in radians)
  • color: int: The color of this Segment. Range: -1 <= color < 16777216.
    • This value can be converted into a rgba string via API's Utils.numberToColor function.
    • The special value -1 means transparent color.
  • vis: boolean: Whether this Segment is visible or not.
  • bias: number: Bias of this Segment.
  • bCoef: number: The bouncing coefficient of this Segment.
  • cGroup: int: The collision group of this Segment.
  • cMask: int: The collision mask of this Segment.
  • normal: Point: The calculated normal vector of this Segment. Only applies to non-curved Segments.
  • v0Normal: Point: The calculated normal direction of the object's tangent line at v0. Only applies to curved Segments.
  • v1Normal: Point: The calculated normal direction of the object's tangent line at v1. Only applies to curved Segments.
  • arcRadius: Point: The calculated radius of this Segment. Only applies to curved Segments.
  • arcCenter: Point: The calculated center point of this Segment. Only applies to curved Segments.

3.3. Plane

A class that defines a plane.

3.3.1. Properties

  • normal: Point: The normal vector of this Plane.
  • dist: number: The distance of this Plane to the origin point(0, 0).
  • bCoef: number: The bouncing coefficient of this Plane.
  • cGroup: int: The collision group of this Plane.
  • cMask: int: The collision mask of this Plane.

3.4. Goal

A class that defines a goal.

3.4.1. Properties

  • p0: Point: The first point of this Goal.
  • p1: Point: The second point of this Goal.
  • team: Team: The team that this Goal belongs to.

3.4.2. Functions

  • check(p1: Point, p2: Point): boolean

    Checks whether the line segment that passes through p1 and p2 intersects with the goal line.

    Parameters:

    • p1: Point: The first point of the line segment to check.
    • p2: Point: The second point of the line segment to check.

    Return value: True if intersection occurs, false otherwise.

3.5. Disc

A class that defines a disc.

3.5.1. Properties

  • pos: Point: The position of this Disc.
  • radius: number: The radius of this Disc.
  • speed: Point: The speed of this Disc.
  • gravity: Point: The gravity of this Disc.
  • damping: number: The damping value of this Disc.
  • invMass: number: The 1/mass value of this Disc.
  • bCoef: number: The bouncing coefficient of this Disc.
  • color: int: The color of this Disc. Range: -1 <= color < 16777216.
    • This value can be converted into a rgba string via API's Utils.numberToColor function.
    • The special value -1 means transparent color.
  • cGroup: int: The collision group of this Disc.
  • cMask: int: The collision mask of this Disc.

3.6. Joint

A class that defines a joint.

3.6.1. Properties

  • d0: int: Index of the first Disc of this Joint.
  • d1: int: Index of the second Disc of this Joint.
  • minLength: number: The minimum length of this Joint.
  • maxLength: number: The maximum length of this Joint.
  • strength: number: The strength of this Joint. (Infinity means rigid.)
  • color: int: The color of this Joint. Range: -1 <= color < 16777216.
    • This value can be converted into a rgba string via API's Utils.numberToColor function.
    • The special value -1 means transparent color.

3.7. Stadium

A class that defines a stadium.

3.7.1. Properties

  • vertices: Vertex[]: All vertices of this Stadium.
  • segments: Segment[]: All segments of this Stadium.
  • planes: Plane[]: All planes of this Stadium.
  • goals: Goal[]: All goals of this Stadium.
  • discs: Disc[]: All discs of this Stadium.
  • joints: Joint[]: All joints of this Stadium.
  • redSpawnPoints: Point[]: All spawn points of this Stadium for the red team.
  • blueSpawnPoints: Point[]: All spawn points of this Stadium for the blue team.
  • playerPhysics: PlayerPhysics: The physics properties of all players for this Stadium.
  • defaultStadiumId: int: The id(index) of this Stadium in the default stadiums array. This value will be 255 in custom Stadiums.
  • maxViewWidth: number: The maximum view width for this Stadium. Used in Renderers.
  • cameraFollow: CameraFollow: Whether the camera will follow the player or not. Used in Renderers.
  • canBeStored: boolean: Whether this Stadium can be stored or not.
  • fullKickOffReset: boolean: Whether the disc positions other than the ball are reset or not after a goal is scored.
  • name: string: The name of this Stadium.
  • width: number: The width of this Stadium.
  • height: number: The height of this Stadium.
  • bgType: BackgroundType: The background type of this Stadium.
  • bgColor: int: The background color of this Stadium. Range: -1 <= bgColor < 16777216.
    • This value can be converted into a rgba string via API's Utils.numberToColor function.
    • The special value -1 means transparent color.
  • bgWidth: number: The width for the background of this Stadium.
  • bgHeight: number: The height for the background of this Stadium.
  • bgKickOffRadius: number: The kick-off circle's radius for the background of this Stadium.
  • bgCornerRadius: number: The radius of the corners for the background of this Stadium.
  • spawnDistance: number: The spawn distance of players for this Stadium.
  • bgGoalLine: number: The goal line's horizontal distance from the default goal positions for the background of this Stadium.
  • isCustom: boolean: Whether this is a custom Stadium or a default Stadium. (readonly)

3.7.2. Functions

  • copy(): Stadium

    Creates a copy of this Stadium object.

    Parameters: None.

    Return value: A new clone of this Stadium object.

  • calculateChecksum(): string|null

    Returns the checksum for this Stadium object.

    Parameters: None.

    Return value: The checksum string of this Stadium object, or null for default stadiums.

  • calculateHash(): int

    Returns the hash value for this Stadium object.

    Parameters: None.

    Return value: The hash value for this Stadium object.

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