Home Reference Source
import {MapView} from 'shapez.io/js/game/map_view.js'
public class | source

MapView

Extends:

BasicSerializableObjectBaseMap → MapView

This is the view of the map, it extends the map which is the raw model and allows to draw it

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

DPI of the background cache images, required in some places

public

cachedBackgroundCanvas: HTMLCanvasElement

The cached background sprite, containing the flat background

public

cachedBackgroundContext: CanvasRenderingContext2D

Method Summary

Public Methods
public
public

Draws the map background

public

Draws the maps foreground

public

drawForegroundLayer(parameters: DrawParameters, layer: Layer)

Draws the layer foreground

public

Draws the map overlay

public

Draws all static entities like buildings etc.

public

drawVisibleChunks(parameters: DrawParameters, method: function, layer: string=)

Calls a given method on all given chunks

public

Draws the wires foreground

public

Initializes all canvases used for background rendering

public

Called when an entity was added, removed or changed

Inherited Summary

From class BasicSerializableObject
public static
public static

getId()

public static

Should return the serialization schema

public static

verify(data: *): string | void

public

deserialize(data: any, root: import("./savegame_serializer").GameRoot): string | void

public
From class BaseMap
public static
public static

getSchema(): {"seed": *}

public

Mapping of 'X|Y' to chunk

public

root: *

public
public

getChunk(chunkX: number, chunkY: number): *

Returns the given chunk by index

public

Gets a chunk if not existent for the given tile

public

getLayerContentXY(x: number, y: number, layer: Layer): Entity

Returns the tile content of a given tile

public

Returns the tile contents of a given tile

public

getLowerLayerContentXY(x: number, y: number): BaseItem=

Returns the lower layers content of the given tile

public

Gets or creates a new chunk if not existent for the given tile

public

getTileContent(tile: Vector, layer: Layer): Entity

Returns the tile content of a given tile

public

Checks a given tile for validty

public

isTileUsed(tile: Vector, layer: Layer): boolean

Checks if the tile is used

public

isTileUsedXY(x: number, y: number, layer: Layer): boolean

Checks if the tile is used

public

Checks if a given tile is within the map bounds

public

Places an entity with the StaticMapEntity component

public

Removes an entity with the StaticMapEntity component

public

setTileContent(tile: Vector, entity: Entity)

Sets the tiles content

Public Constructors

public constructor() source

Fixes typeof DerivedComponent is not assignable to typeof Component, compiled out in non-dev builds

Override:

BaseMap#constructor

Public Members

public backgroundCacheDPI: number source

DPI of the background cache images, required in some places

public cachedBackgroundCanvas: HTMLCanvasElement source

The cached background sprite, containing the flat background

public cachedBackgroundContext: CanvasRenderingContext2D source

Public Methods

public cleanup() source

public drawBackground(parameters: DrawParameters) source

Draws the map background

Params:

NameTypeAttributeDescription
parameters DrawParameters

public drawForeground(parameters: DrawParameters) source

Draws the maps foreground

Params:

NameTypeAttributeDescription
parameters DrawParameters

public drawForegroundLayer(parameters: DrawParameters, layer: Layer) source

Draws the layer foreground

Params:

NameTypeAttributeDescription
parameters DrawParameters
layer Layer

public drawOverlay(parameters: DrawParameters) source

Draws the map overlay

Params:

NameTypeAttributeDescription
parameters DrawParameters

public drawStaticEntityDebugOverlays(drawParameters: DrawParameters) source

Draws all static entities like buildings etc.

Params:

NameTypeAttributeDescription
drawParameters DrawParameters

public drawVisibleChunks(parameters: DrawParameters, method: function, layer: string=) source

Calls a given method on all given chunks

Params:

NameTypeAttributeDescription
parameters DrawParameters
method function
layer string=

public drawWiresForegroundLayer(parameters: DrawParameters) source

Draws the wires foreground

Params:

NameTypeAttributeDescription
parameters DrawParameters

public internalInitializeCachedBackgroundCanvases() source

Initializes all canvases used for background rendering

public onEntityChanged(entity: Entity) source

Called when an entity was added, removed or changed

Params:

NameTypeAttributeDescription
entity Entity