screeps-clockwork 0.2.0 → 0.4.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.
@@ -0,0 +1,484 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * WASM wrapper for the Dijkstra flow field function.
5
+ * @param {Uint32Array} start_packed
6
+ * @param {ClockworkCostMatrix} cost_matrix
7
+ * @returns {FlowField}
8
+ */
9
+ export function js_dijkstra_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): FlowField;
10
+ /**
11
+ * @param {number} start
12
+ * @param {MonoFlowField} flow_field
13
+ * @returns {Path}
14
+ */
15
+ export function js_path_to_mono_flow_field_origin(start: number, flow_field: MonoFlowField): Path;
16
+ /**
17
+ * WASM wrapper for the Dijkstra distance map function.
18
+ * @param {Uint32Array} start_packed
19
+ * @param {ClockworkCostMatrix} cost_matrix
20
+ * @returns {DistanceMap}
21
+ */
22
+ export function js_dijkstra_distance_map(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): DistanceMap;
23
+ /**
24
+ * WASM wrapper for the BFS mono flow field function.
25
+ * @param {Uint32Array} start_packed
26
+ * @param {ClockworkCostMatrix} cost_matrix
27
+ * @returns {MonoFlowField}
28
+ */
29
+ export function js_bfs_mono_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): MonoFlowField;
30
+ /**
31
+ * @param {number} start
32
+ * @param {DistanceMap} distance_map
33
+ * @returns {Path}
34
+ */
35
+ export function js_path_to_distance_map_origin(start: number, distance_map: DistanceMap): Path;
36
+ /**
37
+ * @returns {string}
38
+ */
39
+ export function version(): string;
40
+ /**
41
+ * Exports the global range calculation between two positions.
42
+ * @param {number} packed_pos_1
43
+ * @param {number} packed_pos_2
44
+ * @returns {number}
45
+ */
46
+ export function get_range(packed_pos_1: number, packed_pos_2: number): number;
47
+ /**
48
+ * WASM wrapper for the BFS distance map function.
49
+ * @param {Uint32Array} start_packed
50
+ * @param {ClockworkCostMatrix} cost_matrix
51
+ * @returns {DistanceMap}
52
+ */
53
+ export function js_bfs_distance_map(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): DistanceMap;
54
+ /**
55
+ * WASM wrapper for the BFS flow field function.
56
+ * @param {Uint32Array} start_packed
57
+ * @param {ClockworkCostMatrix} cost_matrix
58
+ * @returns {FlowField}
59
+ */
60
+ export function js_bfs_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): FlowField;
61
+ /**
62
+ * WASM wrapper for the Dijkstra mono flow field function.
63
+ * @param {Uint32Array} start_packed
64
+ * @param {ClockworkCostMatrix} cost_matrix
65
+ * @returns {MonoFlowField}
66
+ */
67
+ export function js_dijkstra_mono_flow_field(start_packed: Uint32Array, cost_matrix: ClockworkCostMatrix): MonoFlowField;
68
+ /**
69
+ * @param {number} start
70
+ * @param {FlowField} flow_field
71
+ * @returns {Path}
72
+ */
73
+ export function js_path_to_flow_field_origin(start: number, flow_field: FlowField): Path;
74
+ /**
75
+ * Translates `COLOR_*` and `COLORS_ALL` constants.
76
+ */
77
+ export enum Color {
78
+ Red = 1,
79
+ Purple = 2,
80
+ Blue = 3,
81
+ Cyan = 4,
82
+ Green = 5,
83
+ Yellow = 6,
84
+ Orange = 7,
85
+ Brown = 8,
86
+ Grey = 9,
87
+ White = 10,
88
+ }
89
+ /**
90
+ * Translates the `DENSITY_*` constants.
91
+ */
92
+ export enum Density {
93
+ Low = 1,
94
+ Moderate = 2,
95
+ High = 3,
96
+ Ultra = 4,
97
+ }
98
+ /**
99
+ * Translates direction constants.
100
+ */
101
+ export enum Direction {
102
+ Top = 1,
103
+ TopRight = 2,
104
+ Right = 3,
105
+ BottomRight = 4,
106
+ Bottom = 5,
107
+ BottomLeft = 6,
108
+ Left = 7,
109
+ TopLeft = 8,
110
+ }
111
+ /**
112
+ * Type used for when the game returns a direction to an exit.
113
+ *
114
+ * Restricted more than `Direction` in that it can't be diagonal. Used as the
115
+ * result of [`Room::find_exit_to`].
116
+ *
117
+ * Can be converted to [`Find`] for immediate use of [`Room::find`]
118
+ * and [`Direction`].
119
+ *
120
+ * [`Room::find`]: crate::objects::Room::find
121
+ * [`Room::find_exit_to`]: crate::objects::Room::find_exit_to
122
+ */
123
+ export enum ExitDirection {
124
+ Top = 1,
125
+ Right = 3,
126
+ Bottom = 5,
127
+ Left = 7,
128
+ }
129
+ /**
130
+ * Translates `FIND_*` constants for interal API calls
131
+ *
132
+ * Unless you're storing the type of find constant to be used for a call, you
133
+ * likely want the constants which implement the `FindConstant` trait to make
134
+ * calls to find methods.
135
+ *
136
+ * This is hidden from the documentation to avoid confusion due to its narrow
137
+ * use case, but wasm_bindgen requires it remain public.
138
+ */
139
+ export enum Find {
140
+ /**
141
+ * Find all exit positions at the top of the room
142
+ */
143
+ ExitTop = 1,
144
+ ExitRight = 3,
145
+ ExitBottom = 5,
146
+ ExitLeft = 7,
147
+ Exit = 10,
148
+ Creeps = 101,
149
+ MyCreeps = 102,
150
+ HostileCreeps = 103,
151
+ SourcesActive = 104,
152
+ Sources = 105,
153
+ DroppedResources = 106,
154
+ Structures = 107,
155
+ MyStructures = 108,
156
+ HostileStructures = 109,
157
+ Flags = 110,
158
+ ConstructionSites = 111,
159
+ MySpawns = 112,
160
+ HostileSpawns = 113,
161
+ MyConstructionSites = 114,
162
+ HostileConstructionSites = 115,
163
+ Minerals = 116,
164
+ Nukes = 117,
165
+ Tombstones = 118,
166
+ PowerCreeps = 119,
167
+ MyPowerCreeps = 120,
168
+ HostilePowerCreeps = 121,
169
+ Deposits = 122,
170
+ Ruins = 123,
171
+ ScoreContainers = 10011,
172
+ ScoreCollectors = 10012,
173
+ SymbolContainers = 10021,
174
+ SymbolDecoders = 10022,
175
+ Reactors = 10051,
176
+ }
177
+ /**
178
+ * Translates the `EFFECT_*` constants, which are natural effect types
179
+ */
180
+ export enum NaturalEffectType {
181
+ Invulnerability = 1001,
182
+ CollapseTimer = 1002,
183
+ }
184
+ /**
185
+ * Translates the `PWR_*` constants, which are types of powers used by power
186
+ * creeps
187
+ */
188
+ export enum PowerType {
189
+ GenerateOps = 1,
190
+ OperateSpawn = 2,
191
+ OperateTower = 3,
192
+ OperateStorage = 4,
193
+ OperateLab = 5,
194
+ OperateExtension = 6,
195
+ OperateObserver = 7,
196
+ OperateTerminal = 8,
197
+ DisruptSpawn = 9,
198
+ DisruptTower = 10,
199
+ Shield = 12,
200
+ RegenSource = 13,
201
+ RegenMineral = 14,
202
+ DisruptTerminal = 15,
203
+ OperatePower = 16,
204
+ Fortify = 17,
205
+ OperateController = 18,
206
+ OperateFactory = 19,
207
+ }
208
+ /**
209
+ * Translates `TERRAIN_*` constants.
210
+ */
211
+ export enum Terrain {
212
+ Plain = 0,
213
+ Wall = 1,
214
+ Swamp = 2,
215
+ }
216
+ /**
217
+ * A wrapper around the `LocalCostMatrix` type from the Screeps API.
218
+ * Instances can be passed between WASM and JS as a pointer, using the
219
+ * methods to get and set values, rather than copying the entire matrix.
220
+ */
221
+ export class ClockworkCostMatrix {
222
+ free(): void;
223
+ /**
224
+ * Creates a new cost matrix within the WASM module. Optionally, a default value
225
+ * can be provided to initialize all cells in the matrix to that value.
226
+ * @param {number | undefined} [_default]
227
+ */
228
+ constructor(_default?: number);
229
+ /**
230
+ * Gets the cost of a given position in the cost matrix.
231
+ * @param {number} x
232
+ * @param {number} y
233
+ * @returns {number}
234
+ */
235
+ get(x: number, y: number): number;
236
+ /**
237
+ * Sets the cost of a given position in the cost matrix.
238
+ * @param {number} x
239
+ * @param {number} y
240
+ * @param {number} value
241
+ */
242
+ set(x: number, y: number, value: number): void;
243
+ }
244
+ /**
245
+ * Maps a distance value onto individual room tile positions.
246
+ */
247
+ export class DistanceMap {
248
+ free(): void;
249
+ /**
250
+ * Converts the distance map into a flat array of distances.
251
+ * @returns {Uint32Array}
252
+ */
253
+ toArray(): Uint32Array;
254
+ /**
255
+ * Gets the distance value at a given position.
256
+ * @param {number} x
257
+ * @param {number} y
258
+ * @returns {number}
259
+ */
260
+ get(x: number, y: number): number;
261
+ /**
262
+ * Sets the distance value at a given position.
263
+ * @param {number} x
264
+ * @param {number} y
265
+ * @param {number} value
266
+ */
267
+ set(x: number, y: number, value: number): void;
268
+ }
269
+ /**
270
+ * A flow field is a 50x50 grid (representing a room), representing viable directions
271
+ * to travel to reach a particular target (or targets). A given tile may have multiple
272
+ * equally valid directions, so we represent this as a bitfield (where each bit in an
273
+ * 8-bit unsigned integer represents a direction that is either viable or not).
274
+ */
275
+ export class FlowField {
276
+ free(): void;
277
+ /**
278
+ * Get the internal value for a given coordinate.
279
+ * @param {number} x
280
+ * @param {number} y
281
+ * @returns {number}
282
+ */
283
+ get(x: number, y: number): number;
284
+ /**
285
+ * Set the internal value for a given coordinate.
286
+ * @param {number} x
287
+ * @param {number} y
288
+ * @param {number} value
289
+ */
290
+ set(x: number, y: number, value: number): void;
291
+ /**
292
+ * Get the list of valid directions for a given coordinate.
293
+ * @param {number} x
294
+ * @param {number} y
295
+ * @returns {any[]}
296
+ */
297
+ getDirections(x: number, y: number): any[];
298
+ /**
299
+ * Set the list of valid directions for a given coordinate.
300
+ * @param {number} x
301
+ * @param {number} y
302
+ * @param {any[]} directions
303
+ */
304
+ setDirections(x: number, y: number, directions: any[]): void;
305
+ /**
306
+ * Add a direction to the list of valid directions for a given coordinate.
307
+ * @param {number} x
308
+ * @param {number} y
309
+ * @param {Direction} direction
310
+ */
311
+ addDirection(x: number, y: number, direction: Direction): void;
312
+ }
313
+ /**
314
+ * A flow field is a 50x50 grid (representing a room), representing viable directions
315
+ * to travel to reach a particular target (or targets). A mono flow field only stores
316
+ * a single direction for each tile, so we represent this as 4 bits of an unsigned
317
+ * integer (0 for no direction, 1 for TOP, etc.).
318
+ */
319
+ export class MonoFlowField {
320
+ free(): void;
321
+ /**
322
+ * Get the direction for a given coordinate.
323
+ * @param {number} x
324
+ * @param {number} y
325
+ * @returns {Direction | undefined}
326
+ */
327
+ get(x: number, y: number): Direction | undefined;
328
+ /**
329
+ * Set the direction for a given coordinate.
330
+ * @param {number} x
331
+ * @param {number} y
332
+ * @param {Direction | undefined} [value]
333
+ */
334
+ set(x: number, y: number, value?: Direction): void;
335
+ }
336
+ /**
337
+ * A list of positions representing a path.
338
+ */
339
+ export class Path {
340
+ free(): void;
341
+ /**
342
+ * @param {number} packed_position
343
+ */
344
+ add(packed_position: number): void;
345
+ /**
346
+ * @param {number} index
347
+ * @returns {number | undefined}
348
+ */
349
+ get(index: number): number | undefined;
350
+ /**
351
+ * @returns {number}
352
+ */
353
+ len(): number;
354
+ /**
355
+ * Given a position, find the index of the next adjacent position
356
+ * in the path. If the position is not in the path, the target is
357
+ * the next adjacent position closest to the end of the path. If
358
+ * the position is neither on nor adjacent to the path, return None.
359
+ * @param {number} packed_position
360
+ * @returns {number | undefined}
361
+ */
362
+ find_next_index(packed_position: number): number | undefined;
363
+ /**
364
+ * @returns {Uint32Array}
365
+ */
366
+ to_array(): Uint32Array;
367
+ /**
368
+ * @returns {Uint32Array}
369
+ */
370
+ to_array_reversed(): Uint32Array;
371
+ }
372
+ /**
373
+ * Tracks fatigue cost for each position in a path. Used to calculate move time
374
+ * for a given creep build.
375
+ */
376
+ export class PathFatigue {
377
+ free(): void;
378
+ /**
379
+ * @param {Path} path
380
+ */
381
+ constructor(path: Path);
382
+ /**
383
+ * Refreshes fatigue cost for each position in the path. If the PathFatigue
384
+ * has not been initialized yet, every position's fatigue cost will be set,
385
+ * even if there is no vision in the room, based on terrain costs. If the
386
+ * list *has* been initialized, only positions with vision will be updated.
387
+ *
388
+ * When there is vision, this also accounts for roads at the position.
389
+ * @param {Path} path
390
+ */
391
+ refresh(path: Path): void;
392
+ /**
393
+ * @returns {number}
394
+ */
395
+ len(): number;
396
+ /**
397
+ * Calculates the total move time for the path, given a fatigue ratio.
398
+ *
399
+ * For unboosted creeps, the ratio is `Math.floor(moveParts * 2 / fatigueParts)`
400
+ * where `fatigue_parts` are any part except MOVE and empty CARRY parts.
401
+ * @param {number} fatigue_ratio
402
+ * @returns {number}
403
+ */
404
+ moveTime(fatigue_ratio: number): number;
405
+ }
406
+ export class SearchGoal {
407
+ free(): void;
408
+ readonly pos: any;
409
+ readonly range: number;
410
+ }
411
+
412
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
413
+
414
+ export interface InitOutput {
415
+ readonly memory: WebAssembly.Memory;
416
+ readonly __wbg_path_free: (a: number, b: number) => void;
417
+ readonly __wbg_pathfatigue_free: (a: number, b: number) => void;
418
+ readonly path_add: (a: number, b: number) => void;
419
+ readonly path_get: (a: number, b: number, c: number) => void;
420
+ readonly path_len: (a: number) => number;
421
+ readonly path_find_next_index: (a: number, b: number, c: number) => void;
422
+ readonly path_to_array: (a: number, b: number) => void;
423
+ readonly path_to_array_reversed: (a: number, b: number) => void;
424
+ readonly pathfatigue_new: (a: number) => number;
425
+ readonly pathfatigue_refresh: (a: number, b: number) => void;
426
+ readonly pathfatigue_moveTime: (a: number, b: number) => number;
427
+ readonly pathfatigue_len: (a: number) => number;
428
+ readonly js_dijkstra_flow_field: (a: number, b: number, c: number) => number;
429
+ readonly __wbg_flowfield_free: (a: number, b: number) => void;
430
+ readonly flowfield_get: (a: number, b: number, c: number) => number;
431
+ readonly flowfield_set: (a: number, b: number, c: number, d: number) => void;
432
+ readonly flowfield_getDirections: (a: number, b: number, c: number, d: number) => void;
433
+ readonly flowfield_setDirections: (a: number, b: number, c: number, d: number, e: number) => void;
434
+ readonly flowfield_addDirection: (a: number, b: number, c: number, d: number) => void;
435
+ readonly js_path_to_mono_flow_field_origin: (a: number, b: number) => number;
436
+ readonly __wbg_monoflowfield_free: (a: number, b: number) => void;
437
+ readonly monoflowfield_get: (a: number, b: number, c: number) => number;
438
+ readonly monoflowfield_set: (a: number, b: number, c: number, d: number) => void;
439
+ readonly __wbg_clockworkcostmatrix_free: (a: number, b: number) => void;
440
+ readonly clockworkcostmatrix_new: (a: number) => number;
441
+ readonly clockworkcostmatrix_get: (a: number, b: number, c: number) => number;
442
+ readonly clockworkcostmatrix_set: (a: number, b: number, c: number, d: number) => void;
443
+ readonly js_dijkstra_distance_map: (a: number, b: number, c: number) => number;
444
+ readonly js_bfs_mono_flow_field: (a: number, b: number, c: number) => number;
445
+ readonly js_path_to_distance_map_origin: (a: number, b: number) => number;
446
+ readonly __wbg_distancemap_free: (a: number, b: number) => void;
447
+ readonly distancemap_toArray: (a: number, b: number) => void;
448
+ readonly distancemap_get: (a: number, b: number, c: number) => number;
449
+ readonly distancemap_set: (a: number, b: number, c: number, d: number) => void;
450
+ readonly version: (a: number) => void;
451
+ readonly get_range: (a: number, b: number) => number;
452
+ readonly js_bfs_distance_map: (a: number, b: number, c: number) => number;
453
+ readonly js_bfs_flow_field: (a: number, b: number, c: number) => number;
454
+ readonly js_dijkstra_mono_flow_field: (a: number, b: number, c: number) => number;
455
+ readonly js_path_to_flow_field_origin: (a: number, b: number) => number;
456
+ readonly __wbg_searchgoal_free: (a: number, b: number) => void;
457
+ readonly searchgoal_pos: (a: number) => number;
458
+ readonly searchgoal_range: (a: number) => number;
459
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
460
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
461
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
462
+ readonly __wbindgen_exn_store: (a: number) => void;
463
+ }
464
+
465
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
466
+ /**
467
+ * Instantiates the given `module`, which can either be bytes or
468
+ * a precompiled `WebAssembly.Module`.
469
+ *
470
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
471
+ *
472
+ * @returns {InitOutput}
473
+ */
474
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
475
+
476
+ /**
477
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
478
+ * for everything else, calls `WebAssembly.instantiate` directly.
479
+ *
480
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
481
+ *
482
+ * @returns {Promise<InitOutput>}
483
+ */
484
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -1,4 +1,4 @@
1
- import { ClockworkCostMatrix } from '../../wasm';
1
+ import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
2
2
  /**
3
3
  * Generate a [distance map](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
4
4
  * using a breadth-first search algorithm.
@@ -10,8 +10,11 @@ import { ClockworkCostMatrix } from '../../wasm';
10
10
  * This might be useful for creeps with only MOVE parts and/or empty
11
11
  * CARRY parts, which don't generate fatigue.
12
12
  *
13
+ * Note that the `roomName` on start positions is ignored - all positions
14
+ * are assumed to be in the same room as the cost matrix.
15
+ *
13
16
  * @param start - The starting positions.
14
17
  * @param costMatrix - The cost matrix to use for the flow field.
15
18
  * @returns The flow field.
16
19
  */
