Home Reference Source

References

summary
public
public

F applyLanguage(languageCode: *): boolean

public

Tries to auto-detect a language

public

F matchOverwriteRecursive(dest: *, src: *)

public
public

V CHANGELOG: Array<{version: string, date: string, entries: Array<String>}>

public

V LANGUAGES: Object<string, {name: string, data: any, code: string, region: string}>

public

V T: *

core

summary
public

Controls the frames and emit signals to draw

public
public
public
public
public
public

Basic state of the game state machine.

public
public
public
public

C Dialog

Basic text based dialog

public

Dialog which simply shows a loading spinner

public
public
public
public
public
public
public
public
public
public
public
public

C Signal

public
public
public
public
public

Position of a sprite within an atlas

public
public

This is the main state machine which drives the game states.

public

Baseclass for all game states which are structured similary: A header with back button + some scrollable content.

public
public

C Vector

public

F cachebust(path: string): *

Generates a cachebuster string.

public

Returns the current dpi

public

F prepareHighDPIContext(context: CanvasRenderingContext2D)

Prepares a context for hihg dpi rendering

public

F resizeCanvas(canvas: HTMLCanvasElement, w: number, h: number)

Resizes a canvas

public

F resizeCanvasAndClear(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D, w: number, h: number)

Resizes a canvas and makes sure its cleared

public

F resizeHighDPICanvas(canvas: HTMLCanvasElement, w: number, h: number)

Resizes a high dpi canvas

public
public
public

Draws a sprite with clipping

public
public

F initBuildingsByCategory(buildings: Object<string, Array<Class<import("../game/meta_building").MetaBuilding>>>)

public
public

F createLogger(context: *): *

public

F globalDebug(context: *, args: ...*)

public

F globalError(context: *, args: ...*)

public

F globalLog(context: *, args: ...*)

public

F globalWarn(context: *, args: ...*)

public

F logSection(name: *, color: *)

public

F serializeError(err: Error | ErrorEvent): *

Serializes an error

public

F stringifyObjectContainingErrors(payload: any): *

Stringifies an object containing circular references and errors

public

F compressU8(uncompressed: *): *

public

F compressU8WHeader(uncompressed: string, header: number): *

public

F compressX64(input: *): *

public

F decompressU8WHeader(compressed: Uint8Array): *

public

F decompressX64(input: *): *

public

F computeCrc(str: string): *

Computes the crc for a given string

public
public

F sha1(str: *): *

public

F accessNestedPropertyReverse(obj: any, keys: Array<string>): *

Access an object in a very annoying way, used for obsfuscation.

public

F arrayDelete(array: Array<any>, index: number)

Deletes from an array at the given index

public

F arrayDeleteValue(array: Array<any>, value: any): *

Deletes the given value from an array

public

F clamp(v: number, minimum: number=, maximum: number=): *

Clamps a value between [min, max]

public

Compare two floats for epsilon equality

public

F fastArrayDelete(array: Array<any>, index: number)

Deletes from an array by swapping with the last element

public

F fastArrayDeleteValue(array: Array<any>, value: any): *

Deletes from an array by swapping with the last element.

public

F fastArrayDeleteValueIfContained(array: Array<any>, value: any): *

public

F fillInLinkIntoTranslation(translation: string, link: string): *

Fills in a <link> tag

public

Finds a nice integer value

public

F findNiceValue(num: number): *

Finds a value which is nice to display, e.g.

public

F formatBigNumber(num: number, separator: string=): string

Formats a big number

public

F formatBigNumberFull(num: number, divider: string=): string

Formats a big number, but does not add any suffix and instead uses its full representation

public

F formatItemsPerSecond(speed: number, double: boolean=, separator: string=): *

Formats a number like 2.51 to "2.51 items / s"

public

Formats seconds into a readable string like "5h 23m"

public

Formats an amount of seconds into something like "5s ago"

public

F generateFileDownload(filename: string, text: string)

Generates a file download

public

Generates rotated variants of the matrix

public
public

F getPlatformName(): "android" | "browser" | "ios" | "standalone" | "unknown"

Returns a platform name

public
public

Returns if this platform is android

public

F isIos(): boolean

Returns if this platform is iOs

public

Returns if the game supports this browser

public

F lerp(a: number, b: number, x: number): *

Interpolates two numbers

public

Makes a new 2D array with undefined contents

public

F makeButton(parent: Element, classes: Array<string>=, innerHTML: string=): *

Helper method to create a new button

public

F makeButtonElement(classes: Array<string>=, innerHTML: string=): *

