@sandustry-modding/types 0.1.0 → 0.3.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.
Files changed (153) hide show
  1. package/README.md +36 -12
  2. package/docs/Changelog.md +46 -0
  3. package/docs/README.md +62 -0
  4. package/package.json +11 -10
  5. package/src/sandkit/api/blueprints.d.ts +33 -0
  6. package/src/sandkit/api/effects.d.ts +127 -0
  7. package/src/sandkit/api/elements.d.ts +385 -0
  8. package/src/sandkit/api/entities.d.ts +79 -0
  9. package/src/sandkit/api/events.d.ts +137 -0
  10. package/src/sandkit/api/excavation.d.ts +58 -0
  11. package/src/sandkit/api/factory.d.ts +38 -0
  12. package/src/sandkit/api/fire.d.ts +33 -0
  13. package/src/sandkit/api/game.d.ts +22 -0
  14. package/src/sandkit/api/grid.d.ts +180 -0
  15. package/src/sandkit/api/hooks.d.ts +357 -0
  16. package/{sandkit → src/sandkit}/api/i18n.d.ts +80 -4
  17. package/{sandkit → src/sandkit}/api/index.d.ts +6 -0
  18. package/src/sandkit/api/lights.d.ts +101 -0
  19. package/{sandkit → src/sandkit}/api/maps.d.ts +15 -0
  20. package/src/sandkit/api/pickups.d.ts +89 -0
  21. package/src/sandkit/api/pipes.d.ts +54 -0
  22. package/src/sandkit/api/player.d.ts +141 -0
  23. package/{sandkit → src/sandkit}/api/rendering.d.ts +8 -0
  24. package/{sandkit → src/sandkit}/api/sandkit-api.d.ts +19 -2
  25. package/src/sandkit/api/shared.d.ts +41 -0
  26. package/{sandkit → src/sandkit}/api/sound.d.ts +32 -2
  27. package/{sandkit → src/sandkit}/api/structures.d.ts +171 -18
  28. package/{sandkit → src/sandkit}/api/tech.d.ts +54 -1
  29. package/src/sandkit/api/terrains.d.ts +147 -0
  30. package/{sandkit → src/sandkit}/api/upgrades.d.ts +9 -0
  31. package/{sandkit → src/sandkit}/api/utils.d.ts +19 -2
  32. package/src/sandkit/api/world.d.ts +105 -0
  33. package/{sandkit → src/sandkit}/enums/index.d.ts +14 -0
  34. package/{shared → src/shared}/api/elements.d.ts +84 -12
  35. package/{shared/api/world.d.ts → src/shared/api/grid.d.ts} +29 -3
  36. package/{shared → src/shared}/api/player.d.ts +12 -0
  37. package/{shared → src/shared}/api/shared.d.ts +5 -3
  38. package/{shared → src/shared}/api/structures.d.ts +46 -0
  39. package/src/shared/api/terrains.d.ts +231 -0
  40. package/src/shared/api/world.d.ts +43 -0
  41. package/{shared → src/shared}/index.d.ts +2 -0
  42. package/src/worker/api/effects.d.ts +52 -0
  43. package/src/worker/api/elements.d.ts +266 -0
  44. package/src/worker/api/events.d.ts +75 -0
  45. package/src/worker/api/fire.d.ts +29 -0
  46. package/src/worker/api/grid.d.ts +45 -0
  47. package/src/worker/api/hooks.d.ts +111 -0
  48. package/src/worker/api/lights.d.ts +43 -0
  49. package/{worker → src/worker}/api/shared.d.ts +8 -3
  50. package/{worker → src/worker}/index.d.ts +8 -5
  51. package/{worker → src/worker}/sandkit-api.d.ts +12 -3
  52. package/CHANGELOG.md +0 -19
  53. package/sandkit/api/effects.d.ts +0 -76
  54. package/sandkit/api/elements.d.ts +0 -237
  55. package/sandkit/api/events.d.ts +0 -53
  56. package/sandkit/api/excavation.d.ts +0 -34
  57. package/sandkit/api/fire.d.ts +0 -26
  58. package/sandkit/api/grid.d.ts +0 -26
  59. package/sandkit/api/hooks.d.ts +0 -52
  60. package/sandkit/api/lights.d.ts +0 -66
  61. package/sandkit/api/player.d.ts +0 -84
  62. package/sandkit/api/shared.d.ts +0 -27
  63. package/sandkit/api/terrains.d.ts +0 -125
  64. package/sandkit/api/world.d.ts +0 -107
  65. package/shared/api/terrains.d.ts +0 -100
  66. package/worker/api/elements.d.ts +0 -60
  67. /package/{global.d.ts → src/global.d.ts} +0 -0
  68. /package/{sandkit → src/sandkit}/api/action.d.ts +0 -0
  69. /package/{sandkit → src/sandkit}/api/assets.d.ts +0 -0
  70. /package/{sandkit → src/sandkit}/api/authorization.d.ts +0 -0
  71. /package/{sandkit → src/sandkit}/api/building.d.ts +0 -0
  72. /package/{sandkit → src/sandkit}/api/camera.d.ts +0 -0
  73. /package/{sandkit → src/sandkit}/api/collector.d.ts +0 -0
  74. /package/{sandkit → src/sandkit}/api/constants.d.ts +0 -0
  75. /package/{sandkit → src/sandkit}/api/cooldown.d.ts +0 -0
  76. /package/{sandkit → src/sandkit}/api/discoveries.d.ts +0 -0
  77. /package/{sandkit → src/sandkit}/api/energy.d.ts +0 -0
  78. /package/{sandkit → src/sandkit}/api/gameconfig.d.ts +0 -0
  79. /package/{sandkit → src/sandkit}/api/input.d.ts +0 -0
  80. /package/{sandkit → src/sandkit}/api/items.d.ts +0 -0
  81. /package/{sandkit → src/sandkit}/api/mods.d.ts +0 -0
  82. /package/{sandkit → src/sandkit}/api/patterns.d.ts +0 -0
  83. /package/{sandkit → src/sandkit}/api/processing.d.ts +0 -0
  84. /package/{sandkit → src/sandkit}/api/progression.d.ts +0 -0
  85. /package/{sandkit → src/sandkit}/api/projectiles.d.ts +0 -0
  86. /package/{sandkit → src/sandkit}/api/random.d.ts +0 -0
  87. /package/{sandkit → src/sandkit}/api/raycast.d.ts +0 -0
  88. /package/{sandkit → src/sandkit}/api/reactions.d.ts +0 -0
  89. /package/{sandkit → src/sandkit}/api/resources.d.ts +0 -0
  90. /package/{sandkit → src/sandkit}/api/scene.d.ts +0 -0
  91. /package/{sandkit → src/sandkit}/api/schedule.d.ts +0 -0
  92. /package/{sandkit → src/sandkit}/api/settings.d.ts +0 -0
  93. /package/{sandkit → src/sandkit}/api/signals.d.ts +0 -0
  94. /package/{sandkit → src/sandkit}/api/sprites.d.ts +0 -0
  95. /package/{sandkit → src/sandkit}/api/storage.d.ts +0 -0
  96. /package/{sandkit → src/sandkit}/api/structureBehaviors.d.ts +0 -0
  97. /package/{sandkit → src/sandkit}/api/time.d.ts +0 -0
  98. /package/{sandkit → src/sandkit}/api/tools.d.ts +0 -0
  99. /package/{sandkit → src/sandkit}/api/triggers.d.ts +0 -0
  100. /package/{sandkit → src/sandkit}/api/ui.d.ts +0 -0
  101. /package/{sandkit → src/sandkit}/api/workers.d.ts +0 -0
  102. /package/{sandkit → src/sandkit}/engine/api/augments.d.ts +0 -0
  103. /package/{sandkit → src/sandkit}/engine/api/auralite.d.ts +0 -0
  104. /package/{sandkit → src/sandkit}/engine/api/blueprints.d.ts +0 -0
  105. /package/{sandkit → src/sandkit}/engine/api/clipboard.d.ts +0 -0
  106. /package/{sandkit → src/sandkit}/engine/api/colorPicker.d.ts +0 -0
  107. /package/{sandkit → src/sandkit}/engine/api/coloringTool.d.ts +0 -0
  108. /package/{sandkit → src/sandkit}/engine/api/conveyors.d.ts +0 -0
  109. /package/{sandkit → src/sandkit}/engine/api/debug.d.ts +0 -0
  110. /package/{sandkit → src/sandkit}/engine/api/drones.d.ts +0 -0
  111. /package/{sandkit → src/sandkit}/engine/api/entities.d.ts +0 -0
  112. /package/{sandkit → src/sandkit}/engine/api/extensions.d.ts +0 -0
  113. /package/{sandkit → src/sandkit}/engine/api/factory.d.ts +0 -0
  114. /package/{sandkit → src/sandkit}/engine/api/foliage.d.ts +0 -0
  115. /package/{sandkit → src/sandkit}/engine/api/foundationColorPicker.d.ts +0 -0
  116. /package/{sandkit → src/sandkit}/engine/api/game.d.ts +0 -0
  117. /package/{sandkit → src/sandkit}/engine/api/heatTransfer.d.ts +0 -0
  118. /package/{sandkit → src/sandkit}/engine/api/index.d.ts +0 -0
  119. /package/{sandkit → src/sandkit}/engine/api/launchers.d.ts +0 -0
  120. /package/{sandkit → src/sandkit}/engine/api/lightColorPicker.d.ts +0 -0
  121. /package/{sandkit → src/sandkit}/engine/api/matters.d.ts +0 -0
  122. /package/{sandkit → src/sandkit}/engine/api/misc.d.ts +0 -0
  123. /package/{sandkit → src/sandkit}/engine/api/portals.d.ts +0 -0
  124. /package/{sandkit → src/sandkit}/engine/api/prefabData.d.ts +0 -0
  125. /package/{sandkit → src/sandkit}/engine/api/prefabDecor.d.ts +0 -0
  126. /package/{sandkit → src/sandkit}/engine/api/prefabulator.d.ts +0 -0
  127. /package/{sandkit → src/sandkit}/engine/api/prismaline.d.ts +0 -0
  128. /package/{sandkit → src/sandkit}/engine/api/prismite.d.ts +0 -0
  129. /package/{sandkit → src/sandkit}/engine/api/queue.d.ts +0 -0
  130. /package/{sandkit → src/sandkit}/engine/api/shadows.d.ts +0 -0
  131. /package/{sandkit → src/sandkit}/engine/api/strataform.d.ts +0 -0
  132. /package/{sandkit → src/sandkit}/engine/api/swarmConsole.d.ts +0 -0
  133. /package/{sandkit → src/sandkit}/engine/api/sweeperDrone.d.ts +0 -0
  134. /package/{sandkit → src/sandkit}/engine/api/teleportZones.d.ts +0 -0
  135. /package/{sandkit → src/sandkit}/engine/api/tutorialBuild.d.ts +0 -0
  136. /package/{sandkit → src/sandkit}/engine/api/usageTracker.d.ts +0 -0
  137. /package/{sandkit → src/sandkit}/engine/api/wall.d.ts +0 -0
  138. /package/{sandkit → src/sandkit}/engine/api/workerLocal.d.ts +0 -0
  139. /package/{sandkit → src/sandkit}/engine/index.d.ts +0 -0
  140. /package/{sandkit → src/sandkit}/engine/retro-console.d.ts +0 -0
  141. /package/{sandkit → src/sandkit}/engine/state.d.ts +0 -0
  142. /package/{sandkit → src/sandkit}/index.d.ts +0 -0
  143. /package/{sandkit → src/sandkit}/react.d.ts +0 -0
  144. /package/{shared → src/shared}/api/effects.d.ts +0 -0
  145. /package/{shared → src/shared}/api/maps.d.ts +0 -0
  146. /package/{shared → src/shared}/api/ui.d.ts +0 -0
  147. /package/{shared → src/shared}/asset.d.ts +0 -0
  148. /package/{shared → src/shared}/engine.d.ts +0 -0
  149. /package/{shared → src/shared}/jsonvalue.d.ts +0 -0
  150. /package/{shared → src/shared}/nominal.d.ts +0 -0
  151. /package/{shared → src/shared}/player.d.ts +0 -0
  152. /package/{worker → src/worker}/api/main.d.ts +0 -0
  153. /package/{worker → src/worker}/api/worker.d.ts +0 -0
