@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.
Files changed (124) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +66 -0
  3. package/global.d.ts +38 -0
  4. package/package.json +44 -0
  5. package/sandkit/api/action.d.ts +28 -0
  6. package/sandkit/api/assets.d.ts +30 -0
  7. package/sandkit/api/authorization.d.ts +54 -0
  8. package/sandkit/api/building.d.ts +92 -0
  9. package/sandkit/api/camera.d.ts +23 -0
  10. package/sandkit/api/collector.d.ts +36 -0
  11. package/sandkit/api/constants.d.ts +21 -0
  12. package/sandkit/api/cooldown.d.ts +26 -0
  13. package/sandkit/api/discoveries.d.ts +18 -0
  14. package/sandkit/api/effects.d.ts +76 -0
  15. package/sandkit/api/elements.d.ts +237 -0
  16. package/sandkit/api/energy.d.ts +70 -0
  17. package/sandkit/api/events.d.ts +53 -0
  18. package/sandkit/api/excavation.d.ts +34 -0
  19. package/sandkit/api/fire.d.ts +26 -0
  20. package/sandkit/api/gameconfig.d.ts +15 -0
  21. package/sandkit/api/grid.d.ts +26 -0
  22. package/sandkit/api/hooks.d.ts +52 -0
  23. package/sandkit/api/i18n.d.ts +101 -0
  24. package/sandkit/api/index.d.ts +66 -0
  25. package/sandkit/api/input.d.ts +119 -0
  26. package/sandkit/api/items.d.ts +60 -0
  27. package/sandkit/api/lights.d.ts +66 -0
  28. package/sandkit/api/maps.d.ts +33 -0
  29. package/sandkit/api/mods.d.ts +18 -0
  30. package/sandkit/api/patterns.d.ts +32 -0
  31. package/sandkit/api/player.d.ts +84 -0
  32. package/sandkit/api/processing.d.ts +66 -0
  33. package/sandkit/api/progression.d.ts +22 -0
  34. package/sandkit/api/projectiles.d.ts +80 -0
  35. package/sandkit/api/random.d.ts +21 -0
  36. package/sandkit/api/raycast.d.ts +19 -0
  37. package/sandkit/api/reactions.d.ts +30 -0
  38. package/sandkit/api/rendering.d.ts +26 -0
  39. package/sandkit/api/resources.d.ts +23 -0
  40. package/sandkit/api/sandkit-api.d.ts +117 -0
  41. package/sandkit/api/scene.d.ts +15 -0
  42. package/sandkit/api/schedule.d.ts +14 -0
  43. package/sandkit/api/settings.d.ts +29 -0
  44. package/sandkit/api/shared.d.ts +27 -0
  45. package/sandkit/api/signals.d.ts +25 -0
  46. package/sandkit/api/sound.d.ts +91 -0
  47. package/sandkit/api/sprites.d.ts +45 -0
  48. package/sandkit/api/storage.d.ts +55 -0
  49. package/sandkit/api/structureBehaviors.d.ts +22 -0
  50. package/sandkit/api/structures.d.ts +320 -0
  51. package/sandkit/api/tech.d.ts +66 -0
  52. package/sandkit/api/terrains.d.ts +125 -0
  53. package/sandkit/api/time.d.ts +13 -0
  54. package/sandkit/api/tools.d.ts +35 -0
  55. package/sandkit/api/triggers.d.ts +24 -0
  56. package/sandkit/api/ui.d.ts +175 -0
  57. package/sandkit/api/upgrades.d.ts +63 -0
  58. package/sandkit/api/utils.d.ts +35 -0
  59. package/sandkit/api/workers.d.ts +14 -0
  60. package/sandkit/api/world.d.ts +107 -0
  61. package/sandkit/engine/api/augments.d.ts +96 -0
  62. package/sandkit/engine/api/auralite.d.ts +21 -0
  63. package/sandkit/engine/api/blueprints.d.ts +47 -0
  64. package/sandkit/engine/api/clipboard.d.ts +46 -0
  65. package/sandkit/engine/api/colorPicker.d.ts +74 -0
  66. package/sandkit/engine/api/coloringTool.d.ts +56 -0
  67. package/sandkit/engine/api/conveyors.d.ts +16 -0
  68. package/sandkit/engine/api/debug.d.ts +16 -0
  69. package/sandkit/engine/api/drones.d.ts +21 -0
  70. package/sandkit/engine/api/entities.d.ts +66 -0
  71. package/sandkit/engine/api/extensions.d.ts +16 -0
  72. package/sandkit/engine/api/factory.d.ts +56 -0
  73. package/sandkit/engine/api/foliage.d.ts +31 -0
  74. package/sandkit/engine/api/foundationColorPicker.d.ts +16 -0
  75. package/sandkit/engine/api/game.d.ts +26 -0
  76. package/sandkit/engine/api/heatTransfer.d.ts +46 -0
  77. package/sandkit/engine/api/index.d.ts +47 -0
  78. package/sandkit/engine/api/launchers.d.ts +16 -0
  79. package/sandkit/engine/api/lightColorPicker.d.ts +16 -0
  80. package/sandkit/engine/api/matters.d.ts +26 -0
  81. package/sandkit/engine/api/misc.d.ts +16 -0
  82. package/sandkit/engine/api/portals.d.ts +16 -0
  83. package/sandkit/engine/api/prefabData.d.ts +36 -0
  84. package/sandkit/engine/api/prefabDecor.d.ts +21 -0
  85. package/sandkit/engine/api/prefabulator.d.ts +21 -0
  86. package/sandkit/engine/api/prismaline.d.ts +26 -0
  87. package/sandkit/engine/api/prismite.d.ts +26 -0
  88. package/sandkit/engine/api/queue.d.ts +41 -0
  89. package/sandkit/engine/api/shadows.d.ts +26 -0
  90. package/sandkit/engine/api/strataform.d.ts +36 -0
  91. package/sandkit/engine/api/swarmConsole.d.ts +71 -0
  92. package/sandkit/engine/api/sweeperDrone.d.ts +16 -0
  93. package/sandkit/engine/api/teleportZones.d.ts +46 -0
  94. package/sandkit/engine/api/tutorialBuild.d.ts +66 -0
  95. package/sandkit/engine/api/usageTracker.d.ts +26 -0
  96. package/sandkit/engine/api/wall.d.ts +31 -0
  97. package/sandkit/engine/api/workerLocal.d.ts +30 -0
  98. package/sandkit/engine/index.d.ts +135 -0
  99. package/sandkit/engine/retro-console.d.ts +52 -0
  100. package/sandkit/engine/state.d.ts +31 -0
  101. package/sandkit/enums/index.d.ts +444 -0
  102. package/sandkit/index.d.ts +47 -0
  103. package/sandkit/react.d.ts +49 -0
  104. package/shared/api/effects.d.ts +76 -0
  105. package/shared/api/elements.d.ts +162 -0
  106. package/shared/api/maps.d.ts +30 -0
  107. package/shared/api/player.d.ts +31 -0
  108. package/shared/api/shared.d.ts +46 -0
  109. package/shared/api/structures.d.ts +138 -0
  110. package/shared/api/terrains.d.ts +100 -0
  111. package/shared/api/ui.d.ts +54 -0
  112. package/shared/api/world.d.ts +71 -0
  113. package/shared/asset.d.ts +14 -0
  114. package/shared/engine.d.ts +17 -0
  115. package/shared/index.d.ts +25 -0
  116. package/shared/jsonvalue.d.ts +30 -0
  117. package/shared/nominal.d.ts +31 -0
  118. package/shared/player.d.ts +173 -0
  119. package/worker/api/elements.d.ts +60 -0
  120. package/worker/api/main.d.ts +16 -0
  121. package/worker/api/shared.d.ts +38 -0
  122. package/worker/api/worker.d.ts +20 -0
  123. package/worker/index.d.ts +29 -0
  124. package/worker/sandkit-api.d.ts +31 -0