Helper method to create a new button element

public

F makeDiv(parent: Element, id: string=, classes: Array<string>=, innerHTML: string=): *

Helper method to create a new div

public

F newEmptyMap(): *

Creates a new map (an empty object without any props)

public

F randomChoice(arr: T[]): T

Chooses a random entry of an array

public

F randomInt(start: number, end: number): *

Returns a random integer in the range [start,end]

public

F removeAllChildren(elem: Element)

Removes all children of the given element

public

Rotates a directional object

public

Rotates a flat 3x3 matrix clockwise Entries: 0 lo 1 mo 2 ro 3 lm 4 mm 5 rm 6 lu 7 mu 8 ru

public

Rounds 1 digit

public

F round1DigitLocalized(speed: number, separator: string=): *

Formats a number like 2.51 to "2.5"

public

Rounds 2 digits

public

Rounds 3 digits

public

Rounds 4 digits

public

F safeModulo(n: number, m: number): *

Modulo which works for negative numbers

public

Returns a smooth pulse between 0 and 1

public

F startFileChoose(acceptedType: string): *

Starts a file chooser

public

F waitNextFrame(): Promise<void>

Waits two frames so the ui is updated

public

F mixVector(v1: Vector, v2: Vector, a: number): *

Interpolates two vectors, for a = 0, returns v1 and for a = 1 return v2, otherwise interpolate

public
public
public

V atlasFiles: AtlasDefinition[]

public
public

V clickDetectorGlobals: {"lastTouchTime": *}

public
public

V IS_DEBUG: *

public

V IS_MAC: *

public

V IS_MOBILE: *

public
public

V THIRDPARTY_URLS: {"discord": string, "github": string, "reddit": string, "shapeViewer": string, "standaloneStorePage": string, "levelTutorialVideos": *}

public

V globalConfig: {"tileSize": number, "halfTileSize": number, "assetsDpi": *, "assetsSharpness": number, "shapesSharpness": number, "statisticsGraphDpi": number, "statisticsGraphSlices": number, "analyticsSliceDurationSeconds": *, "minimumTickRate": number, "maximumTickRate": number, "mapChunkSize": number, "mapChunkOverviewMinZoom": number, "mapChunkWorldSize": *, "beltSpeedItemsPerSecond": number, "minerSpeedItemsPerSecond": *, "defaultItemDiameter": number, "itemSpacingOnBelts": number, "wiresSpeedItemsPerSecond": number, "undergroundBeltMaxTilesByTier": *, "readerAnalyzeIntervalSeconds": number, "buildingSpeeds": *, "initialZoom": number, "minZoomLevel": number, "maxZoomLevel": number, "gameSpeed": number, "warmupTimeSecondsFast": number, "warmupTimeSecondsRegular": number, "smoothing": *, "rendering": *, "debug": *, "info": *}

public
public

V gBuildingsByCategory: Object<string, Array<Class<import("../game/meta_building").MetaBuilding>>>

public

V gComponentRegistry: FactoryTemplate<import("../game/component").Component>

public

V gGameModeRegistry: FactoryTemplate<GameMode>

public

V gGameSpeedRegistry: FactoryTemplate<import("../game/time/base_game_speed").BaseGameSpeed>

public

V gItemRegistry: FactoryTemplate<import("../game/base_item").BaseItem>

public

V gMetaBuildingRegistry: SingletonFactoryTemplate<import("../game/meta_building").MetaBuilding>

public

Used for the bug reporter, and the click detector which both have no handles to this.

public
public

V queryParamOptions: {"embedProvider": *, "fullVersion": *, "sandboxMode": *}

public
public

V CRC_PREFIX: *

public
public
public
public
public

V enumAngleToDirection: {"0": *, "90": *, "180": *, "270": *}

public

V enumDirection: {"top": string, "right": string, "bottom": string, "left": string}

public

V enumDirectionToAngle: {"undefined": number}

public

V enumDirectionToVector: {"top": *, "right": *, "bottom": *, "left": *}

Mapping from string direction to actual vector

public

V enumInvertedDirections: {"undefined": *}

public

T JobEntry: function(message: any): void,

public

T SourceData: { frames: Object.<string, SpriteDefinition>, meta: AtlasMeta }

public

T CacheEntry: { canvas: HTMLCanvasElement, context: CanvasRenderingContext2D, lastUse: number, }

public

T ClickDetectorConstructorArgs: { consumeEvents?: boolean, preventDefault?: boolean, applyCssClass?: string, captureTouchmove?: boolean, targetOnly?: boolean, maxDistance?: number, clickSound?: string, preventClick?: boolean, }

