@sandustry-modding/types 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +66 -0
- package/global.d.ts +38 -0
- package/package.json +44 -0
- package/sandkit/api/action.d.ts +28 -0
- package/sandkit/api/assets.d.ts +30 -0
- package/sandkit/api/authorization.d.ts +54 -0
- package/sandkit/api/building.d.ts +92 -0
- package/sandkit/api/camera.d.ts +23 -0
- package/sandkit/api/collector.d.ts +36 -0
- package/sandkit/api/constants.d.ts +21 -0
- package/sandkit/api/cooldown.d.ts +26 -0
- package/sandkit/api/discoveries.d.ts +18 -0
- package/sandkit/api/effects.d.ts +76 -0
- package/sandkit/api/elements.d.ts +237 -0
- package/sandkit/api/energy.d.ts +70 -0
- package/sandkit/api/events.d.ts +53 -0
- package/sandkit/api/excavation.d.ts +34 -0
- package/sandkit/api/fire.d.ts +26 -0
- package/sandkit/api/gameconfig.d.ts +15 -0
- package/sandkit/api/grid.d.ts +26 -0
- package/sandkit/api/hooks.d.ts +52 -0
- package/sandkit/api/i18n.d.ts +101 -0
- package/sandkit/api/index.d.ts +66 -0
- package/sandkit/api/input.d.ts +119 -0
- package/sandkit/api/items.d.ts +60 -0
- package/sandkit/api/lights.d.ts +66 -0
- package/sandkit/api/maps.d.ts +33 -0
- package/sandkit/api/mods.d.ts +18 -0
- package/sandkit/api/patterns.d.ts +32 -0
- package/sandkit/api/player.d.ts +84 -0
- package/sandkit/api/processing.d.ts +66 -0
- package/sandkit/api/progression.d.ts +22 -0
- package/sandkit/api/projectiles.d.ts +80 -0
- package/sandkit/api/random.d.ts +21 -0
- package/sandkit/api/raycast.d.ts +19 -0
- package/sandkit/api/reactions.d.ts +30 -0
- package/sandkit/api/rendering.d.ts +26 -0
- package/sandkit/api/resources.d.ts +23 -0
- package/sandkit/api/sandkit-api.d.ts +117 -0
- package/sandkit/api/scene.d.ts +15 -0
- package/sandkit/api/schedule.d.ts +14 -0
- package/sandkit/api/settings.d.ts +29 -0
- package/sandkit/api/shared.d.ts +27 -0
- package/sandkit/api/signals.d.ts +25 -0
- package/sandkit/api/sound.d.ts +91 -0
- package/sandkit/api/sprites.d.ts +45 -0
- package/sandkit/api/storage.d.ts +55 -0
- package/sandkit/api/structureBehaviors.d.ts +22 -0
- package/sandkit/api/structures.d.ts +320 -0
- package/sandkit/api/tech.d.ts +66 -0
- package/sandkit/api/terrains.d.ts +125 -0
- package/sandkit/api/time.d.ts +13 -0
- package/sandkit/api/tools.d.ts +35 -0
- package/sandkit/api/triggers.d.ts +24 -0
- package/sandkit/api/ui.d.ts +175 -0
- package/sandkit/api/upgrades.d.ts +63 -0
- package/sandkit/api/utils.d.ts +35 -0
- package/sandkit/api/workers.d.ts +14 -0
- package/sandkit/api/world.d.ts +107 -0
- package/sandkit/engine/api/augments.d.ts +96 -0
- package/sandkit/engine/api/auralite.d.ts +21 -0
- package/sandkit/engine/api/blueprints.d.ts +47 -0
- package/sandkit/engine/api/clipboard.d.ts +46 -0
- package/sandkit/engine/api/colorPicker.d.ts +74 -0
- package/sandkit/engine/api/coloringTool.d.ts +56 -0
- package/sandkit/engine/api/conveyors.d.ts +16 -0
- package/sandkit/engine/api/debug.d.ts +16 -0
- package/sandkit/engine/api/drones.d.ts +21 -0
- package/sandkit/engine/api/entities.d.ts +66 -0
- package/sandkit/engine/api/extensions.d.ts +16 -0
- package/sandkit/engine/api/factory.d.ts +56 -0
- package/sandkit/engine/api/foliage.d.ts +31 -0
- package/sandkit/engine/api/foundationColorPicker.d.ts +16 -0
- package/sandkit/engine/api/game.d.ts +26 -0
- package/sandkit/engine/api/heatTransfer.d.ts +46 -0
- package/sandkit/engine/api/index.d.ts +47 -0
- package/sandkit/engine/api/launchers.d.ts +16 -0
- package/sandkit/engine/api/lightColorPicker.d.ts +16 -0
- package/sandkit/engine/api/matters.d.ts +26 -0
- package/sandkit/engine/api/misc.d.ts +16 -0
- package/sandkit/engine/api/portals.d.ts +16 -0
- package/sandkit/engine/api/prefabData.d.ts +36 -0
- package/sandkit/engine/api/prefabDecor.d.ts +21 -0
- package/sandkit/engine/api/prefabulator.d.ts +21 -0
- package/sandkit/engine/api/prismaline.d.ts +26 -0
- package/sandkit/engine/api/prismite.d.ts +26 -0
- package/sandkit/engine/api/queue.d.ts +41 -0
- package/sandkit/engine/api/shadows.d.ts +26 -0
- package/sandkit/engine/api/strataform.d.ts +36 -0
- package/sandkit/engine/api/swarmConsole.d.ts +71 -0
- package/sandkit/engine/api/sweeperDrone.d.ts +16 -0
- package/sandkit/engine/api/teleportZones.d.ts +46 -0
- package/sandkit/engine/api/tutorialBuild.d.ts +66 -0
- package/sandkit/engine/api/usageTracker.d.ts +26 -0
- package/sandkit/engine/api/wall.d.ts +31 -0
- package/sandkit/engine/api/workerLocal.d.ts +30 -0
- package/sandkit/engine/index.d.ts +135 -0
- package/sandkit/engine/retro-console.d.ts +52 -0
- package/sandkit/engine/state.d.ts +31 -0
- package/sandkit/enums/index.d.ts +444 -0
- package/sandkit/index.d.ts +47 -0
- package/sandkit/react.d.ts +49 -0
- package/shared/api/effects.d.ts +76 -0
- package/shared/api/elements.d.ts +162 -0
- package/shared/api/maps.d.ts +30 -0
- package/shared/api/player.d.ts +31 -0
- package/shared/api/shared.d.ts +46 -0
- package/shared/api/structures.d.ts +138 -0
- package/shared/api/terrains.d.ts +100 -0
- package/shared/api/ui.d.ts +54 -0
- package/shared/api/world.d.ts +71 -0
- package/shared/asset.d.ts +14 -0
- package/shared/engine.d.ts +17 -0
- package/shared/index.d.ts +25 -0
- package/shared/jsonvalue.d.ts +30 -0
- package/shared/nominal.d.ts +31 -0
- package/shared/player.d.ts +173 -0
- package/worker/api/elements.d.ts +60 -0
- package/worker/api/main.d.ts +16 -0
- package/worker/api/shared.d.ts +38 -0
- package/worker/api/worker.d.ts +20 -0
- package/worker/index.d.ts +29 -0
- package/worker/sandkit-api.d.ts +31 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { CellCoordinates, Vector2 } from "../../shared/player";
|
|
2
|
+
import { shared } from "../../shared";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `sandkit.api.elements` — register elements and read or change cells when idle.
|
|
6
|
+
* Main thread only.
|
|
7
|
+
*/
|
|
8
|
+
export namespace elements {
|
|
9
|
+
|
|
10
|
+
// Shared types
|
|
11
|
+
/** Numeric id for a registered element type. */
|
|
12
|
+
export import ElementType = shared.api.elements.ElementType;
|
|
13
|
+
/** Mod or built-in element string id. */
|
|
14
|
+
export import ElementId = shared.api.elements.ElementId;
|
|
15
|
+
/** Type handle or string id accepted by lookup helpers. */
|
|
16
|
+
export import ElementRef = shared.api.elements.ElementRef;
|
|
17
|
+
/** Matter category for element physics behavior. */
|
|
18
|
+
export import MatterType = shared.api.elements.MatterType;
|
|
19
|
+
/** Full definition used to register a custom element. */
|
|
20
|
+
export import ElementDefinition = shared.api.elements.ElementDefinition;
|
|
21
|
+
/** Options for create and replace calls. */
|
|
22
|
+
export import ElementCreateOptions = shared.api.elements.ElementCreateOptions;
|
|
23
|
+
/** Options for element removal. */
|
|
24
|
+
export import ElementRemovalOptions = shared.api.elements.ElementRemovalOptions;
|
|
25
|
+
/** Resolves a string element id to its numeric type. */
|
|
26
|
+
export import getTypeFromId = shared.api.elements.getTypeFromId;
|
|
27
|
+
/** Returns the definition for an element type. */
|
|
28
|
+
export import getDefinitionByType = shared.api.elements.getDefinitionByType;
|
|
29
|
+
/** Returns the element type at a cell, or null. */
|
|
30
|
+
export import getTypeAtCell = shared.api.elements.getTypeAtCell;
|
|
31
|
+
/** Returns the resolved element type at a cell, or null. */
|
|
32
|
+
export import getResolvedTypeAtCell = shared.api.elements.getResolvedTypeAtCell;
|
|
33
|
+
/** Returns the resolved element type from a cell id, or null. */
|
|
34
|
+
export import getResolvedTypeFromCellId = shared.api.elements.getResolvedTypeFromCellId;
|
|
35
|
+
/** Returns element info at a cell, or null. */
|
|
36
|
+
export import getInfoAtCell = shared.api.elements.getInfoAtCell;
|
|
37
|
+
/** Returns the matter type at a cell, or null. */
|
|
38
|
+
export import getMatterTypeAtCell = shared.api.elements.getMatterTypeAtCell;
|
|
39
|
+
/** Returns true when the cell contains the given element type. */
|
|
40
|
+
export import isTypeAtCell = shared.api.elements.isTypeAtCell;
|
|
41
|
+
/** Returns true when the element at the cell is free-falling. */
|
|
42
|
+
export import isFreeFallingAtCell = shared.api.elements.isFreeFallingAtCell;
|
|
43
|
+
/** Returns particle velocity at a cell, or null. */
|
|
44
|
+
export import getVelocityAtCell = shared.api.elements.getVelocityAtCell;
|
|
45
|
+
/** Returns a data field value at a cell, or null. */
|
|
46
|
+
export import getDataFieldAtCell = shared.api.elements.getDataFieldAtCell;
|
|
47
|
+
|
|
48
|
+
/** Optional tooltip metadata on structure interactions. */
|
|
49
|
+
export interface InteractionStructureMetadata {
|
|
50
|
+
/** i18n key for custom interaction label text. */
|
|
51
|
+
textKey?: string;
|
|
52
|
+
/** Hide the label when a data field matches a value. */
|
|
53
|
+
crossedOutWhen?: { dataField: number; equals: number; };
|
|
54
|
+
/** Show the label only when a data field matches a value. */
|
|
55
|
+
visibleWhen?: { dataField: number; equals: number; };
|
|
56
|
+
/** Require the text key to exist in the active locale. */
|
|
57
|
+
onlyWhenTranslated?: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Interaction that destroys specific items. */
|
|
61
|
+
export type InteractionDestroyer = {
|
|
62
|
+
kind: "destroyer";
|
|
63
|
+
/** Item ids removed by this interaction (for example `"drill"`). */
|
|
64
|
+
items: readonly string[];
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/** Interaction that affects specific structures. */
|
|
68
|
+
export type InteractionStructure = InteractionStructureMetadata & {
|
|
69
|
+
kind: "structure";
|
|
70
|
+
/** Structure ids shown in the interaction tooltip. */
|
|
71
|
+
structures: readonly string[];
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** Interaction that affects specific entities. */
|
|
75
|
+
export type InteractionEntity = {
|
|
76
|
+
kind: "entity";
|
|
77
|
+
/** Entity type ids referenced by the interaction. */
|
|
78
|
+
entities: readonly string[];
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/** Interaction that marks the element as flammable. */
|
|
82
|
+
export type InteractionFlammable = { kind: "flammable" };
|
|
83
|
+
/** Interaction that marks the element as meltable. */
|
|
84
|
+
export type InteractionMeltable = { kind: "meltable" };
|
|
85
|
+
/** Interaction that marks the element as freezable. */
|
|
86
|
+
export type InteractionFreezable = { kind: "freezable" };
|
|
87
|
+
/** Interaction handled by custom mod logic and tooltip text. */
|
|
88
|
+
export type InteractionCustom = InteractionStructureMetadata & { kind: "custom" };
|
|
89
|
+
|
|
90
|
+
/** Union of element interaction kinds for tool and structure logic. */
|
|
91
|
+
export type Interaction = InteractionDestroyer
|
|
92
|
+
| InteractionStructure
|
|
93
|
+
| InteractionEntity
|
|
94
|
+
| InteractionFlammable
|
|
95
|
+
| InteractionMeltable
|
|
96
|
+
| InteractionFreezable
|
|
97
|
+
| InteractionCustom;
|
|
98
|
+
|
|
99
|
+
/** Returns all registered element type ids. */
|
|
100
|
+
export function getRegisteredTypes(): ElementType[];
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Registers a new element and returns its assigned type id.
|
|
104
|
+
* @param definition - Full element definition to register.
|
|
105
|
+
* @returns Object with the assigned `elementType`.
|
|
106
|
+
*/
|
|
107
|
+
export function register(definition: ElementDefinition): { elementType: ElementType; };
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Updates fields on an existing element definition.
|
|
111
|
+
* @param elementTypeOrId - Numeric type or string id.
|
|
112
|
+
* @param partial - Fields to merge onto the definition.
|
|
113
|
+
*/
|
|
114
|
+
export function updateDefinition(elementTypeOrId: ElementRef, partial: Partial<ElementDefinition>): void;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Adds an interaction entry to an element definition.
|
|
118
|
+
* @param elementTypeOrId - Numeric type or string id.
|
|
119
|
+
* @param interaction - Interaction entry to append.
|
|
120
|
+
*/
|
|
121
|
+
export function addInteractionInfo(elementTypeOrId: ElementRef, interaction: Interaction): void;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Returns the display name for an element type.
|
|
125
|
+
* @param elementType - Numeric element type.
|
|
126
|
+
*/
|
|
127
|
+
export function getNameByType(elementType: ElementType): string;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Finds a free cell inside a structure footprint, or null.
|
|
131
|
+
* @param structureCellX - Structure anchor cell column.
|
|
132
|
+
* @param structureCellY - Structure anchor cell row.
|
|
133
|
+
* @param structureSize - Structure footprint size in cells.
|
|
134
|
+
* @returns Cell coordinates of a free cell, or null when none.
|
|
135
|
+
*/
|
|
136
|
+
export function findFreeCellInStructure(structureCellX: number, structureCellY: number, structureSize: number): Vector2 | null;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Creates an element at a cell when the simulation is idle.
|
|
140
|
+
* @param cellX - Grid column of the target cell.
|
|
141
|
+
* @param cellY - Grid row of the target cell.
|
|
142
|
+
* @param elementType - Element type to place.
|
|
143
|
+
* @param options - Optional spawn overrides.
|
|
144
|
+
*/
|
|
145
|
+
export function createAtCellWhenIdle(...args: [...CellCoordinates, elementType: ElementType, options?: ElementCreateOptions]): void;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Replaces the element at a cell when the simulation is idle.
|
|
149
|
+
* @param cellX - Grid column of the target cell.
|
|
150
|
+
* @param cellY - Grid row of the target cell.
|
|
151
|
+
* @param elementType - Element type to place.
|
|
152
|
+
* @param options - Optional spawn overrides.
|
|
153
|
+
*/
|
|
154
|
+
export function replaceAtCellWhenIdle(...args: [...CellCoordinates, elementType: ElementType, options?: ElementCreateOptions]): void;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Removes the element at a cell when the simulation is idle.
|
|
158
|
+
* @param cellX - Grid column of the target cell.
|
|
159
|
+
* @param cellY - Grid row of the target cell.
|
|
160
|
+
* @param options - Optional removal flags.
|
|
161
|
+
*/
|
|
162
|
+
export function removeAtCellWhenIdle(...args: [...CellCoordinates, options?: ElementRemovalOptions]): void;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Moves an element between cells when the simulation is idle.
|
|
166
|
+
* @param fromCellX - Source cell column.
|
|
167
|
+
* @param fromCellY - Source cell row.
|
|
168
|
+
* @param toCellX - Destination cell column.
|
|
169
|
+
* @param toCellY - Destination cell row.
|
|
170
|
+
*/
|
|
171
|
+
export function teleportBetweenCellsWhenIdle(fromCellX: number, fromCellY: number, toCellX: number, toCellY: number): void;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sets particle velocity at a cell when the simulation is idle.
|
|
175
|
+
* @param cellX - Grid column of the target cell.
|
|
176
|
+
* @param cellY - Grid row of the target cell.
|
|
177
|
+
* @param velocity - New velocity vector.
|
|
178
|
+
*/
|
|
179
|
+
export function setVelocityAtCellWhenIdle(...args: [...CellCoordinates, velocity: Vector2]): void;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Adds velocity to a particle at a cell when the simulation is idle.
|
|
183
|
+
* @param cellX - Grid column of the target cell.
|
|
184
|
+
* @param cellY - Grid row of the target cell.
|
|
185
|
+
* @param velocity - Velocity delta to add.
|
|
186
|
+
* @param maxSpeed - Optional speed cap after the addition.
|
|
187
|
+
*/
|
|
188
|
+
export function addParticleVelocityAtCellWhenIdle(...args: [...CellCoordinates, velocity: Vector2, maxSpeed?: number]): void;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Converts a cell element to a particle when the simulation is idle.
|
|
192
|
+
* @param cellX - Grid column of the target cell.
|
|
193
|
+
* @param cellY - Grid row of the target cell.
|
|
194
|
+
* @param velocity - Initial particle velocity.
|
|
195
|
+
*/
|
|
196
|
+
export function convertToParticleAtCellWhenIdle(...args: [...CellCoordinates, velocity: Vector2]): void;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Converts a particle back to a solid element when the simulation is idle.
|
|
200
|
+
* @param cellX - Grid column of the target cell.
|
|
201
|
+
* @param cellY - Grid row of the target cell.
|
|
202
|
+
*/
|
|
203
|
+
export function convertFromParticleAtCellWhenIdle(...args: CellCoordinates): void;
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Sets a data field on the element at a cell when the simulation is idle.
|
|
207
|
+
* @param cellX - Grid column of the target cell.
|
|
208
|
+
* @param cellY - Grid row of the target cell.
|
|
209
|
+
* @param fieldNumber - Data field index (1–4).
|
|
210
|
+
* @param value - New field value.
|
|
211
|
+
*/
|
|
212
|
+
export function setDataFieldAtCellWhenIdle(...args: [...CellCoordinates, fieldNumber: 1 | 2 | 3 | 4, value: number]): void;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Refreshes the rendered color at a cell when the simulation is idle.
|
|
216
|
+
* @param cellX - Grid column of the target cell.
|
|
217
|
+
* @param cellY - Grid row of the target cell.
|
|
218
|
+
*/
|
|
219
|
+
export function refreshColorAtCellWhenIdle(...args: CellCoordinates): void;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Sets the physics skip mode at a cell when the simulation is idle.
|
|
223
|
+
* @param cellX - Grid column of the target cell.
|
|
224
|
+
* @param cellY - Grid row of the target cell.
|
|
225
|
+
* @param physicsState - Physics skip flags for the element.
|
|
226
|
+
*/
|
|
227
|
+
export function setPhysicsAtCellWhenIdle(...args: [...CellCoordinates, physicsState: number]): void;
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Sets element duration at a cell when the simulation is idle.
|
|
231
|
+
* @param cellX - Grid column of the target cell.
|
|
232
|
+
* @param cellY - Grid row of the target cell.
|
|
233
|
+
* @param duration - Duration in simulation units.
|
|
234
|
+
* @param options - When `updateMax` is true, also update max duration.
|
|
235
|
+
*/
|
|
236
|
+
export function setDurationAtCellWhenIdle(...args: [...CellCoordinates, duration: number, options?: { updateMax?: boolean; }]): void;
|
|
237
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { CellCoordinates } from "../../shared/player";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `sandkit.api.energy` — structure energy networks, storage, and consumption.
|
|
5
|
+
* Main thread only.
|
|
6
|
+
*/
|
|
7
|
+
export namespace energy {
|
|
8
|
+
/**
|
|
9
|
+
* Registers an energy type on a structure as conductor or storage.
|
|
10
|
+
* @param structureId - Structure type id string.
|
|
11
|
+
* @param type - `conductor` forwards energy; `storage` holds energy.
|
|
12
|
+
* @param options - Capacity and energy-type options for storage nodes.
|
|
13
|
+
*/
|
|
14
|
+
export function registerType(structureId: string, type: 'conductor' | 'storage', options?: EnergyRegisterTypeOptions): void;
|
|
15
|
+
/**
|
|
16
|
+
* Adds energy at a cell. Returns the amount actually added.
|
|
17
|
+
* @param cellX - Grid cell X coordinate.
|
|
18
|
+
* @param cellY - Grid cell Y coordinate.
|
|
19
|
+
* @param amount - Energy amount to add.
|
|
20
|
+
* @param options - Optional energy type and network options.
|
|
21
|
+
*/
|
|
22
|
+
export function addAtCell(...args: [...CellCoordinates, amount: number, options?: EnergyAddOptions]): number;
|
|
23
|
+
/**
|
|
24
|
+
* Consumes energy from the global pool. Returns the amount consumed.
|
|
25
|
+
* @param amount - Energy amount to consume.
|
|
26
|
+
* @param options - When `allOrNothing` is true, consume zero unless the full amount is available.
|
|
27
|
+
*/
|
|
28
|
+
export function consume(amount: number, options?: {
|
|
29
|
+
allOrNothing?: boolean;
|
|
30
|
+
}): number;
|
|
31
|
+
/**
|
|
32
|
+
* Consumes energy from networks other than the one at the cell.
|
|
33
|
+
* @param cellX - Grid cell X coordinate.
|
|
34
|
+
* @param cellY - Grid cell Y coordinate.
|
|
35
|
+
* @param amount - Energy amount to consume.
|
|
36
|
+
*/
|
|
37
|
+
export function consumeExcludingNetworkAtCell(...args: [...CellCoordinates, amount: number]): number;
|
|
38
|
+
/**
|
|
39
|
+
* Returns energy network nodes connected at the cell.
|
|
40
|
+
* @param cellX - Grid cell X coordinate.
|
|
41
|
+
* @param cellY - Grid cell Y coordinate.
|
|
42
|
+
*/
|
|
43
|
+
export function getNetworkAtCell(...args: CellCoordinates): {
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
type: string;
|
|
47
|
+
}[];
|
|
48
|
+
/**
|
|
49
|
+
* Returns free storage capacity in the network at the cell.
|
|
50
|
+
* @param cellX - Grid cell X coordinate.
|
|
51
|
+
* @param cellY - Grid cell Y coordinate.
|
|
52
|
+
*/
|
|
53
|
+
export function getNetworkFreeCapacityAtCell(...args: CellCoordinates): number;
|
|
54
|
+
|
|
55
|
+
/** Options for {@link registerType}. */
|
|
56
|
+
export interface EnergyRegisterTypeOptions {
|
|
57
|
+
/** Maximum stored energy for storage nodes. */
|
|
58
|
+
capacity?: number;
|
|
59
|
+
/** Energy type id when multiple networks exist. */
|
|
60
|
+
energyType?: string;
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Options for {@link addAtCell}. */
|
|
65
|
+
export interface EnergyAddOptions {
|
|
66
|
+
/** Energy type id when multiple networks exist. */
|
|
67
|
+
energyType?: string;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { LooseString } from "../../shared/nominal";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `sandkit.api.events` — subscribe to and emit named game events.
|
|
5
|
+
* Main thread only. The `events` object is frozen; do not replace `on` or `emit`.
|
|
6
|
+
*/
|
|
7
|
+
export namespace events {
|
|
8
|
+
/**
|
|
9
|
+
* Subscribes to an event. Returns an unsubscribe function.
|
|
10
|
+
* @param eventId - Registered event name.
|
|
11
|
+
* @param callback - Called when the event is emitted.
|
|
12
|
+
*/
|
|
13
|
+
export function on<K extends EventId>(eventId: K, callback: (payload: EventPayload<K>) => void): () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Emits an event with a payload to all subscribers.
|
|
16
|
+
* @param eventId - Registered event name.
|
|
17
|
+
* @param payload - Serializable payload passed to listeners.
|
|
18
|
+
*/
|
|
19
|
+
export function emit<K extends EventId>(eventId: K, payload: EventPayload<K>): void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Mutable payload for `player:collision:prepare`.
|
|
23
|
+
* Listeners may change `maxStepCells` (clamped 1–8) and phasing flags.
|
|
24
|
+
*/
|
|
25
|
+
export interface PlayerCollisionPreparePayload {
|
|
26
|
+
/** When true, terrain collision is skipped this sub-step. */
|
|
27
|
+
phaseThroughTerrain: boolean;
|
|
28
|
+
/** When true, structure collision is skipped this sub-step. */
|
|
29
|
+
phaseThroughStructures: boolean;
|
|
30
|
+
/** Max cells the player can step up when blocked horizontally (1–8). */
|
|
31
|
+
maxStepCells: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Known event payloads. Unlisted ids still use `unknown`. */
|
|
35
|
+
export interface EventPayloadMap {
|
|
36
|
+
"player:collision:prepare": PlayerCollisionPreparePayload;
|
|
37
|
+
"player:moved": {
|
|
38
|
+
/**
|
|
39
|
+
* Simulation step duration in seconds.
|
|
40
|
+
* `0` on teleports. The event runs after collision; landing already
|
|
41
|
+
* zeroes `velocity.y`. Vanilla gravity is applied after this event.
|
|
42
|
+
*/
|
|
43
|
+
dt?: number;
|
|
44
|
+
state?: unknown;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Known event names plus any custom string id. */
|
|
49
|
+
export type EventId = LooseString<keyof EventPayloadMap>;
|
|
50
|
+
|
|
51
|
+
/** Event payload type for a given event id. */
|
|
52
|
+
export type EventPayload<K> = K extends keyof EventPayloadMap ? EventPayloadMap[K] : unknown;
|
|
53
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sandkit.api.excavation` — register custom excavation tool dig profiles.
|
|
3
|
+
* Main thread only.
|
|
4
|
+
*/
|
|
5
|
+
export namespace excavation {
|
|
6
|
+
/**
|
|
7
|
+
* Registers an excavation profile by id.
|
|
8
|
+
* @param id - Unique profile id (1–128 chars: letters, numbers, `.`, `_`, `:`, `-`).
|
|
9
|
+
* @param definition - Pattern, power, and profile options.
|
|
10
|
+
*/
|
|
11
|
+
export function registerProfile(id: string, definition: ExcavationProfileDefinitionV1): void;
|
|
12
|
+
|
|
13
|
+
/** Excavation tool profile definition. */
|
|
14
|
+
export interface ExcavationProfileDefinitionV1 {
|
|
15
|
+
/** Dig pattern grid; non-zero cells are removed. */
|
|
16
|
+
pattern: number[][];
|
|
17
|
+
/** Dig strength applied to matched cells. Clamped to 0–1000. */
|
|
18
|
+
power: number;
|
|
19
|
+
/** Optional profile-specific excavation flags. */
|
|
20
|
+
options?: ExcavationProfileOptions;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Options attached to an excavation profile definition. */
|
|
24
|
+
export interface ExcavationProfileOptions {
|
|
25
|
+
fromGun?: boolean;
|
|
26
|
+
fromRocketExplosion?: boolean;
|
|
27
|
+
fromDrill?: boolean;
|
|
28
|
+
useLiteralOutVelocity?: boolean;
|
|
29
|
+
destroyNonDestructible?: boolean;
|
|
30
|
+
forceRemoveAll?: boolean;
|
|
31
|
+
/** Clamped to 0–1000 when set. */
|
|
32
|
+
drillTierDamage?: number;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CellCoordinates } from "../../shared/player";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `sandkit.api.fire` — ignite and burn elements at grid cells.
|
|
5
|
+
* Main thread only.
|
|
6
|
+
*/
|
|
7
|
+
export namespace fire {
|
|
8
|
+
/**
|
|
9
|
+
* Returns true when the element at the cell can burn.
|
|
10
|
+
* @param cellX - Grid cell X coordinate.
|
|
11
|
+
* @param cellY - Grid cell Y coordinate.
|
|
12
|
+
*/
|
|
13
|
+
export function canBurnElementAtCell(...args: CellCoordinates): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Queues a burn at the cell when the simulation is idle.
|
|
16
|
+
* @param cellX - Grid cell X coordinate.
|
|
17
|
+
* @param cellY - Grid cell Y coordinate.
|
|
18
|
+
*/
|
|
19
|
+
export function burnElementAtCellWhenIdle(...args: CellCoordinates): void;
|
|
20
|
+
/**
|
|
21
|
+
* Burns the element at the cell immediately. Returns true on success.
|
|
22
|
+
* @param cellX - Grid cell X coordinate.
|
|
23
|
+
* @param cellY - Grid cell Y coordinate.
|
|
24
|
+
*/
|
|
25
|
+
export function burnElementAtCell(...args: CellCoordinates): boolean;
|
|
26
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { JsonObjectV1, JsonValueV1 } from "../../shared/jsonvalue";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `sandkit.api.gameConfig` — read merged game configuration values.
|
|
5
|
+
* Main thread only.
|
|
6
|
+
*/
|
|
7
|
+
export declare namespace gameConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Returns a config value by key, or undefined when missing.
|
|
10
|
+
* @param key - Game config key (merged defaults and overrides).
|
|
11
|
+
*/
|
|
12
|
+
export function get(key: string): JsonValueV1 | undefined;
|
|
13
|
+
/** Returns the full config object. */
|
|
14
|
+
export function getAll(): JsonObjectV1;
|
|
15
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CellCoordinates } from "../../shared/player";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `sandkit.api.grid` — iterate cells in rectangular and circular regions.
|
|
5
|
+
* Main thread only.
|
|
6
|
+
*/
|
|
7
|
+
export namespace grid {
|
|
8
|
+
/**
|
|
9
|
+
* Calls the callback for each cell in a rectangle.
|
|
10
|
+
* @param cellX - Origin cell column (top-left).
|
|
11
|
+
* @param cellY - Origin cell row (top-left).
|
|
12
|
+
* @param width - Rectangle width in cells.
|
|
13
|
+
* @param height - Rectangle height in cells.
|
|
14
|
+
* @param callback - Invoked for each cell with `(cellX, cellY)`.
|
|
15
|
+
*/
|
|
16
|
+
export function forEachCellInRect(...args: [...CellCoordinates, width: number, height: number, callback: (...args: CellCoordinates) => void]): void;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Calls the callback for each cell inside a circle.
|
|
20
|
+
* @param centerCellX - Circle center cell column.
|
|
21
|
+
* @param centerCellY - Circle center cell row.
|
|
22
|
+
* @param radius - Circle radius in cells.
|
|
23
|
+
* @param callback - Invoked for each cell with `(cellX, cellY)`.
|
|
24
|
+
*/
|
|
25
|
+
export function forEachCellInCircle(centerCellX: number, centerCellY: number, radius: number, callback: (...args: CellCoordinates) => void): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `sandkit.api.hooks` — intercept and modify internal game hook points.
|
|
3
|
+
* Main thread only.
|
|
4
|
+
*/
|
|
5
|
+
export namespace hooks {
|
|
6
|
+
/**
|
|
7
|
+
* Registers an intercept hook. Returns an unsubscribe function.
|
|
8
|
+
* @param hookId - Registered hook identifier.
|
|
9
|
+
* @param callback - Called with hook arguments and context; may cancel the hook.
|
|
10
|
+
* @param options - Optional priority and filter options.
|
|
11
|
+
*/
|
|
12
|
+
export function intercept<K extends keyof InterceptHookMap>(hookId: K, callback: (args: InterceptHookMap[K], context: HookContext) => void, options?: HookOptions): () => void;
|
|
13
|
+
/**
|
|
14
|
+
* Registers a modifier hook. Returns an unsubscribe function.
|
|
15
|
+
* @param hookId - Registered hook identifier.
|
|
16
|
+
* @param callback - Called with hook arguments; may mutate hook payload.
|
|
17
|
+
* @param options - Optional priority and filter options.
|
|
18
|
+
*/
|
|
19
|
+
export function modify<K extends keyof ModifierHookMap>(hookId: K, callback: (args: ModifierHookMap[K]) => void, options?: HookOptions): () => void;
|
|
20
|
+
|
|
21
|
+
/** Map of intercept hook ids to argument shapes (not yet typed in declarations). */
|
|
22
|
+
export interface InterceptHookMap {
|
|
23
|
+
"input:boost-down": Record<string, never>;
|
|
24
|
+
"input:descend-down": Record<string, never>;
|
|
25
|
+
"input:keydown": {
|
|
26
|
+
key?: string;
|
|
27
|
+
code?: string;
|
|
28
|
+
event?: Event;
|
|
29
|
+
};
|
|
30
|
+
"input:keyup": {
|
|
31
|
+
key?: string;
|
|
32
|
+
code?: string;
|
|
33
|
+
event?: Event;
|
|
34
|
+
};
|
|
35
|
+
"input:escape": Record<string, never>;
|
|
36
|
+
"input:scroll": Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Context passed to intercept hook callbacks. */
|
|
40
|
+
export interface HookContext {
|
|
41
|
+
/** When called, the intercepted action is skipped. */
|
|
42
|
+
cancel(): void;
|
|
43
|
+
}
|
|
44
|
+
/** Map of modifier hook ids to argument shapes (not yet typed in declarations). */
|
|
45
|
+
export type ModifierHookMap = unknown
|
|
46
|
+
/** Options for hook registration. */
|
|
47
|
+
export interface HookOptions {
|
|
48
|
+
/** Run this hook before others with lower priority. */
|
|
49
|
+
priority?: number;
|
|
50
|
+
[key: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { LooseString } from "../../shared/nominal";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `sandkit.api.i18n` — translations, locales, and display strings for mods.
|
|
5
|
+
* Main thread only.
|
|
6
|
+
*/
|
|
7
|
+
export namespace i18n {
|
|
8
|
+
/**
|
|
9
|
+
* Translates a key with optional parameter substitution.
|
|
10
|
+
* @param key - Translation key.
|
|
11
|
+
* @param params - Placeholder values for the key template.
|
|
12
|
+
*/
|
|
13
|
+
export function t(key: string, params?: Record<string, string | number>): string;
|
|
14
|
+
/**
|
|
15
|
+
* Registers translation strings for a locale.
|
|
16
|
+
* @param locale - Locale code (e.g. `en`).
|
|
17
|
+
* @param translations - Map of keys to translated strings.
|
|
18
|
+
*/
|
|
19
|
+
export function register(locale: Locale, translations: Record<string, string>): void;
|
|
20
|
+
/** Returns the active locale code. */
|
|
21
|
+
export function getLocale(): Locale;
|
|
22
|
+
/**
|
|
23
|
+
* Returns true when a translation exists for the key.
|
|
24
|
+
* @param key - Translation key.
|
|
25
|
+
* @param locale - Optional locale; defaults to the active locale.
|
|
26
|
+
*/
|
|
27
|
+
export function hasTranslation(key: string, locale?: Locale): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Sets the active locale.
|
|
30
|
+
* @param locale - Locale code to activate.
|
|
31
|
+
*/
|
|
32
|
+
export function setLocale(locale: Locale): Promise<void>;
|
|
33
|
+
/** Returns metadata for all known languages. */
|
|
34
|
+
export function getLanguages(): { code: Locale; nativeName: string; englishName: string; enabled: boolean; }[];
|
|
35
|
+
/** Returns locale codes that have registered translations. */
|
|
36
|
+
export function getAvailableLocales(): Locale[];
|
|
37
|
+
/**
|
|
38
|
+
* Formats a number for the active locale.
|
|
39
|
+
* @param value - Number to format.
|
|
40
|
+
* @param options - Intl-style number format options.
|
|
41
|
+
*/
|
|
42
|
+
export function formatNumber(value: number, options?: I18nNumberFormatOptions): string;
|
|
43
|
+
/**
|
|
44
|
+
* Joins key parts into a single translation key.
|
|
45
|
+
* @param parts - Key segments joined with `.`.
|
|
46
|
+
*/
|
|
47
|
+
export function key(...parts: string[]): string;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the display name from a definition with nameKey or name.
|
|
50
|
+
* @param definition - Object with `nameKey` or `name`.
|
|
51
|
+
*/
|
|
52
|
+
export function getName(definition: { nameKey?: string; name?: string; }): string;
|
|
53
|
+
/**
|
|
54
|
+
* Returns the description from a definition with descriptionKey or description.
|
|
55
|
+
* @param definition - Object with `descriptionKey` or `description`.
|
|
56
|
+
*/
|
|
57
|
+
export function getDescription(definition: { descriptionKey?: string; description?: string; }): string;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a translatable string object with a fallback.
|
|
60
|
+
* @param key - Translation key.
|
|
61
|
+
* @param fallback - Text used when no translation is registered.
|
|
62
|
+
*/
|
|
63
|
+
export function translatable(key: string, fallback: string): { __translatable: true; key: string; fallback: string; };
|
|
64
|
+
/**
|
|
65
|
+
* Sets a global string or lazy resolver used in translations.
|
|
66
|
+
* @param key - Global helper key.
|
|
67
|
+
* @param value - Static string or function that returns the current value.
|
|
68
|
+
*/
|
|
69
|
+
export function setGlobal(key: string, value: string | (() => string)): void;
|
|
70
|
+
/**
|
|
71
|
+
* Returns a global translation helper value.
|
|
72
|
+
* @param key - Global helper key.
|
|
73
|
+
*/
|
|
74
|
+
export function getGlobal(key: string): string | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Removes a global translation helper value.
|
|
77
|
+
* @param key - Global helper key.
|
|
78
|
+
*/
|
|
79
|
+
export function clearGlobal(key: string): void;
|
|
80
|
+
/** Returns all global translation helper values. */
|
|
81
|
+
export function getGlobals(): Record<string, string>;
|
|
82
|
+
/**
|
|
83
|
+
* Formats a key code for display in UI.
|
|
84
|
+
* @param keyCode - Keyboard key code or binding name.
|
|
85
|
+
*/
|
|
86
|
+
export function formatKeyForDisplay(keyCode: string): string;
|
|
87
|
+
|
|
88
|
+
/** Locale code. `"en"` autocompletes; any locale string is allowed. */
|
|
89
|
+
export type Locale = LooseString<"en">;
|
|
90
|
+
|
|
91
|
+
/** Number format options for {@link formatNumber}. */
|
|
92
|
+
export interface I18nNumberFormatOptions {
|
|
93
|
+
/** Minimum fraction digits. */
|
|
94
|
+
minimumFractionDigits?: number;
|
|
95
|
+
/** Maximum fraction digits. */
|
|
96
|
+
maximumFractionDigits?: number;
|
|
97
|
+
/** When true, use grouping separators. */
|
|
98
|
+
useGrouping?: boolean;
|
|
99
|
+
[key: string]: unknown;
|
|
100
|
+
}
|
|
101
|
+
}
|