@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,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structure registration, queries, recipes, and idle mutations.
|
|
3
|
+
*
|
|
4
|
+
* Available as `sandkit.api.structures`.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { CellCoordinates, Vector2 } from "../../shared/player";
|
|
9
|
+
import { shared } from "../../shared";
|
|
10
|
+
// Aliased: `structures` declares a nested `processing` namespace that would
|
|
11
|
+
// otherwise shadow this import.
|
|
12
|
+
import { processing as processingApi } from "./processing";
|
|
13
|
+
|
|
14
|
+
export namespace structures {
|
|
15
|
+
|
|
16
|
+
/** Call callback for each structure of the given type. */
|
|
17
|
+
export import forEachOfType = shared.api.structures.forEachOfType;
|
|
18
|
+
/** Return the structure at a cell, or null. */
|
|
19
|
+
export import getAtCell = shared.api.structures.getAtCell;
|
|
20
|
+
/** Return the definition for a structure type. */
|
|
21
|
+
export import getDefinitionByType = shared.api.structures.getDefinitionByType;
|
|
22
|
+
/** Resolve a string structure id to its type. */
|
|
23
|
+
export import getTypeFromId = shared.api.structures.getTypeFromId;
|
|
24
|
+
/** Return true when a built structure exists at the cell. */
|
|
25
|
+
export import hasBuiltAtCell = shared.api.structures.hasBuiltAtCell;
|
|
26
|
+
/** Return true when a structure matches a string id. */
|
|
27
|
+
export import isType = shared.api.structures.isType;
|
|
28
|
+
/** Return true when the cell structure matches a string id. */
|
|
29
|
+
export import isTypeAtCell = shared.api.structures.isTypeAtCell;
|
|
30
|
+
/** Set spritesheet index on a structure instance. */
|
|
31
|
+
export import setSpritesheetIndex = shared.api.structures.setSpritesheetIndex;
|
|
32
|
+
/** Set spritesheet index on the structure at a cell. */
|
|
33
|
+
export import setSpritesheetIndexAtCell = shared.api.structures.setSpritesheetIndexAtCell;
|
|
34
|
+
/** Map a value through thresholds to a spritesheet index on a structure. */
|
|
35
|
+
export import setSpritesheetIndexByValue = shared.api.structures.setSpritesheetIndexByValue;
|
|
36
|
+
/** Map a value through thresholds to a spritesheet index at a cell. */
|
|
37
|
+
export import setSpritesheetIndexByValueAtCell = shared.api.structures.setSpritesheetIndexByValueAtCell;
|
|
38
|
+
/** Push structure state updates to the game and workers. */
|
|
39
|
+
export import update = shared.api.structures.update;
|
|
40
|
+
/** Set partial data on a structure instance. */
|
|
41
|
+
export import setData = shared.api.structures.setData;
|
|
42
|
+
/** Structure instance in the world. */
|
|
43
|
+
export import Structure = shared.api.structures.Structure;
|
|
44
|
+
/** Structure type id or enum value. */
|
|
45
|
+
export import StructureType = shared.api.structures.StructureType;
|
|
46
|
+
/** Mod or built-in structure string id. */
|
|
47
|
+
export import StructureId = shared.api.structures.StructureId;
|
|
48
|
+
/** Type handle or string id accepted by lookup helpers. */
|
|
49
|
+
export import StructureRef = shared.api.structures.StructureRef;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Register a structure processor handler.
|
|
53
|
+
* @param structureId - Structure type or string id to attach the processor to.
|
|
54
|
+
* @param definition - Periodic processing interval and callback.
|
|
55
|
+
*/
|
|
56
|
+
export function addProcessor(structureId: StructureRef, definition: StructureProcessorDefinitionV1): void;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Register a new structure definition.
|
|
60
|
+
* @param definition - Full structure definition.
|
|
61
|
+
* @param options - When `useRawShape` is true, keep the shape matrix as-is.
|
|
62
|
+
*/
|
|
63
|
+
export function register(definition: SandkitStructureDefinition, options?: { useRawShape?: boolean; }): void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Patch fields on an existing structure definition.
|
|
67
|
+
* @param structureTypeOrId - Structure type value or string id.
|
|
68
|
+
* @param partial - Fields to merge onto the definition.
|
|
69
|
+
* @param options - When `useRawShape` is true, keep the shape matrix as-is.
|
|
70
|
+
*/
|
|
71
|
+
export function updateDefinition(structureTypeOrId: StructureRef, partial: Partial<SandkitStructureDefinition>, options?: { useRawShape?: boolean; }): void;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Add a rotated variant to a base structure type.
|
|
75
|
+
* @param baseStructureTypeOrId - Base structure type or id.
|
|
76
|
+
* @param variant - Variant id and supported rotation angles.
|
|
77
|
+
* @param options - Optional build-mode wiring for the variant.
|
|
78
|
+
*/
|
|
79
|
+
export function addVariant(baseStructureTypeOrId: StructureRef, variant: { id: StructureRef; angles: number[]; }, options?: { addBuildMode?: unknown; }): void;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Register placement rules for a structure.
|
|
83
|
+
* @param definition - Hotbar placement field configuration.
|
|
84
|
+
*/
|
|
85
|
+
export function registerPlacementConfig(definition: PlacementConfigDefinition): void;
|
|
86
|
+
|
|
87
|
+
/** Return structure types unlocked for building. */
|
|
88
|
+
export function getUnlockedTypes(): Set<StructureRef>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Return true when the player blocks building at the cell.
|
|
92
|
+
* @param cellX - Grid column of the target cell.
|
|
93
|
+
* @param cellY - Grid row of the target cell.
|
|
94
|
+
*/
|
|
95
|
+
export function isBlockedByPlayerAtCell(...args: CellCoordinates): boolean;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Return true when a launcher structure is at the cell.
|
|
99
|
+
* @param cellX - Grid column of the target cell.
|
|
100
|
+
* @param cellY - Grid row of the target cell.
|
|
101
|
+
*/
|
|
102
|
+
export function isLauncherAtCell(...args: CellCoordinates): boolean;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Return true when a structure type is unlocked.
|
|
106
|
+
* @param structureType - Structure type value or string id.
|
|
107
|
+
*/
|
|
108
|
+
export function isUnlockedByType(structureType: StructureRef): boolean;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Map a numeric value through thresholds to a spritesheet index.
|
|
112
|
+
* @param value - Numeric value to map.
|
|
113
|
+
* @param thresholds - Ascending threshold values.
|
|
114
|
+
* @returns Spritesheet frame index.
|
|
115
|
+
*/
|
|
116
|
+
export function mapValueToSpritesheetIndex(value: number, thresholds: number[]): number;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Build a structure at a cell when simulation is idle.
|
|
120
|
+
* @param cellX - Grid column of the target cell.
|
|
121
|
+
* @param cellY - Grid row of the target cell.
|
|
122
|
+
* @param structureTypeOrId - Structure type or string id to build.
|
|
123
|
+
* @param options - Optional build overrides.
|
|
124
|
+
*/
|
|
125
|
+
export function buildAtCellWhenIdle(...args: [...CellCoordinates, structureTypeOrId: StructureRef, options?: StructureBuildOptions]): void;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Remove a structure at a cell when simulation is idle.
|
|
129
|
+
* @param cellX - Grid column of the target cell.
|
|
130
|
+
* @param cellY - Grid row of the target cell.
|
|
131
|
+
* @param options - Optional removal flags.
|
|
132
|
+
*/
|
|
133
|
+
export function removeAtCellWhenIdle(...args: [...CellCoordinates, options?: StructureRemovalOptions]): void;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Remove structures between two cells when simulation is idle.
|
|
137
|
+
* @param startCellX - Start cell column.
|
|
138
|
+
* @param startCellY - Start cell row.
|
|
139
|
+
* @param endCellX - End cell column.
|
|
140
|
+
* @param endCellY - End cell row.
|
|
141
|
+
* @param options - Optional bulk-removal flags.
|
|
142
|
+
*/
|
|
143
|
+
export function removeBetweenCellsWhenIdle(startCellX: number, startCellY: number, endCellX: number, endCellY: number, options?: StructureBulkRemovalOptions): void;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Remove structures at many cells when simulation is idle.
|
|
147
|
+
* @param positions - Cell positions to clear.
|
|
148
|
+
* @param options - Optional bulk-removal flags.
|
|
149
|
+
*/
|
|
150
|
+
export function removeAtCellsWhenIdle(positions: Vector2[], options?: StructureBulkRemovalOptions): void;
|
|
151
|
+
|
|
152
|
+
/** Structure recipe registration by machine kind. */
|
|
153
|
+
export namespace recipes {
|
|
154
|
+
/**
|
|
155
|
+
* Register a planter box recipe.
|
|
156
|
+
* @param id - Machine recipe slot id.
|
|
157
|
+
* @param definition - Grower recipe definition.
|
|
158
|
+
*/
|
|
159
|
+
export function register(id: 'planterBox', definition: PlanterBoxRecipeDefinitionV1): void;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Register a shaker recipe.
|
|
163
|
+
* @param id - Machine recipe slot id.
|
|
164
|
+
* @param definition - Shaker recipe definition.
|
|
165
|
+
*/
|
|
166
|
+
export function register(id: 'shaker', definition: ShakerRecipeDefinitionV1): void;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Register a kinetic press recipe.
|
|
170
|
+
* @param id - Machine recipe slot id.
|
|
171
|
+
* @param definition - Kinetic press recipe definition.
|
|
172
|
+
*/
|
|
173
|
+
export function register(id: 'kineticPress', definition: KineticPressRecipeDefinitionV1): void;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Register a weighted refinery machine recipe.
|
|
177
|
+
* @param id - Refinery machine id.
|
|
178
|
+
* @param definition - Weighted input/output recipe.
|
|
179
|
+
*/
|
|
180
|
+
export function register(id: 'condenser' | 'steamDryer' | 'synthesizer' | 'snowmaker' | 'smelter', definition: WeightedRefineryRecipeDefinitionV1): void;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Per-structure processing enablement and registration. */
|
|
184
|
+
export namespace processing {
|
|
185
|
+
/** Return true when processing is enabled at a cell. */
|
|
186
|
+
export import isEnabledAt = shared.api.structures.processing.isEnabledAt;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Register a custom processing definition by id.
|
|
190
|
+
* @param id - Unique processing registration id.
|
|
191
|
+
* @param definition - Structure type, interval, and callback.
|
|
192
|
+
*/
|
|
193
|
+
export function register(id: StructureId, definition: StructureProcessingDefinitionV1): void;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Enable or disable processing at a cell.
|
|
197
|
+
* @param cellX - Grid column of the target cell.
|
|
198
|
+
* @param cellY - Grid row of the target cell.
|
|
199
|
+
* @param enabled - Desired processing enabled state.
|
|
200
|
+
* @returns True when the enabled state changed.
|
|
201
|
+
*/
|
|
202
|
+
export function setEnabledAt(...args: [...CellCoordinates, enabled: boolean]): boolean;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Build mode entry for a structure definition. */
|
|
206
|
+
export interface StructureBuildMode {
|
|
207
|
+
type: string;
|
|
208
|
+
directions?: string[];
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Rotated variant entry for a structure definition. */
|
|
212
|
+
export interface StructureVariant {
|
|
213
|
+
id: StructureRef;
|
|
214
|
+
angles: number[];
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Render settings for a structure definition. */
|
|
218
|
+
export interface StructureRender {
|
|
219
|
+
imageName?: string;
|
|
220
|
+
size?: { width: number; height: number };
|
|
221
|
+
offset?: { x: number; y: number };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Full structure definition registered with the game. */
|
|
225
|
+
export interface SandkitStructureDefinition {
|
|
226
|
+
id: StructureId;
|
|
227
|
+
nameKey?: string;
|
|
228
|
+
descriptionKey?: string;
|
|
229
|
+
categoryKey?: string;
|
|
230
|
+
order?: number;
|
|
231
|
+
buildModes?: StructureBuildMode[];
|
|
232
|
+
shape?: number[][];
|
|
233
|
+
variants?: StructureVariant[];
|
|
234
|
+
render?: StructureRender;
|
|
235
|
+
defaultData?: Record<string, unknown>;
|
|
236
|
+
[key: string]: unknown;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** Options passed to {@link buildAtCellWhenIdle}. */
|
|
240
|
+
export interface StructureBuildOptions {
|
|
241
|
+
[key: string]: unknown;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** Options passed to {@link removeAtCellWhenIdle}. */
|
|
245
|
+
export interface StructureRemovalOptions {
|
|
246
|
+
/** Also remove underlying terrain cells in the footprint. */
|
|
247
|
+
removeCells?: boolean;
|
|
248
|
+
/** Skip visual teardown effects. */
|
|
249
|
+
skipVisuals?: boolean;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/** Options passed to bulk structure removal helpers. */
|
|
253
|
+
export interface StructureBulkRemovalOptions {
|
|
254
|
+
removeCells?: boolean;
|
|
255
|
+
skipVisuals?: boolean;
|
|
256
|
+
/** When set, only remove structures at these positions. */
|
|
257
|
+
preserveUnselectable?: boolean;
|
|
258
|
+
onlyPositions?: Vector2[];
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Periodic structure processor attached with {@link addProcessor}. */
|
|
262
|
+
export interface StructureProcessorDefinitionV1 {
|
|
263
|
+
/** Tick interval in milliseconds. Must be > 0. */
|
|
264
|
+
intervalMs: number;
|
|
265
|
+
/** Synchronous callback invoked for each structure instance. */
|
|
266
|
+
process: (state: unknown, structure: Structure) => void;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Placement hotbar field definition. */
|
|
270
|
+
export type PlacementConfigField =
|
|
271
|
+
| PlacementConfigIntegerField
|
|
272
|
+
| PlacementConfigChoiceField;
|
|
273
|
+
|
|
274
|
+
/** Integer placement field with optional bounds. */
|
|
275
|
+
export interface PlacementConfigIntegerField {
|
|
276
|
+
type: "integer";
|
|
277
|
+
id: string;
|
|
278
|
+
labelKey: string;
|
|
279
|
+
min?: number;
|
|
280
|
+
max?: number;
|
|
281
|
+
default?: number;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Choice placement field with labeled options. */
|
|
285
|
+
export interface PlacementConfigChoiceField {
|
|
286
|
+
type: "choice";
|
|
287
|
+
id: string;
|
|
288
|
+
labelKey: string;
|
|
289
|
+
options: readonly {
|
|
290
|
+
value: string;
|
|
291
|
+
labelKey: string;
|
|
292
|
+
}[];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** Placement rule definition for a structure type. */
|
|
296
|
+
export interface PlacementConfigDefinition {
|
|
297
|
+
structureId: StructureId;
|
|
298
|
+
fields: PlacementConfigField[];
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/** Planter box recipe definition shape. */
|
|
302
|
+
export type PlanterBoxRecipeDefinitionV1 = processingApi.PlanterBoxRecipeDefinitionV1;
|
|
303
|
+
/** Shaker recipe definition shape. */
|
|
304
|
+
export type ShakerRecipeDefinitionV1 = processingApi.ShakerRecipeDefinitionV1;
|
|
305
|
+
/** Kinetic press recipe definition shape. */
|
|
306
|
+
export type KineticPressRecipeDefinitionV1 = processingApi.KineticPressRecipeDefinitionV1;
|
|
307
|
+
|
|
308
|
+
/** Weighted refinery recipe definition shape. */
|
|
309
|
+
export interface WeightedRefineryRecipeDefinitionV1 {
|
|
310
|
+
input: processingApi.WeightedRecipeOutput["elementType"];
|
|
311
|
+
outputs: processingApi.WeightedRecipeOutput[];
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Custom structure processing definition shape. */
|
|
315
|
+
export interface StructureProcessingDefinitionV1 {
|
|
316
|
+
structureType: StructureRef;
|
|
317
|
+
intervalMs: number;
|
|
318
|
+
process: (state: unknown, structure: Structure) => void;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Tech as TechEnum } from "../enums/index";
|
|
2
|
+
import type { LooseString, TaggedNumber } from "../../shared/nominal";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Tech tree definitions, nodes, and lock state.
|
|
6
|
+
*
|
|
7
|
+
* Available as `sandkit.api.tech`.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
export namespace tech {
|
|
12
|
+
/**
|
|
13
|
+
* Return a tech definition by string id.
|
|
14
|
+
* @param techId - Tech entry identifier.
|
|
15
|
+
*/
|
|
16
|
+
export function getDefinitionById(techId: TechGridId): TechDefinition | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Patch fields on an existing tech definition.
|
|
19
|
+
* @param techId - Tech entry identifier.
|
|
20
|
+
* @param updates - Fields to merge into the definition.
|
|
21
|
+
*/
|
|
22
|
+
export function updateDefinition(techId: TechGridId, updates: Partial<TechDefinition>): void;
|
|
23
|
+
/**
|
|
24
|
+
* Add a new tech definition by id.
|
|
25
|
+
* @param techId - Tech entry identifier.
|
|
26
|
+
* @param definition - Full tech definition to register.
|
|
27
|
+
*/
|
|
28
|
+
export function addDefinition(techId: TechGridId, definition: TechDefinition): void;
|
|
29
|
+
/**
|
|
30
|
+
* Register a tech node on the grid with parent and position options.
|
|
31
|
+
* @param techId - Tech grid node id.
|
|
32
|
+
* @param definition - Tech definition for the node.
|
|
33
|
+
* @param options - Parent node id and optional preferred grid position.
|
|
34
|
+
*/
|
|
35
|
+
export function registerNode(techId: TechGridId, definition: TechDefinition, options: { parentId: TechGridId; preferredPosition?: TechGridPosition; }): TechGridPosition;
|
|
36
|
+
/**
|
|
37
|
+
* Return true when a tech entry is locked.
|
|
38
|
+
* @param techId - Tech entry id (string or numeric enum).
|
|
39
|
+
*/
|
|
40
|
+
export function isLockedById(techId: TechGridId): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Set locked state for a tech entry by id.
|
|
43
|
+
* @param techId - Tech entry id (string or numeric enum).
|
|
44
|
+
* @param locked - When true, the tech cannot be purchased.
|
|
45
|
+
*/
|
|
46
|
+
export function setLockedById(techId: TechGridId, locked: boolean): void;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Tech grid node id.
|
|
50
|
+
* Built-in {@link TechEnum} values autocomplete; custom string ids and tagged handles are allowed.
|
|
51
|
+
*/
|
|
52
|
+
export type TechGridId = TechEnum | LooseString<never> | TaggedNumber<"tech">;
|
|
53
|
+
/** Tech definition shape. */
|
|
54
|
+
export interface TechDefinition {
|
|
55
|
+
/** Display name translation key. */
|
|
56
|
+
nameKey?: string;
|
|
57
|
+
/** Description translation key. */
|
|
58
|
+
descriptionKey?: string;
|
|
59
|
+
[key: string]: unknown;
|
|
60
|
+
}
|
|
61
|
+
/** Position on the tech grid. */
|
|
62
|
+
export interface TechGridPosition {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terrain registration, queries, and idle cell mutations.
|
|
3
|
+
*
|
|
4
|
+
* Available as `sandkit.api.terrains`.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { CellCoordinates } from '../../shared/player';
|
|
9
|
+
import { shared } from '../../shared';
|
|
10
|
+
import type { elements } from './elements';
|
|
11
|
+
|
|
12
|
+
export namespace terrains {
|
|
13
|
+
|
|
14
|
+
/** Resolve a terrain string id to its cell type number. */
|
|
15
|
+
export import getTypeFromId = shared.api.terrains.getTypeFromId;
|
|
16
|
+
/** Return terrain cell type at a cell, or null. */
|
|
17
|
+
export import getTypeAtCell = shared.api.terrains.getTypeAtCell;
|
|
18
|
+
/** Return terrain data at a cell, or null. */
|
|
19
|
+
export import getDataAtCell = shared.api.terrains.getDataAtCell;
|
|
20
|
+
/** Return true when any terrain exists at the cell. */
|
|
21
|
+
export import isAtCell = shared.api.terrains.isAtCell;
|
|
22
|
+
/** Return true when terrain at the cell matches a string id. */
|
|
23
|
+
export import isTypeAtCell = shared.api.terrains.isTypeAtCell;
|
|
24
|
+
/** Return true when a cell id represents terrain. */
|
|
25
|
+
export import isCellIdTerrain = shared.api.terrains.isCellIdTerrain;
|
|
26
|
+
/** Apply damage to terrain at a cell. */
|
|
27
|
+
export import damageAtCell = shared.api.terrains.damageAtCell;
|
|
28
|
+
/** Create terrain at a cell immediately. */
|
|
29
|
+
export import createAtCell = shared.api.terrains.createAtCell;
|
|
30
|
+
/** Replace terrain at a cell immediately. */
|
|
31
|
+
export import replaceAtCell = shared.api.terrains.replaceAtCell;
|
|
32
|
+
/** Remove terrain at a cell immediately. */
|
|
33
|
+
export import removeAtCell = shared.api.terrains.removeAtCell;
|
|
34
|
+
/** Options for terrain create, replace, and remove calls. */
|
|
35
|
+
export import TerrainMutationOptions = shared.api.terrains.TerrainMutationOptions;
|
|
36
|
+
/** Numeric terrain cell type handle. */
|
|
37
|
+
export import TerrainType = shared.api.terrains.TerrainType;
|
|
38
|
+
/** Mod or built-in terrain string id. */
|
|
39
|
+
export import TerrainId = shared.api.terrains.TerrainId;
|
|
40
|
+
/** Type handle or string id accepted by mutation helpers. */
|
|
41
|
+
export import TerrainRef = shared.api.terrains.TerrainRef;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Register a new terrain definition.
|
|
45
|
+
* @param definition - Terrain definition to register.
|
|
46
|
+
* @returns Object with the assigned `cellType`.
|
|
47
|
+
*/
|
|
48
|
+
export function register(definition: TerrainDefinition): { cellType: TerrainType; };
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Patch fields on an existing terrain definition.
|
|
52
|
+
* @param cellTypeOrId - Numeric cell type or terrain string id.
|
|
53
|
+
* @param partial - Fields to merge onto the definition.
|
|
54
|
+
*/
|
|
55
|
+
export function updateDefinition(cellTypeOrId: TerrainRef, partial: Partial<TerrainDefinition>): void;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Create terrain at a cell when simulation is idle.
|
|
59
|
+
* @param cellX - Grid column of the target cell.
|
|
60
|
+
* @param cellY - Grid row of the target cell.
|
|
61
|
+
* @param terrainTypeOrId - Numeric cell type or terrain string id.
|
|
62
|
+
* @param options - Optional mutation flags.
|
|
63
|
+
*/
|
|
64
|
+
export function createAtCellWhenIdle(...args: [...CellCoordinates, terrainTypeOrId: TerrainRef, options?: TerrainMutationOptions]): void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Replace terrain at a cell when simulation is idle.
|
|
68
|
+
* @param cellX - Grid column of the target cell.
|
|
69
|
+
* @param cellY - Grid row of the target cell.
|
|
70
|
+
* @param terrainTypeOrId - Numeric cell type or terrain string id.
|
|
71
|
+
* @param options - Optional mutation flags.
|
|
72
|
+
*/
|
|
73
|
+
export function replaceAtCellWhenIdle(...args: [...CellCoordinates, terrainTypeOrId: TerrainRef, options?: TerrainMutationOptions]): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Remove terrain at a cell when simulation is idle.
|
|
77
|
+
* @param cellX - Grid column of the target cell.
|
|
78
|
+
* @param cellY - Grid row of the target cell.
|
|
79
|
+
* @param options - Optional mutation flags.
|
|
80
|
+
*/
|
|
81
|
+
export function removeAtCellWhenIdle(...args: [...CellCoordinates, options?: TerrainMutationOptions]): void;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Set terrain hit points at a cell when simulation is idle.
|
|
85
|
+
* @param cellX - Grid column of the target cell.
|
|
86
|
+
* @param cellY - Grid row of the target cell.
|
|
87
|
+
* @param hp - New hit point value.
|
|
88
|
+
*/
|
|
89
|
+
export function setHpAtCellWhenIdle(...args: [...CellCoordinates, hp: number]): void;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Set terrain hit points at a cell immediately.
|
|
93
|
+
* @param cellX - Grid column of the target cell.
|
|
94
|
+
* @param cellY - Grid row of the target cell.
|
|
95
|
+
* @param hp - New hit point value.
|
|
96
|
+
* @returns True when hp changed or the terrain was removed.
|
|
97
|
+
*/
|
|
98
|
+
export function setHpAtCell(...args: [...CellCoordinates, hp: number]): boolean;
|
|
99
|
+
|
|
100
|
+
/** Terrain definition shape for {@link register} and {@link updateDefinition}. */
|
|
101
|
+
export interface TerrainDefinition {
|
|
102
|
+
/** Unique mod-scoped terrain id. */
|
|
103
|
+
id: string;
|
|
104
|
+
/** i18n key for the terrain display name. */
|
|
105
|
+
nameKey?: string;
|
|
106
|
+
/** Default terrain hit points. */
|
|
107
|
+
hp?: number;
|
|
108
|
+
/** Material id used for rendering. Must be > obstacle breakpoint and < 150. */
|
|
109
|
+
materialId?: number;
|
|
110
|
+
/** UI/meta color as 0xRRGGBB. */
|
|
111
|
+
metaColor?: number;
|
|
112
|
+
/** Base terrain color as HSL components. */
|
|
113
|
+
colorHSL?: [number, number, number];
|
|
114
|
+
/** Tool item ids required to excavate this terrain. */
|
|
115
|
+
excavationRequirements?: readonly string[];
|
|
116
|
+
/** Tooltip interactions shown for this terrain. */
|
|
117
|
+
interactions?: readonly elements.Interaction[];
|
|
118
|
+
/** Default element drop when the terrain is destroyed. */
|
|
119
|
+
output?: {
|
|
120
|
+
elementType: elements.ElementType;
|
|
121
|
+
chance: number;
|
|
122
|
+
};
|
|
123
|
+
[key: string]: unknown;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Game time in milliseconds and tick counter.
|
|
3
|
+
*
|
|
4
|
+
* Available as `sandkit.api.time`.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
export namespace time {
|
|
9
|
+
/** Return elapsed game time in milliseconds. */
|
|
10
|
+
export function getTimeMs(): number;
|
|
11
|
+
/** Return the current simulation tick number. */
|
|
12
|
+
export function getTick(): number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-specific API helpers.
|
|
3
|
+
*
|
|
4
|
+
* Available as `sandkit.api.tools`.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
export namespace tools {
|
|
9
|
+
/** Grabber tool size and state. */
|
|
10
|
+
export namespace grabber {
|
|
11
|
+
/**
|
|
12
|
+
* Set grabber radius size.
|
|
13
|
+
* @param size - Grab radius in cells.
|
|
14
|
+
*/
|
|
15
|
+
export function setSize(size: number): void;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Return current grabber radius size.
|
|
19
|
+
* @returns Grab radius in cells.
|
|
20
|
+
*/
|
|
21
|
+
export function getSize(): number;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Return true when grabber tool is active.
|
|
25
|
+
* @returns True when the grabber is the active tool.
|
|
26
|
+
*/
|
|
27
|
+
export function isActive(): boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Return true when grabber holds elements.
|
|
31
|
+
* @returns True when the grabber buffer is not empty.
|
|
32
|
+
*/
|
|
33
|
+
export function isLoaded(): boolean;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interval-based main-thread trigger registration.
|
|
3
|
+
*
|
|
4
|
+
* Available as `sandkit.api.triggers`.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
export namespace triggers {
|
|
9
|
+
/**
|
|
10
|
+
* Register a repeating trigger with interval and callback.
|
|
11
|
+
* @param triggerId - Unique trigger identifier.
|
|
12
|
+
* @param definition - Interval in ticks and callback to invoke.
|
|
13
|
+
*/
|
|
14
|
+
export function register(triggerId: string, definition: MainTriggerDefinition): void;
|
|
15
|
+
|
|
16
|
+
/** Main-thread trigger definition shape. */
|
|
17
|
+
export interface MainTriggerDefinition {
|
|
18
|
+
/** Interval between callbacks in simulation ticks. */
|
|
19
|
+
interval: number;
|
|
20
|
+
/** Called each time the trigger fires. */
|
|
21
|
+
callback: () => void;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
}
|