Click detector creation payload typehints

public

T DirectionalObject: { top: any, right: any, bottom: any, left: any }

game

summary
public
public

Class for items on belts etc.

public

Stores a path of belts, used for optimizing performance

public
public

C Camera

public
public

The core manages the root and represents the whole game.

public
public

C Entity

public

Typedefs for all entity components.

public
public
public

A game system processes all entities which match a given schema, usually a list of required components.

public
public
public
public
public
public
public
public
public

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

public
public
public

The game root is basically the whole game state at a given point, combining all important classes.

public
public
public
public
public

F getCodeFromBuildingData(metaBuilding: MetaBuilding, variant: string, rotationVariant: number): String

Finds the code for a given variant

public

F registerBuildingVariant(meta: typeof MetaBuilding, variant: string, rotationVariant: number)

Registers a new variant

public
public
public
public
public
public
public
public

F getRandomHint(): *

Finds a new hint to show about the game which the user hasn't seen within this session

public
public
public

F itemResolverSingleton(root: import("./root").GameRoot, data: {$: string, data: any}): *

Resolves items so we share instances

public

Returns a keycode -> string

public
public

Once all sprites are loaded, propagates the cache

public
public

F createSimpleShape(layers: *): Array<import("./shape_definition").ShapeLayer>

Converts the given parameters to a valid shape definition

public

F applyGameTheme(id: *)

public

V enumSavePriority: {"regular": number, "asap": number}

public

Stores a lookup table for all building variants (for better performance)

public
public
public
public

V enumMouseButton: {"left": string, "middle": string, "right": string}

public

V enumColorMixingResults: {"undefined": *}

public

V enumColorToShortcode: {"undefined": string}

public

V enumColors: {"red": string, "green": string, "blue": string, "yellow": string, "purple": string, "cyan": string, "white": string, "uncolored": string}

public

V enumColorsToHexCode: {"undefined": string}

public
public
public
public
public
public

V KEYMAPPINGS: {"general": *, "ingame": *, "navigation": *, "buildings": *, "placement": *, "massSelect": *, "placementModifiers": *}

public
public
public

V enumAnalyticsDataSource: {"produced": string, "stored": string, "delivered": string}

public

V layers: Array<Layer>

public
public

V enumSubShape: {"rect": string, "circle": string, "star": string, "windmill": string}

public

V enumSubShapeToShortcode: {"undefined": string}

public

V THEME: *

public

V VANILLA_THEMES: {"dark": *, "light": *}

public

V enumHubGoalRewards: {"reward_cutter_and_trash": string, "reward_rotater": string, "reward_painter": string, "reward_mixer": string, "reward_stacker": string, "reward_balancer": string, "reward_tunnel": string, "reward_rotater_ccw": string, "reward_rotater_180": string, "reward_miner_chainable": string, "reward_underground_belt_tier_2": string, "reward_belt_reader": string, "reward_splitter": string, "reward_cutter_quad": string, "reward_painter_double": string, "reward_storage": string, "reward_merger": string, "reward_wires_painter_and_levers": string, "reward_display": string, "reward_constant_signal": string, "reward_logic_gates": string, "reward_virtual_processing": string, "reward_filter": string, "reward_demo_end": string, "reward_blueprints": string, "reward_freeplay": string, "no_reward": string, "no_reward_freeplay": string}

Don't forget to also update tutorial_goals_mappings.js as well as the translations!

public

Stores which reward unlocks what

public

T BuildingVariantIdentifier: { metaClass: typeof MetaBuilding, metaInstance?: MetaBuilding, variant?: string, rotationVariant?: number, tileSize?: Vector, sprite?: AtlasSprite, blueprintSprite?: AtlasSprite, silhouetteColor?: string }

public

T StaticComponent: typeof Component