@@ -0,0 +1,162 @@
1
+ import type { ElementType as ElementTypeEnum } from "../../sandkit/enums/index";
2
+ import type { CellCoordinates, Vector2 } from "../../shared/player";
3
+ import type { CellId, LooseString, TaggedNumber } from "../nominal";
4
+
5
+ /**
6
+ * Shared `sandkit.api.elements` base — element reads and definitions.
7
+ *
8
+ * Workers add direct mutation helpers on top of this shape. Main thread adds
9
+ * idle-scheduled mutations and registration APIs.
10
+ *
11
+ * @internal Base namespace reused by main and worker declarations.
12
+ */
13
+ export namespace elements {
14
+ /**
15
+ * Numeric element type handle.
16
+ * Built-in {@link ElementTypeEnum} values autocomplete; `getTypeFromId` returns a tagged handle.
17
+ */
18
+ export type ElementType = ElementTypeEnum | TaggedNumber<"elementType">;
19
+
20
+ /** Mod or built-in element string id. */
21
+ export type ElementId = LooseString<never>;
22
+ /** Type handle or string id accepted by lookup helpers. */
23
+ export type ElementRef = ElementType | ElementId;
24
+
25
+ /** Physical behaviour category for an element. */
26
+ export enum MatterType {
27
+ Solid = 1,
28
+ Liquid = 2,
29
+ Particle = 3,
30
+ Gas = 4,
31
+ Static = 5,
32
+ Slushy = 6,
33
+ Wisp = 7,
34
+ Powder = 8,
35
+ }
36
+
37
+ /** Mod-registered element definition snapshot. */
38
+ export type ElementDefinition = {
39
+ id: string,
40
+ nameKey: string,
41
+ defaultDataFields?: { [key: string]: number },
42
+ colors: {
43
+ variantFromDataField1?: {
44
+ rangeMin?: number,
45
+ rangeMax?: number,
46
+ invert?: boolean,
47
+ useGradient?: boolean,
48
+ },
49
+ variants: [number, number, number][],
50
+ },
51
+ density: number,
52
+ matterType: MatterType,
53
+ getExtraProps?: () => { data: Record<PropertyKey, any> }
54
+ };
55
+
56
+ /** Options for {@link createAtCell}, replace, and idle create helpers. */
57
+ export interface ElementCreateOptions {
58
+ /** Initial element data bag. */
59
+ data?: Record<string, unknown>;
60
+ /** Override element density. */
61
+ density?: number;
62
+ /** Set both max and remaining duration. */
63
+ duration?: number;
64
+ /** Override free-fall state on spawn. */
65
+ isFreeFalling?: boolean;
66
+ /** Override default data fields 1–4. */
67
+ dataFields?: {
68
+ field1?: number;
69
+ field2?: number;
70
+ field3?: number;
71
+ field4?: number;
72
+ };
73
+ /** Spawn as a particle with the given velocity. */
74
+ particle?: {
75
+ velocity: Vector2;
76
+ };
77
+ /** Skip collector accounting when placing the element. */
78
+ skipCollectorCheck?: boolean;
79
+ }
80
+
81
+ /** Options for element removal helpers. */
82
+ export interface ElementRemovalOptions {
83
+ /** Skip collector accounting when removing the element. */
84
+ skipCollectorCheck?: boolean;
85
+ }
86
+
87
+ /**
88
+ * Resolve a mod element string id to a type handle.
89
+ * @param elementId - Mod-registered element id.
90
+ */
91
+ export function getTypeFromId(elementId: ElementId): ElementType;
92
+
93
+ /**
94
+ * Look up the definition for a type handle.
95
+ * @param elementType - Numeric element type.
96
+ */
97
+ export function getDefinitionByType(elementType: ElementType): ElementDefinition | undefined;
98
+
99
+ /**
100
+ * Return the raw element type at a cell (may differ from resolved type).
101
+ * @param cellX - Grid column of the target cell.
102
+ * @param cellY - Grid row of the target cell.
103
+ */
104
+ export function getTypeAtCell(...args: CellCoordinates): ElementType | null;
105
+
106
+ /**
107
+ * Return the resolved element type after overlays and particles.
108
+ * @param cellX - Grid column of the target cell.
109
+ * @param cellY - Grid row of the target cell.
110
+ */
111
+ export function getResolvedTypeAtCell(...args: CellCoordinates): ElementType | null;
112
+
113
+ /**
114
+ * Return the resolved element type from a packed cell id.
115
+ * @param cellId - Packed cell id from {@link world.getCellIdAtCell}.
116
+ */
117
+ export function getResolvedTypeFromCellId(cellId: CellId): ElementType | null;
118
+
119
+ /**
120
+ * Return element index, particle flag, and ids at a cell.
121
+ * @param cellX - Grid column of the target cell.
122
+ * @param cellY - Grid row of the target cell.
123
+ */
124
+ export function getInfoAtCell(...args: CellCoordinates): { elementType: ElementType; isParticle: boolean; cellId: CellId; elementIndex: number; } | null;
125
+
126
+ /**
127
+ * Return the matter category at a cell, or null when empty.
128
+ * @param cellX - Grid column of the target cell.
129
+ * @param cellY - Grid row of the target cell.
130
+ */
131
+ export function getMatterTypeAtCell(...args: CellCoordinates): MatterType | null;
132
+
133
+ /**
134
+ * Return true when the cell holds the given element type.
135
+ * @param cellX - Grid column of the target cell.
136
+ * @param cellY - Grid row of the target cell.
137
+ * @param elementType - Element type to compare.
138
+ */
139
+ export function isTypeAtCell(...args: [...CellCoordinates, elementType: ElementType]): boolean;
140
+
141
+ /**
142
+ * Return true when the element at the cell is falling.
143
+ * @param cellX - Grid column of the target cell.
144
+ * @param cellY - Grid row of the target cell.
145
+ */
146
+ export function isFreeFallingAtCell(...args: CellCoordinates): boolean;
147
+
148
+ /**
149
+ * Return per-cell velocity for moving elements.
150
+ * @param cellX - Grid column of the target cell.
151
+ * @param cellY - Grid row of the target cell.
152
+ */
153
+ export function getVelocityAtCell(...args: CellCoordinates): { x: number; y: number; } | null;
154
+
155
+ /**
156
+ * Read element data field 1–4 at a cell.
157
+ * @param cellX - Grid column of the target cell.
158
+ * @param cellY - Grid row of the target cell.
159
+ * @param fieldNumber - Data field index (1–4).
160
+ */
161
+ export function getDataFieldAtCell(...args: [...CellCoordinates, fieldNumber: 1 | 2 | 3 | 4]): number | null;
162
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Shared `sandkit.api.maps` base — active custom map metadata.
3
+ *
4
+ * @internal Base namespace reused by main and worker declarations.
5
+ */
6
+ export namespace maps {
7
+ /**
8
+ * Return the currently loaded custom map definition.
9
+ * @returns Active map metadata, or `null` outside custom maps.
10
+ */
11
+ export function getActive(): Readonly<ActiveMapV1> | null;
12
+
13
+ /**
14
+ * Active custom map record (version 1 schema).
15
+ *
16
+ * Shape varies by map. Known fields are optional; additional keys may exist.
17
+ */
18
+ export interface ActiveMapV1 {
19
+ id?: string;
20
+ deployment?: unknown;
21
+ spawn?: unknown;
22
+ topBounds?: {
23
+ soft?: number;
24
+ hard?: number;
25
+ };
26
+ parallax?: unknown;
27
+ depthLight?: unknown;
28
+ [key: string]: unknown;
29
+ }
30
+ }
@@ -0,0 +1,31 @@
1
+ import type { CellCoordinates, Vector2 } from "../../shared/player";
2
+
3
+ /**
4
+ * Shared `sandkit.api.player` base — player position and collision queries.
5
+ *
6
+ * @internal Base namespace reused by main and worker declarations.
7
+ */
8
+ export namespace player {
9
+ /**
10
+ * Return the player center position in world pixels.
11
+ * @returns World position as `{ x, y }` in pixels.
12
+ */
13
+ export function getWorldPosition(): Vector2;
14
+
15
+ /**
16
+ * Return true when the player hitbox overlaps the cell.
17
+ * @param cellX - Grid column of the cell.
18
+ * @param cellY - Grid row of the cell.
19
+ * @returns True when the player overlaps the cell.
20
+ */
21
+ export function isCollidingWithCell(...args: CellCoordinates): boolean;
22
+
23
+ /**
24
+ * Return true when the player is within `radius` cells of the point.
25
+ * @param cellX - Grid column of the reference cell.
26
+ * @param cellY - Grid row of the reference cell.
27
+ * @param radius - Maximum distance in cells (inclusive).
28
+ * @returns True when the player is inside the radius.
29
+ */
30
+ export function isWithinRadiusOfCell(...args: [...CellCoordinates, radius: number]): boolean;
31
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Shared `sandkit.api.shared` base — cross-thread shared memory buffers.
3
+ *
4
+ * Main thread uses {@link shared.buffers.get} and `create`. Workers extend this
5
+ * with `require` in worker `sandkit.api.shared`.
6
+ *
7
+ * @internal Base namespace reused by main and worker declarations.
8
+ */
9
+ export namespace shared {
10
+ /** Named shared memory buffers (`create` / `get` on main; `require` on workers). */
11
+ export namespace buffers {
12
+ /**
13
+ * Look up a named shared buffer without creating it.
14
+ * @param key - Buffer name shared across threads.
15
+ * @returns The typed array, or `undefined` when the buffer does not exist.
16
+ */
17
+ export function get(key: string): SharedArray | undefined;
18
+ }
19
+
20
+ /**
21
+ * Typed array backing a shared buffer.
22
+ *
23
+ * Use {@link SharedArrayType} when creating or requiring a buffer. The runtime
24
+ * returns the matching `*Array` constructor for the configured type.
25
+ */
26
+ export type SharedArray =
27
+ | Uint8Array
28
+ | Uint16Array
29
+ | Uint32Array
30
+ | Int8Array
31
+ | Int16Array
32
+ | Int32Array
33
+ | Float32Array
34
+ | Float64Array;
35
+
36
+ /** Discriminator for the underlying typed array kind. */
37
+ export type SharedArrayType =
38
+ | "uint8"
39
+ | "uint16"
40
+ | "uint32"
41
+ | "int8"
42
+ | "int16"
43
+ | "int32"
44
+ | "float32"
45
+ | "float64";
46
+ }
@@ -0,0 +1,138 @@
1
+ import type { CellCoordinates } from "../../shared/player";
2
+ import type { LooseString, TaggedNumber } from "../nominal";
3
+ import type { StructureType as StructureTypeEnum } from "../../sandkit/enums/index";
4
+
5
+ /**
6
+ * Shared `sandkit.api.structures` base — structure lookup and mutation.
7
+ *
8
+ * @internal Base namespace reused by main and worker declarations.
9
+ */
10
+ export namespace structures {
11
+ /**
12
+ * Invoke a callback for every structure of the given type.
13
+ * @param structureTypeOrId - Structure type value or string id.
14
+ * @param callback - Called once per matching structure instance.
15
+ */
16
+ export function forEachOfType(structureTypeOrId: StructureRef, callback: (structure: Structure) => void): void;
17
+
18
+ /**
19
+ * Return the structure at a cell, or null when none.
20
+ * @param cellX - Grid column of the target cell.
21
+ * @param cellY - Grid row of the target cell.
22
+ */
23
+ export function getAtCell(...args: CellCoordinates): Structure | null;
24
+
25
+ /**
26
+ * Return the mod-registered or built-in definition for a structure type.
27
+ * @param structureType - Structure type value or string id.
28
+ */
29
+ export function getDefinitionByType(structureType: StructureRef): any;
30
+
31
+ /**
32
+ * Map a structure string id to its runtime type value.
33
+ * @param structureId - Structure string id.
34
+ */
35
+ export function getTypeFromId(structureId: StructureId): StructureType;
36
+
37
+ /**
38
+ * Return true when a completed structure occupies the cell.
39
+ * @param cellX - Grid column of the target cell.
40
+ * @param cellY - Grid row of the target cell.
41
+ */
42
+ export function hasBuiltAtCell(...args: CellCoordinates): boolean;
43
+
44
+ /**
45
+ * Return true when the structure matches the given id.
46
+ * @param structure - Structure instance, or null.
47
+ * @param structureId - Structure string id to compare.
48
+ */
49
+ export function isType(structure: Structure | null, structureId: StructureId): boolean;
50
+
51
+ /**
52
+ * Return true when the cell structure matches the given id.
53
+ * @param cellX - Grid column of the target cell.
54
+ * @param cellY - Grid row of the target cell.
55
+ * @param structureId - Structure string id to compare.
56
+ */
57
+ export function isTypeAtCell(...args: [...CellCoordinates, structureId: StructureId]): boolean;
58
+
59
+ /**
60
+ * Set the spritesheet frame index on a structure instance.
61
+ * @param structure - Target structure instance.
62
+ * @param index - Spritesheet frame index.
63
+ */
64
+ export function setSpritesheetIndex(structure: Structure, index: number): void;
65
+
66
+ /**
67
+ * Set spritesheet frame index for the structure at a cell.
68
+ * @param cellX - Grid column of the target cell.
69
+ * @param cellY - Grid row of the target cell.
70
+ * @param index - Spritesheet frame index.
71
+ */
72
+ export function setSpritesheetIndexAtCell(...args: [...CellCoordinates, index: number]): void;
73
+
74
+ /**
75
+ * Pick spritesheet index from a value and threshold table on a structure.
76
+ * @param structure - Target structure instance.
77
+ * @param value - Numeric value mapped through thresholds.
78
+ * @param thresholds - Ascending threshold values.
79
+ */
80
+ export function setSpritesheetIndexByValue(structure: Structure, value: number, thresholds: number[]): void;
81
+
82
+ /**
83
+ * Same as {@link setSpritesheetIndexByValue} for the structure at a cell.
84
+ * @param cellX - Grid column of the target cell.
85
+ * @param cellY - Grid row of the target cell.
86
+ * @param value - Numeric value mapped through thresholds.
87
+ * @param thresholds - Ascending threshold values.
88
+ */
89
+ export function setSpritesheetIndexByValueAtCell(...args: [...CellCoordinates, value: number, thresholds: number[]]): void;
90
+
91
+ /**
92
+ * Push structure field changes to simulation.
93
+ * @param structure - Structure instance to update.
94
+ * @param options - When `propagateToWorkers` is true, sync to worker threads.
95
+ */
96
+ export function update(structure: Structure, options?: { propagateToWorkers?: boolean; }): void;
97
+
98
+ /**
99
+ * Merge partial data onto a structure.
100
+ * @param structure - Structure instance to update.
101
+ * @param partial - Fields to merge onto `structure.data`.
102
+ * @param options - When `propagateToWorkers` is true, sync to worker threads.
103
+ */
104
+ export function setData(structure: Structure, partial: any, options?: { propagateToWorkers?: boolean; }): void;
105
+
106
+ /** Structure processing enablement checks. */
107
+ export namespace processing {
108
+ /**
109
+ * Return true when processing is enabled at the cell.
110
+ * @param cellX - Grid column of the target cell.
111
+ * @param cellY - Grid row of the target cell.
112
+ */
113
+ export function isEnabledAt(...args: CellCoordinates): boolean;
114
+ }
115
+
116
+ /** Per-structure custom data bag. */
117
+ export interface StructureData {
118
+ elementId?: string | null;
119
+ elementType?: TaggedNumber<"elementType"> | null;
120
+ [key: string]: unknown;
121
+ }
122
+
123
+ /** Live structure instance in the world grid. */
124
+ export interface Structure {
125
+ x: number;
126
+ y: number;
127
+ trapped?: boolean;
128
+ data?: StructureData;
129
+ [key: string]: unknown;
130
+ }
131
+
132
+ /** Numeric structure type handle. Built-in enum values autocomplete. */
133
+ export type StructureType = StructureTypeEnum | TaggedNumber<"structureType">;
134
+ /** Mod or built-in structure string id. */
135
+ export type StructureId = LooseString<never>;
136
+ /** Type handle or string id accepted by lookup helpers. */
137
+ export type StructureRef = StructureType | StructureId;
138
+ }
@@ -0,0 +1,100 @@
1
+ import type { CellCoordinates } from "../../shared/player";
2
+ import type { CellId, LooseString, TaggedNumber } from "../nominal";
3
+ import type { CellType as CellTypeEnum } from "../../sandkit/enums/index";
4
+
5
+ /**
6
+ * Shared `sandkit.api.terrains` base — terrain type lookup and cell mutation.
7
+ *
8
+ * @internal Base namespace reused by main and worker declarations.
9
+ */
10
+ export namespace terrains {
11
+ /**
12
+ * Resolve a terrain string id to a numeric cell type.
13
+ * @param terrainId - Mod-registered or built-in terrain id.
14
+ * @returns Numeric terrain cell type.
15
+ */
16
+ export function getTypeFromId(terrainId: TerrainId): TerrainType;
17
+
18
+ /**
19
+ * Return the terrain cell type at a cell, or null when none.
20
+ * @param cellX - Grid column of the target cell.
21
+ * @param cellY - Grid row of the target cell.
22
+ */
23
+ export function getTypeAtCell(...args: CellCoordinates): TerrainType | null;
24
+
25
+ /**
26
+ * Return terrain cell type and hit points at a cell.
27
+ * @param cellX - Grid column of the target cell.
28
+ * @param cellY - Grid row of the target cell.
29
+ * @returns Cell type and hp, or null when the cell is not terrain.
30
+ */
31
+ export function getDataAtCell(...args: CellCoordinates): { cellType: TerrainType; hp: number | null; } | null;
32
+
33
+ /**
34
+ * Return true when any terrain occupies the cell.
35
+ * @param cellX - Grid column of the target cell.
36
+ * @param cellY - Grid row of the target cell.
37
+ */
38
+ export function isAtCell(...args: CellCoordinates): boolean;
39
+
40
+ /**
41
+ * Return true when the cell terrain matches the given id.
42
+ * @param cellX - Grid column of the target cell.
43
+ * @param cellY - Grid row of the target cell.
44
+ * @param terrainId - Terrain string id to compare.
45
+ */
46
+ export function isTypeAtCell(...args: [...CellCoordinates, terrainId: TerrainId]): boolean;
47
+
48
+ /**
49
+ * Return true when a packed cell id refers to terrain.
50
+ * @param cellId - Packed cell id from {@link world.getCellIdAtCell}.
51
+ */
52
+ export function isCellIdTerrain(cellId: CellId): boolean;
53
+
54
+ /**
55
+ * Apply damage to terrain at a cell.
56
+ * @param cellX - Grid column of the target cell.
57
+ * @param cellY - Grid row of the target cell.
58
+ * @param damage - Damage amount to apply.
59
+ */
60
+ export function damageAtCell(...args: [...CellCoordinates, damage: number]): void;
61
+
62
+ /**
63
+ * Place terrain at an empty cell.
64
+ * @param cellX - Grid column of the target cell.
65
+ * @param cellY - Grid row of the target cell.
66
+ * @param terrainTypeOrId - Numeric cell type or terrain string id.
67
+ * @param options - Optional mutation flags.
68
+ */
69
+ export function createAtCell(...args: [...CellCoordinates, terrainTypeOrId: TerrainRef, options?: TerrainMutationOptions]): void;
70
+
71
+ /**
72
+ * Replace existing terrain at a cell.
73
+ * @param cellX - Grid column of the target cell.
74
+ * @param cellY - Grid row of the target cell.
75
+ * @param terrainTypeOrId - Numeric cell type or terrain string id.
76
+ * @param options - Optional mutation flags.
77
+ */
78
+ export function replaceAtCell(...args: [...CellCoordinates, terrainTypeOrId: TerrainRef, options?: TerrainMutationOptions]): void;
79
+
80
+ /**
81
+ * Remove terrain from a cell.
82
+ * @param cellX - Grid column of the target cell.
83
+ * @param cellY - Grid row of the target cell.
84
+ * @param options - Optional mutation flags.
85
+ */
86
+ export function removeAtCell(...args: [...CellCoordinates, options?: TerrainMutationOptions]): void;
87
+
88
+ /** Options for terrain create, replace, or remove calls. */
89
+ export interface TerrainMutationOptions {
90
+ /** Skip shadow updates around the changed cell. */
91
+ skipShadow?: boolean;
92
+ }
93
+
94
+ /** Numeric terrain / {@link CellTypeEnum} handle. */
95
+ export type TerrainType = CellTypeEnum | TaggedNumber<"terrainType">;
96
+ /** Mod or built-in terrain string id. */
97
+ export type TerrainId = LooseString<never>;
98
+ /** Type handle or string id accepted by mutation helpers. */
99
+ export type TerrainRef = TerrainType | TerrainId;
100
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Shared `sandkit.api.ui` base — lightweight UI helpers available on workers.
3
+ *
4
+ * Main thread adds richer UI APIs on top of this shape.
5
+ *
6
+ * @internal Base namespace reused by main and worker declarations.
7
+ */
8
+ export namespace ui {
9
+ /**
10
+ * Show a short on-screen toast message.
11
+ * @param message - Plain text, translation key, or translatable value.
12
+ * @param options - Cooldown, style, and auto-dismiss options.
13
+ */
14
+ export function toast(message: LocalizedText, options?: ToastOptions): void;
15
+
16
+ /** Plain text, translation key object, or i18n translatable value. */
17
+ export type LocalizedText =
18
+ | string
19
+ | I18nTextKey
20
+ | I18nTranslatable;
21
+
22
+ /** Translation key with optional parameter substitution. */
23
+ export interface I18nTextKey {
24
+ /** Namespaced translation key (for example `ui|save|save`). */
25
+ key: string;
26
+ /** Values merged into the translated string. */
27
+ params?: Record<string, string | number>;
28
+ }
29
+
30
+ /** Value returned by `sandkit.api.i18n.translatable`. */
31
+ export interface I18nTranslatable {
32
+ __translatable: true;
33
+ key: string;
34
+ fallback: string;
35
+ }
36
+
37
+ /** Cooldown, style, and auto-dismiss options for {@link toast}. */
38
+ export interface ToastOptions {
39
+ /** Minimum ms before the same toast can show again. */
40
+ cooldown?: number;
41
+ /**
42
+ * Dedupe key paired with {@link ToastOptions.cooldown}.
43
+ * Defaults to the message string or `message.key`.
44
+ */
45
+ cooldownKey?: string;
46
+ /**
47
+ * Auto-dismiss delay in ms. Default `5000`.
48
+ * Set `false` to keep the toast until another toast replaces it.
49
+ */
50
+ duration?: number | false;
51
+ /** Visual style applied to the toast body. */
52
+ variant?: "danger" | "hint" | "hole" | (string & {});
53
+ }
54
+ }
@@ -0,0 +1,71 @@
1
+ import type { CellCoordinates, Vector2 } from "../../shared/player";
2
+ import type { CellId as PackedCellId } from "../nominal";
3
+
4
+ /**
5
+ * Shared `sandkit.api.world` base — cell and terrain queries plus excavation.
6
+ *
7
+ * Main thread adds idle scheduling and fog helpers on top of this shape.
8
+ *
9
+ * @internal Base namespace reused by main and worker declarations.
10
+ */
11
+ export namespace world {
12
+ /**
13
+ * Return the packed cell id at grid coordinates.
14
+ * @param cellX - Grid column of the target cell.
15
+ * @param cellY - Grid row of the target cell.
16
+ * @returns Packed cell id for the cell.
17
+ */
18
+ export function getCellIdAtCell(...args: CellCoordinates): CellId;
19
+
20
+ /**
21
+ * Return true when the cell has no element or terrain content.
22
+ * @param cellX - Grid column of the target cell.
23
+ * @param cellY - Grid row of the target cell.
24
+ */
25
+ export function isCellEmptyAtCell(...args: CellCoordinates): boolean;
26
+
27
+ /**
28
+ * Return true when the cell holds terrain (not an element).
29
+ * @param cellX - Grid column of the target cell.
30
+ * @param cellY - Grid row of the target cell.
31
+ */
32
+ export function isTerrainAtCell(...args: CellCoordinates): boolean;
33
+
34
+ /**
35
+ * Mark the cell active for simulation this tick.
36
+ * @param cellX - Grid column of the target cell.
37
+ * @param cellY - Grid row of the target cell.
38
+ */
39
+ export function reportActivityAtCell(...args: CellCoordinates): void;
40
+
41
+ /**
42
+ * Apply excavation damage and eject velocity at a cell.
43
+ * @param cellX - Grid column of the target cell.
44
+ * @param cellY - Grid row of the target cell.
45
+ * @param outVelocity - Ejection velocity written into this vector.
46
+ * @param damage - Damage applied to terrain in the pattern.
47
+ * @param options - Optional excavation source flags.
48
+ */
49
+ export function excavateAtCell(...args: [...CellCoordinates, outVelocity: Vector2, damage: number, options?: ExcavateOptions]): void;
50
+
51
+ /** Packed cell id from {@link getCellIdAtCell}. */
52
+ export type CellId = PackedCellId;
53
+
54
+ /** Flags that control how {@link excavateAtCell} resolves damage and drops. */
55
+ export interface ExcavateOptions {
56
+ /** Treat the dig as gun fire for terrain resistance checks. */
57
+ fromGun?: boolean;
58
+ /** Treat the dig as rocket or dynamite explosion damage. */
59
+ fromRocketExplosion?: boolean;
60
+ /** Treat the dig as drill damage. */
61
+ fromDrill?: boolean;
62
+ /** Use {@link outVelocity} literally instead of deriving ejection speed. */
63
+ useLiteralOutVelocity?: boolean;
64
+ /** Allow removing terrain marked non-destructible. */
65
+ destroyNonDestructible?: boolean;
66
+ /** Force-remove all matched cells regardless of normal rules. */
67
+ forceRemoveAll?: boolean;
68
+ /** Extra drill-tier damage when {@link fromDrill} is true. Clamped to 0–1000. */
69
+ drillTierDamage?: number;
70
+ }
71
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared asset reference shape.
3
+ *
4
+ * @internal Base type reused by domain shapes such as {@link Player}. Not a
5
+ * runtime `sandkit` namespace.
6
+ */
7
+
8
+ /** Reference to a loaded sprite or texture asset. */
9
+ export interface AssetRef {
10
+ /** Runtime asset id. */
11
+ id: number
12
+ /** Asset category discriminator used by the renderer. */
13
+ type: number
14
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Shared engine API stub types.
3
+ *
4
+ * Used where `sandkit.engine.api` namespaces overlap the public mod API but are
5
+ * not fully typed in declarations.
6
+ *
7
+ * @internal
8
+ */
9
+
10
+ /** Stub for an unresolved engine method. @internal */
11
+ export type EngineFn = (...args: unknown[]) => unknown;
12
+
13
+ /**
14
+ * Loose bag for namespaces that overlap `sandkit.api` (different names / state-first).
15
+ * @internal
16
+ */
17
+ export type EngineOverlapNs = Record<string, EngineFn | Record<string, unknown> | unknown>;