17
- export declare function bfsDistanceMap(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../../wasm").DistanceMap;
20
+ export declare function bfsDistanceMap(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").DistanceMap;
@@ -1,4 +1,4 @@
1
- import { ClockworkCostMatrix } from '../../wasm';
1
+ import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
2
2
  /**
3
3
  * Generate a [flow field](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
4
4
  * using a breadth-first search algorithm.
@@ -14,7 +14,7 @@ import { ClockworkCostMatrix } from '../../wasm';
14
14
  * @param costMatrix - The cost matrix to use for the flow field.
15
15
  * @returns The flow field.
16
16
  */
17
- export declare function bfsFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../../wasm").FlowField;
17
+ export declare function bfsFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").FlowField;
18
18
  /**
19
19
  * Generate a [mono-directional flow field](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html)
20
20
  * for a set of positions using a breadth-first search algorithm.
@@ -26,8 +26,11 @@ export declare function bfsFlowField(start: RoomPosition[], costMatrix: Clockwor
26
26
  * This might be useful for creeps with only MOVE parts and/or empty
27
27
  * CARRY parts, which don't generate fatigue.
28
28
  *
29
+ * Note that the `roomName` on start positions is ignored - all positions
30
+ * are assumed to be in the same room as the cost matrix.
31
+ *
29
32
  * @param start - The starting positions.
30
33
  * @param costMatrix - The cost matrix to use for the flow field.
31
34
  * @returns The flow field.
32
35
  */
33
- export declare function bfsMonoFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../../wasm").MonoFlowField;
36
+ export declare function bfsMonoFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").MonoFlowField;
@@ -1,4 +1,4 @@
1
- import { ClockworkCostMatrix } from '../../wasm/screeps_clockwork';
1
+ import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
2
2
  /**
3
3
  * Generate a [distance map](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
4
4
  * using Dijkstra's algorithm.
@@ -8,8 +8,11 @@ import { ClockworkCostMatrix } from '../../wasm/screeps_clockwork';
8
8
  * Note that values of 0 in the cost matrix may have unexpected behavior. You probably want
9
9
  * a cost matrix with a default value of at least 1.
10
10
  *
11
+ * Note that the `roomName` on start positions is ignored - all positions
12
+ * are assumed to be in the same room as the cost matrix.
13
+ *
11
14
  * @param start - The starting positions.
12
15
  * @param costMatrix - The cost matrix to use for the flow field.
13
16
  * @returns The flow field.
14
17
  */
15
- export declare function dijkstraDistanceMap(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../../wasm/screeps_clockwork").DistanceMap;
18
+ export declare function dijkstraDistanceMap(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").DistanceMap;
@@ -1,4 +1,4 @@
1
- import { ClockworkCostMatrix } from '../../wasm/screeps_clockwork';
1
+ import { ClockworkCostMatrix } from '../wasm/screeps_clockwork';
2
2
  /**
3
3
  * Generate a [flow field](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html) for a set of positions
4
4
  * using Dijkstra's algorithm.
@@ -12,7 +12,7 @@ import { ClockworkCostMatrix } from '../../wasm/screeps_clockwork';
12
12
  * @param costMatrix - The cost matrix to use for the flow field.
13
13
  * @returns The flow field.
14
14
  */
15
- export declare function dijkstraFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../../wasm/screeps_clockwork").FlowField;
15
+ export declare function dijkstraFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").FlowField;
16
16
  /**
17
17
  * Generate a [mono-directional flow field](https://glitchassassin.github.io/screeps-clockwork/primitives/flowfield.html)
18
18
  * for a set of positions using Dijkstra's algorithm.
@@ -22,8 +22,11 @@ export declare function dijkstraFlowField(start: RoomPosition[], costMatrix: Clo
22
22
  * Note that values of 0 in the cost matrix may have unexpected behavior. You probably want
23
23
  * a cost matrix with a default value of at least 1.
24
24
  *
25
+ * Note that the `roomName` on start positions is ignored - all positions
26
+ * are assumed to be in the same room as the cost matrix.
27
+ *
25
28
  * @param start - The starting positions.
26
29
  * @param costMatrix - The cost matrix to use for the flow field.
27
30
  * @returns The flow field.
28
31
  */
29
- export declare function dijkstraMonoFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../../wasm/screeps_clockwork").MonoFlowField;
32
+ export declare function dijkstraMonoFlowField(start: RoomPosition[], costMatrix: ClockworkCostMatrix): import("../wasm/screeps_clockwork").MonoFlowField;
@@ -0,0 +1,26 @@
1
+ import { Path as ClockworkPath } from '../wasm/screeps_clockwork';
2
+ export declare class Path {
3
+ private readonly path;
4
+ constructor(path: ClockworkPath);
5
+ [Symbol.iterator](): {
6
+ next: () => {
7
+ value: RoomPosition;
8
+ done: boolean;
9
+ };
10
+ };
11
+ /**
12
+ * Iterate over the path in reverse order
13
+ */
14
+ reversed(): Generator<never, {
15
+ next: () => {
16
+ value: RoomPosition;
17
+ done: boolean;
18
+ };
19
+ }, unknown>;
20
+ get(index: number): RoomPosition;
21
+ get length(): number;
22
+ findNextIndex(index: number): number | undefined;
23
+ toArray(): RoomPosition[];
24
+ toArrayReversed(): RoomPosition[];
25
+ free(): void;
26
+ }
@@ -0,0 +1,3 @@
1
+ import { DistanceMap } from '../wasm/screeps_clockwork';
2
+ import { Path } from './path';
3
+ export declare function pathToDistanceMapOrigin(start: RoomPosition, distanceMap: DistanceMap): Path;
@@ -0,0 +1,3 @@
1
+ import { FlowField } from '../wasm/screeps_clockwork';
2
+ import { Path } from './path';
3
+ export declare function pathToFlowFieldOrigin(start: RoomPosition, flowField: FlowField): Path;
@@ -0,0 +1,3 @@
1
+ import { MonoFlowField } from '../wasm/screeps_clockwork';
2
+ import { Path } from './path';
3
+ export declare function pathToMonoFlowFieldOrigin(start: RoomPosition, flowField: MonoFlowField): Path;
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "screeps-clockwork",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "A WASM movement library for Screeps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/src/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "run-s build:lib build:src",
9
- "build:lib": "wasm-pack build --target web --out-dir wasm --config build.rustflags=[\\'-Ctarget-feature=-reference-types\\',\\'-Ctarget-feature=-multivalue\\',\\'-Ctarget-feature=-sign-ext\\'] -Z build-std=std,panic_abort",
9
+ "build:lib": "wasm-pack build --target web --out-dir src/wasm --config build.rustflags=[\\'-Ctarget-feature=-reference-types\\',\\'-Ctarget-feature=-multivalue\\',\\'-Ctarget-feature=-sign-ext\\'] -Z build-std=std,panic_abort",
10
10
  "build:src": "rollup -c",
11
11
  "build:docs": "typedoc",
12
12
  "watch": "run-s build watch:both",
13
13
  "watch:lib": "cargo-watch -w lib -s \"npm run build:lib\"",
14
- "watch:src": "wait-on wasm/screeps_clockwork_bg.wasm && rollup -cw",
14
+ "watch:src": "wait-on src/wasm/screeps_clockwork_bg.wasm && rollup -cw",
15
15
  "watch:pserver": "rollup -cw --environment DEST:pserver",
16
16
  "watch:both": "run-p watch:lib watch:pserver"
17
17
  },