BeltPath
Extends:
Stores a path of belts, used for optimizing performance
Static Method Summary
| Static Public Methods | ||
| public static |
fromSerialized(root: GameRoot, data: Object): BeltPath | string Creates a path from a serialized object |
|
| public static |
|
|
| public static |
getSchema(): {"entityPath": *, "items": *, "spacingToFirstItem": *} |
|
Constructor Summary
| Public Constructor | ||
| public |
constructor(root: GameRoot, entityPath: Array<Entity>) |
|
Member Summary
| Public Members | ||
| public |
|
|
| public |
entityPath: * |
|
| public |
Stores the items sorted, and their distance to the previous item (or start) Layout: [distanceToNext, item] |
|
| public |
How many items past the first item are compressed |
|
| public |
root: * |
|
| public |
|
|
| public |
totalLength: * |
|
| public |
Current bounds of this path |
|
Method Summary
| Public Methods | ||
| public |
Returns whether this path can accept a new item |
|
| public |
Checks if this belt path should render simplified |
|
| public |
computeAcceptingEntityAndSlot(debug_Silent: boolean=): {entity: Entity, slot: number, direction?: enumDirection} Finds the entity which accepts our items |
|
| public |
Computes the tile bounds of the path |
|
| public |
computePositionFromProgress(progress: number): Vector Computes a world space position from the given progress |
|
| public |
Computes the total length of the path |
|
| public |
debug_checkIntegrity(currentChange: string): * Checks if this path is valid |
|
| public |
debug_failIntegrity(change: string, reason: Array<any>) Helper to throw an error on mismatch |
|
| public |
deleteEntityOnEnd(entity: Entity) Deletes the last entity |
|
| public |
deleteEntityOnPathSplitIntoTwo(entity: Entity): BeltPath Splits this path at the given entity by removing it, and returning the new secondary paht |
|
| public |
deleteEntityOnStart(entity: Entity) Deletes the entity of the start of the path |
|
| public |
draw(parameters: DrawParameters) Draws the path |
|
| public |
drawDebug(parameters: DrawParameters) |
|
| public |
extendByPath(otherPath: BeltPath) Extends the path by the given other path |
|
| public |
extendOnBeginning(entity: Entity) Extends the path with the given entity on the beginning |
|
| public |
extendOnEnd(entity: Entity) Extends the belt path by the given belt |
|
| public |
findItemAtTile(tile: Vector): BaseItem | null SLOW / Tries to find the item closest to the given tile |
|
| public |
Initializes the path by computing the properties which are not saved |
|
| public |
isEndEntity(entity: Entity): boolean Returns if the given entity is the end entity of the path |
|
| public |
isStartEntity(entity: Entity): boolean Returns if the given entity is the start entity of the path |
|
| public |
Recomputes cache variables once the path was changed |
|
| public |
Called by the belt system when the surroundings changed |
|
| public |
tryAcceptItem(item: BaseItem): boolean Tries to accept the item |
|
| public |
tryHandOverItem(item: BaseItem): boolean Tries to hand over the item to the end entity |
|
| public |
update() Performs one tick |
|
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 static fromSerialized(root: GameRoot, data: Object): BeltPath | string source
Creates a path from a serialized object
public static getSchema(): {"entityPath": *, "items": *, "spacingToFirstItem": *} source
Should return the serialization schema
Override:
BasicSerializableObject#getSchemaReturn:
| {"entityPath": *, "items": *, "spacingToFirstItem": *} |
Public Constructors
Public Members
public acceptorTarget: * source
public entityPath: * source
public items: Array<[number, BaseItem]> source
Stores the items sorted, and their distance to the previous item (or start) Layout: [distanceToNext, item]
public numCompressedItemsAfterFirstItem: number source
How many items past the first item are compressed
public root: * source
public spacingToFirstItem: * source
public totalLength: * source
Public Methods
public computeAcceptingEntityAndSlot(debug_Silent: boolean=): {entity: Entity, slot: number, direction?: enumDirection} source
Finds the entity which accepts our items
Params:
| Name | Type | Attribute | Description |
| debug_Silent | boolean= | Whether debug output should be silent |
public computePositionFromProgress(progress: number): Vector source
Computes a world space position from the given progress
Params:
| Name | Type | Attribute | Description |
| progress | number |
public debug_checkIntegrity(currentChange: string): * source
Checks if this path is valid
Params:
| Name | Type | Attribute | Description |
| currentChange | string |
|
Return:
| * |
public debug_failIntegrity(change: string, reason: Array<any>) source
Helper to throw an error on mismatch
public deleteEntityOnEnd(entity: Entity) source
Deletes the last entity
Params:
| Name | Type | Attribute | Description |
| entity | Entity |
public deleteEntityOnPathSplitIntoTwo(entity: Entity): BeltPath source
Splits this path at the given entity by removing it, and returning the new secondary paht
Params:
| Name | Type | Attribute | Description |
| entity | Entity |
public deleteEntityOnStart(entity: Entity) source
Deletes the entity of the start of the path
Params:
| Name | Type | Attribute | Description |
| entity | Entity |
public draw(parameters: DrawParameters) source
Draws the path
Params:
| Name | Type | Attribute | Description |
| parameters | DrawParameters |
public drawDebug(parameters: DrawParameters) source
Params:
| Name | Type | Attribute | Description |
| parameters | DrawParameters |
public extendByPath(otherPath: BeltPath) source
Extends the path by the given other path
Params:
| Name | Type | Attribute | Description |
| otherPath | BeltPath |
public extendOnBeginning(entity: Entity) source
Extends the path with the given entity on the beginning
Params:
| Name | Type | Attribute | Description |
| entity | Entity |
public extendOnEnd(entity: Entity) source
Extends the belt path by the given belt
Params:
| Name | Type | Attribute | Description |
| entity | Entity |
public findItemAtTile(tile: Vector): BaseItem | null source
SLOW / Tries to find the item closest to the given tile
Params:
| Name | Type | Attribute | Description |
| tile | Vector |
public init(computeSpacing: boolean) source
Initializes the path by computing the properties which are not saved
Params:
| Name | Type | Attribute | Description |
| computeSpacing | boolean | Whether to also compute the spacing |
public isEndEntity(entity: Entity): boolean source
Returns if the given entity is the end entity of the path
Params:
| Name | Type | Attribute | Description |
| entity | Entity |
public isStartEntity(entity: Entity): boolean source
Returns if the given entity is the start entity of the path
Params:
| Name | Type | Attribute | Description |
| entity | Entity |
public tryAcceptItem(item: BaseItem): boolean source
Tries to accept the item
Params:
| Name | Type | Attribute | Description |
| item | BaseItem |
