import {ShapeDefinitionManager} from 'shapez.io/js/game/shape_definition_manager.js'ShapeDefinitionManager
Extends:
Constructor Summary
| Public Constructor | ||
| public |
constructor(root: GameRoot) |
|
Member Summary
| Public Members | ||
| public |
|
|
| public |
root: * |
|
| public |
Store a cache from key -> definition |
|
| public |
shapeKeyToItem: {} 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 |
getShapeItemFromDefinition(definition: ShapeDefinition): ShapeItem Returns a shape item for a given definition |
|
| public |
getShapeItemFromShortKey(hash: string): ShapeItem Returns a item instance from a given short key |
|
| public |
registerOrReturnHandle(definition: ShapeDefinition): * Checks if we already have cached this definition, and if so throws it away and returns the already cached variant |
|
| public |
registerShapeDefinition(definition: ShapeDefinition) 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 |
shapeActionPaintWith(definition: ShapeDefinition, color: enumColors): ShapeDefinition 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 |
shapeActionRotate180(definition: ShapeDefinition): ShapeDefinition Generates a definition for rotating a shape FL |
|
| public |
shapeActionRotateCCW(definition: ShapeDefinition): ShapeDefinition Generates a definition for rotating a shape counter clockwise |
|
| public |
shapeActionRotateCW(definition: ShapeDefinition): ShapeDefinition 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 |
|
|
| public |
deserialize(data: any, root: import("./savegame_serializer").GameRoot): string | void |
|
| public |
|
|
Static Public Methods
Public Constructors
public constructor(root: GameRoot) source
Fixes typeof DerivedComponent is not assignable to typeof Component, compiled out in non-dev builds
Override:
BasicSerializableObject#constructorParams:
| Name | Type | Attribute | Description |
| root | GameRoot |
Public Members
public operationCache: Object<string, Array<ShapeDefinition>|ShapeDefinition> source
public root: * source
public shapeKeyToDefinition: Object<string, ShapeDefinition> source
Store a cache from key -> definition
Public Methods
public getDefinitionFromSimpleShapes(subShapes: [enumSubShape, enumSubShape, enumSubShape, enumSubShape]): ShapeDefinition source
Params:
| Name | Type | Attribute | Description |
| subShapes | [enumSubShape, enumSubShape, enumSubShape, enumSubShape] |
public getShapeFromShortKey(hash: string): ShapeDefinition source
Returns a shape instance from a given short key
Params:
| Name | Type | Attribute | Description |
| hash | string |
public getShapeItemFromDefinition(definition: ShapeDefinition): ShapeItem source
Returns a shape item for a given definition
Params:
| Name | Type | Attribute | Description |
| definition | ShapeDefinition |
public getShapeItemFromShortKey(hash: string): ShapeItem source
Returns a item instance from a given short key
Params:
| Name | Type | Attribute | Description |
| hash | string |
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:
| Name | Type | Attribute | Description |
| definition | ShapeDefinition |
Return:
| * |
public registerShapeDefinition(definition: ShapeDefinition) source
Registers a new shape definition
Params:
| Name | Type | Attribute | Description |
| definition | ShapeDefinition |
public shapeActionCutHalf(definition: ShapeDefinition): [ShapeDefinition, ShapeDefinition] source
Generates a definition for splitting a shape definition in two halfs
Params:
| Name | Type | Attribute | Description |
| 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:
| Name | Type | Attribute | Description |
| 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:
| Name | Type | Attribute | Description |
| definition | ShapeDefinition | ||
| color | enumColors |
public shapeActionPaintWith4Colors(definition: ShapeDefinition, colors: [enumColors, enumColors, enumColors, enumColors]): ShapeDefinition source
Generates a definition for painting it with the 4 colors
Params:
| Name | Type | Attribute | Description |
| definition | ShapeDefinition | ||
| colors | [enumColors, enumColors, enumColors, enumColors] |
public shapeActionRotate180(definition: ShapeDefinition): ShapeDefinition source
Generates a definition for rotating a shape FL
Params:
| Name | Type | Attribute | Description |
| definition | ShapeDefinition |
public shapeActionRotateCCW(definition: ShapeDefinition): ShapeDefinition source
Generates a definition for rotating a shape counter clockwise
Params:
| Name | Type | Attribute | Description |
| definition | ShapeDefinition |
public shapeActionRotateCW(definition: ShapeDefinition): ShapeDefinition source
Generates a definition for rotating a shape clockwise
Params:
| Name | Type | Attribute | Description |
| definition | ShapeDefinition |
public shapeActionStack(lowerDefinition: ShapeDefinition, upperDefinition: ShapeDefinition): ShapeDefinition source
Generates a definition for stacking the upper definition onto the lower one
Params:
| Name | Type | Attribute | Description |
| lowerDefinition | ShapeDefinition | ||
| upperDefinition | ShapeDefinition |
