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

MapChunk

Direct Subclass:

MapChunkView

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

Which entities this chunk contains, sorted by layer

public

Stores the contents of the regular layer

public

Stores the contents of the layers

public

Stores the contents of the lower (= map resources) layer

public

patches: Array<{pos: Vector, item: BaseItem, size: number}>

Store which patches we have so we can render them in the overview

public

root: *

public

Tile space rectangle, can be used for culling

public

tileX: *

public

tileY: *

public

Stores the contents of the wires layer

public

World space rectangle, can be used for culling

public

x: *

public

y: *

Method Summary

Public Methods
public

Generates the lower layer "terrain"

public

Checks if this chunk has predefined contents, and if so returns true and generates the predefined contents

public

getLayerContentFromWorldCoords(worldX: number, worldY: number, layer: Layer): Entity=

Returns the contents of this chunk from the given world space coordinates

public

Returns the contents of this chunk from the given world space coordinates

public

getLowerLayerFromWorldCoords(worldX: number, worldY: number): BaseItem=

public

getTileContentFromLocalCoords(localX: number, localY: number): Entity=

Returns the chunks contents from the given local coordinates

public

getTileContentFromWorldCoords(worldX: number, worldY: number): Entity=

Returns the contents of this chunk from the given world space coordinates

public

internalGeneratePatch(rng: RandomNumberGenerator, patchSize: number, item: any, overrideX: number=, overrideY: number=)

Generates a patch filled with the given item

public

setLayerContentFromWorldCords(tileX: number, tileY: number, contents: Entity, layer: Layer)

Sets the chunks contents

Public Constructors

public constructor(root: GameRoot, x: number, y: number) source

Params:

NameTypeAttributeDescription
root GameRoot
x number
y number

Public Members

public containedEntities: Array<Entity> source

public containedEntitiesByLayer: Record<Layer, Array<Entity>> source

Which entities this chunk contains, sorted by layer

public contents: Array<ArrayEntity>> source

Stores the contents of the regular layer

public layersContents: Map<string, Array<ArrayEntity>>> source

Stores the contents of the layers

public lowerLayer: Array<ArrayBaseItem>> source

Stores the contents of the lower (= map resources) layer

public patches: Array<{pos: Vector, item: BaseItem, size: number}> source

Store which patches we have so we can render them in the overview

public root: * source

public tileSpaceRectangle: * source

Tile space rectangle, can be used for culling

public tileX: * source

public tileY: * source

public wireContents: Array<ArrayEntity>> source

Stores the contents of the wires layer

public worldSpaceRectangle: * source

World space rectangle, can be used for culling

public x: * source

public y: * source

Public Methods

public generateLowerLayer() source

Generates the lower layer "terrain"

public generatePredefined(rng: RandomNumberGenerator): boolean source

Checks if this chunk has predefined contents, and if so returns true and generates the predefined contents

Params:

NameTypeAttributeDescription
rng RandomNumberGenerator

Return:

boolean

public getLayerContentFromWorldCoords(worldX: number, worldY: number, layer: Layer): Entity= source

Returns the contents of this chunk from the given world space coordinates

Params:

NameTypeAttributeDescription
worldX number
worldY number
layer Layer

Return:

Entity=

public getLayersContentsMultipleFromWorldCoords(worldX: number, worldY: number): Array<Entity> source

Returns the contents of this chunk from the given world space coordinates

Params:

NameTypeAttributeDescription
worldX number
worldY number

Return:

Array<Entity>

public getLowerLayerFromWorldCoords(worldX: number, worldY: number): BaseItem= source

Params:

NameTypeAttributeDescription
worldX number
worldY number

Return:

BaseItem=

public getTileContentFromLocalCoords(localX: number, localY: number): Entity= source

Returns the chunks contents from the given local coordinates

Params:

NameTypeAttributeDescription
localX number
localY number

Return:

Entity=

public getTileContentFromWorldCoords(worldX: number, worldY: number): Entity= source

Returns the contents of this chunk from the given world space coordinates

Params:

NameTypeAttributeDescription
worldX number
worldY number

Return:

Entity=

public internalGeneratePatch(rng: RandomNumberGenerator, patchSize: number, item: any, overrideX: number=, overrideY: number=) source

Generates a patch filled with the given item

Params:

NameTypeAttributeDescription
rng RandomNumberGenerator
patchSize number
item any
overrideX number=

Override the X position of the patch

overrideY number=

Override the Y position of the patch

public setLayerContentFromWorldCords(tileX: number, tileY: number, contents: Entity, layer: Layer) source

Sets the chunks contents

Params:

NameTypeAttributeDescription
tileX number
tileY number
contents Entity
layer Layer