dredless 0.7.0 → 1.0.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/README.md +22 -57
- package/dist/browser/dredless.global.js +794 -98
- package/dist/browser/dredless.global.js.map +4 -4
- package/docs/ACCOUNT.md +146 -0
- package/docs/API_REFERENCE.md +63 -2563
- package/docs/BROWSER_API.md +151 -70
- package/docs/CLIENT.md +183 -0
- package/docs/EVENTS.md +136 -0
- package/docs/GETTING_STARTED.md +135 -0
- package/docs/MACHINES.md +351 -0
- package/docs/MANAGEMENT.md +285 -0
- package/docs/NODE_API.md +120 -318
- package/docs/PLAYER_INVENTORY.md +235 -0
- package/docs/PROTOCOL.md +227 -0
- package/docs/README.md +44 -0
- package/docs/TROUBLESHOOTING.md +91 -0
- package/docs/WORLD_STATE.md +183 -0
- package/package.json +1 -2
- package/src/browser.d.ts +31 -1
- package/src/browser.js +10 -0
- package/src/client/core.js +302 -15
- package/src/client/domains/index.js +57 -7
- package/src/client/index.d.ts +1 -1
- package/src/index.d.ts +299 -13
- package/src/index.js +10 -0
- package/src/network/account.js +182 -0
- package/src/network/disconnect.d.ts +2 -0
- package/src/network/disconnect.js +53 -0
- package/src/network/index.d.ts +1 -0
- package/src/network/index.js +1 -0
- package/src/network/invites.d.ts +0 -3
- package/src/network/invites.js +3 -40
- package/src/network/session.d.ts +2 -0
- package/src/network/session.js +21 -0
- package/src/protocol/outbound/ship-management.d.ts +66 -1
- package/src/protocol/outbound/ship-management.js +83 -0
- package/src/state/model/decoder.js +70 -10
- package/src/state/model/index.d.ts +4 -0
- package/src/state/model/state.js +22 -7
- package/src/state/world/index.js +27 -1
package/docs/API_REFERENCE.md
CHANGED
|
@@ -1,2584 +1,84 @@
|
|
|
1
|
-
#
|
|
1
|
+
# API reference
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
Here, "endpoint" means a public method, constructor, domain method, or exported
|
|
5
|
-
helper function. The actual browser/game wire protocol remains an implementation
|
|
6
|
-
detail unless a helper explicitly builds or decodes protocol payloads.
|
|
3
|
+
[Documentation index](README.md) · [Getting started](GETTING_STARTED.md)
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
## Find an API
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
| Area | Entry points | Reference |
|
|
8
|
+
|------------------------------------------------|--------------------------------------------|---------------------------------------------|
|
|
9
|
+
| Node HTTP sessions and connections | `Session`, `AnonSession`, `Dredless` | [Node API](NODE_API.md) |
|
|
10
|
+
| Browser sessions and socket attachment | `BrowserSession`, browser `Dredless` | [Browser API](BROWSER_API.md) |
|
|
11
|
+
| Client readiness, retention, disconnects | `DredlessClient`, `client.net` | [Client](CLIENT.md) |
|
|
12
|
+
| Callbacks and event payloads | `on`, `off`, `once` | [Events](EVENTS.md) |
|
|
13
|
+
| World, entity, and nearby ship reads | `currentShip`, `overworld`, entity handles | [World state](WORLD_STATE.md) |
|
|
14
|
+
| Input, inventory, blueprints, chat | `client.player`, `client.inventory` | [Player and inventory](PLAYER_INVENTORY.md) |
|
|
15
|
+
| Machine configuration and context menus | `ship.machines`, `client.tips` | [Machines](MACHINES.md) |
|
|
16
|
+
| Crew, logs, ship settings, saving, perks | `client.management` | [Management](MANAGEMENT.md) |
|
|
17
|
+
| Account details, clan tags, applied perk ships | Session account methods | [Account](ACCOUNT.md) |
|
|
18
|
+
| Builders, decoders, generator mazes, raw state | Protocol subpaths, `client.debug` | [Protocol and debugging](PROTOCOL.md) |
|
|
19
|
+
| Failures and unsupported assumptions | - | [Troubleshooting](TROUBLESHOOTING.md) |
|
|
12
20
|
|
|
13
|
-
|
|
21
|
+
## Imports
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
Use `dredless/node` for explicit Node sessions and `dredless/browser` for ambient browser authentication. Both provide a
|
|
24
|
+
runtime namespace as the default export and shared APIs as named exports. The package root selects a runtime through
|
|
25
|
+
package export conditions; explicit imports make that choice clear.
|
|
16
26
|
|
|
17
27
|
```js
|
|
18
|
-
import {
|
|
19
|
-
import { WorldStore, WorldState } from "dredless/world";
|
|
20
|
-
import { generateGeneratorMaze } from "dredless/game/generator-maze";
|
|
21
|
-
import { encodeMsgpack, decodeMsgpack, decodeIncomingFrame } from "dredless/protocol";
|
|
28
|
+
import Dredless, {DredlessClient, LoaderPosition, DropReason} from "dredless/node";
|
|
22
29
|
```
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
Focused imports include `dredless/client`, `dredless/session`, `dredless/network`, `dredless/world`, `dredless/model`,
|
|
32
|
+
`dredless/state`, and [protocol subpaths](PROTOCOL.md#import-map). Subpaths do not necessarily re-export everything
|
|
33
|
+
available from a runtime entrypoint. `package.json` is the authoritative [export map](../package.json).
|
|
25
34
|
|
|
26
|
-
|
|
35
|
+
## Reading signatures
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
dredless/node
|
|
32
|
-
dredless/client
|
|
33
|
-
dredless/network
|
|
34
|
-
dredless/state
|
|
35
|
-
dredless/session
|
|
36
|
-
dredless/servers
|
|
37
|
-
dredless/ships
|
|
38
|
-
dredless/connection
|
|
39
|
-
dredless/world
|
|
40
|
-
dredless/model
|
|
41
|
-
dredless/game/generator-maze
|
|
42
|
-
dredless/game/model
|
|
43
|
-
dredless/protocol
|
|
44
|
-
dredless/protocol/blueprint
|
|
45
|
-
dredless/protocol/comms
|
|
46
|
-
dredless/protocol/commands
|
|
47
|
-
dredless/protocol/inventory
|
|
48
|
-
dredless/protocol/ship-management
|
|
49
|
-
dredless/protocol/sign
|
|
50
|
-
dredless/protocol/ui-config
|
|
51
|
-
dredless/crypto/chacha
|
|
52
|
-
dredless/compression/lz4
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
The root module defaults to the Node API for types and direct Node imports. Browser bundlers may use the root `browser` condition for JavaScript, but `dredless/browser` is the reliable import for browser IntelliSense.
|
|
56
|
-
|
|
57
|
-
Both runtime entrypoints re-export world/model classes, protocol builders, config builders, codec helpers, and common type shapes.
|
|
58
|
-
|
|
59
|
-
## Common Input Types
|
|
60
|
-
|
|
61
|
-
### `Server`
|
|
62
|
-
|
|
63
|
-
Returned by `fetchServers()`. Player counts and ping are returned separately by `fetchServerStatus()` or `fetchServerStatuses()`.
|
|
64
|
-
|
|
65
|
-
```ts
|
|
66
|
-
interface Server {
|
|
67
|
-
index: number;
|
|
68
|
-
domain: string;
|
|
69
|
-
description: string;
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### `ServerRef`
|
|
74
|
-
|
|
75
|
-
Accepted anywhere a server is required.
|
|
76
|
-
|
|
77
|
-
```ts
|
|
78
|
-
type ServerRef = number | Server;
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Passing a number selects a server index. Passing a `Server` object uses its
|
|
82
|
-
domain and index directly.
|
|
83
|
-
|
|
84
|
-
### `Ship`
|
|
85
|
-
|
|
86
|
-
Returned by ship list reads.
|
|
87
|
-
|
|
88
|
-
```ts
|
|
89
|
-
interface Ship {
|
|
90
|
-
id: number | null;
|
|
91
|
-
hexCode: string | null;
|
|
92
|
-
name: string;
|
|
93
|
-
iconUrl: string | null;
|
|
94
|
-
playerCount: number;
|
|
95
|
-
owned: boolean;
|
|
96
|
-
saved: boolean;
|
|
97
|
-
color: string;
|
|
98
|
-
time: number | null;
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Ship names are returned exactly as provided by the Drednot server. In
|
|
103
|
-
particular, `fetchShips()` and `fetchShipList()` preserve leading and trailing
|
|
104
|
-
spaces; it is up to callers to optionally trim those spaces from `name`.
|
|
105
|
-
|
|
106
|
-
### `InviteMetadata`
|
|
107
|
-
|
|
108
|
-
Returned by `fetchInviteMetadata()`.
|
|
109
|
-
|
|
110
|
-
```ts
|
|
111
|
-
interface InviteMetadata {
|
|
112
|
-
shipId: string | null;
|
|
113
|
-
name: string | null;
|
|
114
|
-
previewImageUrl: string | null;
|
|
115
|
-
hostname: string;
|
|
116
|
-
inviteCode: string;
|
|
117
|
-
color?: string | null;
|
|
118
|
-
}
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Invite metadata also preserves leading and trailing spaces in the
|
|
122
|
-
ship name returned by the invite page. The optional `color` field is included
|
|
123
|
-
only when `includeColor: true` is passed and is sampled from the preview image.
|
|
124
|
-
|
|
125
|
-
### `ShipList`
|
|
126
|
-
|
|
127
|
-
Returned by `fetchShipList()`.
|
|
128
|
-
|
|
129
|
-
```ts
|
|
130
|
-
interface ShipList {
|
|
131
|
-
playerCount?: number;
|
|
132
|
-
maxPlayerCount?: number;
|
|
133
|
-
isMuted?: boolean;
|
|
134
|
-
ships: Ship[];
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
### `ShipSpec`, `ShipRef`
|
|
139
|
-
|
|
140
|
-
Accepted by join/start methods.
|
|
141
|
-
|
|
142
|
-
```ts
|
|
143
|
-
type ShipSpec =
|
|
144
|
-
| { type: "join_or_load"; id: number | string }
|
|
145
|
-
| { type: "new"; name?: string | null; color?: string | null }
|
|
146
|
-
| { type: "invite"; code: string };
|
|
147
|
-
|
|
148
|
-
type ShipRef = number | string | Ship | ShipSpec | null;
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
Useful interpretations:
|
|
152
|
-
|
|
153
|
-
```txt
|
|
154
|
-
number -> ship id
|
|
155
|
-
string -> ship id/hex-like selector, depending on server API
|
|
156
|
-
Ship -> ship from fetchShips/fetchShipList
|
|
157
|
-
{ type: "new" } -> create or start a new ship
|
|
158
|
-
{ type: "invite" } -> join by invite code
|
|
159
|
-
null or undefined -> default behavior for the method
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
## Runtime Top-Level APIs
|
|
163
|
-
|
|
164
|
-
Top-level runtime APIs are split by environment:
|
|
165
|
-
|
|
166
|
-
- Node explicit session/token/start helpers: [NODE_API.md](./NODE_API.md)
|
|
167
|
-
- Browser ambient session/start helpers: [BROWSER_API.md](./BROWSER_API.md)
|
|
168
|
-
|
|
169
|
-
`Connection`, `Session`, `AnonSession`, `BrowserSession`, `Dredless`, and `DredlessBrowser` are documented in those runtime-specific files.
|
|
170
|
-
|
|
171
|
-
## `DredlessClient`
|
|
172
|
-
|
|
173
|
-
`DredlessClient` owns the websocket, outgoing commands, incoming packets, and
|
|
174
|
-
decoded state domains.
|
|
175
|
-
|
|
176
|
-
```ts
|
|
177
|
-
class DredlessClient {
|
|
178
|
-
constructor(connection: Connection, options?: { connect?: boolean });
|
|
179
|
-
static attachWebSocket(websocket: unknown, options?: AttachWebSocketOptions): DredlessClient;
|
|
180
|
-
|
|
181
|
-
connection: Connection | null;
|
|
182
|
-
session: Session | null;
|
|
183
|
-
baseUrl: string | null;
|
|
184
|
-
attachMode: "observe" | "bootstrap" | "readonly" | null;
|
|
185
|
-
attached: boolean;
|
|
186
|
-
serverId: number | null;
|
|
187
|
-
server: Server | null;
|
|
188
|
-
netPort: number | null;
|
|
189
|
-
gameToken: string;
|
|
190
|
-
ws: unknown;
|
|
191
|
-
sid: number | null;
|
|
192
|
-
connected: boolean;
|
|
193
|
-
ready: boolean;
|
|
194
|
-
packetCount: number;
|
|
195
|
-
lastPacket: unknown;
|
|
196
|
-
|
|
197
|
-
net: ClientNetDomain;
|
|
198
|
-
debug: ClientDebugDomain;
|
|
199
|
-
player: PlayerDomain;
|
|
200
|
-
inventory: InventoryDomain;
|
|
201
|
-
management: ShipManagementDomain;
|
|
202
|
-
readyPromise: Promise<this>;
|
|
203
|
-
|
|
204
|
-
whenReady(): Promise<this>;
|
|
205
|
-
close(code?: number, reason?: string): this;
|
|
206
|
-
disconnect(code?: number, reason?: string): this;
|
|
207
|
-
|
|
208
|
-
currentShip(): ShipDomain | null;
|
|
209
|
-
ship(): ShipDomain | null;
|
|
210
|
-
overworld(): OverworldDomain | null;
|
|
211
|
-
world(id: number): WorldDomain | null;
|
|
212
|
-
shipWorld(options?: { includeTiles?: boolean; includeModel?: boolean }): WorldSnapshot | null;
|
|
213
|
-
state(options?: { includeTiles?: boolean; includeModel?: boolean }): ClientSnapshot;
|
|
214
|
-
entities(scope?: number | string): EntitySummary[];
|
|
215
|
-
entity(entityId: number, scope?: number | string): EntitySnapshot | null;
|
|
216
|
-
currentPlayerEntity(): EntityHandle | null;
|
|
217
|
-
|
|
218
|
-
on(type: string, callback: (...args: unknown[]) => void): this;
|
|
219
|
-
off(type: string, callback: (...args: unknown[]) => void): this;
|
|
220
|
-
once(type: string, callback: (...args: unknown[]) => void): this;
|
|
221
|
-
}
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Constructor
|
|
225
|
-
|
|
226
|
-
```js
|
|
227
|
-
const client = new DredlessClient(connection);
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
By default the constructor opens the websocket. For tests or offline state
|
|
231
|
-
inspection, pass `{ connect: false }`:
|
|
232
|
-
|
|
233
|
-
```js
|
|
234
|
-
const client = new DredlessClient(connection, { connect: false });
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### `DredlessClient.attachWebSocket(websocket, options?)`
|
|
238
|
-
|
|
239
|
-
```ts
|
|
240
|
-
type WebSocketAttachMode = "observe" | "bootstrap" | "readonly";
|
|
241
|
-
|
|
242
|
-
interface AttachWebSocketOptions {
|
|
243
|
-
mode?: WebSocketAttachMode;
|
|
244
|
-
connected?: boolean | null;
|
|
245
|
-
ready?: boolean;
|
|
246
|
-
sid?: number | null;
|
|
247
|
-
baseUrl?: string | null;
|
|
248
|
-
session?: Session | null;
|
|
249
|
-
serverId?: number | null;
|
|
250
|
-
server?: Server | null;
|
|
251
|
-
netPort?: number | null;
|
|
252
|
-
gameToken?: string;
|
|
253
|
-
}
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
Attaches Dredless to an existing websocket without requiring a `Connection`.
|
|
257
|
-
This is intended for observing or integrating with an already-open browser/game websocket.
|
|
258
|
-
|
|
259
|
-
Modes:
|
|
260
|
-
|
|
261
|
-
- `"observe"` default: decodes incoming packets and allows explicit writes through normal handle/client methods, but does not send hello, bootstrap, or keepalive automatically.
|
|
262
|
-
- `"bootstrap"`: treats the websocket like a normally owned Dredless socket; sends hello on open and runs bootstrap, keepalive, and queued-message flushing on ready.
|
|
263
|
-
- `"readonly"`: decodes incoming packets only and rejects all write methods. `close()` is a no-op in this mode.
|
|
264
|
-
|
|
265
|
-
Optional metadata such as `server`, `serverId`, and `netPort` is only used for snapshots/logging; it is not required to attach.
|
|
266
|
-
|
|
267
|
-
```js
|
|
268
|
-
const client = DredlessClient.attachWebSocket(window.tpgaClient.repsocket.websocket);
|
|
269
|
-
client.on("packet", (packet) => console.log(packet.type));
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
### Lifecycle endpoints
|
|
273
|
-
|
|
274
|
-
```ts
|
|
275
|
-
whenReady(): Promise<this>;
|
|
276
|
-
close(code?: number, reason?: string): this;
|
|
277
|
-
disconnect(code?: number, reason?: string): this;
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
`whenReady()` resolves once the ready packet is received. For normally-owned clients and `attachWebSocket(..., { mode: "bootstrap" })`, bootstrap commands have also been sent.
|
|
281
|
-
|
|
282
|
-
### World/domain endpoints
|
|
283
|
-
|
|
284
|
-
```ts
|
|
285
|
-
currentShip(): ShipDomain | null;
|
|
286
|
-
ship(): ShipDomain | null;
|
|
287
|
-
currentPlayerEntity(): EntityHandle | null;
|
|
288
|
-
overworld(): OverworldDomain | null;
|
|
289
|
-
world(id: number): WorldDomain | null;
|
|
290
|
-
shipWorld(options?): WorldSnapshot | null;
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
Use `currentShip()` for the currently loaded ship world. Use `overworld()` for
|
|
294
|
-
zone-level objects such as nearby ships and overworld entities.
|
|
295
|
-
|
|
296
|
-
`currentPlayerEntity()` returns the current player entity handle in the loaded
|
|
297
|
-
ship world, or `null` before the player entity is known.
|
|
298
|
-
|
|
299
|
-
### Compatibility entity endpoints
|
|
300
|
-
|
|
301
|
-
```ts
|
|
302
|
-
entities(scope?: number | string): EntitySummary[];
|
|
303
|
-
entity(entityId: number, scope?: number | string): EntitySnapshot | null;
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
Prefer `client.currentShip()?.entities` and `client.overworld()?.entities` for
|
|
307
|
-
new code. These compatibility methods use `"ship"` by default.
|
|
308
|
-
|
|
309
|
-
Valid common scopes are:
|
|
310
|
-
|
|
311
|
-
```txt
|
|
312
|
-
"ship"
|
|
313
|
-
"current"
|
|
314
|
-
"overworld"
|
|
315
|
-
number world id
|
|
316
|
-
```
|
|
317
|
-
|
|
318
|
-
### Events
|
|
319
|
-
|
|
320
|
-
```ts
|
|
321
|
-
on(type: string, callback: (...args: unknown[]) => void): this;
|
|
322
|
-
off(type: string, callback: (...args: unknown[]) => void): this;
|
|
323
|
-
once(type: string, callback: (...args: unknown[]) => void): this;
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
Events are implementation-defined strings emitted by the client event bus.
|
|
327
|
-
|
|
328
|
-
### Context menus: `client.tips`
|
|
329
|
-
|
|
330
|
-
```js
|
|
331
|
-
const door = client.currentShip().machines.doors()[0];
|
|
332
|
-
const menu = await door.openTips();
|
|
333
|
-
console.log(menu.options);
|
|
334
|
-
client.tips.select("Restrict to Crew"); // Also accepts a zero-based option index.
|
|
335
|
-
|
|
336
|
-
// Open and select in one operation:
|
|
337
|
-
await client.tips.choose(door, "Restrict to Captains");
|
|
338
|
-
|
|
339
|
-
// Dismiss without selecting an option:
|
|
340
|
-
await door.openTips();
|
|
341
|
-
await client.tips.close();
|
|
342
|
-
|
|
343
|
-
// Set access and wait for the server's model update:
|
|
344
|
-
await door.setRank("guest");
|
|
345
|
-
await client.currentShip().machines.spawnPoints()[0].setRank("crew");
|
|
346
|
-
```
|
|
347
|
-
|
|
348
|
-
`client.tips.open(entity, options?)` accepts an entity handle or an entity id in
|
|
349
|
-
the current world and resolves to a frozen `TipList` with
|
|
350
|
-
`{ entity, world, filter, x, y, options }`. Every entity handle also exposes
|
|
351
|
-
`openTips(options?)`. `client.tips.current` is the latest menu, or `null` after
|
|
352
|
-
selection, an empty menu, or disconnect. The `tip-list` event receives
|
|
353
|
-
`(menu, world)` including empty menus; the existing raw `side-event` is preserved.
|
|
354
|
-
The server does not send an entity id in a tip list: `entity` is inferred from
|
|
355
|
-
the API's requested target and is `null` for unsolicited menus. Avoid mixing raw
|
|
356
|
-
context-menu commands with an API operation in progress.
|
|
357
|
-
|
|
358
|
-
`select(option, command?)` sends the selected index and returns the client.
|
|
359
|
-
`choose(entity, option, options?)` opens a fresh menu and selects by exact text
|
|
360
|
-
or index, resolving to the client once selection is sent. Neither method waits
|
|
361
|
-
for the resulting action to complete.
|
|
362
|
-
|
|
363
|
-
`close(options?)` sends the captured left-click dismissal input with no focused
|
|
364
|
-
entity or selected option, then resolves to the client after the server sends an
|
|
365
|
-
empty tip list for the menu's world. It skips sending when no menu is open and
|
|
366
|
-
uses the same timeout and overlap rules as `open()`. Optional `command` fields
|
|
367
|
-
can supply click coordinates or inventory/view settings.
|
|
368
|
-
|
|
369
|
-
Door and spawn-point `setRank(rank, options?)` accept `"guest"`, `"crew"`,
|
|
370
|
-
`"captain"`, or `0`, `1`, `3`. They resolve to the client after the model confirms
|
|
371
|
-
the requested rank, and skip sending when the rank already matches. These are
|
|
372
|
-
access restrictions; they do not change a player's ship rank.
|
|
373
|
-
|
|
374
|
-
Options are `{ timeout?: number, command?: Command }`. The timeout defaults to
|
|
375
|
-
5000 milliseconds per response (menu and, for `setRank`, rank confirmation).
|
|
376
|
-
Calls reject on timeout, disconnect, unknown options, invalid ranks, or a target
|
|
377
|
-
outside the current world. Only one asynchronous tip operation may run per
|
|
378
|
-
client; overlapping calls reject. The server still enforces permissions and
|
|
379
|
-
interaction range; these helpers do not move the player or grant access.
|
|
380
|
-
|
|
381
|
-
## `client.state()` Output
|
|
382
|
-
|
|
383
|
-
```ts
|
|
384
|
-
interface ClientSnapshot {
|
|
385
|
-
baseUrl: string;
|
|
386
|
-
session: SessionSnapshot;
|
|
387
|
-
connection: ConnectionSnapshot | null;
|
|
388
|
-
attachMode: "observe" | "bootstrap" | "readonly" | null;
|
|
389
|
-
serverId: number | null;
|
|
390
|
-
server: Server | null;
|
|
391
|
-
netPort: number | null;
|
|
392
|
-
sid: number | null;
|
|
393
|
-
ready: boolean;
|
|
394
|
-
connected: boolean;
|
|
395
|
-
currentWorldId: number | null;
|
|
396
|
-
worlds: WorldSnapshot[];
|
|
397
|
-
cpuLoad: number | null;
|
|
398
|
-
inventory: InventoryState;
|
|
399
|
-
puiPanels: PuiEvent[];
|
|
400
|
-
commsPanels: CommsEvent[];
|
|
401
|
-
currentCommsPanel: CommsEvent | null;
|
|
402
|
-
warnings: unknown[];
|
|
403
|
-
effects: unknown[];
|
|
404
|
-
chat: unknown[];
|
|
405
|
-
motd: unknown[];
|
|
406
|
-
sessionMessages: unknown[];
|
|
407
|
-
scannerResults: ScannerResult[];
|
|
408
|
-
lastScannerResult: ScannerResult | null;
|
|
409
|
-
shipConfig: ShipConfig | null;
|
|
410
|
-
captainSubrank: CaptainSubrank | null;
|
|
411
|
-
playerList: ShipPlayerList | null;
|
|
412
|
-
outfits: { sid: number; outfit: unknown }[];
|
|
413
|
-
commandAcks: CommandAck[];
|
|
414
|
-
lastCommandAck: CommandAck | null;
|
|
415
|
-
decodeErrors: unknown[];
|
|
416
|
-
packetCount: number;
|
|
417
|
-
lastPacket: unknown;
|
|
418
|
-
}
|
|
419
|
-
```
|
|
420
|
-
|
|
421
|
-
## Client Domain APIs
|
|
422
|
-
|
|
423
|
-
### `client.net`
|
|
424
|
-
|
|
425
|
-
Low-level outgoing network domain.
|
|
426
|
-
|
|
427
|
-
```ts
|
|
428
|
-
interface ClientNetDomain {
|
|
429
|
-
connected: boolean;
|
|
430
|
-
ready: boolean;
|
|
431
|
-
sid: number | null;
|
|
432
|
-
packetCount: number;
|
|
433
|
-
lastPacket: unknown;
|
|
434
|
-
send(command?: Command): DredlessClient;
|
|
435
|
-
sendMessage(message: unknown, options?: { afterReady?: boolean }): DredlessClient;
|
|
436
|
-
sendRaw(message: unknown, options?: { afterReady?: boolean }): DredlessClient;
|
|
437
|
-
sendEntityCommand(cmd: string, args?: unknown[]): DredlessClient;
|
|
438
|
-
sendUiConfig(data: unknown): DredlessClient;
|
|
439
|
-
sendBlueprintPlacement(placement: BlueprintPlacement): DredlessClient;
|
|
440
|
-
setOutfit(outfit: unknown): DredlessClient;
|
|
441
|
-
}
|
|
442
|
-
```
|
|
443
|
-
|
|
444
|
-
`send()` signs and sends a command-like packet. `sendMessage()` sends a decoded
|
|
445
|
-
protocol message. `sendRaw()` sends already-built/raw content. The specialized
|
|
446
|
-
helpers build the corresponding protocol command and return the client for
|
|
447
|
-
chaining.
|
|
448
|
-
|
|
449
|
-
### `Command`
|
|
450
|
-
|
|
451
|
-
General command shape for movement, actions, UI focus, and drag operations.
|
|
452
|
-
|
|
453
|
-
```ts
|
|
454
|
-
interface Command {
|
|
455
|
-
type?: number;
|
|
456
|
-
n?: number | null;
|
|
457
|
-
x?: number;
|
|
458
|
-
y?: number;
|
|
459
|
-
mx?: number;
|
|
460
|
-
my?: number;
|
|
461
|
-
vx?: number;
|
|
462
|
-
vy?: number;
|
|
463
|
-
jump?: boolean;
|
|
464
|
-
jump_held?: boolean;
|
|
465
|
-
drop?: boolean;
|
|
466
|
-
act1?: boolean;
|
|
467
|
-
act1_held?: boolean;
|
|
468
|
-
exit?: boolean;
|
|
469
|
-
act2?: boolean;
|
|
470
|
-
act_alt?: boolean;
|
|
471
|
-
act_alt_held?: boolean;
|
|
472
|
-
wrench_mode?: number;
|
|
473
|
-
turret_mode?: number;
|
|
474
|
-
scr_w?: number;
|
|
475
|
-
scr_h?: number;
|
|
476
|
-
motion?: number;
|
|
477
|
-
focus_ent?: number | null;
|
|
478
|
-
config_ent?: number | null;
|
|
479
|
-
tip_select?: number | null;
|
|
480
|
-
inv_slot?: number;
|
|
481
|
-
blur?: boolean;
|
|
482
|
-
drag?: DragPayload | null;
|
|
483
|
-
}
|
|
484
|
-
```
|
|
485
|
-
|
|
486
|
-
### `client.debug`
|
|
487
|
-
|
|
488
|
-
Read-only debugging and raw-state access.
|
|
489
|
-
|
|
490
|
-
```ts
|
|
491
|
-
interface ClientDebugDomain {
|
|
492
|
-
packets(): unknown[];
|
|
493
|
-
decodeErrors(): unknown[];
|
|
494
|
-
worldStore(): WorldStore;
|
|
495
|
-
modelTable(worldId: number, tableId: number): Map<number, ModelRecord>;
|
|
496
|
-
modelRecord(worldId: number, tableId: number, entityId: number): ModelRecord | null;
|
|
497
|
-
puiPanels(): PuiEvent[];
|
|
498
|
-
commsPanels(): CommsEvent[];
|
|
499
|
-
}
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
### `client.player`
|
|
503
|
-
|
|
504
|
-
Player input and action domain.
|
|
505
|
-
|
|
506
|
-
```ts
|
|
507
|
-
interface PlayerDomain {
|
|
508
|
-
current(): PlayerSummary | null;
|
|
509
|
-
entity(): EntityHandle | null;
|
|
510
|
-
name(): string | null;
|
|
511
|
-
rank(): CurrentPlayerRank;
|
|
512
|
-
move(vector?: { x?: number; y?: number }, command?: Command): DredlessClient;
|
|
513
|
-
aim(point?: { x?: number; y?: number; mx?: number; my?: number }, command?: Command): DredlessClient;
|
|
514
|
-
action(flags?: Command, command?: Command): DredlessClient;
|
|
515
|
-
useEntity(entity: number | EntityHandle | EntitySummary, options?: { invSlot?: number; hold?: boolean }, command?: Command): DredlessClient;
|
|
516
|
-
useHeldItem(options?: { invSlot?: number; hold?: boolean }, command?: Command): DredlessClient;
|
|
517
|
-
placeHeldItem(options?: { invSlot?: number; hold?: boolean }, command?: Command): DredlessClient;
|
|
518
|
-
placeBlueprint(placement: BlueprintPlacement, options?: { invSlot?: number; hold?: boolean; mx?: number; my?: number }, command?: Command): DredlessClient;
|
|
519
|
-
rotateHeldItem(options?: { invSlot?: number; hold?: boolean }, command?: Command): DredlessClient;
|
|
520
|
-
selectSlot(invSlot?: number, command?: Command): DredlessClient;
|
|
521
|
-
inputSettings(): CurrentInputSettings;
|
|
522
|
-
setInputSettings(settings?: InputSettings, options?: { send?: boolean }): DredlessClient;
|
|
523
|
-
setView(width: number, height: number, options?: { send?: boolean }): DredlessClient;
|
|
524
|
-
setScreenSize(width: number, height: number, options?: { send?: boolean }): DredlessClient;
|
|
525
|
-
setWrenchMode(mode: WrenchMode, options?: { send?: boolean }): DredlessClient;
|
|
526
|
-
setTurretMode(mode: TurretMode, options?: { send?: boolean }): DredlessClient;
|
|
527
|
-
}
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
### Input setting shapes
|
|
531
|
-
|
|
532
|
-
```ts
|
|
533
|
-
const WrenchMode = { DropAllItems: "drop-all-items", GrabPrimaryItems: "grab-primary-items", GrabAllItems: "grab-all-items" } as const;
|
|
534
|
-
type WrenchMode = typeof WrenchMode[keyof typeof WrenchMode];
|
|
535
|
-
|
|
536
|
-
const TurretMode = { ContinuousFire: "continuous-fire", VolleyFire: "volley-fire" } as const;
|
|
537
|
-
type TurretMode = typeof TurretMode[keyof typeof TurretMode];
|
|
538
|
-
|
|
539
|
-
interface InputSettings {
|
|
540
|
-
wrenchMode?: WrenchMode;
|
|
541
|
-
turretMode?: TurretMode;
|
|
542
|
-
viewWidth?: number;
|
|
543
|
-
viewHeight?: number;
|
|
544
|
-
screenWidth?: number;
|
|
545
|
-
screenHeight?: number;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
interface CurrentInputSettings {
|
|
549
|
-
wrenchMode: "drop-all-items" | "grab-primary-items" | "grab-all-items" | null;
|
|
550
|
-
turretMode: "continuous-fire" | "volley-fire" | null;
|
|
551
|
-
viewWidth: number | null;
|
|
552
|
-
viewHeight: number | null;
|
|
553
|
-
screenWidth: number | null;
|
|
554
|
-
screenHeight: number | null;
|
|
555
|
-
}
|
|
556
|
-
```
|
|
557
|
-
|
|
558
|
-
### `client.inventory`
|
|
559
|
-
|
|
560
|
-
Inventory read and slot movement domain.
|
|
561
|
-
|
|
562
|
-
```ts
|
|
563
|
-
type InventoryArea = "all" | "hotbar" | "equipment";
|
|
564
|
-
type InventorySlotRef = number | EquipmentSlot | InventorySlotHandle | InventorySlotSnapshot;
|
|
565
|
-
const EquipmentSlot = { Head: "head", Face: "face", Body: "body", Back: "back", Hands: "hands", Feet: "feet" } as const;
|
|
566
|
-
type EquipmentSlot = typeof EquipmentSlot[keyof typeof EquipmentSlot];
|
|
567
|
-
|
|
568
|
-
interface InventoryDomain {
|
|
569
|
-
state(): InventoryState;
|
|
570
|
-
hotbarSize(): number;
|
|
571
|
-
allSlots(): InventorySlotHandle[];
|
|
572
|
-
slot(ref: InventorySlotRef): InventorySlotHandle;
|
|
573
|
-
hotbarSlots(): InventorySlotHandle[];
|
|
574
|
-
equipmentSlots(): { head: InventorySlotHandle; face: InventorySlotHandle; body: InventorySlotHandle; back: InventorySlotHandle; hands: InventorySlotHandle; feet: InventorySlotHandle };
|
|
575
|
-
findItem(itemId: number, options?: { area?: InventoryArea }): InventorySlotHandle | null;
|
|
576
|
-
findItems(itemId: number, options?: { area?: InventoryArea }): InventorySlotHandle[];
|
|
577
|
-
firstEmpty(options?: { area?: InventoryArea }): InventorySlotHandle | null;
|
|
578
|
-
move(source: InventorySlotRef, target: InventorySlotRef, options?: { split?: boolean }, command?: Command): DredlessClient;
|
|
579
|
-
equip(source: InventorySlotRef, equipmentSlot?: EquipmentSlot | { split?: boolean }, options?: { split?: boolean } | Command, command?: Command): DredlessClient;
|
|
580
|
-
unequip(equipmentSlot: EquipmentSlot, target?: InventorySlotRef, options?: { split?: boolean }, command?: Command): DredlessClient;
|
|
581
|
-
select(slot: InventorySlotRef, command?: Command): DredlessClient;
|
|
582
|
-
}
|
|
583
|
-
```
|
|
584
|
-
|
|
585
|
-
Slot handles expose live slot reads and convenience actions:
|
|
586
|
-
|
|
587
|
-
```ts
|
|
588
|
-
interface InventorySlotHandle {
|
|
589
|
-
index: number;
|
|
590
|
-
kind: "hotbar" | "equipment" | null;
|
|
591
|
-
equipmentSlot: "head" | "face" | "body" | "back" | "hands" | "feet" | null;
|
|
592
|
-
itemId: number | null;
|
|
593
|
-
itemName: string | null;
|
|
594
|
-
count: number;
|
|
595
|
-
empty: boolean;
|
|
596
|
-
exists(): boolean;
|
|
597
|
-
snapshot(): InventorySlotSnapshot | null;
|
|
598
|
-
moveTo(target: InventorySlotRef, options?: { split?: boolean }, command?: Command): DredlessClient;
|
|
599
|
-
equip(equipmentSlot?: EquipmentSlot | { split?: boolean }, options?: { split?: boolean } | Command, command?: Command): DredlessClient;
|
|
600
|
-
unequip(target?: InventorySlotRef, options?: { split?: boolean }, command?: Command): DredlessClient;
|
|
601
|
-
select(command?: Command): DredlessClient;
|
|
602
|
-
}
|
|
603
|
-
```
|
|
604
|
-
|
|
605
|
-
Inventory state is normalized and does not expose raw `items`, `item_counts`, or `general_slots` arrays. `hotbarSize` is the protocol-provided hotbar slot count from `general_slots`; equipment slots are separate fixed absolute indexes (`16`, `17`, `18`, `19`, `20`, `21`). `equip()` may omit the equipment slot; in that case it infers the target from the item schema and throws if the source slot is empty or the item is not equipment.
|
|
606
|
-
|
|
607
|
-
```ts
|
|
608
|
-
interface InventorySlotSnapshot {
|
|
609
|
-
index: number;
|
|
610
|
-
itemId: number | null;
|
|
611
|
-
itemName: string | null;
|
|
612
|
-
count: number;
|
|
613
|
-
kind: "hotbar" | "equipment";
|
|
614
|
-
equipmentSlot: "head" | "face" | "body" | "back" | "hands" | "feet" | null;
|
|
615
|
-
empty: boolean;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
interface InventoryState {
|
|
619
|
-
type: "inventory";
|
|
620
|
-
filter?: number;
|
|
621
|
-
hotbarSize: number;
|
|
622
|
-
slots: InventorySlotSnapshot[];
|
|
623
|
-
hotbar: InventorySlotSnapshot[];
|
|
624
|
-
equipment: {
|
|
625
|
-
head: InventorySlotSnapshot;
|
|
626
|
-
face: InventorySlotSnapshot;
|
|
627
|
-
body: InventorySlotSnapshot;
|
|
628
|
-
back: InventorySlotSnapshot;
|
|
629
|
-
hands: InventorySlotSnapshot;
|
|
630
|
-
feet: InventorySlotSnapshot;
|
|
631
|
-
};
|
|
632
|
-
}
|
|
633
|
-
```
|
|
634
|
-
### `client.management`
|
|
635
|
-
|
|
636
|
-
Ship-management command and state domain.
|
|
637
|
-
|
|
638
|
-
```ts
|
|
639
|
-
interface ShipManagementDomain {
|
|
640
|
-
requestPlayerList(): DredlessClient;
|
|
641
|
-
resetInvite(): DredlessClient;
|
|
642
|
-
setPrivacy(privacy: ShipPrivacy): DredlessClient;
|
|
643
|
-
recoverStarterItem(itemId: number): DredlessClient;
|
|
644
|
-
setPlayerRank(refId: number, rank: ShipPlayerRank): DredlessClient;
|
|
645
|
-
kickPlayer(refId: number): DredlessClient;
|
|
646
|
-
banPlayer(refId: number): DredlessClient;
|
|
647
|
-
demoteSelf(): DredlessClient;
|
|
648
|
-
config(): ShipConfig | null;
|
|
649
|
-
hasCheats(): boolean;
|
|
650
|
-
playerList(): ShipPlayerList | null;
|
|
651
|
-
}
|
|
652
|
-
```
|
|
653
|
-
|
|
654
|
-
Input aliases:
|
|
655
|
-
|
|
656
|
-
```ts
|
|
657
|
-
type ShipPrivacy = 0 | 1 | boolean | "public" | "private";
|
|
658
|
-
type ShipPlayerRank = 0 | 1 | 3 | "guest" | "crew" | "captain";
|
|
659
|
-
type PlayerShipRank = "guest" | "crew" | "crew-invite-pending-deprecated" | "captain" | "banned";
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
Output shapes:
|
|
663
|
-
|
|
664
|
-
```ts
|
|
665
|
-
interface ShipConfig {
|
|
666
|
-
privacy: number | null;
|
|
667
|
-
privacyName: "public" | "private" | null;
|
|
668
|
-
inviteKey: string | null;
|
|
669
|
-
teamId: number | null;
|
|
670
|
-
patronPerks: unknown[];
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
interface CaptainSubrank {
|
|
674
|
-
subrank: number | null;
|
|
675
|
-
enableCheats: boolean;
|
|
676
|
-
}
|
|
677
|
-
|
|
678
|
-
interface CurrentPlayerRank {
|
|
679
|
-
shipRank: PlayerShipRank | null;
|
|
680
|
-
subrank: number | null;
|
|
681
|
-
isCaptain: boolean;
|
|
682
|
-
patronTier: "bronze" | "silver" | "gold" | "plat" | "flux" | null;
|
|
683
|
-
}
|
|
684
|
-
|
|
685
|
-
interface PlayerListEntry {
|
|
686
|
-
refId: number | null;
|
|
687
|
-
discrim: string | null;
|
|
688
|
-
discrimColor: number | null;
|
|
689
|
-
teamRank: number | null;
|
|
690
|
-
captainRank: number | null;
|
|
691
|
-
isCaptain: boolean;
|
|
692
|
-
isShipOwner: boolean;
|
|
693
|
-
canBeManaged: boolean;
|
|
694
|
-
time: number | null;
|
|
695
|
-
items: unknown[];
|
|
696
|
-
aliasDiscrims: unknown[];
|
|
697
|
-
extraAliasCount: number;
|
|
698
|
-
onlineCount: number | null;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
interface ShipPlayerList {
|
|
702
|
-
ownerCaptainRank: number | null;
|
|
703
|
-
shipOwners: PlayerListEntry[];
|
|
704
|
-
players: PlayerListEntry[];
|
|
705
|
-
changes: PlayerListEntry[];
|
|
706
|
-
removedPlayers: number[];
|
|
707
|
-
}
|
|
708
|
-
```
|
|
709
|
-
|
|
710
|
-
## World Domains
|
|
711
|
-
|
|
712
|
-
### `WorldDomain`
|
|
713
|
-
|
|
714
|
-
Available from `client.currentShip()`, `client.overworld()`, and
|
|
715
|
-
`client.world(id)`.
|
|
716
|
-
|
|
717
|
-
```ts
|
|
718
|
-
interface WorldDomain {
|
|
719
|
-
id: number | null;
|
|
720
|
-
entities: EntityCollection;
|
|
721
|
-
machines: MachineCollection;
|
|
722
|
-
players: PlayerCollection;
|
|
723
|
-
blocks: BlockCollection;
|
|
724
|
-
materials: MaterialCollection;
|
|
725
|
-
exists(): boolean;
|
|
726
|
-
snapshot(options?: { includeTiles?: boolean; includeModel?: boolean }): WorldSnapshot | null;
|
|
727
|
-
}
|
|
728
|
-
```
|
|
729
|
-
|
|
730
|
-
### `ShipDomain`
|
|
731
|
-
|
|
732
|
-
```ts
|
|
733
|
-
interface ShipDomain extends WorldDomain {
|
|
734
|
-
metadata: ShipWorldMetadataSummary | null;
|
|
735
|
-
entity(): EntityHandle | null;
|
|
736
|
-
overworldEntity: EntityHandle | null;
|
|
737
|
-
}
|
|
738
|
-
```
|
|
739
|
-
|
|
740
|
-
`entity()` returns the current ship's overworld entity handle, not a ship-world
|
|
741
|
-
placed entity.
|
|
742
|
-
|
|
743
|
-
### `OverworldDomain`
|
|
744
|
-
|
|
745
|
-
```ts
|
|
746
|
-
interface OverworldDomain extends WorldDomain {
|
|
747
|
-
ships(options?: ShipReadOptions): ShipHandle[];
|
|
748
|
-
shipByHex(hexCode: string, options?: ShipReadOptions): ShipHandle | null;
|
|
749
|
-
shipByEntity(entity: number | EntityHandle | EntitySummary, options?: ShipReadOptions): ShipHandle | null;
|
|
750
|
-
}
|
|
751
|
-
```
|
|
752
|
-
|
|
753
|
-
Ship read options:
|
|
754
|
-
|
|
755
|
-
```ts
|
|
756
|
-
interface ShipReadOptions {
|
|
757
|
-
includeWorld?: boolean;
|
|
758
|
-
includeTiles?: boolean;
|
|
759
|
-
includeModel?: boolean;
|
|
760
|
-
sort?: "distance" | null;
|
|
761
|
-
}
|
|
762
|
-
```
|
|
763
|
-
|
|
764
|
-
## Entity API
|
|
765
|
-
|
|
766
|
-
Entity ids are scoped to their world. Overworld entities and ship-world entities
|
|
767
|
-
do not share one global id pool.
|
|
768
|
-
|
|
769
|
-
### `EntityCollection`
|
|
770
|
-
|
|
771
|
-
```ts
|
|
772
|
-
interface EntityCollection {
|
|
773
|
-
all(): EntityHandle[];
|
|
774
|
-
snapshots(): EntitySnapshot[];
|
|
775
|
-
states(): EntitySnapshot[];
|
|
776
|
-
raw(): EntitySummary[];
|
|
777
|
-
get(entity: number | EntityHandle | EntitySummary): EntityHandle;
|
|
778
|
-
}
|
|
779
|
-
```
|
|
780
|
-
|
|
781
|
-
Use:
|
|
782
|
-
|
|
783
|
-
```js
|
|
784
|
-
const shipEntity = client.currentShip().entities.get(14);
|
|
785
|
-
const overworldEntity = client.overworld().entities.get(2495754);
|
|
786
|
-
```
|
|
787
|
-
|
|
788
|
-
Costs:
|
|
789
|
-
|
|
790
|
-
```txt
|
|
791
|
-
all() -> creates lightweight handles
|
|
792
|
-
raw() -> returns current summary objects
|
|
793
|
-
snapshots() -> clones and freezes summaries
|
|
794
|
-
states() -> alias of snapshots()
|
|
795
|
-
get(id) -> creates one lightweight handle
|
|
796
|
-
```
|
|
797
|
-
|
|
798
|
-
### `EntityHandle`
|
|
799
|
-
|
|
800
|
-
```ts
|
|
801
|
-
interface EntityHandle {
|
|
802
|
-
/** @deprecated Use id. */
|
|
803
|
-
entity: number;
|
|
804
|
-
id: number;
|
|
805
|
-
position: TransformSummary | null;
|
|
806
|
-
health: HealthSummary | null;
|
|
807
|
-
contents: EntityContentsSummary | null;
|
|
808
|
-
exists(): boolean;
|
|
809
|
-
snapshot(): EntitySnapshot | null;
|
|
810
|
-
is(type: EntityTypeName): boolean;
|
|
811
|
-
has(feature: EntityFeatureName): boolean;
|
|
812
|
-
feature(feature: EntityFeatureName): unknown | null;
|
|
813
|
-
as(type: EntityTypeName): MachineHandle | null;
|
|
814
|
-
asLoader(): LoaderHandle | null;
|
|
815
|
-
asPusher(): PusherHandle | null;
|
|
816
|
-
asLauncher(): LauncherHandle | null;
|
|
817
|
-
asNavigationUnit(): NavigationUnitHandle | null;
|
|
818
|
-
asCommsStation(): CommsStationHandle | null;
|
|
819
|
-
asSign(): SignHandle | null;
|
|
820
|
-
asGenerator(): GeneratorHandle | null;
|
|
821
|
-
asCargoHatch(): CargoHatchHandle | null;
|
|
822
|
-
asCannon(): CannonHandle | null;
|
|
823
|
-
asThruster(): ThrusterHandle | null;
|
|
824
|
-
asHelm(): HelmHandle | null;
|
|
825
|
-
asDoor(): DoorHandle | null;
|
|
826
|
-
asSpawnPoint(): SpawnPointHandle | null;
|
|
827
|
-
asShieldProjector(): ShieldProjectorHandle | null;
|
|
828
|
-
asFluidTank(): FluidTankHandle | null;
|
|
829
|
-
asCargoEjector(): CargoEjectorHandle | null;
|
|
830
|
-
asExpandoBox(): ExpandoBoxHandle | null;
|
|
831
|
-
use(options?: { invSlot?: number; hold?: boolean }, command?: Command): DredlessClient;
|
|
832
|
-
}
|
|
833
|
-
```
|
|
834
|
-
|
|
835
|
-
### `EntitySnapshot`
|
|
836
|
-
|
|
837
|
-
Frozen point-in-time entity read.
|
|
838
|
-
|
|
839
|
-
```ts
|
|
840
|
-
interface EntitySnapshot extends EntitySummary {
|
|
841
|
-
id: number;
|
|
842
|
-
position: TransformSummary | null;
|
|
843
|
-
rotation: number | null;
|
|
844
|
-
type: EntitySnapshotType;
|
|
845
|
-
is(type: EntityTypeName): boolean;
|
|
846
|
-
has(feature: EntityFeatureName): boolean;
|
|
847
|
-
feature(feature: EntityFeatureName): unknown | null;
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
interface EntitySnapshotType {
|
|
851
|
-
category: EntitySummary["category"] | null;
|
|
852
|
-
machine: string | null;
|
|
853
|
-
item: string | null;
|
|
854
|
-
components: string[];
|
|
855
|
-
}
|
|
856
|
-
```
|
|
857
|
-
|
|
858
|
-
### `EntitySummary`
|
|
859
|
-
|
|
860
|
-
Raw normalized entity shape.
|
|
861
|
-
|
|
862
|
-
```ts
|
|
863
|
-
interface EntitySummary {
|
|
864
|
-
entity: number;
|
|
865
|
-
category:
|
|
866
|
-
| "placed_entity"
|
|
867
|
-
| "loose_item"
|
|
868
|
-
| "untyped_holder"
|
|
869
|
-
| "metadata"
|
|
870
|
-
| "player"
|
|
871
|
-
| "ship_control"
|
|
872
|
-
| "blueprint_preview"
|
|
873
|
-
| "entity";
|
|
874
|
-
typeId: number | null;
|
|
875
|
-
typeName: string | null;
|
|
876
|
-
markerTypeId: number | null;
|
|
877
|
-
markerTypeName: string | null;
|
|
878
|
-
label: string;
|
|
879
|
-
kind: string[];
|
|
880
|
-
transform: TransformSummary | null;
|
|
881
|
-
footprint: {
|
|
882
|
-
width: number;
|
|
883
|
-
height: number;
|
|
884
|
-
source:
|
|
885
|
-
| "type"
|
|
886
|
-
| "marker"
|
|
887
|
-
| "heuristic"
|
|
888
|
-
| "default"
|
|
889
|
-
| "crate"
|
|
890
|
-
| "huge_thruster"
|
|
891
|
-
| "hover_outline";
|
|
892
|
-
};
|
|
893
|
-
contents: EntityContentsSummary | null;
|
|
894
|
-
occupies: { x: number; y: number }[];
|
|
895
|
-
tables: { tableId: number; name: string | null; record: ModelRecord }[];
|
|
896
|
-
}
|
|
897
|
-
```
|
|
898
|
-
|
|
899
|
-
### `EntityContentsSummary`
|
|
900
|
-
|
|
901
|
-
Feature/component container for an entity.
|
|
902
|
-
|
|
903
|
-
```ts
|
|
904
|
-
interface EntityContentsSummary {
|
|
905
|
-
itemHolder?: ItemHolderSummary;
|
|
906
|
-
expandoBox?: ExpandoBoxSummary;
|
|
907
|
-
hoverOutline?: HoverOutlineSummary;
|
|
908
|
-
mapMarker?: MapMarkerSummary;
|
|
909
|
-
dockingSpring?: DockingSpringSummary;
|
|
910
|
-
hugeThruster?: HugeThrusterSummary;
|
|
911
|
-
blueprintPreview?: BlueprintPreviewSummary;
|
|
912
|
-
itemCrate?: ItemCrateSummary;
|
|
913
|
-
health?: HealthSummary;
|
|
914
|
-
bot?: BotSummary;
|
|
915
|
-
fabricator?: FabricatorSummary;
|
|
916
|
-
cargoEjector?: CargoEjectorSummary;
|
|
917
|
-
cannon?: CannonSummary;
|
|
918
|
-
thruster?: ThrusterSummary;
|
|
919
|
-
pusher?: PusherSummary;
|
|
920
|
-
pusherBeam?: PusherBeamSummary;
|
|
921
|
-
launcher?: LauncherSummary;
|
|
922
|
-
loader?: LoaderSummary;
|
|
923
|
-
cargoHatch?: CargoHatchSummary;
|
|
924
|
-
navigationUnit?: NavigationUnitSummary;
|
|
925
|
-
commsStation?: CommsStationSummary;
|
|
926
|
-
fluidTank?: FluidTankSummary;
|
|
927
|
-
shieldGenerator?: ShieldGeneratorSummary;
|
|
928
|
-
shieldProjector?: ShieldProjectorSummary;
|
|
929
|
-
helm?: HelmSummary;
|
|
930
|
-
player?: PlayerSummary;
|
|
931
|
-
shipControl?: ShipControlSummary;
|
|
932
|
-
sign?: SignSummary;
|
|
933
|
-
spawnPoint?: SpawnPointSummary;
|
|
934
|
-
door?: DoorSummary;
|
|
935
|
-
shipSize?: ShipSizeSummary;
|
|
936
|
-
}
|
|
937
|
-
```
|
|
938
|
-
|
|
939
|
-
Feature lookup accepts the canonical component names above and selected aliases
|
|
940
|
-
such as `outline`, `beam`, `inventory`, `filter`, `filterMode`, `filterSlots`,
|
|
941
|
-
`occupied`, `mapMarker`, and `blueprint`.
|
|
942
|
-
|
|
943
|
-
## Machine API
|
|
944
|
-
|
|
945
|
-
### `MachineCollection`
|
|
946
|
-
|
|
947
|
-
```ts
|
|
948
|
-
interface MachineCollection {
|
|
949
|
-
state(): MachineSummary;
|
|
950
|
-
raw(): MachineSummary;
|
|
951
|
-
loaders(): LoaderHandle[];
|
|
952
|
-
loader(entity: number | EntityHandle | EntitySummary): LoaderHandle;
|
|
953
|
-
pushers(): PusherHandle[];
|
|
954
|
-
pusher(entity: number | EntityHandle | EntitySummary): PusherHandle;
|
|
955
|
-
launchers(): LauncherHandle[];
|
|
956
|
-
launcher(entity: number | EntityHandle | EntitySummary): LauncherHandle;
|
|
957
|
-
navigationUnits(): NavigationUnitHandle[];
|
|
958
|
-
navigationUnit(entity?: number | EntityHandle | EntitySummary | null): NavigationUnitHandle | null;
|
|
959
|
-
fabricators(): FabricatorHandle[];
|
|
960
|
-
fabricator(entity: number | EntityHandle | EntitySummary): FabricatorHandle;
|
|
961
|
-
commsStations(): CommsStationHandle[];
|
|
962
|
-
commsStation(entity?: number | EntityHandle | EntitySummary | null): CommsStationHandle | null;
|
|
963
|
-
signs(): SignHandle[];
|
|
964
|
-
sign(entity: number | EntityHandle | EntitySummary): SignHandle;
|
|
965
|
-
generators(): GeneratorHandle[];
|
|
966
|
-
generator(entity: number | EntityHandle | EntitySummary): GeneratorHandle;
|
|
967
|
-
cargoHatches(): CargoHatchHandle[];
|
|
968
|
-
cargoHatch(entity: number | EntityHandle | EntitySummary): CargoHatchHandle;
|
|
969
|
-
cargoEjectors(): CargoEjectorHandle[];
|
|
970
|
-
cargoEjector(entity: number | EntityHandle | EntitySummary): CargoEjectorHandle;
|
|
971
|
-
cannons(): CannonHandle[];
|
|
972
|
-
cannon(entity: number | EntityHandle | EntitySummary): CannonHandle;
|
|
973
|
-
thrusters(): ThrusterHandle[];
|
|
974
|
-
thruster(entity: number | EntityHandle | EntitySummary): ThrusterHandle;
|
|
975
|
-
helms(): HelmHandle[];
|
|
976
|
-
helm(entity: number | EntityHandle | EntitySummary): HelmHandle;
|
|
977
|
-
doors(): DoorHandle[];
|
|
978
|
-
door(entity: number | EntityHandle | EntitySummary): DoorHandle;
|
|
979
|
-
spawnPoints(): SpawnPointHandle[];
|
|
980
|
-
spawnPoint(entity: number | EntityHandle | EntitySummary): SpawnPointHandle;
|
|
981
|
-
shieldProjectors(): ShieldProjectorHandle[];
|
|
982
|
-
shieldProjector(entity: number | EntityHandle | EntitySummary): ShieldProjectorHandle;
|
|
983
|
-
fluidTanks(): FluidTankHandle[];
|
|
984
|
-
fluidTank(entity: number | EntityHandle | EntitySummary): FluidTankHandle;
|
|
985
|
-
expandoBoxes(): ExpandoBoxHandle[];
|
|
986
|
-
expandoBox(entity: number | EntityHandle | EntitySummary): ExpandoBoxHandle;
|
|
987
|
-
}
|
|
988
|
-
```
|
|
989
|
-
|
|
990
|
-
### `MachineSummary`
|
|
991
|
-
|
|
992
|
-
Grouped machine/component state.
|
|
993
|
-
|
|
994
|
-
```ts
|
|
995
|
-
interface MachineSummary {
|
|
996
|
-
itemHolders: ItemHolderSummary[];
|
|
997
|
-
health: HealthSummary[];
|
|
998
|
-
fabricators: FabricatorSummary[];
|
|
999
|
-
cargoEjectors: CargoEjectorSummary[];
|
|
1000
|
-
cannons: CannonSummary[];
|
|
1001
|
-
thrusters: ThrusterSummary[];
|
|
1002
|
-
pushers: PusherSummary[];
|
|
1003
|
-
pusherBeams: PusherBeamSummary[];
|
|
1004
|
-
launchers: LauncherSummary[];
|
|
1005
|
-
loaders: LoaderSummary[];
|
|
1006
|
-
cargoHatches: CargoHatchSummary[];
|
|
1007
|
-
navigationUnits: NavigationUnitSummary[];
|
|
1008
|
-
commsStations: CommsStationSummary[];
|
|
1009
|
-
fluidTanks: FluidTankSummary[];
|
|
1010
|
-
shieldGenerators: ShieldGeneratorSummary[];
|
|
1011
|
-
shieldProjectors: ShieldProjectorSummary[];
|
|
1012
|
-
helms: HelmSummary[];
|
|
1013
|
-
signs: SignSummary[];
|
|
1014
|
-
spawnPoints: SpawnPointSummary[];
|
|
1015
|
-
doors: DoorSummary[];
|
|
1016
|
-
expandoBoxes: ExpandoBoxSummary[];
|
|
1017
|
-
}
|
|
1018
|
-
```
|
|
1019
|
-
|
|
1020
|
-
### Common machine handle
|
|
1021
|
-
|
|
1022
|
-
```ts
|
|
1023
|
-
interface MachineHandle extends EntityHandle {
|
|
1024
|
-
open(options?: { invSlot?: number; hold?: boolean }, command?: Command): DredlessClient;
|
|
1025
|
-
}
|
|
1026
|
-
```
|
|
1027
|
-
|
|
1028
|
-
`open()` focuses/uses the entity through the player command path.
|
|
1029
|
-
|
|
1030
|
-
### `LoaderHandle`
|
|
1031
|
-
|
|
1032
|
-
```ts
|
|
1033
|
-
interface LoaderHandle extends MachineHandle {
|
|
1034
|
-
state: LoaderSummary | null;
|
|
1035
|
-
configure(config?: LoaderConfig): DredlessClient;
|
|
1036
|
-
configureFull(config?: LoaderFullConfig): DredlessClient;
|
|
1037
|
-
copy(config?: LoaderFullConfig): DredlessClient;
|
|
1038
|
-
setPickPlace(pick: LoaderPosition, place: LoaderPosition, config?: LoaderConfig): DredlessClient;
|
|
1039
|
-
setPriority(priority: LoaderPriority, config?: LoaderConfig): DredlessClient;
|
|
1040
|
-
setStack(stack: number, config?: LoaderConfig): DredlessClient;
|
|
1041
|
-
setCycle(cycle: number, config?: LoaderConfig): DredlessClient;
|
|
1042
|
-
setRequireOutput(requireOutput: boolean, config?: LoaderConfig): DredlessClient;
|
|
1043
|
-
setWaitForStack(waitForStack: boolean, config?: LoaderConfig): DredlessClient;
|
|
1044
|
-
setFilterMode(filterMode: LoaderFilterMode): DredlessClient;
|
|
1045
|
-
setFilterItems(filterSlots?: Array<number | null | undefined>): DredlessClient;
|
|
1046
|
-
pick: number | undefined;
|
|
1047
|
-
place: number | undefined;
|
|
1048
|
-
priority: number | undefined;
|
|
1049
|
-
stack: number | undefined;
|
|
1050
|
-
cycle: number | undefined;
|
|
1051
|
-
requireOutput: boolean | undefined;
|
|
1052
|
-
waitForStack: boolean | undefined;
|
|
1053
|
-
filterMode: number | undefined;
|
|
1054
|
-
filterSlots: Array<number | null>;
|
|
1055
|
-
}
|
|
1056
|
-
```
|
|
1057
|
-
|
|
1058
|
-
Config inputs:
|
|
1059
|
-
|
|
1060
|
-
```ts
|
|
1061
|
-
const LoaderPosition = { TopLeft: "top-left", TopMiddle: "top-middle", TopRight: "top-right", MiddleLeft: "middle-left", MiddleRight: "middle-right", BottomLeft: "bottom-left", BottomMiddle: "bottom-middle", BottomRight: "bottom-right" } as const;
|
|
1062
|
-
type LoaderPosition = typeof LoaderPosition[keyof typeof LoaderPosition];
|
|
1063
|
-
|
|
1064
|
-
const LoaderPriority = { Low: "low", Normal: "normal", High: "high" } as const;
|
|
1065
|
-
type LoaderPriority = typeof LoaderPriority[keyof typeof LoaderPriority];
|
|
1066
|
-
|
|
1067
|
-
const LoaderFilterMode = { AllowAll: "allow-all", BlockFilter: "block-filter", AllowFilter: "allow-filter", BlockAll: "block-all" } as const;
|
|
1068
|
-
type LoaderFilterMode = typeof LoaderFilterMode[keyof typeof LoaderFilterMode];
|
|
1069
|
-
|
|
1070
|
-
interface LoaderConfig {
|
|
1071
|
-
pick?: LoaderPosition;
|
|
1072
|
-
place?: LoaderPosition;
|
|
1073
|
-
priority?: LoaderPriority;
|
|
1074
|
-
stack?: number;
|
|
1075
|
-
cycle?: number;
|
|
1076
|
-
requireOutput?: boolean;
|
|
1077
|
-
waitForStack?: boolean;
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
interface LoaderFullConfig extends LoaderConfig {
|
|
1081
|
-
filterMode?: LoaderFilterMode;
|
|
1082
|
-
filterSlots?: Array<number | null | undefined>;
|
|
1083
|
-
}
|
|
1084
|
-
```
|
|
1085
|
-
|
|
1086
|
-
State output:
|
|
1087
|
-
|
|
1088
|
-
Loader state uses the official component defaults when configuration fields
|
|
1089
|
-
are omitted: pick `3` (middle-left), place `4` (middle-right), normal priority,
|
|
1090
|
-
stack `16`, cycle `1` second, and both flags disabled. Cycle times are converted
|
|
1091
|
-
from ticks at 20 ticks per second. Flag updates set their absolute boolean
|
|
1092
|
-
values; repeated updates do not toggle them. Raw loader configuration is stored
|
|
1093
|
-
in model table `69` (wire section `162`), separately from navigation state.
|
|
1094
|
-
|
|
1095
|
-
```ts
|
|
1096
|
-
interface LoaderSummary {
|
|
1097
|
-
entity: number;
|
|
1098
|
-
pick: number | null;
|
|
1099
|
-
pickName: string | null;
|
|
1100
|
-
place: number | null;
|
|
1101
|
-
placeName: string | null;
|
|
1102
|
-
priority: number | null;
|
|
1103
|
-
priorityName: string | null;
|
|
1104
|
-
requireOutput: boolean | null;
|
|
1105
|
-
waitForStack: boolean | null;
|
|
1106
|
-
stack: number | null;
|
|
1107
|
-
cycle: number | null;
|
|
1108
|
-
filterMode: number | null;
|
|
1109
|
-
filterModeName: string | null;
|
|
1110
|
-
filterSlots: (number | null)[] | null;
|
|
1111
|
-
heldItemId: number | null;
|
|
1112
|
-
heldItemName: string | null;
|
|
1113
|
-
heldCount: number | null;
|
|
1114
|
-
active: boolean;
|
|
1115
|
-
progress: number | null;
|
|
1116
|
-
state: ModelRecord;
|
|
1117
|
-
filterState: ModelRecord;
|
|
1118
|
-
filterSlotsState: ModelRecord;
|
|
1119
|
-
}
|
|
1120
|
-
```
|
|
1121
|
-
|
|
1122
|
-
### `PusherHandle`
|
|
1123
|
-
|
|
1124
|
-
```ts
|
|
1125
|
-
interface PusherHandle extends MachineHandle {
|
|
1126
|
-
state: PusherSummary | null;
|
|
1127
|
-
beam: PusherBeamSummary | null;
|
|
1128
|
-
configure(config?: PusherConfig): DredlessClient;
|
|
1129
|
-
setAngle(angle: number, config?: PusherConfig): DredlessClient;
|
|
1130
|
-
setSpeed(speed: number, config?: PusherConfig): DredlessClient;
|
|
1131
|
-
setLength(length: number, config?: PusherConfig): DredlessClient;
|
|
1132
|
-
setMode(mode: PusherMode, config?: PusherConfig): DredlessClient;
|
|
1133
|
-
setFilteredMode(mode: PusherMode, config?: PusherConfig): DredlessClient;
|
|
1134
|
-
setFilterInventory(filterInventory: boolean, config?: PusherConfig): DredlessClient;
|
|
1135
|
-
setFilterItems(filterSlots?: Array<number | null | undefined>): DredlessClient;
|
|
1136
|
-
angle: number | undefined;
|
|
1137
|
-
speed: number | undefined;
|
|
1138
|
-
length: number | undefined;
|
|
1139
|
-
mode: number | undefined;
|
|
1140
|
-
filteredMode: number | undefined;
|
|
1141
|
-
}
|
|
1142
|
-
```
|
|
1143
|
-
|
|
1144
|
-
Config input:
|
|
1145
|
-
|
|
1146
|
-
```ts
|
|
1147
|
-
const PusherMode = { Push: "push", Pull: "pull", DoNothing: "do-nothing" } as const;
|
|
1148
|
-
type PusherMode = typeof PusherMode[keyof typeof PusherMode];
|
|
1149
|
-
|
|
1150
|
-
interface PusherConfig {
|
|
1151
|
-
mode?: PusherMode;
|
|
1152
|
-
filteredMode?: PusherMode;
|
|
1153
|
-
angle?: number;
|
|
1154
|
-
speed?: number;
|
|
1155
|
-
filterInventory?: boolean;
|
|
1156
|
-
length?: number;
|
|
1157
|
-
}
|
|
1158
|
-
```
|
|
1159
|
-
|
|
1160
|
-
State output:
|
|
1161
|
-
|
|
1162
|
-
```ts
|
|
1163
|
-
interface PusherSummary {
|
|
1164
|
-
entity: number;
|
|
1165
|
-
mode: number;
|
|
1166
|
-
modeName: string | null;
|
|
1167
|
-
filteredMode: number;
|
|
1168
|
-
filteredModeName: string | null;
|
|
1169
|
-
angle: number | null;
|
|
1170
|
-
speed: number;
|
|
1171
|
-
length: number;
|
|
1172
|
-
filterInventory: boolean;
|
|
1173
|
-
filterSlots: (number | null)[] | null;
|
|
1174
|
-
state: ModelRecord;
|
|
1175
|
-
filterSlotsState: ModelRecord;
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
interface PusherBeamSummary {
|
|
1179
|
-
entity: number;
|
|
1180
|
-
active: boolean;
|
|
1181
|
-
mode: number;
|
|
1182
|
-
modeName: string | null;
|
|
1183
|
-
lengthRaw: number;
|
|
1184
|
-
length: number;
|
|
1185
|
-
state: ModelRecord;
|
|
1186
|
-
}
|
|
1187
|
-
```
|
|
1188
|
-
|
|
1189
|
-
Pusher beams are associated with the same entity as their parent pusher, exposed
|
|
1190
|
-
as `pusher.beam`, `entity.feature("beam")`, and `machines.state().pusherBeams`.
|
|
1191
|
-
|
|
1192
|
-
### `LauncherHandle`
|
|
1193
|
-
|
|
1194
|
-
```ts
|
|
1195
|
-
interface LauncherHandle extends MachineHandle {
|
|
1196
|
-
state: LauncherSummary | null;
|
|
1197
|
-
setAngle(angle: number): DredlessClient;
|
|
1198
|
-
setPower(power: number): DredlessClient;
|
|
1199
|
-
angleDegrees: number | undefined;
|
|
1200
|
-
angleRadians: number | undefined;
|
|
1201
|
-
angleRaw: number | null | undefined;
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
interface LauncherSummary {
|
|
1205
|
-
entity: number;
|
|
1206
|
-
angleRaw: number | null;
|
|
1207
|
-
angleRadians: number | null;
|
|
1208
|
-
angleDegrees: number | null;
|
|
1209
|
-
state: ModelRecord;
|
|
1210
|
-
}
|
|
1211
|
-
```
|
|
1212
|
-
|
|
1213
|
-
Launcher power may not be present until the relevant UI has exposed it.
|
|
1214
|
-
|
|
1215
|
-
### `NavigationUnitHandle`
|
|
1216
|
-
|
|
1217
|
-
```ts
|
|
1218
|
-
interface NavigationUnitHandle extends MachineHandle {
|
|
1219
|
-
state: NavigationUnitSummary | null;
|
|
1220
|
-
configure(config?: NavigationUnitConfig): DredlessClient;
|
|
1221
|
-
copy(config?: NavigationUnitConfig): DredlessClient;
|
|
1222
|
-
paste(config?: NavigationUnitConfig): DredlessClient;
|
|
1223
|
-
setDestination(destination: number, config?: NavigationUnitConfig): DredlessClient;
|
|
1224
|
-
setAutoWarp(config?: NavigationUnitConfig): DredlessClient;
|
|
1225
|
-
startWarp(config?: NavigationUnitConfig): DredlessClient;
|
|
1226
|
-
cancelWarp(config?: NavigationUnitConfig): DredlessClient;
|
|
1227
|
-
destination: number | undefined;
|
|
1228
|
-
autoWarpOnShieldFailure: boolean | undefined;
|
|
1229
|
-
autoWarpOnNoCaptains: boolean | undefined;
|
|
1230
|
-
warp: string | undefined;
|
|
1231
|
-
}
|
|
1232
|
-
```
|
|
1233
|
-
|
|
1234
|
-
Config and state:
|
|
1235
|
-
|
|
1236
|
-
```ts
|
|
1237
|
-
interface NavigationUnitConfig {
|
|
1238
|
-
destination?: number;
|
|
1239
|
-
page?: number;
|
|
1240
|
-
warp?: boolean | "start" | "idle" | "cancel";
|
|
1241
|
-
autoWarpOnShieldFailure?: boolean;
|
|
1242
|
-
autoWarpOnNoCaptains?: boolean;
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
interface NavigationUnitSummary {
|
|
1246
|
-
entity: number;
|
|
1247
|
-
destination: number;
|
|
1248
|
-
destinationName: string | null;
|
|
1249
|
-
autoWarpOnShieldFailure: boolean | null;
|
|
1250
|
-
autoWarpOnNoCaptains: boolean | null;
|
|
1251
|
-
state: ModelRecord;
|
|
1252
|
-
}
|
|
1253
|
-
```
|
|
1254
|
-
|
|
1255
|
-
### `FabricatorHandle`
|
|
1256
|
-
|
|
1257
|
-
```ts
|
|
1258
|
-
interface FabricatorHandle extends MachineHandle {
|
|
1259
|
-
state: FabricatorSummary | null;
|
|
1260
|
-
panel(): PuiEvent | null;
|
|
1261
|
-
add(itemId: number, count?: number, index?: number): DredlessClient;
|
|
1262
|
-
sub(itemId: number, count?: number, index?: number): DredlessClient;
|
|
1263
|
-
clearQueue(): DredlessClient;
|
|
1264
|
-
toggleRepeat(): DredlessClient;
|
|
1265
|
-
lockResource(row: number): DredlessClient;
|
|
1266
|
-
unlockResource(row: number): DredlessClient;
|
|
1267
|
-
eject(row: number): DredlessClient;
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
const FabricatorType = { Starter: "starter", Munitions: "munitions", Engineering: "engineering", Equipment: "equipment" } as const;
|
|
1271
|
-
type FabricatorType = typeof FabricatorType[keyof typeof FabricatorType];
|
|
1272
|
-
|
|
1273
|
-
interface FabricatorSummary {
|
|
1274
|
-
entity: number;
|
|
1275
|
-
type: FabricatorType | null;
|
|
1276
|
-
typeIndex: number | null;
|
|
1277
|
-
state: ModelRecord;
|
|
1278
|
-
rows: { itemId: number | null; itemName: string | null; count: number | null }[];
|
|
1279
|
-
progress: number | null;
|
|
1280
|
-
progressRaw: number | null;
|
|
1281
|
-
active: boolean;
|
|
1282
|
-
craftingItemId: number | null;
|
|
1283
|
-
craftingItemName: string | null;
|
|
1284
|
-
craftingCount: number | null;
|
|
1285
|
-
}
|
|
1286
|
-
```
|
|
1287
|
-
|
|
1288
|
-
### `CommsStationHandle`
|
|
1289
|
-
|
|
1290
|
-
```ts
|
|
1291
|
-
interface CommsStationHandle extends MachineHandle {
|
|
1292
|
-
state: CommsStationSummary | null;
|
|
1293
|
-
panel(): CommsEvent | null;
|
|
1294
|
-
sendMessage(message?: string): DredlessClient;
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
|
-
interface CommsStationSummary {
|
|
1298
|
-
entity: number;
|
|
1299
|
-
typeId: number;
|
|
1300
|
-
typeName: string | null;
|
|
1301
|
-
charges: number | null;
|
|
1302
|
-
maxCharges: number;
|
|
1303
|
-
chargeRatio: number | null;
|
|
1304
|
-
occupied: boolean;
|
|
1305
|
-
state: ModelRecord;
|
|
1306
|
-
}
|
|
1307
|
-
```
|
|
1308
|
-
|
|
1309
|
-
### `SignHandle`
|
|
1310
|
-
|
|
1311
|
-
```ts
|
|
1312
|
-
interface SignHandle extends MachineHandle {
|
|
1313
|
-
state: SignSummary | null;
|
|
1314
|
-
setText(text?: string, mode?: SignDisplayMode): DredlessClient;
|
|
1315
|
-
text: string | undefined;
|
|
1316
|
-
mode: number | undefined;
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
const SignDisplayMode = { Always: "always", WhenNear: "when-near", OnHover: "on-hover" } as const;
|
|
1320
|
-
type SignDisplayMode = typeof SignDisplayMode[keyof typeof SignDisplayMode];
|
|
1321
|
-
|
|
1322
|
-
interface SignSummary {
|
|
1323
|
-
entity: number;
|
|
1324
|
-
text: string;
|
|
1325
|
-
displayMode: number;
|
|
1326
|
-
displayModeName: string | null;
|
|
1327
|
-
state: ModelRecord;
|
|
1328
|
-
}
|
|
1329
|
-
```
|
|
1330
|
-
|
|
1331
|
-
### `GeneratorHandle`
|
|
1332
|
-
|
|
1333
|
-
```ts
|
|
1334
|
-
interface GeneratorHandle extends MachineHandle {
|
|
1335
|
-
state: ShieldGeneratorSummary | null;
|
|
1336
|
-
solvePuzzle(solution: string | number): DredlessClient;
|
|
1337
|
-
}
|
|
37
|
+
Signature blocks show how to call the API, using TypeScript notation for optional arguments and return values. They are
|
|
38
|
+
reference notation, not JavaScript programs to paste into an application. Examples labeled **fragment** require
|
|
39
|
+
variables established in a setup guide.
|
|
1338
40
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
storedItemName: string | null;
|
|
1348
|
-
storedItemCount: number | null;
|
|
1349
|
-
hasShieldCore: boolean;
|
|
1350
|
-
boostState: number;
|
|
1351
|
-
boostStateName: string | null;
|
|
1352
|
-
boostTimer: number;
|
|
1353
|
-
boostActive: boolean;
|
|
1354
|
-
puzzleSeed: number | null;
|
|
1355
|
-
puzzleSolution: string | null;
|
|
1356
|
-
state: ModelRecord;
|
|
1357
|
-
itemState: ModelRecord;
|
|
1358
|
-
boostStateRaw: ModelRecord;
|
|
1359
|
-
}
|
|
1360
|
-
```
|
|
1361
|
-
|
|
1362
|
-
### `CargoHatchHandle`
|
|
1363
|
-
|
|
1364
|
-
```ts
|
|
1365
|
-
interface CargoHatchHandle extends MachineHandle {
|
|
1366
|
-
state: CargoHatchSummary | null;
|
|
1367
|
-
configure(config?: Pick<LoaderFullConfig, "filterMode" | "filterSlots">): DredlessClient;
|
|
1368
|
-
copy(config?: Pick<LoaderFullConfig, "filterMode" | "filterSlots">): DredlessClient;
|
|
1369
|
-
paste(config?: Pick<LoaderFullConfig, "filterMode" | "filterSlots">): DredlessClient;
|
|
1370
|
-
setFilterMode(filterMode: LoaderFilterMode): DredlessClient;
|
|
1371
|
-
setFilterItems(filterSlots?: Array<number | null | undefined>): DredlessClient;
|
|
1372
|
-
}
|
|
1373
|
-
|
|
1374
|
-
interface CargoHatchSummary {
|
|
1375
|
-
entity: number;
|
|
1376
|
-
typeId: number;
|
|
1377
|
-
typeName: string | null;
|
|
1378
|
-
filterMode: number;
|
|
1379
|
-
filterModeName: string | null;
|
|
1380
|
-
filterSlots: (number | null)[] | null;
|
|
1381
|
-
openFraction: number | null;
|
|
1382
|
-
filterState: ModelRecord;
|
|
1383
|
-
filterSlotsState: ModelRecord;
|
|
1384
|
-
}
|
|
1385
|
-
```
|
|
1386
|
-
|
|
1387
|
-
### Other machine handles
|
|
1388
|
-
|
|
1389
|
-
```ts
|
|
1390
|
-
interface CannonHandle extends MachineHandle {
|
|
1391
|
-
state: CannonSummary | null;
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
interface ThrusterHandle extends MachineHandle {
|
|
1395
|
-
state: ThrusterSummary | null;
|
|
1396
|
-
}
|
|
1397
|
-
|
|
1398
|
-
interface HelmHandle extends MachineHandle {
|
|
1399
|
-
state: HelmSummary | null;
|
|
1400
|
-
occupied: boolean | undefined;
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
interface DoorHandle extends EntityHandle {
|
|
1404
|
-
state: DoorSummary | null;
|
|
1405
|
-
rank: number | undefined;
|
|
1406
|
-
open: boolean | undefined;
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
interface SpawnPointHandle extends MachineHandle {
|
|
1410
|
-
state: SpawnPointSummary | null;
|
|
1411
|
-
rank: number | undefined;
|
|
1412
|
-
}
|
|
1413
|
-
|
|
1414
|
-
interface ShieldProjectorHandle extends MachineHandle {
|
|
1415
|
-
state: ShieldProjectorSummary | null;
|
|
1416
|
-
active: boolean | undefined;
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
|
-
interface FluidTankHandle extends MachineHandle {
|
|
1420
|
-
state: FluidTankSummary | null;
|
|
1421
|
-
amount: number | null | undefined;
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
interface ExpandoBoxHandle extends MachineHandle {
|
|
1425
|
-
state: ExpandoBoxSummary | null;
|
|
1426
|
-
item: number | null | undefined;
|
|
1427
|
-
count: number | null | undefined;
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
interface CargoEjectorSummary {
|
|
1431
|
-
entity: number;
|
|
1432
|
-
typeId: number;
|
|
1433
|
-
typeName: string | null;
|
|
1434
|
-
progress: number | null;
|
|
1435
|
-
active: boolean | null;
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
interface CargoEjectorHandle extends MachineHandle {
|
|
1439
|
-
state: CargoEjectorSummary | null;
|
|
1440
|
-
progress: number | null | undefined;
|
|
1441
|
-
active: boolean | null | undefined;
|
|
1442
|
-
setDirection(direction: FixedAngleDirection): DredlessClient;
|
|
1443
|
-
copy(direction?: FixedAngleDirection): DredlessClient;
|
|
1444
|
-
paste(direction?: FixedAngleDirection): DredlessClient;
|
|
1445
|
-
}
|
|
1446
|
-
```
|
|
1447
|
-
|
|
1448
|
-
Associated summary shapes:
|
|
1449
|
-
|
|
1450
|
-
Cannon summaries expose `relativeAngleRadians` relative to the mount and
|
|
1451
|
-
`absoluteAngleRadians` in ship coordinates, normalized to `[0, 2π)`, replacing
|
|
1452
|
-
the raw `aim` field. The relative angle is `null` when aim is unavailable; the
|
|
1453
|
-
absolute angle is `null` when either aim or mounting rotation is unavailable.
|
|
1454
|
-
|
|
1455
|
-
```ts
|
|
1456
|
-
interface CannonSummary {
|
|
1457
|
-
entity: number;
|
|
1458
|
-
typeId: number;
|
|
1459
|
-
typeName: string | null;
|
|
1460
|
-
ammoItemId: number | null;
|
|
1461
|
-
ammoName: string | null;
|
|
1462
|
-
ammoCount: number;
|
|
1463
|
-
relativeAngleRadians: number | null; // Barrel angle relative to its mount.
|
|
1464
|
-
absoluteAngleRadians: number | null; // Ship coordinates, normalized to [0, 2π).
|
|
1465
|
-
recoil: number | null;
|
|
1466
|
-
recoil2: number | null;
|
|
1467
|
-
recoils: [number | null, number | null];
|
|
1468
|
-
charge: number | null;
|
|
1469
|
-
charged: boolean | null;
|
|
1470
|
-
spin: number | null;
|
|
1471
|
-
coolingCellCount: number;
|
|
1472
|
-
state: ModelRecord;
|
|
1473
|
-
}
|
|
1474
|
-
|
|
1475
|
-
interface ThrusterSummary {
|
|
1476
|
-
entity: number;
|
|
1477
|
-
typeId: number;
|
|
1478
|
-
typeName: string | null;
|
|
1479
|
-
facing: number;
|
|
1480
|
-
facingName:
|
|
1481
|
-
| "bottom"
|
|
1482
|
-
| "top"
|
|
1483
|
-
| "right"
|
|
1484
|
-
| "left"
|
|
1485
|
-
| "bottom-right"
|
|
1486
|
-
| "bottom-left"
|
|
1487
|
-
| "top-right"
|
|
1488
|
-
| "top-left"
|
|
1489
|
-
| null;
|
|
1490
|
-
fuel: number | null;
|
|
1491
|
-
state: ModelRecord;
|
|
1492
|
-
}
|
|
1493
|
-
|
|
1494
|
-
interface HelmSummary {
|
|
1495
|
-
entity: number;
|
|
1496
|
-
typeId: number;
|
|
1497
|
-
typeName: string | null;
|
|
1498
|
-
occupied: boolean;
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
interface DoorSummary {
|
|
1502
|
-
entity: number;
|
|
1503
|
-
rank: number;
|
|
1504
|
-
rankName: string | null;
|
|
1505
|
-
open: boolean;
|
|
1506
|
-
rankState: ModelRecord;
|
|
1507
|
-
state: ModelRecord;
|
|
1508
|
-
}
|
|
1509
|
-
|
|
1510
|
-
interface SpawnPointSummary {
|
|
1511
|
-
entity: number;
|
|
1512
|
-
rank: number;
|
|
1513
|
-
rankName: string | null;
|
|
1514
|
-
state: ModelRecord;
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
interface ShieldProjectorSummary {
|
|
1518
|
-
entity: number;
|
|
1519
|
-
active: boolean;
|
|
1520
|
-
state: ModelRecord;
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
interface FluidTankSummary {
|
|
1524
|
-
entity: number;
|
|
1525
|
-
amount: number | null;
|
|
1526
|
-
state: ModelRecord;
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
|
-
interface ExpandoBoxSummary {
|
|
1530
|
-
entity: number;
|
|
1531
|
-
itemId: number | null;
|
|
1532
|
-
itemName: string | null;
|
|
1533
|
-
count: number | null;
|
|
1534
|
-
width: number | null;
|
|
1535
|
-
height: number | null;
|
|
1536
|
-
rawWidth: number | null;
|
|
1537
|
-
rawHeight: number | null;
|
|
1538
|
-
itemState: ModelRecord;
|
|
1539
|
-
sizeState: ModelRecord;
|
|
1540
|
-
}
|
|
1541
|
-
```
|
|
1542
|
-
|
|
1543
|
-
## Ship Reads
|
|
1544
|
-
|
|
1545
|
-
### `ShipHandle`
|
|
1546
|
-
|
|
1547
|
-
Returned by `client.overworld()?.ships()`.
|
|
1548
|
-
|
|
1549
|
-
```ts
|
|
1550
|
-
interface ShipHandle {
|
|
1551
|
-
entity: number;
|
|
1552
|
-
name: string | null;
|
|
1553
|
-
hexCode: string | null;
|
|
1554
|
-
distance: number | null;
|
|
1555
|
-
worldId: number | null;
|
|
1556
|
-
hasWorldData: boolean;
|
|
1557
|
-
world(): WorldDomain | null;
|
|
1558
|
-
snapshot(): ShipReadSummary;
|
|
1559
|
-
}
|
|
1560
|
-
```
|
|
1561
|
-
|
|
1562
|
-
### `ShipReadSummary`
|
|
1563
|
-
|
|
1564
|
-
```ts
|
|
1565
|
-
interface ShipReadSummary {
|
|
1566
|
-
entity: number;
|
|
1567
|
-
name: string | null;
|
|
1568
|
-
hexCode: string | null;
|
|
1569
|
-
color: number | null;
|
|
1570
|
-
colorCss: string | null;
|
|
1571
|
-
position: { x: number | null; y: number | null; rot: number | null } | null;
|
|
1572
|
-
distance: number | null;
|
|
1573
|
-
footprint: EntitySummary["footprint"];
|
|
1574
|
-
label: string;
|
|
1575
|
-
kind: string[];
|
|
1576
|
-
thrust: { x: number | null; y: number | null };
|
|
1577
|
-
shield: ShipShieldSummary | null;
|
|
1578
|
-
warp: ShipWarpSummary | null;
|
|
1579
|
-
worldId: number | null;
|
|
1580
|
-
hasWorldData: boolean;
|
|
1581
|
-
world: WorldSnapshot | null;
|
|
1582
|
-
control: ShipControlSummary;
|
|
1583
|
-
entitySummary: EntitySummary;
|
|
1584
|
-
}
|
|
1585
|
-
```
|
|
1586
|
-
|
|
1587
|
-
### `ShipControlSummary`
|
|
1588
|
-
|
|
1589
|
-
```ts
|
|
1590
|
-
interface ShipControlSummary {
|
|
1591
|
-
entity: number;
|
|
1592
|
-
name: string | null;
|
|
1593
|
-
hexCode: string | null;
|
|
1594
|
-
shipWorldId: number | null;
|
|
1595
|
-
color: number | null;
|
|
1596
|
-
colorCss: string | null;
|
|
1597
|
-
thrustX: number | null;
|
|
1598
|
-
thrustY: number | null;
|
|
1599
|
-
value52: number | null;
|
|
1600
|
-
value84: number | null;
|
|
1601
|
-
value96: number | null;
|
|
1602
|
-
shield: ShipShieldSummary | null;
|
|
1603
|
-
warp: ShipWarpSummary | null;
|
|
1604
|
-
state: ModelRecord;
|
|
1605
|
-
}
|
|
1606
|
-
```
|
|
1607
|
-
|
|
1608
|
-
### Ship shield and warp summaries
|
|
1609
|
-
|
|
1610
|
-
```ts
|
|
1611
|
-
interface ShipShieldSummary {
|
|
1612
|
-
maxHp: number | null;
|
|
1613
|
-
baseHp: number | null;
|
|
1614
|
-
activeTankHp: number | null;
|
|
1615
|
-
inactiveTankHp: number | null;
|
|
1616
|
-
tankValues: number[];
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
interface ShipWarpSummary {
|
|
1620
|
-
active: boolean;
|
|
1621
|
-
ticks: number;
|
|
1622
|
-
elapsedSeconds: number;
|
|
1623
|
-
durationSeconds: number;
|
|
1624
|
-
remainingSeconds: number;
|
|
1625
|
-
}
|
|
1626
|
-
```
|
|
1627
|
-
|
|
1628
|
-
## Player, Blocks, Materials
|
|
1629
|
-
|
|
1630
|
-
```ts
|
|
1631
|
-
interface PlayerCollection {
|
|
1632
|
-
all(): PlayerSummary[];
|
|
1633
|
-
current(): PlayerSummary | null;
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
interface BlockCollection {
|
|
1637
|
-
all(): BlockSummary[];
|
|
1638
|
-
at(x: number, y: number): BlockSummary | null;
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
|
-
interface MaterialCollection {
|
|
1642
|
-
all(): MaterialSummary[];
|
|
1643
|
-
}
|
|
1644
|
-
```
|
|
1645
|
-
|
|
1646
|
-
### `PlayerSummary`
|
|
1647
|
-
|
|
1648
|
-
```ts
|
|
1649
|
-
interface PlayerSummary {
|
|
1650
|
-
entity: number;
|
|
1651
|
-
name: string | null;
|
|
1652
|
-
heldItemId: number | null;
|
|
1653
|
-
heldItemName: string | null;
|
|
1654
|
-
repairTargetDistance: number | null;
|
|
1655
|
-
repairTargetAngle: number | null;
|
|
1656
|
-
shipRank: PlayerShipRank | null;
|
|
1657
|
-
patronTier: "bronze" | "silver" | "gold" | "plat" | "flux" | null;
|
|
1658
|
-
isDeveloper: boolean;
|
|
1659
|
-
isPatron: boolean;
|
|
1660
|
-
piloting: boolean;
|
|
1661
|
-
muted: boolean;
|
|
1662
|
-
actionPreview: PlayerActionPreviewSummary | null;
|
|
1663
|
-
state: ModelRecord;
|
|
1664
|
-
}
|
|
1665
|
-
```
|
|
1666
|
-
|
|
1667
|
-
### `PlayerActionPreviewSummary`
|
|
1668
|
-
|
|
1669
|
-
```ts
|
|
1670
|
-
interface PlayerActionPreviewSummary {
|
|
1671
|
-
entity: number;
|
|
1672
|
-
active: boolean;
|
|
1673
|
-
x: number | null;
|
|
1674
|
-
y: number | null;
|
|
1675
|
-
width: number | null;
|
|
1676
|
-
height: number | null;
|
|
1677
|
-
progress: number | null;
|
|
1678
|
-
color: number | null;
|
|
1679
|
-
colorCss: string | null;
|
|
1680
|
-
actionName: "place" | "break" | "blueprint" | null;
|
|
1681
|
-
blueprintId: number | null;
|
|
1682
|
-
blueprintItems: BlueprintPreviewSummary[];
|
|
1683
|
-
state: ModelRecord;
|
|
1684
|
-
}
|
|
1685
|
-
```
|
|
1686
|
-
|
|
1687
|
-
### `BlockSummary`
|
|
1688
|
-
|
|
1689
|
-
```ts
|
|
1690
|
-
interface BlockSummary {
|
|
1691
|
-
x: number;
|
|
1692
|
-
y: number;
|
|
1693
|
-
entities: EntitySummary[];
|
|
1694
|
-
}
|
|
1695
|
-
```
|
|
1696
|
-
|
|
1697
|
-
### `MaterialSummary`
|
|
1698
|
-
|
|
1699
|
-
```ts
|
|
1700
|
-
interface MaterialSummary {
|
|
1701
|
-
material: number;
|
|
1702
|
-
name: string | null;
|
|
1703
|
-
count: number;
|
|
1704
|
-
solid: boolean | null;
|
|
1705
|
-
hp: number | null;
|
|
1706
|
-
}
|
|
1707
|
-
```
|
|
1708
|
-
|
|
1709
|
-
## World State Classes
|
|
1710
|
-
|
|
1711
|
-
These classes are public mostly for inspection, replay, testing, and lower-level
|
|
1712
|
-
tooling.
|
|
1713
|
-
|
|
1714
|
-
### `WorldStore`
|
|
1715
|
-
|
|
1716
|
-
```ts
|
|
1717
|
-
class WorldStore {
|
|
1718
|
-
currentWorldId: number | null;
|
|
1719
|
-
worlds: Map<number, WorldState>;
|
|
1720
|
-
|
|
1721
|
-
get(id: number): WorldState;
|
|
1722
|
-
apply(packet: unknown): WorldUpdate | null;
|
|
1723
|
-
snapshot(options?: { includeTiles?: boolean; includeModel?: boolean }): WorldSnapshot[];
|
|
1724
|
-
ids(): number[];
|
|
1725
|
-
overworld(): WorldState | null;
|
|
1726
|
-
shipWorld(): WorldState | null;
|
|
1727
|
-
currentShipEntity(): EntitySummary | null;
|
|
1728
|
-
}
|
|
1729
|
-
```
|
|
1730
|
-
|
|
1731
|
-
### `WorldState`
|
|
1732
|
-
|
|
1733
|
-
```ts
|
|
1734
|
-
class WorldState {
|
|
1735
|
-
constructor(id: number);
|
|
1736
|
-
|
|
1737
|
-
id: number;
|
|
1738
|
-
seed: number | null;
|
|
1739
|
-
isOverworld: boolean | null;
|
|
1740
|
-
tileset: Tileset | null;
|
|
1741
|
-
blockWidth: number | null;
|
|
1742
|
-
blockHeight: number | null;
|
|
1743
|
-
parentWorld: number | null;
|
|
1744
|
-
parentEntity: number | null;
|
|
1745
|
-
tiles: Map<string, Tile>;
|
|
1746
|
-
chunks: unknown[];
|
|
1747
|
-
events: unknown[];
|
|
1748
|
-
modelPackets: unknown[];
|
|
1749
|
-
commsBubbles: CommsBubbleSummary[];
|
|
1750
|
-
model: ModelState;
|
|
1751
|
-
lastChunkPatch: unknown;
|
|
1752
|
-
lastPacket: unknown;
|
|
1753
|
-
meta: unknown;
|
|
1754
|
-
|
|
1755
|
-
readMeta(packet: unknown): void;
|
|
1756
|
-
addCommsBubble(packet: unknown): CommsBubbleSummary;
|
|
1757
|
-
decodeEncrypted(data: Uint8Array | ArrayBuffer | number[]): unknown;
|
|
1758
|
-
applyTile(value: unknown): Tile | null;
|
|
1759
|
-
applyChunk(value: unknown): Tile[] | null;
|
|
1760
|
-
setTile(tile: Tile): Tile;
|
|
1761
|
-
normalizeTile(tile: Tile): Tile;
|
|
1762
|
-
materials(): MaterialSummary[];
|
|
1763
|
-
snapshot(options?: { includeTiles?: boolean; includeModel?: boolean }): WorldSnapshot;
|
|
1764
|
-
table(id: number): Map<number, ModelRecord>;
|
|
1765
|
-
record(tableId: number, entityId: number): ModelRecord | null;
|
|
1766
|
-
tileDefinition(material: number): TileDefinition | null;
|
|
1767
|
-
entity(entityId: number): EntitySummary | null;
|
|
1768
|
-
entities(): EntitySummary[];
|
|
1769
|
-
blocks(): BlockSummary[];
|
|
1770
|
-
}
|
|
1771
|
-
```
|
|
1772
|
-
|
|
1773
|
-
### `ModelState`
|
|
1774
|
-
|
|
1775
|
-
```ts
|
|
1776
|
-
class ModelState {
|
|
1777
|
-
generation: number | null;
|
|
1778
|
-
tables: Map<number, Map<number, ModelRecord>>;
|
|
1779
|
-
removedEntities: number[];
|
|
1780
|
-
lastUpdate: unknown;
|
|
1781
|
-
errors: unknown[];
|
|
1782
|
-
|
|
1783
|
-
table(id: number): Map<number, ModelRecord>;
|
|
1784
|
-
record(tableId: number, entityId: number): ModelRecord | null;
|
|
1785
|
-
entity(entityId: number): EntitySummary | null;
|
|
1786
|
-
entities(): EntitySummary[];
|
|
1787
|
-
blocks(): BlockSummary[];
|
|
1788
|
-
apply(bytes: Uint8Array | ArrayBuffer | number[]): unknown;
|
|
1789
|
-
snapshot(options?: { includeTables?: boolean }): ModelSnapshot;
|
|
1790
|
-
tablesSnapshot(): unknown[];
|
|
1791
|
-
transforms(): TransformSummary[];
|
|
1792
|
-
itemHolders(): ItemHolderSummary[];
|
|
1793
|
-
fabricators(): FabricatorSummary[];
|
|
1794
|
-
players(): PlayerSummary[];
|
|
1795
|
-
shipControls(): ShipControlSummary[];
|
|
1796
|
-
shipMetadata(): ShipWorldMetadataSummary | null;
|
|
1797
|
-
machines(): MachineSummary;
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
type ModelRecord = Record<string, unknown>;
|
|
1801
|
-
```
|
|
1802
|
-
|
|
1803
|
-
### `WorldSnapshot`
|
|
1804
|
-
|
|
1805
|
-
```ts
|
|
1806
|
-
interface WorldSnapshot {
|
|
1807
|
-
id: number;
|
|
1808
|
-
is_overworld: boolean | null;
|
|
1809
|
-
overworldZone: OverworldZoneSummary | null;
|
|
1810
|
-
shipMetadata: ShipWorldMetadataSummary | null;
|
|
1811
|
-
tileset: Tileset | null;
|
|
1812
|
-
seed: number | null;
|
|
1813
|
-
block_w: number | null;
|
|
1814
|
-
block_h: number | null;
|
|
1815
|
-
parent_world: number | null;
|
|
1816
|
-
parent_ent: number | null;
|
|
1817
|
-
tileCount: number;
|
|
1818
|
-
chunkCount: number;
|
|
1819
|
-
lastChunkPatch: unknown;
|
|
1820
|
-
lastPacket: unknown;
|
|
1821
|
-
meta: unknown;
|
|
1822
|
-
materials: MaterialSummary[];
|
|
1823
|
-
model: ModelSnapshot;
|
|
1824
|
-
entities: EntitySummary[];
|
|
1825
|
-
blocks: BlockSummary[];
|
|
1826
|
-
transforms: TransformSummary[];
|
|
1827
|
-
machines: MachineSummary;
|
|
1828
|
-
players: PlayerSummary[];
|
|
1829
|
-
shipControls: ShipControlSummary[];
|
|
1830
|
-
commsBubbles: CommsBubbleSummary[];
|
|
1831
|
-
tiles?: Tile[];
|
|
1832
|
-
}
|
|
1833
|
-
```
|
|
1834
|
-
|
|
1835
|
-
### World metadata
|
|
1836
|
-
|
|
1837
|
-
```ts
|
|
1838
|
-
interface OverworldZoneSummary {
|
|
1839
|
-
id: number;
|
|
1840
|
-
baseId: number;
|
|
1841
|
-
layer: number;
|
|
1842
|
-
key: string;
|
|
1843
|
-
name: string;
|
|
1844
|
-
tiered: boolean;
|
|
1845
|
-
displayName: string;
|
|
1846
|
-
}
|
|
1847
|
-
|
|
1848
|
-
interface ShipWorldMetadataSummary {
|
|
1849
|
-
name: string | null;
|
|
1850
|
-
color: number | null;
|
|
1851
|
-
colorCss: string | null;
|
|
1852
|
-
width: number | null;
|
|
1853
|
-
height: number | null;
|
|
1854
|
-
lockdownTimerSeconds: number | null;
|
|
1855
|
-
lockdownCountdownSeconds: number | null;
|
|
1856
|
-
onlineShipOwnerCount: number | null;
|
|
1857
|
-
requiredShipOwnerCount: number | null;
|
|
1858
|
-
allShipOwnersOnline: boolean | null;
|
|
1859
|
-
lockdownEngaged: boolean | null;
|
|
1860
|
-
lockdownState: ModelRecord;
|
|
1861
|
-
shipState: ModelRecord;
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
|
-
interface WorldUpdate {
|
|
1865
|
-
type: string;
|
|
1866
|
-
world: WorldState | null;
|
|
1867
|
-
packet?: unknown;
|
|
1868
|
-
bubble?: CommsBubbleSummary;
|
|
1869
|
-
decoded?: unknown;
|
|
1870
|
-
updates?: unknown[];
|
|
1871
|
-
result?: unknown;
|
|
1872
|
-
}
|
|
1873
|
-
```
|
|
1874
|
-
|
|
1875
|
-
### Tiles
|
|
1876
|
-
|
|
1877
|
-
```ts
|
|
1878
|
-
interface Tile {
|
|
1879
|
-
x: number;
|
|
1880
|
-
y: number;
|
|
1881
|
-
material: number;
|
|
1882
|
-
materialName?: string | null;
|
|
1883
|
-
shape: number;
|
|
1884
|
-
shapeName?: string | null;
|
|
1885
|
-
hp: number;
|
|
1886
|
-
/** @deprecated Use hp. Raw 0-255 HP fraction byte, not absolute integrity. */
|
|
1887
|
-
integrity: number;
|
|
1888
|
-
color: number | null;
|
|
1889
|
-
solid?: boolean | null;
|
|
1890
|
-
maxHp?: number | null;
|
|
1891
|
-
hpRatio?: number | null;
|
|
1892
|
-
hpValue?: number | null;
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
|
-
interface TilePhysics {
|
|
1896
|
-
filter?: {
|
|
1897
|
-
categoryBits: number;
|
|
1898
|
-
maskBits: number;
|
|
1899
|
-
groupIndex: number;
|
|
1900
|
-
};
|
|
1901
|
-
transparent?: boolean;
|
|
1902
|
-
walkway?: boolean;
|
|
1903
|
-
restitution?: number;
|
|
1904
|
-
friction?: number;
|
|
1905
|
-
}
|
|
1906
|
-
|
|
1907
|
-
interface TileDefinition {
|
|
1908
|
-
name?: string;
|
|
1909
|
-
solid: boolean;
|
|
1910
|
-
destruct_item?: number;
|
|
1911
|
-
blocks_bullets?: boolean;
|
|
1912
|
-
hp?: number;
|
|
1913
|
-
no_build_surface?: boolean;
|
|
1914
|
-
physics?: TilePhysics;
|
|
1915
|
-
}
|
|
1916
|
-
|
|
1917
|
-
interface Tileset {
|
|
1918
|
-
scale: number;
|
|
1919
|
-
atlas: string;
|
|
1920
|
-
tile_width: number;
|
|
1921
|
-
tiles: TileDefinition[];
|
|
1922
|
-
}
|
|
1923
|
-
```
|
|
1924
|
-
|
|
1925
|
-
### `ModelSnapshot`
|
|
1926
|
-
|
|
1927
|
-
```ts
|
|
1928
|
-
interface ModelSnapshot {
|
|
1929
|
-
generation: number | null;
|
|
1930
|
-
tableCount: number;
|
|
1931
|
-
entityCount: number;
|
|
1932
|
-
removedEntities: number[];
|
|
1933
|
-
lastUpdate: unknown;
|
|
1934
|
-
errors: unknown[];
|
|
1935
|
-
entities: EntitySummary[];
|
|
1936
|
-
blocks: BlockSummary[];
|
|
1937
|
-
transforms: TransformSummary[];
|
|
1938
|
-
players: PlayerSummary[];
|
|
1939
|
-
shipControls: ShipControlSummary[];
|
|
1940
|
-
machines: MachineSummary;
|
|
1941
|
-
tables: unknown[];
|
|
1942
|
-
}
|
|
1943
|
-
```
|
|
1944
|
-
|
|
1945
|
-
## Additional Entity Component Shapes
|
|
1946
|
-
|
|
1947
|
-
```ts
|
|
1948
|
-
interface TransformSummary {
|
|
1949
|
-
entity: number;
|
|
1950
|
-
x: number | null;
|
|
1951
|
-
y: number | null;
|
|
1952
|
-
rot: number | null;
|
|
1953
|
-
flags: unknown[];
|
|
1954
|
-
}
|
|
1955
|
-
|
|
1956
|
-
interface ItemHolderSummary {
|
|
1957
|
-
entity: number;
|
|
1958
|
-
itemId: number | null;
|
|
1959
|
-
itemName: string | null;
|
|
1960
|
-
count: number | null;
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
interface ItemCrateSummary {
|
|
1964
|
-
entity: number;
|
|
1965
|
-
itemId: number | null;
|
|
1966
|
-
itemName: string | null;
|
|
1967
|
-
count: number | null;
|
|
1968
|
-
width: number | null;
|
|
1969
|
-
height: number | null;
|
|
1970
|
-
itemState: ModelRecord;
|
|
1971
|
-
sizeState: ModelRecord;
|
|
1972
|
-
}
|
|
1973
|
-
|
|
1974
|
-
interface HoverOutlineSummary {
|
|
1975
|
-
entity: number;
|
|
1976
|
-
width: number | null;
|
|
1977
|
-
height: number | null;
|
|
1978
|
-
rawWidth: number | null;
|
|
1979
|
-
rawHeight: number | null;
|
|
1980
|
-
state: ModelRecord;
|
|
1981
|
-
}
|
|
1982
|
-
|
|
1983
|
-
interface MapMarkerSummary {
|
|
1984
|
-
entity: number;
|
|
1985
|
-
kind: string;
|
|
1986
|
-
title: string | null;
|
|
1987
|
-
key: string | null;
|
|
1988
|
-
description: string | null;
|
|
1989
|
-
color: number | null;
|
|
1990
|
-
colorCss: string | null;
|
|
1991
|
-
accentColor: number | null;
|
|
1992
|
-
accentColorCss: string | null;
|
|
1993
|
-
width: number | null;
|
|
1994
|
-
height: number | null;
|
|
1995
|
-
labelState: ModelRecord;
|
|
1996
|
-
zoneState: ModelRecord;
|
|
1997
|
-
}
|
|
1998
|
-
|
|
1999
|
-
interface DockingSpringSummary {
|
|
2000
|
-
entity: number;
|
|
2001
|
-
id: number | null;
|
|
2002
|
-
width: number;
|
|
2003
|
-
height: number;
|
|
2004
|
-
state: ModelRecord;
|
|
2005
|
-
}
|
|
2006
|
-
|
|
2007
|
-
interface HugeThrusterSummary {
|
|
2008
|
-
entity: number;
|
|
2009
|
-
width: number;
|
|
2010
|
-
height: number;
|
|
2011
|
-
state: ModelRecord;
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
interface ShipSizeSummary {
|
|
2015
|
-
entity: number;
|
|
2016
|
-
width: number | null;
|
|
2017
|
-
height: number | null;
|
|
2018
|
-
rawWidth: number | null;
|
|
2019
|
-
rawHeight: number | null;
|
|
2020
|
-
state: ModelRecord;
|
|
2021
|
-
}
|
|
2022
|
-
|
|
2023
|
-
interface HealthSummary {
|
|
2024
|
-
entity: number;
|
|
2025
|
-
hp: number | null;
|
|
2026
|
-
maxHp: number | null;
|
|
2027
|
-
ratio: number | null;
|
|
2028
|
-
state: ModelRecord;
|
|
2029
|
-
}
|
|
2030
|
-
|
|
2031
|
-
interface BotSummary {
|
|
2032
|
-
entity: number;
|
|
2033
|
-
className: string;
|
|
2034
|
-
identifier: string;
|
|
2035
|
-
typeA: number | null;
|
|
2036
|
-
typeB: number | null;
|
|
2037
|
-
}
|
|
2038
|
-
```
|
|
2039
|
-
|
|
2040
|
-
## Blueprint Shapes
|
|
2041
|
-
|
|
2042
|
-
### Placement request
|
|
2043
|
-
|
|
2044
|
-
```ts
|
|
2045
|
-
interface BlueprintPlacement {
|
|
2046
|
-
x: number;
|
|
2047
|
-
y: number;
|
|
2048
|
-
width?: number;
|
|
2049
|
-
height?: number;
|
|
2050
|
-
w?: number;
|
|
2051
|
-
h?: number;
|
|
2052
|
-
source: string;
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
interface BlueprintPlacementMessage {
|
|
2056
|
-
type: 9;
|
|
2057
|
-
x: number;
|
|
2058
|
-
y: number;
|
|
2059
|
-
w: number;
|
|
2060
|
-
h: number;
|
|
2061
|
-
source: string;
|
|
2062
|
-
}
|
|
2063
|
-
```
|
|
2064
|
-
|
|
2065
|
-
### Preview state
|
|
2066
|
-
|
|
2067
|
-
```ts
|
|
2068
|
-
interface BlueprintPreviewSummary {
|
|
2069
|
-
entity: number;
|
|
2070
|
-
itemId: number;
|
|
2071
|
-
itemName: string | null;
|
|
2072
|
-
bits: number;
|
|
2073
|
-
rawBits: number | null;
|
|
2074
|
-
placementOffsets: number[];
|
|
2075
|
-
placementCount: number;
|
|
2076
|
-
placements: {
|
|
2077
|
-
offset: number;
|
|
2078
|
-
x: number | null;
|
|
2079
|
-
y: number | null;
|
|
2080
|
-
itemId: number;
|
|
2081
|
-
itemName: string | null;
|
|
2082
|
-
}[];
|
|
2083
|
-
x: number | null;
|
|
2084
|
-
y: number | null;
|
|
2085
|
-
rot: number | null;
|
|
2086
|
-
state: ModelRecord;
|
|
2087
|
-
}
|
|
2088
|
-
```
|
|
2089
|
-
|
|
2090
|
-
## PUI And Comms Shapes
|
|
2091
|
-
|
|
2092
|
-
```ts
|
|
2093
|
-
interface PuiEvent {
|
|
2094
|
-
type: "pui";
|
|
2095
|
-
filter?: number;
|
|
2096
|
-
ent_id?: number;
|
|
2097
|
-
update?: boolean;
|
|
2098
|
-
data?: unknown;
|
|
2099
|
-
world?: number | null;
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
|
-
interface CommsMessage {
|
|
2103
|
-
type: 3;
|
|
2104
|
-
msg: string;
|
|
2105
|
-
}
|
|
2106
|
-
|
|
2107
|
-
interface NormalizedCommsMessage {
|
|
2108
|
-
raw: unknown;
|
|
2109
|
-
text: string;
|
|
2110
|
-
}
|
|
2111
|
-
|
|
2112
|
-
interface CommsEvent {
|
|
2113
|
-
type: "comms";
|
|
2114
|
-
filter?: number;
|
|
2115
|
-
ent_id: number | null;
|
|
2116
|
-
entity: number | null;
|
|
2117
|
-
msgs_text: unknown[];
|
|
2118
|
-
rawMessages: unknown[];
|
|
2119
|
-
messages: NormalizedCommsMessage[];
|
|
2120
|
-
update?: boolean;
|
|
2121
|
-
world?: number | null;
|
|
2122
|
-
}
|
|
2123
|
-
|
|
2124
|
-
interface CommsBubbleSummary {
|
|
2125
|
-
sequence: number;
|
|
2126
|
-
worldId: number;
|
|
2127
|
-
entity: number | null;
|
|
2128
|
-
modelId: number | null;
|
|
2129
|
-
message: string;
|
|
2130
|
-
color: number | null;
|
|
2131
|
-
colorCss: string | null;
|
|
2132
|
-
durationSeconds: number | null;
|
|
2133
|
-
raw: unknown;
|
|
2134
|
-
}
|
|
2135
|
-
```
|
|
2136
|
-
|
|
2137
|
-
## Scanner And Ack Shapes
|
|
2138
|
-
|
|
2139
|
-
```ts
|
|
2140
|
-
interface CommandAck {
|
|
2141
|
-
world: number;
|
|
2142
|
-
commandNumber: number;
|
|
2143
|
-
}
|
|
2144
|
-
|
|
2145
|
-
interface ScannerResult {
|
|
2146
|
-
kind: "manifest" | "bom" | "unknown";
|
|
2147
|
-
sid: number | null;
|
|
2148
|
-
shipHex: string | null;
|
|
2149
|
-
shipName: string | null;
|
|
2150
|
-
blocks: Record<string, number> | null;
|
|
2151
|
-
objects: Record<string, number> | null;
|
|
2152
|
-
inventories: Record<string, number> | null;
|
|
2153
|
-
materials: Record<string, number> | null;
|
|
2154
|
-
}
|
|
2155
|
-
```
|
|
2156
|
-
|
|
2157
|
-
## Helper Function Exports
|
|
2158
|
-
|
|
2159
|
-
These are public lower-level helpers. Prefer the object/domain methods unless
|
|
2160
|
-
you explicitly need protocol payloads or decoded utility functions.
|
|
2161
|
-
|
|
2162
|
-
### Msgpack
|
|
2163
|
-
|
|
2164
|
-
Module: `dredless/protocol/msgpack` or root.
|
|
41
|
+
- `DredlessClient` return: sent or queued, without server confirmation.
|
|
42
|
+
- `Promise<T>` return: asynchronous; read the method's documented completion condition. A promise can mean permission
|
|
43
|
+
granted and commit sent, observed state changed, or a server response arrived.
|
|
44
|
+
- `null`/`undefined`: state may be unavailable, not loaded, removed, or not applicable. Read the specific method's
|
|
45
|
+
contract before treating absence as an empty list or zero.
|
|
46
|
+
- `state` is usually a property on a machine handle; `state()` is a method on domains such as inventory and machine
|
|
47
|
+
collections.
|
|
48
|
+
- Large summary interfaces are linked to the declarations instead of duplicated field by field here.
|
|
2165
49
|
|
|
2166
|
-
|
|
2167
|
-
function decodeMsgpack(bytes: Uint8Array | ArrayBuffer | number[]): unknown;
|
|
2168
|
-
function encodeMsgpack(value: unknown): Uint8Array;
|
|
2169
|
-
```
|
|
2170
|
-
|
|
2171
|
-
### Commands
|
|
2172
|
-
|
|
2173
|
-
Module: `dredless/protocol/commands` or root.
|
|
2174
|
-
|
|
2175
|
-
```ts
|
|
2176
|
-
function buildSignedCommandPacket(command: Command, sessionId: number): Uint8Array;
|
|
2177
|
-
```
|
|
2178
|
-
|
|
2179
|
-
### Inventory helpers
|
|
2180
|
-
|
|
2181
|
-
Module: `dredless/protocol/inventory` or root.
|
|
2182
|
-
|
|
2183
|
-
```ts
|
|
2184
|
-
function normalizeEquipmentSlot(slot: EquipmentSlot): 16 | 17 | 18 | 19 | 20 | 21;
|
|
2185
|
-
function equipmentSlotName(slot: number): "head" | "face" | "body" | "back" | "hands" | "feet" | null;
|
|
2186
|
-
function buildInventoryDragCommand(source: number, target: number, split?: boolean): InventoryDragCommand;
|
|
2187
|
-
function buildEquipItemCommand(source: number, slot: EquipmentSlot, split?: boolean): InventoryDragCommand;
|
|
2188
|
-
function buildUnequipItemCommand(slot: EquipmentSlot, target?: number, split?: boolean): InventoryDragCommand;
|
|
2189
|
-
function normalizeInventoryEvent(event: unknown): InventoryState;
|
|
2190
|
-
```
|
|
2191
|
-
|
|
2192
|
-
Inventory drag output remains protocol-shaped:
|
|
2193
|
-
|
|
2194
|
-
```ts
|
|
2195
|
-
interface InventoryDragCommand {
|
|
2196
|
-
drag: {
|
|
2197
|
-
source: number;
|
|
2198
|
-
target: number;
|
|
2199
|
-
split: boolean;
|
|
2200
|
-
};
|
|
2201
|
-
}
|
|
2202
|
-
```
|
|
2203
|
-
|
|
2204
|
-
`normalizeInventoryEvent()` returns the normalized `InventoryState` shape documented under `client.inventory`.
|
|
2205
|
-
|
|
2206
|
-
### Chat helpers
|
|
2207
|
-
|
|
2208
|
-
Module: `dredless/protocol/chat` or root.
|
|
2209
|
-
|
|
2210
|
-
```ts
|
|
2211
|
-
function buildChatMessage(message?: string): ChatMessage;
|
|
2212
|
-
```
|
|
2213
|
-
|
|
2214
|
-
Ship chat uses protocol message type 2. It is separate from comms-station
|
|
2215
|
-
messages, which use type 3. The game handles ship chat through the same
|
|
2216
|
-
chat-command path used by its chat commands, so client.sendChatMessage() can
|
|
2217
|
-
send executable chat commands as well as ordinary chat text. For example:
|
|
2218
|
-
|
|
2219
|
-
```js
|
|
2220
|
-
client.sendChatMessage("/save");
|
|
2221
|
-
```
|
|
2222
|
-
|
|
2223
|
-
### Comms helpers
|
|
2224
|
-
|
|
2225
|
-
Module: `dredless/protocol/comms` or root.
|
|
2226
|
-
|
|
2227
|
-
```ts
|
|
2228
|
-
function buildCommsMessage(message?: string): CommsMessage;
|
|
2229
|
-
function normalizeCommsEvent(event: unknown): CommsEvent;
|
|
2230
|
-
function flattenRichText(value: unknown): string;
|
|
2231
|
-
```
|
|
2232
|
-
|
|
2233
|
-
### Sign helpers
|
|
2234
|
-
|
|
2235
|
-
Module: `dredless/protocol/sign` or root.
|
|
2236
|
-
|
|
2237
|
-
```ts
|
|
2238
|
-
function buildSignTextMessage(text?: string, mode?: SignDisplayMode): SignTextMessage;
|
|
2239
|
-
function normalizeSignDisplayMode(mode?: SignDisplayMode): 0 | 1 | 2;
|
|
2240
|
-
function signDisplayModeName(mode: number): SignDisplayMode | null;
|
|
2241
|
-
```
|
|
2242
|
-
|
|
2243
|
-
Output:
|
|
2244
|
-
|
|
2245
|
-
```ts
|
|
2246
|
-
interface SignTextMessage {
|
|
2247
|
-
type: 5;
|
|
2248
|
-
cmd: "sign_text";
|
|
2249
|
-
args: [string, 0 | 1 | 2];
|
|
2250
|
-
}
|
|
2251
|
-
```
|
|
2252
|
-
|
|
2253
|
-
### Ship-management helpers
|
|
2254
|
-
|
|
2255
|
-
Module: `dredless/protocol/ship-management` or root.
|
|
2256
|
-
|
|
2257
|
-
```ts
|
|
2258
|
-
function buildShipManagementMessage(act: string, arg?: unknown, extra?: Record<string, unknown> | null): ShipManagementMessage;
|
|
2259
|
-
function buildShipPrivacyMessage(privacy: ShipPrivacy): ShipManagementMessage;
|
|
2260
|
-
function buildStarterRecoveryMessage(itemId: number): ShipManagementMessage;
|
|
2261
|
-
function buildPlayerListMessage(): ShipManagementMessage;
|
|
2262
|
-
function buildInviteResetMessage(): ShipManagementMessage;
|
|
2263
|
-
function buildSetPlayerRankMessage(refId: number, rank: ShipPlayerRank): ShipManagementMessage;
|
|
2264
|
-
function buildKickPlayerMessage(refId: number): ShipManagementMessage;
|
|
2265
|
-
function buildBanPlayerMessage(refId: number): ShipManagementMessage;
|
|
2266
|
-
function buildDemoteSelfMessage(): ShipManagementMessage;
|
|
2267
|
-
function normalizePrivacy(privacy: ShipPrivacy): 0 | 1;
|
|
2268
|
-
function normalizePlayerRank(rank: ShipPlayerRank): 0 | 1 | 3;
|
|
2269
|
-
function normalizeShipConfig(event: unknown): ShipConfig;
|
|
2270
|
-
function normalizeCaptainSubrank(event: unknown): CaptainSubrank;
|
|
2271
|
-
function normalizeShipPlayerList(event: unknown, previous?: ShipPlayerList | null, currentCaptainSubrank?: CaptainSubrank | null): ShipPlayerList;
|
|
2272
|
-
```
|
|
2273
|
-
|
|
2274
|
-
Message output:
|
|
2275
|
-
|
|
2276
|
-
```ts
|
|
2277
|
-
interface ShipManagementMessage {
|
|
2278
|
-
type: 4;
|
|
2279
|
-
act: string;
|
|
2280
|
-
arg: unknown;
|
|
2281
|
-
rank?: unknown;
|
|
2282
|
-
}
|
|
2283
|
-
```
|
|
2284
|
-
|
|
2285
|
-
### Blueprint helpers
|
|
2286
|
-
|
|
2287
|
-
Module: `dredless/protocol/blueprint` or root.
|
|
2288
|
-
|
|
2289
|
-
```ts
|
|
2290
|
-
function buildBlueprintPlacementMessage(placement: BlueprintPlacement): BlueprintPlacementMessage;
|
|
2291
|
-
```
|
|
2292
|
-
|
|
2293
|
-
### UI config helpers
|
|
2294
|
-
|
|
2295
|
-
Module: `dredless/protocol/ui-config` or root.
|
|
2296
|
-
|
|
2297
|
-
```ts
|
|
2298
|
-
function buildNavigationUnitConfigData(entity: number, config: NavigationUnitConfig & { destination: number }): Uint8Array;
|
|
2299
|
-
function buildNavigationUnitClipboardConfigData(config: NavigationUnitConfig & { destination: number }): Uint8Array;
|
|
2300
|
-
function buildNavigationUnitPasteConfigData(entity: number, config: NavigationUnitConfig & { destination: number }): Uint8Array;
|
|
2301
|
-
function buildGeneratorMazePuzzleData(entity: number, solution: string | number): Uint8Array;
|
|
2302
|
-
function buildCargoHatchFilterConfigData(entity: number, filterMode?: LoaderFilterMode): Uint8Array;
|
|
2303
|
-
function buildCargoHatchFilterItemsData(entity: number, filterSlots?: Array<number | null | undefined>): Uint8Array;
|
|
2304
|
-
function buildCargoHatchFullConfigData(entity: number, config?: Pick<LoaderFullConfig, "filterMode" | "filterSlots">): Uint8Array;
|
|
2305
|
-
function buildCargoHatchCopyConfigData(config?: Pick<LoaderFullConfig, "filterMode" | "filterSlots">): Uint8Array;
|
|
2306
|
-
function buildClipboardConfigData(target: ClipboardTarget, commandName: string, values?: Iterable<number>): Uint8Array;
|
|
2307
|
-
function buildClipboardFixedAngleData(target: ClipboardTarget, direction: FixedAngleDirection): Uint8Array;
|
|
2308
|
-
function buildGeneratorClipboardDirectionData(direction: FixedAngleDirection): Uint8Array;
|
|
2309
|
-
function buildCargoEjectorDirectionData(entity: number, direction: FixedAngleDirection): Uint8Array;
|
|
2310
|
-
function buildCargoEjectorPasteConfigData(entity: number, direction: FixedAngleDirection): Uint8Array;
|
|
2311
|
-
function buildCargoEjectorCopyConfigData(direction: FixedAngleDirection): Uint8Array;
|
|
2312
|
-
function buildCargoEjectorClipboardDirectionData(direction: FixedAngleDirection): Uint8Array;
|
|
2313
|
-
function buildExpandoClipboardAngleData(angle: number): Uint8Array;
|
|
2314
|
-
function buildLoaderClipboardConfigData(config?: LoaderConfig): Uint8Array;
|
|
2315
|
-
function buildLoaderConfigData(entity: number, config?: LoaderConfig): Uint8Array;
|
|
2316
|
-
function buildLoaderCopyConfigData(config?: LoaderFullConfig): Uint8Array;
|
|
2317
|
-
function buildLoaderFilterConfigData(entity: number, filterMode?: LoaderFilterMode): Uint8Array;
|
|
2318
|
-
function buildLoaderFilterItemsData(entity: number, filterSlots?: Array<number | null | undefined>): Uint8Array;
|
|
2319
|
-
function buildLoaderFullConfigData(entity: number, config?: LoaderFullConfig): Uint8Array;
|
|
2320
|
-
function buildPusherConfigData(entity: number, config?: PusherConfig): Uint8Array;
|
|
2321
|
-
function buildPusherFilterItemsData(entity: number, filterSlots?: Array<number | null | undefined>): Uint8Array;
|
|
2322
|
-
```
|
|
2323
|
-
|
|
2324
|
-
Clipboard/config input types:
|
|
2325
|
-
|
|
2326
|
-
```ts
|
|
2327
|
-
type ClipboardTarget =
|
|
2328
|
-
| number
|
|
2329
|
-
| "loader" | "loader-config" | "loaderConfig"
|
|
2330
|
-
| "hatch" | "cargo-hatch" | "cargoHatch"
|
|
2331
|
-
| "ejector" | "cargo-ejector" | "cargoEjector"
|
|
2332
|
-
| "expando" | "expando-box" | "expandoBox"
|
|
2333
|
-
| "generator" | "shield-generator" | "shieldGenerator"
|
|
2334
|
-
| "navigation" | "navigation-unit" | "navigationUnit"
|
|
2335
|
-
| "nav" | "nav-unit" | "navUnit";
|
|
2336
|
-
|
|
2337
|
-
const FixedAngleDirection = { Right: "right", Up: "up", Left: "left", Down: "down" } as const;
|
|
2338
|
-
type FixedAngleDirection = typeof FixedAngleDirection[keyof typeof FixedAngleDirection];
|
|
2339
|
-
```
|
|
2340
|
-
|
|
2341
|
-
### Generator maze helpers
|
|
2342
|
-
|
|
2343
|
-
Module: `dredless/game/generator-maze` or root.
|
|
2344
|
-
|
|
2345
|
-
```ts
|
|
2346
|
-
function generateGeneratorMaze(seed: number): GeneratorMaze;
|
|
2347
|
-
function solveGeneratorMazeSeed(seed: number): string;
|
|
2348
|
-
function maybeSolveGeneratorMazeSeed(seed: number | null | undefined): string | null;
|
|
2349
|
-
```
|
|
2350
|
-
|
|
2351
|
-
Output:
|
|
2352
|
-
|
|
2353
|
-
```ts
|
|
2354
|
-
interface GeneratorMazeCellWalls {
|
|
2355
|
-
up: boolean;
|
|
2356
|
-
down: boolean;
|
|
2357
|
-
left: boolean;
|
|
2358
|
-
right: boolean;
|
|
2359
|
-
}
|
|
2360
|
-
|
|
2361
|
-
interface GeneratorMazeCell {
|
|
2362
|
-
x: number;
|
|
2363
|
-
y: number;
|
|
2364
|
-
value: number;
|
|
2365
|
-
hex: string;
|
|
2366
|
-
digit: number;
|
|
2367
|
-
walls: GeneratorMazeCellWalls;
|
|
2368
|
-
backtrackDirection: number;
|
|
2369
|
-
marker: number;
|
|
2370
|
-
}
|
|
2371
|
-
|
|
2372
|
-
interface GeneratorMaze {
|
|
2373
|
-
seed: number;
|
|
2374
|
-
width: number;
|
|
2375
|
-
height: number;
|
|
2376
|
-
cells: GeneratorMazeCell[];
|
|
2377
|
-
rows: GeneratorMazeCell[][];
|
|
2378
|
-
solution: string;
|
|
2379
|
-
}
|
|
2380
|
-
```
|
|
2381
|
-
|
|
2382
|
-
### Crypto, compression, and model decoding
|
|
2383
|
-
|
|
2384
|
-
Modules: `dredless/crypto/chacha`, `dredless/compression/lz4`,
|
|
2385
|
-
`dredless/model`, and root.
|
|
2386
|
-
|
|
2387
|
-
```ts
|
|
2388
|
-
function decryptPayload(
|
|
2389
|
-
wireBytes: Uint8Array | ArrayBuffer | number[],
|
|
2390
|
-
worldId: number,
|
|
2391
|
-
seed: number
|
|
2392
|
-
): Uint8Array;
|
|
2393
|
-
|
|
2394
|
-
function decompressLz4Frame(bytes: Uint8Array | ArrayBuffer | number[]): Uint8Array;
|
|
50
|
+
## IDs and scopes
|
|
2395
51
|
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
function createInviteShipSpec(code: string): ShipSpec;
|
|
2406
|
-
```
|
|
2407
|
-
|
|
2408
|
-
`createShipSpec()` returns a `{ type: "new", ... }` ship spec.
|
|
2409
|
-
`createInviteShipSpec()` returns a `{ type: "invite", code }` ship spec.
|
|
2410
|
-
|
|
2411
|
-
## Public Constants From Subpath Modules
|
|
2412
|
-
|
|
2413
|
-
These constants are exported by helper subpaths for consumers that need protocol
|
|
2414
|
-
symbols. They are not required for normal object-domain use.
|
|
2415
|
-
|
|
2416
|
-
### `dredless/protocol/blueprint`
|
|
2417
|
-
|
|
2418
|
-
```ts
|
|
2419
|
-
const BLUEPRINT_PLACEMENT_TYPE: 9;
|
|
2420
|
-
```
|
|
2421
|
-
|
|
2422
|
-
### `dredless/protocol/comms`
|
|
2423
|
-
|
|
2424
|
-
```ts
|
|
2425
|
-
const COMMS_MESSAGE_TYPE: 3;
|
|
2426
|
-
```
|
|
2427
|
-
|
|
2428
|
-
### `dredless/protocol/inventory`
|
|
2429
|
-
|
|
2430
|
-
```ts
|
|
2431
|
-
const EQUIPMENT_SLOT_INDEXES: Readonly<{
|
|
2432
|
-
head: 16;
|
|
2433
|
-
face: 17;
|
|
2434
|
-
body: 18;
|
|
2435
|
-
back: 19;
|
|
2436
|
-
hands: 20;
|
|
2437
|
-
feet: 21;
|
|
2438
|
-
}>;
|
|
2439
|
-
```
|
|
2440
|
-
|
|
2441
|
-
### `dredless/protocol/ship-management`
|
|
2442
|
-
|
|
2443
|
-
```ts
|
|
2444
|
-
const BAN_ACTION: "ban";
|
|
2445
|
-
const DEMOTE_SELF_ACTION: "demote_self";
|
|
2446
|
-
const KICK_ACTION: "kick";
|
|
2447
|
-
const PLAYER_LIST_ACTION: "player_list";
|
|
2448
|
-
const INVITE_RESET_ACTION: "invite_reset";
|
|
2449
|
-
const SET_PRIVACY_ACTION: "set_privacy";
|
|
2450
|
-
const SET_RANK_ACTION: "set_rank";
|
|
2451
|
-
const SHIP_MANAGEMENT_TYPE: 4;
|
|
2452
|
-
const STARTER_RECOVERY_ACTION: "starter_recovery";
|
|
2453
|
-
```
|
|
2454
|
-
|
|
2455
|
-
### `dredless/protocol/sign`
|
|
2456
|
-
|
|
2457
|
-
```ts
|
|
2458
|
-
const SIGN_TEXT_COMMAND: "sign_text";
|
|
2459
|
-
const SIGN_DISPLAY_MODES: Map<0 | 1 | 2, "always" | "when-near" | "on-hover">;
|
|
2460
|
-
```
|
|
2461
|
-
|
|
2462
|
-
### `dredless/protocol/ui-config`
|
|
2463
|
-
|
|
2464
|
-
```ts
|
|
2465
|
-
const CLIPBOARD_ACTION: 1;
|
|
2466
|
-
const CLIPBOARD_ANGLE_COMMAND: "angle";
|
|
2467
|
-
const CLIPBOARD_FIXED_ANGLE_COMMAND: "angle_fixed";
|
|
2468
|
-
const CLIPBOARD_TARGET_VALUES: Map<string, number>;
|
|
2469
|
-
const FIXED_ANGLE_VALUES: Map<string, 0 | 1 | 2 | 3>;
|
|
2470
|
-
const GENERATOR_MAZE_PUZZLE_COMMAND: "maze_puzzle";
|
|
2471
|
-
const LOADER_CONFIG_COMMAND: "config_loader";
|
|
2472
|
-
const LOADER_FALSE: 0x8e;
|
|
2473
|
-
const LOADER_FILTER_CONFIG_COMMAND: "filter_config";
|
|
2474
|
-
const LOADER_FILTER_ITEMS_COMMAND: "filter_items";
|
|
2475
|
-
const LOADER_TRUE: 0x8d;
|
|
2476
|
-
const NAV_UNIT_COMMAND: "config_nav_unit";
|
|
2477
|
-
const NAV_UNIT_FALSE: 0x8d;
|
|
2478
|
-
const NAV_UNIT_TRUE: 0x8e;
|
|
2479
|
-
const PUSHER_CONFIG_COMMAND: "config_pusher";
|
|
2480
|
-
const PUSHER_FILTER_ITEMS_COMMAND: "filter_items";
|
|
2481
|
-
```
|
|
2482
|
-
|
|
2483
|
-
## Usage Patterns
|
|
2484
|
-
|
|
2485
|
-
### Read loaders from a live client
|
|
2486
|
-
|
|
2487
|
-
Use [NODE_API.md](./NODE_API.md) or [BROWSER_API.md](./BROWSER_API.md) to start a client for the current runtime.
|
|
2488
|
-
|
|
2489
|
-
```js
|
|
2490
|
-
await client.whenReady();
|
|
2491
|
-
|
|
2492
|
-
for (const loader of client.currentShip().machines.loaders()) {
|
|
2493
|
-
console.log(loader.id, loader.pick, loader.place, loader.cycle);
|
|
2494
|
-
}
|
|
2495
|
-
```
|
|
2496
|
-
|
|
2497
|
-
### Read all nearby ships, including detailed loaded worlds when available
|
|
2498
|
-
|
|
2499
|
-
```js
|
|
2500
|
-
const ships = client.overworld().ships({
|
|
2501
|
-
includeWorld: true,
|
|
2502
|
-
includeModel: true,
|
|
2503
|
-
sort: "distance"
|
|
2504
|
-
});
|
|
2505
|
-
|
|
2506
|
-
for (const ship of ships) {
|
|
2507
|
-
const snapshot = ship.snapshot();
|
|
2508
|
-
console.log(snapshot.name, snapshot.hexCode, snapshot.hasWorldData);
|
|
2509
|
-
}
|
|
2510
|
-
```
|
|
2511
|
-
|
|
2512
|
-
### Use generic features before narrowing to a machine type
|
|
2513
|
-
|
|
2514
|
-
```js
|
|
2515
|
-
const entity = client.currentShip().entities.get(14);
|
|
2516
|
-
|
|
2517
|
-
if (entity.has("loader")) {
|
|
2518
|
-
const loader = entity.asLoader();
|
|
2519
|
-
loader.setCycle(10);
|
|
2520
|
-
}
|
|
2521
|
-
|
|
2522
|
-
if (entity.has("outline")) {
|
|
2523
|
-
console.log(entity.feature("outline"));
|
|
2524
|
-
}
|
|
2525
|
-
```
|
|
2526
|
-
|
|
2527
|
-
### Configure a pusher
|
|
2528
|
-
|
|
2529
|
-
```js
|
|
2530
|
-
const pusher = client.currentShip().machines.pusher(27);
|
|
2531
|
-
|
|
2532
|
-
pusher.configure({
|
|
2533
|
-
mode: "push",
|
|
2534
|
-
filteredMode: "pull",
|
|
2535
|
-
angle: 90,
|
|
2536
|
-
speed: 20,
|
|
2537
|
-
length: 30,
|
|
2538
|
-
filterInventory: true
|
|
2539
|
-
});
|
|
2540
|
-
```
|
|
2541
|
-
|
|
2542
|
-
### Configure a navigation unit
|
|
2543
|
-
|
|
2544
|
-
```js
|
|
2545
|
-
const nav = client.currentShip().machines.navigationUnit();
|
|
2546
|
-
|
|
2547
|
-
nav.setDestination(30, {
|
|
2548
|
-
autoWarpOnShieldFailure: true,
|
|
2549
|
-
autoWarpOnNoCaptains: false
|
|
2550
|
-
});
|
|
2551
|
-
```
|
|
2552
|
-
|
|
2553
|
-
## Cost Guidelines
|
|
2554
|
-
|
|
2555
|
-
Use handles for normal live code:
|
|
52
|
+
| Value | Meaning |
|
|
53
|
+
|--------------------------------|------------------------------------------------------------------------------------|
|
|
54
|
+
| `server.index` | Server selector; numeric `ServerRef` means this index, not an array position |
|
|
55
|
+
| World ID | Identifies a decoded world in `client.debug.worldStore()` |
|
|
56
|
+
| Entity `id` / summary `entity` | Entity ID within a world; the same number can mean something else in another world |
|
|
57
|
+
| Player `refId` | Management player-list reference for rank, kick, ban, and unban operations |
|
|
58
|
+
| `sid` | WebSocket protocol session ID; not the player's entity ID |
|
|
59
|
+
| Ship `hexCode` | Human-visible ship code, without braces |
|
|
60
|
+
| Account perk ship `shipId` | Decimal string from the account removal form; use it with `removeShipPerks()` |
|
|
2556
61
|
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
client.currentShip().machines.loader(id);
|
|
2560
|
-
```
|
|
62
|
+
Do not convert account perk ship `shipId` to/from `hexCode`; the form and display identifiers are
|
|
63
|
+
distinct. [Account methods](ACCOUNT.md#ships-with-patron-perks) returns both.
|
|
2561
64
|
|
|
2562
|
-
|
|
65
|
+
`ReadWorldScope` accepts `"ship"`, `"current"`, `"overworld"`, or a numeric world ID. Prefer world-scoped handles for
|
|
66
|
+
writes. A handle does not guarantee the entity exists, belongs to the current world, or is in range.
|
|
2563
67
|
|
|
2564
|
-
|
|
2565
|
-
client.currentShip().entities.raw();
|
|
2566
|
-
client.currentShip().machines.state();
|
|
2567
|
-
```
|
|
68
|
+
## Types and state shapes
|
|
2568
69
|
|
|
2569
|
-
|
|
70
|
+
The maintained declaration files are the full field/overload reference:
|
|
2570
71
|
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
client.
|
|
2574
|
-
|
|
2575
|
-
|
|
72
|
+
| Need | Declaration |
|
|
73
|
+
|--------------------------------------------------------------------|--------------------------------------------------------------------------|
|
|
74
|
+
| Shared client, handles, config, summary, snapshot, and event types | [src/index.d.ts](../src/index.d.ts) |
|
|
75
|
+
| Browser factories and ambient sessions | [src/browser.d.ts](../src/browser.d.ts) |
|
|
76
|
+
| Protocol-only helpers and constants | [src/protocol/index.d.ts](../src/protocol/index.d.ts) and its re-exports |
|
|
2576
77
|
|
|
2577
|
-
|
|
2578
|
-
|
|
78
|
+
Useful type families: `Server`/`ServerStatus`/`Ship`/`ShipList`; `AccountDetails`/`ClanTagDetails`/`AccountPerkShip`;
|
|
79
|
+
`ClientSnapshot`/`WorldSnapshot`/`ModelSnapshot`; `EntitySnapshot`/`EntitySummary`/`EntityContentsSummary`;
|
|
80
|
+
machine-specific `*Handle`, `*Config`, and `*Summary`; `InventoryState`; `ShipConfig`/`ShipPlayerList`/`CrewLog`; and
|
|
81
|
+
`Command`/`TipList`/`DisconnectInfo`.
|
|
2579
82
|
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
client.debug.decodeErrors();
|
|
2583
|
-
client.debug.worldStore();
|
|
2584
|
-
```
|
|
83
|
+
Some implementation methods and overloads predate the declarations. A reference page calls out known differences where
|
|
84
|
+
they affect usage; do not infer runtime support from a signature alone.
|