TypeScript does not support Abstract Static methods (https://github.com/microsoft/TypeScript/issues/34516) One workaround is to declare the type of the component and reference that for static methods

public

T null: typeof Component[]

public

T LevelDefinition: { shape: string, required: number, reward: enumHubGoalRewards, throughputOnly?: boolean }

public

T TierRequirement: { required: Array<UpgradeRequirement> improvement?: number, excludePrevious?: boolean }

public

T UpgradeRequirement: { shape: string, amount: number }

public
public

T AcceptorsAffectingTile: Array<{ entity: Entity, slot: import("./components/item_acceptor").ItemAcceptorSlot, toTile: Vector, fromDirection: enumDirection }>

Typing helper

public

T AcceptorsAndEjectorsAffectingTile: { acceptors: AcceptorsAffectingTile, ejectors: EjectorsAffectingTile }

public

T EjectorsAffectingTile: Array<{ entity: Entity, slot: import("./components/item_ejector").ItemEjectorSlot, fromTile: Vector, toDirection: enumDirection }>

Typing helper

public

T ShapeLayer: [ShapeLayerItem?, ShapeLayerItem?, ShapeLayerItem?, ShapeLayerItem?]

Order is Q1 (tr), Q2(br), Q3(bl), Q4(tl)

public

T ShapeLayerItem: { subShape: enumSubShape, color: enumColors, }

public

T TutorialGoalReward: Array<[typeof MetaBuilding, string]>

game/buildings

summary
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public

game/components

summary
public
public
public
public
public
public
public
public
public
public
public
public
public
public

V enumClippedBeltUnderlayType: {"full": string, "bottomOnly": string, "topOnly": string, "none": string}

Store which type an underlay is, this is cached so we can easily render it.

public
public

V enumItemProcessorTypes: {"balancer": string, "cutter": string, "cutterQuad": string, "rotater": string, "rotaterCCW": string, "rotater180": string, "stacker": string, "trash": string, "mixer": string, "painter": string, "painterDouble": string, "painterQuad": string, "hub": string, "filter": string, "reader": string}

public

V enumLogicGateType: {"and": string, "not": string, "xor": string, "or": string, "transistor": string, "analyzer": string, "rotater": string, "unstacker": string, "cutter": string, "compare": string, "stacker": string, "painter": string}

public

V enumUndergroundBeltMode: {"sender": string, "receiver": string}

public

V enumWireType: {"forward": string, "turn": string, "split": string, "cross": string}

public

V enumPinSlotType: {"logicalEjector": string, "logicalAcceptor": string}

public

T BeltUnderlayTile: { pos: Vector, direction: enumDirection, cachedType?: enumClippedBeltUnderlayType }

public

T PendingFilterItem: { item: BaseItem, progress: number }

public

T ItemAcceptorLocatedSlot: { slot: ItemAcceptorSlot, index: number, acceptedDirection: enumDirection }

Contains information about a slot plus its location

public

T ItemAcceptorSlot: { pos: Vector, directions: enumDirection[], filter?: ItemType }

public

T ItemAcceptorSlotConfig: { pos: Vector, directions: enumDirection[], filter?: ItemType }

public

T ItemEjectorSlot: { pos: Vector, direction: enumDirection, item: BaseItem, progress: number?, cachedDestSlot?: import("./item_acceptor").ItemAcceptorLocatedSlot, cachedBeltPath?: BeltPath, cachedTargetEntity?: Entity }

public

T EjectorCharge: { remainingTime: number, items: Array<EjectorItemToEject>, }

public

T EjectorItemToEject: { item: BaseItem, requiredSlot?: number, preferredSlot?: number }

public

T LinkedUndergroundBelt: { entity: Entity, distance: number }

public

T WirePinSlot: { pos: Vector, type: enumPinSlotType, direction: enumDirection, value: BaseItem, linkedNetwork: import("../systems/wire").WireNetwork }

public

T WirePinSlotDefinition: { pos: Vector, type: enumPinSlotType, direction: enumDirection }

game/hud

summary
public
public
public
public

game/hud/parts

summary
public
public
public
public
public

Contains all logic for the building placer - this doesn't include the rendering of info boxes or drawing.

public
public
public
public
public
public

Allows to inspect entities by pressing F8 while hovering them

public
public
public

Helper class which allows peaking through to the wires layer

public
public
public
public
public
public

Manages the pinned shapes on the left side of the screen

public
public
public
public
public
public
public
public

Simple wrapper for a shape definition within the shape statistics

public
public

Offers to open the tutorial video after completing a level

public
public
public
public
public
public
public
public

V enumNotificationType: {"saved": string, "upgrade": string, "success": string}

public

V enumDisplayMode: {"icons": string, "detailed": string}

public

Stores how many seconds one unit is

public

T DebugChange: { label: string, area: Rectangle, hideAt: number, fillColor: string }

public
public

T KeyCode: {keyCode: number}

public

T Waypoint: { label: string | null, center: { x: number, y: number }, zoomLevel: number, layer: Layer, }

game/items

summary
public
public
public
public

Returns whether the item is Boolean and TRUE

public

Returns whether the item is truthy

public
public

game/modes

summary
public
public

F generateLevelDefinitions(limitedVersion: boolean): *

Generates the level definitions

game/systems

summary
public

Manages all belts

public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public

T ProcessorImplementationPayload: { entity: Entity, items: Array<{ item: BaseItem, sourceSlot: number }>, itemsBySlot: Object<number, BaseItem>, outItems: Array<ProducedItem> }

Type of a processor implementation

public

T ProducedItem: { item: BaseItem, preferredSlot?: number, requiredSlot?: number, doNotTrack?: boolean }

Whole data for a produced item

game/time

summary
public
public
public
public
public

modloader

summary
public
public
public

F matchOverwriteRecursiveSettings(dest: *, src: *)

public

T ModInfo: { title: String, id: String, description: String, authors: Array<String>, version: String, gameVersion: number, dependencies: Array<String>, incompatible: Array<String>, translations: {}, settings: {}, updateStaticSettings: Function, updateStaticTranslations: Function, gameInitializedRootClasses: Function, gameInitializedRootManagers: Function, gameBeforeFirstUpdate: Function, main: Function, }

public

T null: string[]

public

T ModPack: { mods: [ { url: string, id: string, config: {}, settings: {}, }, ], modOrder?: [], }

platform

summary
public
public
public
public
public
public
public
public
public

V MUSIC: {"theme": *, "menu": string}

public

V SOUNDS: {"uiClick": string, "uiError": string, "dialogError": string, "dialogOk": string, "swishHide": string, "swishShow": string, "badgeNotification": string, "levelComplete": string, "destroyBuilding": string, "placeBuilding": string, "placeBelt": string, "copy": string}

public

platform/ad_providers

summary
public
public
public

platform/browser

summary
public
public
public
public
public
public
public

platform/electron

summary
public
public

profile

summary
public
public
public
public
public
public
public
public
public

V enumCategories: {"general": string, "userInterface": string, "performance": string, "advanced": string, "debug": string}

public
public
public

savegame

summary
public
public
public
public

Serializes a savegame

public
public

Base serialization data type

public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public
public

F compressObject(obj: object): {"keys": *, "values": *, "data": *}

public
public

Returns if the given savegame has any supported interface

public

F deserializeSchema(obj: object, schema: Schema, data: object, baseclassErrorResult: string | void | null=, root: import("../game/root").GameRoot=): string | void

Deserializes data into an object

public

F extendSchema(base: Schema, newOne: Schema): Schema

Extends a schema by adding the properties from the new schema to the existing base schema

public

F serializeSchema(obj: object, schema: Schema, mergeWith: object=): object

Serializes an object using the given schema, mergin with the given properties

public

F verifySchema(schema: Schema, data: object): string | void

Verifies stored data using the given schema

public

F schemaToJsonSchema(schema: import("./serialization").Schema): *

public

V savegameInterfaces: Object<any, typeof BaseSavegameInterface>

public

V enumLocalSavegameStatus: {"offline": string, "synced": string}

public

V types: {"int": *, "uint": *, "float": *, "ufloat": *, "string": *, "entity": *, "weakEntityRef": *, "vector": *, "tileVector": *, "bool": *, "nullable": function, "classId": function, "keyValueMap": function, "enum": function, "obj": function, "objData": function, "knownType": function, "array": function, "fixedSizeArray": function, "classRef": function, "structured": function, "pair": function, "classWithMetaclass": function}

public
public

T SavegamesData: { version: number, savegames: Array<SavegameMetadata> }

public

A full schema declaration

savegame/schemas

summary
public
public
public
public
public
public
public
public
public
public

V codes: {"1": *, "2": *, "3": *, "4": *, "5": *, "6": *, "47": *, "48": *, "7": *, "8": *, "9": *, "10": *, "11": *, "12": *, "13": *, "14": *, "15": *, "16": *, "17": *, "18": *, "19": *, "20": *, "21": *, "22": *, "23": *, "24": *, "25": *, "26": *, "27": *, "28": *, "29": *, "30": *, "52": *, "53": *, "54": *, "55": *, "31": *, "32": *, "34": *, "35": *, "36": *, "38": *, "60": *, "33": *, "37": *, "39": *, "40": *, "42": *, "44": *, "45": *, "50": *, "51": *, "46": *, "43": *, "49": *, "61": *}

public

T OldStaticMapEntity: { origin: TypeVector, tileSize: TypeVector, rotation: TypeNumber, originalRotation: TypeNumber, spriteKey?: string, blueprintSpriteKey: string, silhouetteColor: string }

states

summary
public
public
public
public
public
public
public
public
public
public

V gameCreationAction: {"new": string, "resume": string}