Home Reference Source
import {HUDBuildingPlacer} from 'shapez.io/js/game/hud/parts/building_placer.js'
public class | source

HUDBuildingPlacer

Extends:

BaseHUDPartHUDBuildingPlacerLogic → HUDBuildingPlacer

Member Summary

Public Members
public
public
public
public

element: *

public
public

Stores the click detectors for the variants so we can clean them up later

public
public

Method Summary

Public Methods
public
public

Cleans up all variant click detectors

public

createElements(parent: HTMLElement)

public

draw(parameters: DrawParameters)

public
public
public
public
public
public

makeLockIndicatorSprite(layer: Layer): *

Makes the lock indicator sprite for the given layer

public

Rerenders the building info dialog

public

Rerenders the variants displayed

Inherited Summary

From class BaseHUDPart
public
public

root: *

public

Cleans up the hud element, if overridden make sure to call super.cleanup

public

Cleans up all click detectors

public

close()

Should close the element, in case its supported

public

closeOnBackgroundClick(element: HTMLElement, closeMethod: function)

Closes this element when its background is clicked

public

createElements(parent: HTMLElement)

Should create all require elements

public

draw(parameters: DrawParameters)

Should draw the hud

public

Should draw any overlays (screen space)

public

Forwards the game speed keybindings so you can toggle pause / Fastforward in the building tooltip and such

public

Forwards the map movement keybindings so you can move the map with the arrow keys

public

Should initialize the element, called after the elements have been created

public

Should return true if this overlay is open and currently blocking any user interaction

public

Registers a new click detector

public

Should return false if the game should be paused

public

Should return true if the widget has a modal dialog opened and thus the game does not need to update / redraw

public

trackClicks(element: Element, handler: function, args: import("../../core/click_detector").ClickDetectorConstructorArgs=)

Helper method to construct a new click detector

public

update()

Should update any required logic

From class HUDBuildingPlacerLogic
public get

Returns the current base rotation for the current meta-building.

public set

Sets the base rotation for the current meta-building.

public get

Returns the current direction lock corner, that is, the corner between mouse and original start point

public get

Returns if the direction lock is currently active

public

The current rotation

public

The side for direction lock

public

Whether the side for direction lock has not yet been determined.

public

currentMetaBuilding: TypedTrackedState<MetaBuilding>

The current building

public

currentVariant: TypedTrackedState<string>

Current building variant

public

Whether we are currently drag-deleting

public

Whether we are currently dragging

public

We use a fake entity to get information about how a building will look once placed

public
public

The tile we last dragged from

public

The current rotation preference for each building.

public

Stores which variants for each building we prefer, this is based on what the user last selected

public

signals: {"variantChanged": *, "draggingStarted": *}

public

Aborts any dragging

public

Aborts the placement

public

Checks if the direction lock key got released and if such, resets the placement

public

computeDirectionLockPath(): Array<{tile: Vector, rotation: number}>

Finds the path which the current direction lock will use

public

Cycles through the variants

public

Tries to delete the building under the mouse

public

Performs the direction locked placement between two points after releasing the mouse

public

Initializes the logic

public

Initializes all bindings

public

onEditModeChanged(layer: Layer)

Called when the edit mode got changed

public

onMouseDown(pos: Vector, button: enumMouseButton): *

mouse down pre handler

public

onMouseMove(pos: Vector): *

mouse move pre handler

public

Mouse up handler

public

Called when the selected buildings changed

public

setVariant(variant: string)

Sets the current variant to the given variant

public

Starts the pipette function

public

startSelection(metaBuilding: MetaBuilding)

Selects a given building

public

Switches the side for the direction lock manually

public

Tries to place the current building at the given tile

public

Tries to rotate the current building

public

update()

Public Members

public buildingInfoElements: {} source

public currentInterpolatedCornerTile: * source

public domAttach: * source

public element: * source

public lockIndicatorSprites: {} source

public variantClickDetectors: Array<ClickDetectorConstructorArgs> source

Stores the click detectors for the variants so we can clean them up later

public variantsAttach: * source

public variantsElement: * source

Public Methods

public cleanup() source

Cleans up the hud element, if overridden make sure to call super.cleanup

Override:

BaseHUDPart#cleanup

public cleanupVariantClickDetectors() source

Cleans up all variant click detectors

public createElements(parent: HTMLElement) source

Should create all require elements

Override:

BaseHUDPart#createElements

Params:

NameTypeAttributeDescription
parent HTMLElement

public draw(parameters: DrawParameters) source

Should draw the hud

Override:

BaseHUDPart#draw

Params:

NameTypeAttributeDescription
parameters DrawParameters

public drawDirectionLock(parameters: DrawParameters) source

Params:

NameTypeAttributeDescription
parameters DrawParameters

public drawLayerPeek(parameters: DrawParameters) source

Params:

NameTypeAttributeDescription
parameters DrawParameters

public drawMatchingAcceptorsAndEjectors(parameters: DrawParameters) source

Params:

NameTypeAttributeDescription
parameters DrawParameters

public drawRegularPlacement(parameters: DrawParameters) source

Params:

NameTypeAttributeDescription
parameters DrawParameters

public initialize() source

Initializes the logic

Override:

HUDBuildingPlacerLogic#initialize

public makeLockIndicatorSprite(layer: Layer): * source

Makes the lock indicator sprite for the given layer

Params:

NameTypeAttributeDescription
layer Layer

Return:

*

public rerenderInfoDialog() source

Rerenders the building info dialog

public rerenderVariants() source

Rerenders the variants displayed