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

ShapeDefinitionManager

Extends:

BasicSerializableObject → ShapeDefinitionManager

Static Method Summary

Static Public Methods
public static

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public
public

root: *

public

Store a cache from key -> definition

public

Store a cache from key -> item

Method Summary

Public Methods
public

getDefinitionFromSimpleShapes(subShapes: [enumSubShape, enumSubShape, enumSubShape, enumSubShape]): ShapeDefinition

public

Returns a shape instance from a given short key

public

Returns a shape item for a given definition

public

Returns a item instance from a given short key

public

Checks if we already have cached this definition, and if so throws it away and returns the already cached variant

public

Registers a new shape definition

public

shapeActionCutHalf(definition: ShapeDefinition): [ShapeDefinition, ShapeDefinition]

Generates a definition for splitting a shape definition in two halfs

public

shapeActionCutQuad(definition: ShapeDefinition): [ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]

Generates a definition for splitting a shape definition in four quads

public

Generates a definition for painting it with the given color

public

shapeActionPaintWith4Colors(definition: ShapeDefinition, colors: [enumColors, enumColors, enumColors, enumColors]): ShapeDefinition

Generates a definition for painting it with the 4 colors

public

Generates a definition for rotating a shape FL

public

Generates a definition for rotating a shape counter clockwise

public

Generates a definition for rotating a shape clockwise

public

shapeActionStack(lowerDefinition: ShapeDefinition, upperDefinition: ShapeDefinition): ShapeDefinition

Generates a definition for stacking the upper definition onto the lower one

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

Static Public Methods

public static getId(): string source

Override:

BasicSerializableObject#getId

Return:

string

Public Constructors

public constructor(root: GameRoot) source

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

Override:

BasicSerializableObject#constructor

Params:

NameTypeAttributeDescription
root GameRoot

Public Members

public root: * source

public shapeKeyToDefinition: Object<string, ShapeDefinition> source

Store a cache from key -> definition

public shapeKeyToItem: {} source

Store a cache from key -> item

Public Methods

public getDefinitionFromSimpleShapes(subShapes: [enumSubShape, enumSubShape, enumSubShape, enumSubShape]): ShapeDefinition source

Params:

NameTypeAttributeDescription
subShapes [enumSubShape, enumSubShape, enumSubShape, enumSubShape]

Return:

ShapeDefinition

public getShapeFromShortKey(hash: string): ShapeDefinition source

Returns a shape instance from a given short key

Params:

NameTypeAttributeDescription
hash string

Return:

ShapeDefinition

public getShapeItemFromDefinition(definition: ShapeDefinition): ShapeItem source

Returns a shape item for a given definition

Params:

NameTypeAttributeDescription
definition ShapeDefinition

Return:

ShapeItem

public getShapeItemFromShortKey(hash: string): ShapeItem source

Returns a item instance from a given short key

Params:

NameTypeAttributeDescription
hash string

Return:

ShapeItem

public registerOrReturnHandle(definition: ShapeDefinition): * source

Checks if we already have cached this definition, and if so throws it away and returns the already cached variant

Params:

NameTypeAttributeDescription
definition ShapeDefinition

Return:

*

public registerShapeDefinition(definition: ShapeDefinition) source

Registers a new shape definition

Params:

NameTypeAttributeDescription
definition ShapeDefinition

public shapeActionCutHalf(definition: ShapeDefinition): [ShapeDefinition, ShapeDefinition] source

Generates a definition for splitting a shape definition in two halfs

Params:

NameTypeAttributeDescription
definition ShapeDefinition

Return:

[ShapeDefinition, ShapeDefinition]

public shapeActionCutQuad(definition: ShapeDefinition): [ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition] source

Generates a definition for splitting a shape definition in four quads

Params:

NameTypeAttributeDescription
definition ShapeDefinition

Return:

[ShapeDefinition, ShapeDefinition, ShapeDefinition, ShapeDefinition]

public shapeActionPaintWith(definition: ShapeDefinition, color: enumColors): ShapeDefinition source

Generates a definition for painting it with the given color

Params:

NameTypeAttributeDescription
definition ShapeDefinition
color enumColors

Return:

ShapeDefinition

public shapeActionPaintWith4Colors(definition: ShapeDefinition, colors: [enumColors, enumColors, enumColors, enumColors]): ShapeDefinition source

Generates a definition for painting it with the 4 colors

Params:

NameTypeAttributeDescription
definition ShapeDefinition
colors [enumColors, enumColors, enumColors, enumColors]

Return:

ShapeDefinition

public shapeActionRotate180(definition: ShapeDefinition): ShapeDefinition source

Generates a definition for rotating a shape FL

Params:

NameTypeAttributeDescription
definition ShapeDefinition

Return:

ShapeDefinition

public shapeActionRotateCCW(definition: ShapeDefinition): ShapeDefinition source

Generates a definition for rotating a shape counter clockwise

Params:

NameTypeAttributeDescription
definition ShapeDefinition

Return:

ShapeDefinition

public shapeActionRotateCW(definition: ShapeDefinition): ShapeDefinition source

Generates a definition for rotating a shape clockwise

Params:

NameTypeAttributeDescription
definition ShapeDefinition

Return:

ShapeDefinition

public shapeActionStack(lowerDefinition: ShapeDefinition, upperDefinition: ShapeDefinition): ShapeDefinition source

Generates a definition for stacking the upper definition onto the lower one

Params:

NameTypeAttributeDescription
lowerDefinition ShapeDefinition
upperDefinition ShapeDefinition

Return:

ShapeDefinition