Class Brick

This is used for creating brick objects in Brick Hill.

Example of a brick that can kill players:

Example

let brick = new Brick(new Vector3(0, 0, 0), new Vector3(5, 5, 5), "#f54242")
brick.visibility = 0.5

Game.newBrick(brick) // "Parent" the brick to the game so players will download it.

brick.touching(debounce((p) => {
p.kill()
}, 500)) // We add a debounce of half a second to prevent double hits.

Hierarchy

  • EventEmitter
    • Brick

Constructors

Properties

_hitMonitor?: Timeout
_hitMonitorActive: boolean
_hitMonitorSpeed: number
_playersTouching: Set<Player>
_steps: Timeout[]
clickDistance: number = 50

The minimum distance a player must be to click the brick (if it is a clickable brick).

clickable: boolean = false

Whether or not the brick is a clickable brick.

collision: boolean = true

If the brick is passable by other players.

color: string

The current color of the brick.

destroyed: boolean

If .destroy() has been called on the brick.

lightColor: string = "#000000"

The current light color (in hex) of the brick.

lightEnabled: boolean = false

If enabled, the brick will emit lighting.

lightRange: number = 5

The range of the brick's lighting.

model: number

The asset id the brick will appear as.

name: string

The name of the brick.

netId: number

The network id of the brick.

position: Vector3

The current position of the brick.

rotation: Vector3

The current rotation of the brick.

scale: Vector3

The current scale of the brick.

shape: string

The shape of the brick.

socket: ClientSocket

If player.newBrick() is called, a socket is attached to the brick, so the brick changes
will be sent to the player instead of everyone.

visibility: number = 0

The visibility of the brick. (1 = fully visible, 0 = invisible)

brickId: number = 0
captureRejectionSymbol: typeof captureRejectionSymbol
captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

defaultMaxListeners: number
errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Accessors

Methods

  • Parameters

    • event: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Brick

  • Calls the specified callback when a player clicks the brick.

    Example

    const purpleBrick = world.bricks.find(brick => brick.name === 'purpleBrick')

    purpleBrick.clicked((player, secure) => {
    if (!secure) return // The server has validated that the player is currently *near* the brick.
    console.log(player.username + " clicked this brick!")
    })

    Parameters

    • callback: ((player: Player, secure?: boolean) => void)
        • (player: Player, secure?: boolean): void
        • Parameters

          • player: Player
          • Optional secure: boolean

          Returns void

    Returns Disconnectable

  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

  • Returns (string | symbol)[]

  • Returns number

  • Checks if this brick is colliding with another

    Parameters

    • brick: Brick

      The brick used to check collision against

    Returns boolean

  • Parameters

    • type: string | symbol

    Returns number

  • Parameters

    • event: string | symbol

    Returns Function[]

  • Parameters

    • event: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Brick

  • Parameters

    • event: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Brick

  • Parameters

    • event: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Brick

  • Parameters

    • event: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Brick

  • Parameters

    • event: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Brick

  • Parameters

    • event: string | symbol

    Returns Function[]

  • Parameters

    • Optional event: string | symbol

    Returns Brick

  • Parameters

    • event: string | symbol
    • listener: ((...args: any[]) => void)
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Brick

  • Parameters

    • clickable: boolean
    • clickDistance: number = 50

    Returns Promise<boolean>

  • Parameters

    • collision: boolean

    Returns Promise<boolean>

  • Parameters

    • color: string

    Returns Promise<boolean>

  • Identical to setInterval, but will be cleared after the brick is destroyed. Use this if you want to attach loops to bricks, but don't want to worry about clearing them after they're destroyed.

    Parameters

    • callback: (() => void)

      The callback function.

        • (): void
        • Returns void

    • delay: number

      The delay in milliseconds.

    Returns Timeout

  • Parameters

    • color: string

    Returns Promise<boolean>

  • Parameters

    • range: number

    Returns Promise<boolean>

  • Parameters

    • n: number

    Returns Brick

  • Parameters

    • model: number

    Returns Promise<boolean>

  • Parameters

    • visibility: number

    Returns Promise<boolean>

  • Calls the specified callback with the player who touched the brick.

    Example

    const purpleBrick = world.bricks.find(brick => brick.name === "purpleBrick")

    purpleBrick.touching((player) => {
    player.kill()
    })

    Parameters

    • callback: ((player: Player) => void)
        • (player: Player): void
        • Parameters

          Returns void

    Returns Disconnectable

  • Calls the specified callback when a player (who previously touched the brick) steps off of it.
    This will fire even if the player dies while touching the brick.

    However, if the player leaves the game this will NOT fire.

    Example

    const purpleBrick = world.bricks.find(brick => brick.name === 'purpleBrick')

    purpleBrick.touchingEnded((player) => {
    console.log("Get back on that brick!")
    })

    Parameters

    • callback: ((player: Player) => void)
        • (player: Player): void
        • Parameters

          Returns void

    Returns Disconnectable

  • Deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

  • Parameters

    • emitter: EventEmitter
    • event: string

    Returns AsyncIterableIterator<any>

  • Parameters

    • emitter: NodeEventTarget
    • event: string | symbol

    Returns Promise<any[]>

  • Parameters

    • emitter: DOMEventTarget
    • event: string

    Returns Promise<any[]>