@@ -0,0 +1,385 @@
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 on the main thread.
6
+ * Main thread only.
7
+ *
8
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements`
9
+ */
10
+ export namespace elements {
11
+
12
+ // Shared types
13
+ /**
14
+ * Numeric id for a registered element type.
15
+ *
16
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements`
17
+ */
18
+ export import ElementType = shared.api.elements.ElementType;
19
+ /**
20
+ * Mod or built-in element string id.
21
+ *
22
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements`
23
+ */
24
+ export import ElementId = shared.api.elements.ElementId;
25
+ /**
26
+ * Type handle or string id accepted by lookup helpers.
27
+ *
28
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements`
29
+ */
30
+ export import ElementRef = shared.api.elements.ElementRef;
31
+ /**
32
+ * Matter category for element physics behavior.
33
+ *
34
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements`
35
+ */
36
+ export import MatterType = shared.api.elements.MatterType;
37
+ /**
38
+ * Full definition used to register a custom element.
39
+ *
40
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements.register`
41
+ */
42
+ export import ElementDefinition = shared.api.elements.ElementDefinition;
43
+ /**
44
+ * Options for create and replace calls.
45
+ *
46
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements.createAtCell`
47
+ */
48
+ export import ElementCreateOptions = shared.api.elements.ElementCreateOptions;
49
+ /**
50
+ * Options for element removal.
51
+ *
52
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements.removeAtCell`
53
+ */
54
+ export import ElementRemovalOptions = shared.api.elements.ElementRemovalOptions;
55
+
56
+ /** Returns the mod string id for a numeric element type. */
57
+ export import getIdByType = shared.api.elements.getIdByType;
58
+ /** Resolves a string element id to its numeric type. */
59
+ export import getTypeById = shared.api.elements.getTypeById;
60
+ /**
61
+ * @deprecated Use {@link getTypeById} instead.
62
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.getTypeById`
63
+ */
64
+ export import getTypeFromId = shared.api.elements.getTypeFromId;
65
+ /** Returns the definition for an element type. */
66
+ export import getDefinitionByType = shared.api.elements.getDefinitionByType;
67
+ /** Returns the element type at a cell, or null. */
68
+ export import getTypeAtCell = shared.api.elements.getTypeAtCell;
69
+ /** Returns the resolved element type at a cell, or null. */
70
+ export import getResolvedTypeAtCell = shared.api.elements.getResolvedTypeAtCell;
71
+ /** Returns the resolved element type from a cell id, or null. */
72
+ export import getResolvedTypeFromCellId = shared.api.elements.getResolvedTypeFromCellId;
73
+ /** Returns element info at a cell, or null. */
74
+ export import getInfoAtCell = shared.api.elements.getInfoAtCell;
75
+ /** Returns the matter type at a cell, or null. */
76
+ export import getMatterTypeAtCell = shared.api.elements.getMatterTypeAtCell;
77
+ /** Returns true when the cell contains the given element type or id. */
78
+ export import isTypeAtCell = shared.api.elements.isTypeAtCell;
79
+ /** Returns true when the element at the cell is free-falling. */
80
+ export import isFreeFallingAtCell = shared.api.elements.isFreeFallingAtCell;
81
+ /** Returns particle velocity at a cell, or null. */
82
+ export import getVelocityAtCell = shared.api.elements.getVelocityAtCell;
83
+ /** Returns a data field value at a cell, or null. */
84
+ export import getDataFieldAtCell = shared.api.elements.getDataFieldAtCell;
85
+
86
+ /** Optional tooltip metadata on structure interactions. */
87
+ export interface InteractionStructureMetadata {
88
+ /** i18n key for custom interaction label text. */
89
+ textKey?: string;
90
+ /** Hide the label when a data field matches a value. */
91
+ crossedOutWhen?: { dataField: number; equals: number; };
92
+ /** Show the label only when a data field matches a value. */
93
+ visibleWhen?: { dataField: number; equals: number; };
94
+ /** Require the text key to exist in the active locale. */
95
+ onlyWhenTranslated?: boolean;
96
+ }
97
+
98
+ /** Interaction that destroys specific items. */
99
+ export type InteractionDestroyer = {
100
+ kind: "destroyer";
101
+ /** Item ids removed by this interaction (for example `"drill"`). */
102
+ items: readonly string[];
103
+ };
104
+
105
+ /** Interaction that affects specific structures. */
106
+ export type InteractionStructure = InteractionStructureMetadata & {
107
+ kind: "structure";
108
+ /** Structure ids shown in the interaction tooltip. */
109
+ structures: readonly string[];
110
+ };
111
+
112
+ /** Interaction that affects specific entities. */
113
+ export type InteractionEntity = {
114
+ kind: "entity";
115
+ /** Entity type ids referenced by the interaction. */
116
+ entities: readonly string[];
117
+ };
118
+
119
+ /** Interaction that marks the element as flammable. */
120
+ export type InteractionFlammable = { kind: "flammable" };
121
+ /** Interaction that marks the element as meltable. */
122
+ export type InteractionMeltable = { kind: "meltable" };
123
+ /** Interaction that marks the element as freezable. */
124
+ export type InteractionFreezable = { kind: "freezable" };
125
+ /** Interaction handled by custom mod logic and tooltip text. */
126
+ export type InteractionCustom = InteractionStructureMetadata & { kind: "custom" };
127
+
128
+ /** Union of element interaction kinds for tool and structure logic. */
129
+ export type Interaction = InteractionDestroyer
130
+ | InteractionStructure
131
+ | InteractionEntity
132
+ | InteractionFlammable
133
+ | InteractionMeltable
134
+ | InteractionFreezable
135
+ | InteractionCustom;
136
+
137
+ /**
138
+ * Returns all registered element type ids.
139
+ *
140
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements.getRegisteredTypes`
141
+ */
142
+ export function getRegisteredTypes(): ElementType[];
143
+
144
+ /**
145
+ * Registers a new element and returns its assigned type id.
146
+ *
147
+ * @param definition - Full element definition to register.
148
+ * @returns Object with the assigned `elementType`.
149
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements.register`
150
+ */
151
+ export function register(definition: ElementDefinition): { elementType: ElementType; };
152
+
153
+ /**
154
+ * Updates fields on an existing element definition.
155
+ *
156
+ * @param elementTypeOrId - Numeric type or string id.
157
+ * @param partial - Fields to merge onto the definition.
158
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements.updateDefinition`
159
+ */
160
+ export function updateDefinition(elementTypeOrId: ElementRef, partial: Partial<ElementDefinition>): void;
161
+
162
+ /**
163
+ * Adds an interaction entry to an element definition.
164
+ *
165
+ * @param elementTypeOrId - Numeric type or string id.
166
+ * @param interaction - Interaction entry to append.
167
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements.addInteractionInfo`
168
+ */
169
+ export function addInteractionInfo(elementTypeOrId: ElementRef, interaction: Interaction): void;
170
+
171
+ /**
172
+ * Returns the display name for an element type.
173
+ *
174
+ * @param elementType - Numeric element type.
175
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements.getNameByType`
176
+ */
177
+ export function getNameByType(elementType: ElementType): string;
178
+
179
+ /**
180
+ * Finds a free cell inside a structure footprint, or null.
181
+ *
182
+ * @param structureCellX - Structure anchor cell column.
183
+ * @param structureCellY - Structure anchor cell row.
184
+ * @param structureSizeCells - Structure footprint size in cells.
185
+ * @returns Cell coordinates of a free cell, or null when none.
186
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.elements.findFreeCellInStructure`
187
+ */
188
+ export function findFreeCellInStructure(structureCellX: number, structureCellY: number, structureSizeCells: number): Vector2 | null;
189
+
190
+ /**
191
+ * Create an element at a cell. Main-entry writes are deferred; reads see the old grid.
192
+ *
193
+ * @param cellX - Grid column of the target cell.
194
+ * @param cellY - Grid row of the target cell.
195
+ * @param elementTypeOrId - Numeric type or string id.
196
+ * @param options - Optional spawn overrides.
197
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.createAtCell`
198
+ */
199
+ export function createAtCell(...args: [...CellCoordinates, elementTypeOrId: ElementRef, options?: ElementCreateOptions]): void;
200
+
201
+ /**
202
+ * @deprecated Use {@link createAtCell} instead.
203
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.createAtCell`
204
+ */
205
+ export function createAtCellWhenIdle(...args: [...CellCoordinates, elementTypeOrId: ElementRef, options?: ElementCreateOptions]): void;
206
+
207
+ /**
208
+ * Replace the element at a cell. Main-entry writes are deferred; reads see the old grid.
209
+ *
210
+ * @param cellX - Grid column of the target cell.
211
+ * @param cellY - Grid row of the target cell.
212
+ * @param elementTypeOrId - Numeric type or string id.
213
+ * @param options - Optional spawn overrides.
214
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.replaceAtCell`
215
+ */
216
+ export function replaceAtCell(...args: [...CellCoordinates, elementTypeOrId: ElementRef, options?: ElementCreateOptions]): void;
217
+
218
+ /**
219
+ * @deprecated Use {@link replaceAtCell} instead.
220
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.replaceAtCell`
221
+ */
222
+ export function replaceAtCellWhenIdle(...args: [...CellCoordinates, elementTypeOrId: ElementRef, options?: ElementCreateOptions]): void;
223
+
224
+ /**
225
+ * Remove the element at a cell. Main-entry writes are deferred; reads see the old grid.
226
+ *
227
+ * @param cellX - Grid column of the target cell.
228
+ * @param cellY - Grid row of the target cell.
229
+ * @param options - Optional removal flags.
230
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.removeAtCell`
231
+ */
232
+ export function removeAtCell(...args: [...CellCoordinates, options?: ElementRemovalOptions]): void;
233
+
234
+ /**
235
+ * @deprecated Use {@link removeAtCell} instead.
236
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.removeAtCell`
237
+ */
238
+ export function removeAtCellWhenIdle(...args: [...CellCoordinates, options?: ElementRemovalOptions]): void;
239
+
240
+ /**
241
+ * Move an element between cells. Main-entry writes are deferred; reads see the old grid.
242
+ *
243
+ * @param fromCellX - Source cell column.
244
+ * @param fromCellY - Source cell row.
245
+ * @param toCellX - Destination cell column.
246
+ * @param toCellY - Destination cell row.
247
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.teleportBetweenCells`
248
+ */
249
+ export function teleportBetweenCells(fromCellX: number, fromCellY: number, toCellX: number, toCellY: number): void;
250
+
251
+ /**
252
+ * @deprecated Use {@link teleportBetweenCells} instead.
253
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.teleportBetweenCells`
254
+ */
255
+ export function teleportBetweenCellsWhenIdle(fromCellX: number, fromCellY: number, toCellX: number, toCellY: number): void;
256
+
257
+ /**
258
+ * Set particle velocity at a cell. Main-entry writes are deferred; reads see the old grid.
259
+ *
260
+ * @param cellX - Grid column of the target cell.
261
+ * @param cellY - Grid row of the target cell.
262
+ * @param velocity - New velocity vector.
263
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.setVelocityAtCell`
264
+ */
265
+ export function setVelocityAtCell(...args: [...CellCoordinates, velocity: Vector2]): void;
266
+
267
+ /**
268
+ * @deprecated Use {@link setVelocityAtCell} instead.
269
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.setVelocityAtCell`
270
+ */
271
+ export function setVelocityAtCellWhenIdle(...args: [...CellCoordinates, velocity: Vector2]): void;
272
+
273
+ /**
274
+ * Add velocity to a particle at a cell. Main-entry writes are deferred; reads see the old grid.
275
+ *
276
+ * @param cellX - Grid column of the target cell.
277
+ * @param cellY - Grid row of the target cell.
278
+ * @param velocity - Velocity delta to add.
279
+ * @param maxSpeedCellsPerSecond - Optional speed cap after the addition.
280
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.addParticleVelocityAtCell`
281
+ */
282
+ export function addParticleVelocityAtCell(...args: [...CellCoordinates, velocity: Vector2, maxSpeedCellsPerSecond?: number]): void;
283
+
284
+ /**
285
+ * @deprecated Use {@link addParticleVelocityAtCell} instead.
286
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.addParticleVelocityAtCell`
287
+ */
288
+ export function addParticleVelocityAtCellWhenIdle(...args: [...CellCoordinates, velocity: Vector2, maxSpeedCellsPerSecond?: number]): void;
289
+
290
+ /**
291
+ * Convert a cell element to a particle. Main-entry writes are deferred; reads see the old grid.
292
+ *
293
+ * @param cellX - Grid column of the target cell.
294
+ * @param cellY - Grid row of the target cell.
295
+ * @param velocity - Initial particle velocity.
296
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.convertToParticleAtCell`
297
+ */
298
+ export function convertToParticleAtCell(...args: [...CellCoordinates, velocity: Vector2]): void;
299
+
300
+ /**
301
+ * @deprecated Use {@link convertToParticleAtCell} instead.
302
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.convertToParticleAtCell`
303
+ */
304
+ export function convertToParticleAtCellWhenIdle(...args: [...CellCoordinates, velocity: Vector2]): void;
305
+
306
+ /**
307
+ * Convert a particle back to a solid element. Main-entry writes are deferred; reads see the old grid.
308
+ *
309
+ * @param cellX - Grid column of the target cell.
310
+ * @param cellY - Grid row of the target cell.
311
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.convertFromParticleAtCell`
312
+ */
313
+ export function convertFromParticleAtCell(...args: CellCoordinates): void;
314
+
315
+ /**
316
+ * @deprecated Use {@link convertFromParticleAtCell} instead.
317
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.convertFromParticleAtCell`
318
+ */
319
+ export function convertFromParticleAtCellWhenIdle(...args: CellCoordinates): void;
320
+
321
+ /**
322
+ * Set a data field on the element at a cell. Main-entry writes are deferred; reads see the old grid.
323
+ *
324
+ * @param cellX - Grid column of the target cell.
325
+ * @param cellY - Grid row of the target cell.
326
+ * @param fieldNumber - Data field index (1–4).
327
+ * @param value - New field value.
328
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.setDataFieldAtCell`
329
+ */
330
+ export function setDataFieldAtCell(...args: [...CellCoordinates, fieldNumber: 1 | 2 | 3 | 4, value: number]): void;
331
+
332
+ /**
333
+ * @deprecated Use {@link setDataFieldAtCell} instead.
334
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.setDataFieldAtCell`
335
+ */
336
+ export function setDataFieldAtCellWhenIdle(...args: [...CellCoordinates, fieldNumber: 1 | 2 | 3 | 4, value: number]): void;
337
+
338
+ /**
339
+ * Refresh the rendered color at a cell. Main-entry writes are deferred; reads see the old grid.
340
+ *
341
+ * @param cellX - Grid column of the target cell.
342
+ * @param cellY - Grid row of the target cell.
343
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.refreshColorAtCell`
344
+ */
345
+ export function refreshColorAtCell(...args: CellCoordinates): void;
346
+
347
+ /**
348
+ * @deprecated Use {@link refreshColorAtCell} instead.
349
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.refreshColorAtCell`
350
+ */
351
+ export function refreshColorAtCellWhenIdle(...args: CellCoordinates): void;
352
+
353
+ /**
354
+ * Set the physics skip mode at a cell. Main-entry writes are deferred; reads see the old grid.
355
+ *
356
+ * @param cellX - Grid column of the target cell.
357
+ * @param cellY - Grid row of the target cell.
358
+ * @param physicsState - Physics skip flags for the element.
359
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.setPhysicsAtCell`
360
+ */
361
+ export function setPhysicsAtCell(...args: [...CellCoordinates, physicsState: number]): void;
362
+
363
+ /**
364
+ * @deprecated Use {@link setPhysicsAtCell} instead.
365
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.setPhysicsAtCell`
366
+ */
367
+ export function setPhysicsAtCellWhenIdle(...args: [...CellCoordinates, physicsState: number]): void;
368
+
369
+ /**
370
+ * Set element duration at a cell. Main-entry writes are deferred; reads see the old grid.
371
+ *
372
+ * @param cellX - Grid column of the target cell.
373
+ * @param cellY - Grid row of the target cell.
374
+ * @param durationTicks - Duration in simulation ticks.
375
+ * @param options - When `updateMax` is true, also update max duration.
376
+ * @see https://sandustry.com/sandkit.html#mutations-heading Official Sandkit API — Main entry `api.elements.setDurationAtCell`
377
+ */
378
+ export function setDurationAtCell(...args: [...CellCoordinates, durationTicks: number, options?: { updateMax?: boolean; }]): void;
379
+
380
+ /**
381
+ * @deprecated Use {@link setDurationAtCell} instead.
382
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias of `api.elements.setDurationAtCell`
383
+ */
384
+ export function setDurationAtCellWhenIdle(...args: [...CellCoordinates, durationTicks: number, options?: { updateMax?: boolean; }]): void;
385
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Entity spawn, capture, and lifecycle helpers.
3
+ *
4
+ * Available as `sandkit.api.entities`.
5
+ *
6
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.entities`
7
+ */
8
+ export namespace entities {
9
+ /**
10
+ * Return one live entity by runtime id.
11
+ *
12
+ * @param entityId - Runtime entity id.
13
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.entities.getById`
14
+ */
15
+ export function getById(entityId: number): Entity | undefined;
16
+
17
+ /**
18
+ * Return all live entities of one type.
19
+ *
20
+ * @param entityTypeId - Registered entity type string id.
21
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.entities.getAllByType`
22
+ */
23
+ export function getAllByType(entityTypeId: string): Entity[];
24
+
25
+ /**
26
+ * Spawn an entity at world position.
27
+ *
28
+ * @param entityTypeId - Registered entity type string id.
29
+ * @param worldX - Spawn x position in world pixels.
30
+ * @param worldY - Spawn y position in world pixels.
31
+ * @returns The spawned entity instance.
32
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.entities.spawnAtWorld`
33
+ */
34
+ export function spawnAtWorld(entityTypeId: string, worldX: number, worldY: number): Entity;
35
+
36
+ /**
37
+ * Remove an entity from the world.
38
+ *
39
+ * @param entityId - Runtime entity id.
40
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.entities.remove`
41
+ */
42
+ export function remove(entityId: number): void;
43
+
44
+ /**
45
+ * Launch an entity with angle and optional speed.
46
+ *
47
+ * @param entityId - Runtime entity id.
48
+ * @param angleRadians - Launch angle in radians.
49
+ * @param speed - Optional launch speed.
50
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.entities.launch`
51
+ */
52
+ export function launch(entityId: number, angleRadians: number, speed?: number): void;
53
+
54
+ /**
55
+ * Start capture for an entity (for example vacuum capture).
56
+ *
57
+ * @param entityId - Runtime entity id.
58
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.entities.startCapture`
59
+ */
60
+ export function startCapture(entityId: number): void;
61
+
62
+ /**
63
+ * Collect an entity (for example into inventory or storage).
64
+ *
65
+ * @param entityId - Runtime entity id.
66
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.entities.collect`
67
+ */
68
+ export function collect(entityId: number): void;
69
+
70
+ /** Active entity instance in the world. */
71
+ export interface Entity {
72
+ id: number;
73
+ x: number;
74
+ y: number;
75
+ targetX?: number;
76
+ targetY?: number;
77
+ [key: string]: unknown;
78
+ }
79
+ }
@@ -0,0 +1,137 @@
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
+ *
11
+ * @param eventId - Registered event name.
12
+ * @param callback - Called when the event is emitted.
13
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.events.on`
14
+ */
15
+ export function on<K extends EventId>(eventId: K, callback: (payload: EventPayload<K>) => void): () => void;
16
+
17
+ /**
18
+ * Emits an event with a payload to all subscribers.
19
+ *
20
+ * @param eventId - Registered event name.
21
+ * @param payload - Serializable payload passed to listeners.
22
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.events.emit`
23
+ */
24
+ export function emit<K extends EventId>(eventId: K, payload: EventPayload<K>): void;
25
+
26
+ /**
27
+ * Mutable payload for `player:collision:prepare`.
28
+ * Listeners may change `maxStepCells` (clamped 1–8) and phasing flags.
29
+ */
30
+ export interface PlayerCollisionPreparePayload {
31
+ /** When true, terrain collision is skipped this sub-step. */
32
+ phaseThroughTerrain: boolean;
33
+ /** When true, structure collision is skipped this sub-step. */
34
+ phaseThroughStructures: boolean;
35
+ /** Max cells the player can step up when blocked horizontally (1–8). */
36
+ maxStepCells: number;
37
+ }
38
+
39
+ /** Known event payloads. Unlisted ids still use `unknown`. */
40
+ export interface EventPayloadMap {
41
+ "item:used": {
42
+ itemId: string;
43
+ useId: string;
44
+ kind: string;
45
+ cellX: number;
46
+ cellY: number;
47
+ prepared: Readonly<Record<string, unknown>>;
48
+ };
49
+ "frame:render": Record<string, unknown>;
50
+ "scene:game:started": Record<string, unknown>;
51
+ /** @deprecated Use `"scene:game:started"` instead. */
52
+ "scene:started:game": EventPayloadMap["scene:game:started"];
53
+ "earlyAccess:completed": Record<string, unknown>;
54
+ /** @deprecated Use `"earlyAccess:completed"` instead. */
55
+ "earlyAccess:complete": EventPayloadMap["earlyAccess:completed"];
56
+ "terrain:destroyed": {
57
+ cellX: number;
58
+ cellY: number;
59
+ cellType: number;
60
+ /** @deprecated Use {@link cellX} instead. */
61
+ x?: number;
62
+ /** @deprecated Use {@link cellY} instead. */
63
+ y?: number;
64
+ };
65
+ "fog:cellRevealed": {
66
+ cellX: number;
67
+ cellY: number;
68
+ /** @deprecated Use {@link cellX} instead. */
69
+ x?: number;
70
+ /** @deprecated Use {@link cellY} instead. */
71
+ y?: number;
72
+ };
73
+ "upgrade:levelSelected": {
74
+ itemId: string;
75
+ upgradeId: string;
76
+ level: number;
77
+ };
78
+ "building:placed": {
79
+ structure: Record<string, unknown>;
80
+ x: number;
81
+ y: number;
82
+ isBatch: boolean;
83
+ isCopied: boolean;
84
+ };
85
+ "building:removed": {
86
+ structureId: string;
87
+ x: number;
88
+ y: number;
89
+ isBatch: boolean;
90
+ };
91
+ "structures:placed": { structures: unknown[]; };
92
+ "structures:removed": {
93
+ removed: unknown[];
94
+ structures?: unknown[];
95
+ byMove: boolean;
96
+ };
97
+ "structures:moved": {
98
+ moved: unknown[];
99
+ failedToPlace: unknown[];
100
+ };
101
+ "game:ready": Record<string, unknown>;
102
+ "game:started": Record<string, unknown>;
103
+ "tutorial:stepChanged": { step: unknown; };
104
+ "tutorial:completed": { skipped: boolean; };
105
+ "tech:unlocked": {
106
+ techId: string;
107
+ suppressMusic: boolean;
108
+ };
109
+ "worldItem:pickedUp": {
110
+ worldItemId: number;
111
+ type: string;
112
+ };
113
+ "resource:collected": {
114
+ resourceId: string;
115
+ amount: number;
116
+ sourceKind: string;
117
+ cellX: number;
118
+ cellY: number;
119
+ };
120
+ "player:collision:prepare": PlayerCollisionPreparePayload;
121
+ "player:moved": {
122
+ /**
123
+ * Simulation step duration in seconds.
124
+ * `0` on teleports. The event runs after collision; landing already
125
+ * zeroes `velocity.y`. Vanilla gravity is applied after this event.
126
+ */
127
+ dt?: number;
128
+ state?: unknown;
129
+ };
130
+ }
131
+
132
+ /** Known event names plus any custom string id. */
133
+ export type EventId = LooseString<keyof EventPayloadMap>;
134
+
135
+ /** Event payload type for a given event id. */
136
+ export type EventPayload<K> = K extends keyof EventPayloadMap ? EventPayloadMap[K] : unknown;
137
+ }
@@ -0,0 +1,58 @@
1
+ import type { elements } from "../../shared/api/elements";
2
+ import type { terrains } from "../../shared/api/terrains";
3
+
4
+ /**
5
+ * `sandkit.api.excavation` — register custom excavation tool dig profiles.
6
+ * Main thread only.
7
+ *
8
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.excavation`
9
+ */
10
+ export namespace excavation {
11
+ /**
12
+ * Registers an excavation profile by id.
13
+ *
14
+ * @param id - Unique profile id (1–128 chars: letters, numbers, `.`, `_`, `:`, `-`).
15
+ * @param definition - Pattern, power, terrain rules, and profile options.
16
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — Main entry `api.excavation.registerProfile`
17
+ */
18
+ export function registerProfile(id: string, definition: ExcavationProfileDefinitionV1): void;
19
+
20
+ /** Excavation tool profile definition. */
21
+ export interface ExcavationProfileDefinitionV1 {
22
+ /** Dig pattern grid; non-zero cells are removed. */
23
+ pattern?: number[][];
24
+ /** Dig strength applied to matched cells. Clamped to 0–1000. */
25
+ power: number;
26
+ /** Optional profile-specific excavation flags. */
27
+ options?: ExcavationProfileOptions;
28
+ /** Per-terrain output and damage rules. */
29
+ terrainRules?: readonly ExcavationTerrainRule[];
30
+ }
31
+
32
+ /** Options attached to an excavation profile definition. */
33
+ export interface ExcavationProfileOptions {
34
+ fromGun?: boolean;
35
+ fromRocketExplosion?: boolean;
36
+ fromDrill?: boolean;
37
+ useLiteralOutVelocity?: boolean;
38
+ destroyNonDestructible?: boolean;
39
+ forceRemoveAll?: boolean;
40
+ /** Clamped to 0–1000 when set. */
41
+ drillTierDamage?: number;
42
+ }
43
+
44
+ /** Terrain match rule within an excavation profile. */
45
+ export interface ExcavationTerrainRule {
46
+ /** Terrain cell type to match. */
47
+ cellType: terrains.TerrainRef;
48
+ /**
49
+ * @deprecated Use {@link cellType} instead.
50
+ * @see https://sandustry.com/sandkit.html Official Sandkit API — deprecated alias in `api.excavation.registerProfile` terrain rules
51
+ */
52
+ terrainType?: terrains.TerrainRef;
53
+ /** Damage applied when this rule matches. */
54
+ damage?: number;
55
+ /** Element type produced when this terrain is excavated. */
56
+ outputElementType?: elements.ElementRef;
57
+ }
58
+ }