screeps-clockwork 0.7.2 → 0.9.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.
@@ -1,10 +1,29 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
- export function version(): string;
4
1
  /**
5
2
  * Exports the global range calculation between two positions.
3
+ * @param {number} packed_pos_1
4
+ * @param {number} packed_pos_2
5
+ * @returns {number}
6
6
  */
7
7
  export function get_range(packed_pos_1: number, packed_pos_2: number): number;
8
+ /**
9
+ * @param {number} room_name
10
+ * @param {number | null} [plain_cost]
11
+ * @param {number | null} [swamp_cost]
12
+ * @param {number | null} [wall_cost]
13
+ * @returns {ClockworkCostMatrix}
14
+ */
15
+ export function get_terrain_cost_matrix(room_name: number, plain_cost?: number | null, swamp_cost?: number | null, wall_cost?: number | null): ClockworkCostMatrix;
16
+ /**
17
+ * @param {Uint32Array} start_packed
18
+ * @param {Function} get_cost_matrix
19
+ * @param {number} max_rooms
20
+ * @param {number} max_ops
21
+ * @param {number} max_path_cost
22
+ * @param {Uint32Array | null} [any_of_destinations]
23
+ * @param {Uint32Array | null} [all_of_destinations]
24
+ * @returns {SearchResult}
25
+ */
26
+ export function js_astar_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_rooms: number, max_ops: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
8
27
  /**
9
28
  * WASM wrapper for the BFS multiroom distance map function.
10
29
  *
@@ -20,58 +39,206 @@ export function get_range(packed_pos_1: number, packed_pos_2: number): number;
20
39
  *
21
40
  * # Returns
22
41
  * A `MultiroomDistanceMap` containing the distances from the start positions
42
+ * @param {Uint32Array} start_packed
43
+ * @param {Function} get_cost_matrix
44
+ * @param {number} max_ops
45
+ * @param {number} max_rooms
46
+ * @param {number} max_path_cost
47
+ * @param {Uint32Array | null} [any_of_destinations]
48
+ * @param {Uint32Array | null} [all_of_destinations]
49
+ * @returns {SearchResult}
23
50
  */
24
51
  export function js_bfs_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_ops: number, max_rooms: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
52
+ /**
53
+ * @param {Uint32Array} start_packed
54
+ * @param {Function} get_cost_matrix
55
+ * @param {number} max_ops
56
+ * @param {number} max_rooms
57
+ * @param {number} max_path_cost
58
+ * @param {Uint32Array | null} [any_of_destinations]
59
+ * @param {Uint32Array | null} [all_of_destinations]
60
+ * @returns {SearchResult}
61
+ */
25
62
  export function js_dijkstra_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_ops: number, max_rooms: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
63
+ /**
64
+ * @param {number} start
65
+ * @param {MultiroomDistanceMap} distance_map
66
+ * @param {DirectionOrder} direction_order
67
+ * @returns {Path}
68
+ */
69
+ export function js_path_to_multiroom_distance_map_origin(start: number, distance_map: MultiroomDistanceMap, direction_order: DirectionOrder): Path;
70
+ /**
71
+ * @param {number} start
72
+ * @param {MultiroomFlowField} flow_field
73
+ * @returns {Path}
74
+ */
75
+ export function js_path_to_multiroom_flow_field_origin(start: number, flow_field: MultiroomFlowField): Path;
76
+ /**
77
+ * @param {number} start
78
+ * @param {MultiroomMonoFlowField} flow_field
79
+ * @returns {Path}
80
+ */
26
81
  export function js_path_to_multiroom_mono_flow_field_origin(start: number, flow_field: MultiroomMonoFlowField): Path;
82
+ /**
83
+ * Creates a flow field for the given distance map.
84
+ * @param {MultiroomDistanceMap} distance_map
85
+ * @param {DirectionOrder} direction_order
86
+ * @returns {MultiroomFlowField}
87
+ */
88
+ export function multiroomFlowField(distance_map: MultiroomDistanceMap, direction_order: DirectionOrder): MultiroomFlowField;
27
89
  /**
28
90
  * Creates a monodirectional flow field for the given distance map.
91
+ * @param {MultiroomDistanceMap} distance_map
92
+ * @param {DirectionOrder} direction_order
93
+ * @returns {MultiroomMonoFlowField}
29
94
  */
30
- export function multiroomMonoFlowField(distance_map: MultiroomDistanceMap): MultiroomMonoFlowField;
31
- export function get_terrain_cost_matrix(room_name: number, plain_cost?: number | null, swamp_cost?: number | null, wall_cost?: number | null): ClockworkCostMatrix;
95
+ export function multiroomMonoFlowField(distance_map: MultiroomDistanceMap, direction_order: DirectionOrder): MultiroomMonoFlowField;
32
96
  /**
33
- * Creates a flow field for the given distance map.
97
+ * @returns {string}
34
98
  */
35
- export function multiroomFlowField(distance_map: MultiroomDistanceMap): MultiroomFlowField;
36
- export function js_path_to_multiroom_flow_field_origin(start: number, flow_field: MultiroomFlowField): Path;
37
- export function js_path_to_multiroom_distance_map_origin(start: number, distance_map: MultiroomDistanceMap): Path;
38
- export function js_astar_multiroom_distance_map(start_packed: Uint32Array, get_cost_matrix: Function, max_rooms: number, max_ops: number, max_path_cost: number, any_of_destinations?: Uint32Array | null, all_of_destinations?: Uint32Array | null): SearchResult;
99
+ export function version(): string;
39
100
  /**
40
- * Translates `COLOR_*` and `COLORS_ALL` constants.
101
+ * A wrapper around the `LocalCostMatrix` type from the Screeps API.
102
+ * Instances can be passed between WASM and JS as a pointer, using the
103
+ * methods to get and set values, rather than copying the entire matrix.
41
104
  */
42
- export enum Color {
43
- Red = 1,
44
- Purple = 2,
45
- Blue = 3,
46
- Cyan = 4,
47
- Green = 5,
48
- Yellow = 6,
49
- Orange = 7,
50
- Brown = 8,
51
- Grey = 9,
52
- White = 10,
105
+ export class ClockworkCostMatrix {
106
+ static __wrap(ptr: any): any;
107
+ /**
108
+ * Creates a new cost matrix within the WASM module. Optionally, a default value
109
+ * can be provided to initialize all cells in the matrix to that value.
110
+ * @param {number | null} [_default]
111
+ */
112
+ constructor(_default?: number | null);
113
+ __destroy_into_raw(): any;
114
+ __wbg_ptr: any;
115
+ free(): void;
116
+ /**
117
+ * Gets the cost of a given position in the cost matrix.
118
+ * @param {number} x
119
+ * @param {number} y
120
+ * @returns {number}
121
+ */
122
+ get(x: number, y: number): number;
123
+ /**
124
+ * Sets the cost of a given position in the cost matrix.
125
+ * @param {number} x
126
+ * @param {number} y
127
+ * @param {number} value
128
+ */
129
+ set(x: number, y: number, value: number): void;
53
130
  }
131
+ /**
132
+ * Translates `COLOR_*` and `COLORS_ALL` constants.
133
+ */
134
+ export type Color = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
135
+ /**
136
+ * Translates `COLOR_*` and `COLORS_ALL` constants.
137
+ * @enum {1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10}
138
+ */
139
+ export const Color: Readonly<{
140
+ Red: 1;
141
+ "1": "Red";
142
+ Purple: 2;
143
+ "2": "Purple";
144
+ Blue: 3;
145
+ "3": "Blue";
146
+ Cyan: 4;
147
+ "4": "Cyan";
148
+ Green: 5;
149
+ "5": "Green";
150
+ Yellow: 6;
151
+ "6": "Yellow";
152
+ Orange: 7;
153
+ "7": "Orange";
154
+ Brown: 8;
155
+ "8": "Brown";
156
+ Grey: 9;
157
+ "9": "Grey";
158
+ White: 10;
159
+ "10": "White";
160
+ }>;
54
161
  /**
55
162
  * Translates the `DENSITY_*` constants.
56
163
  */
57
- export enum Density {
58
- Low = 1,
59
- Moderate = 2,
60
- High = 3,
61
- Ultra = 4,
62
- }
164
+ export type Density = 1 | 2 | 3 | 4;
165
+ /**
166
+ * Translates the `DENSITY_*` constants.
167
+ * @enum {1 | 2 | 3 | 4}
168
+ */
169
+ export const Density: Readonly<{
170
+ Low: 1;
171
+ "1": "Low";
172
+ Moderate: 2;
173
+ "2": "Moderate";
174
+ High: 3;
175
+ "3": "High";
176
+ Ultra: 4;
177
+ "4": "Ultra";
178
+ }>;
63
179
  /**
64
180
  * Translates direction constants.
65
181
  */
66
- export enum Direction {
67
- Top = 1,
68
- TopRight = 2,
69
- Right = 3,
70
- BottomRight = 4,
71
- Bottom = 5,
72
- BottomLeft = 6,
73
- Left = 7,
74
- TopLeft = 8,
182
+ export type Direction = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
183
+ /**
184
+ * Translates direction constants.
185
+ * @enum {1 | 2 | 3 | 4 | 5 | 6 | 7 | 8}
186
+ */
187
+ export const Direction: Readonly<{
188
+ Top: 1;
189
+ "1": "Top";
190
+ TopRight: 2;
191
+ "2": "TopRight";
192
+ Right: 3;
193
+ "3": "Right";
194
+ BottomRight: 4;
195
+ "4": "BottomRight";
196
+ Bottom: 5;
197
+ "5": "Bottom";
198
+ BottomLeft: 6;
199
+ "6": "BottomLeft";
200
+ Left: 7;
201
+ "7": "Left";
202
+ TopLeft: 8;
203
+ "8": "TopLeft";
204
+ }>;
205
+ export type DirectionOrder = 0 | 1;
206
+ /**
207
+ * @enum {0 | 1}
208
+ */
209
+ export const DirectionOrder: Readonly<{
210
+ CardinalFirst: 0;
211
+ "0": "CardinalFirst";
212
+ DiagonalFirst: 1;
213
+ "1": "DiagonalFirst";
214
+ }>;
215
+ /**
216
+ * Maps a distance value onto individual room tile positions.
217
+ */
218
+ export class DistanceMap {
219
+ static __wrap(ptr: any): any;
220
+ __destroy_into_raw(): number | undefined;
221
+ __wbg_ptr: number | undefined;
222
+ free(): void;
223
+ /**
224
+ * Gets the distance value at a given position.
225
+ * @param {number} x
226
+ * @param {number} y
227
+ * @returns {number}
228
+ */
229
+ get(x: number, y: number): number;
230
+ /**
231
+ * Sets the distance value at a given position.
232
+ * @param {number} x
233
+ * @param {number} y
234
+ * @param {number} value
235
+ */
236
+ set(x: number, y: number, value: number): void;
237
+ /**
238
+ * Converts the distance map into a flat array of distances.
239
+ * @returns {Uint32Array}
240
+ */
241
+ toArray(): Uint32Array;
75
242
  }
76
243
  /**
77
244
  * Type used for when the game returns a direction to an exit.
@@ -85,12 +252,30 @@ export enum Direction {
85
252
  * [`Room::find`]: crate::objects::Room::find
86
253
  * [`Room::find_exit_to`]: crate::objects::Room::find_exit_to
87
254
  */
88
- export enum ExitDirection {
89
- Top = 1,
90
- Right = 3,
91
- Bottom = 5,
92
- Left = 7,
93
- }
255
+ export type ExitDirection = 1 | 3 | 5 | 7;
256
+ /**
257
+ * Type used for when the game returns a direction to an exit.
258
+ *
259
+ * Restricted more than `Direction` in that it can't be diagonal. Used as the
260
+ * result of [`Room::find_exit_to`].
261
+ *
262
+ * Can be converted to [`Find`] for immediate use of [`Room::find`]
263
+ * and [`Direction`].
264
+ *
265
+ * [`Room::find`]: crate::objects::Room::find
266
+ * [`Room::find_exit_to`]: crate::objects::Room::find_exit_to
267
+ * @enum {1 | 3 | 5 | 7}
268
+ */
269
+ export const ExitDirection: Readonly<{
270
+ Top: 1;
271
+ "1": "Top";
272
+ Right: 3;
273
+ "3": "Right";
274
+ Bottom: 5;
275
+ "5": "Bottom";
276
+ Left: 7;
277
+ "7": "Left";
278
+ }>;
94
279
  /**
95
280
  * Translates `FIND_*` constants for interal API calls
96
281
  *
@@ -101,123 +286,89 @@ export enum ExitDirection {
101
286
  * This is hidden from the documentation to avoid confusion due to its narrow
102
287
  * use case, but wasm_bindgen requires it remain public.
103
288
  */
104
- export enum Find {
105
- /**
106
- * Find all exit positions at the top of the room
107
- */
108
- ExitTop = 1,
109
- ExitRight = 3,
110
- ExitBottom = 5,
111
- ExitLeft = 7,
112
- Exit = 10,
113
- Creeps = 101,
114
- MyCreeps = 102,
115
- HostileCreeps = 103,
116
- SourcesActive = 104,
117
- Sources = 105,
118
- DroppedResources = 106,
119
- Structures = 107,
120
- MyStructures = 108,
121
- HostileStructures = 109,
122
- Flags = 110,
123
- ConstructionSites = 111,
124
- MySpawns = 112,
125
- HostileSpawns = 113,
126
- MyConstructionSites = 114,
127
- HostileConstructionSites = 115,
128
- Minerals = 116,
129
- Nukes = 117,
130
- Tombstones = 118,
131
- PowerCreeps = 119,
132
- MyPowerCreeps = 120,
133
- HostilePowerCreeps = 121,
134
- Deposits = 122,
135
- Ruins = 123,
136
- ScoreContainers = 10011,
137
- ScoreCollectors = 10012,
138
- SymbolContainers = 10021,
139
- SymbolDecoders = 10022,
140
- Reactors = 10051,
141
- }
289
+ export type Find = 1 | 3 | 5 | 7 | 10 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 10011 | 10012 | 10021 | 10022 | 10051;
142
290
  /**
143
- * Translates the `EFFECT_*` constants, which are natural effect types
144
- */
145
- export enum NaturalEffectType {
146
- Invulnerability = 1001,
147
- CollapseTimer = 1002,
148
- }
149
- /**
150
- * Translates the `PWR_*` constants, which are types of powers used by power
151
- * creeps
152
- */
153
- export enum PowerType {
154
- GenerateOps = 1,
155
- OperateSpawn = 2,
156
- OperateTower = 3,
157
- OperateStorage = 4,
158
- OperateLab = 5,
159
- OperateExtension = 6,
160
- OperateObserver = 7,
161
- OperateTerminal = 8,
162
- DisruptSpawn = 9,
163
- DisruptTower = 10,
164
- Shield = 12,
165
- RegenSource = 13,
166
- RegenMineral = 14,
167
- DisruptTerminal = 15,
168
- OperatePower = 16,
169
- Fortify = 17,
170
- OperateController = 18,
171
- OperateFactory = 19,
172
- }
173
- /**
174
- * Translates `TERRAIN_*` constants.
175
- */
176
- export enum Terrain {
177
- Plain = 0,
178
- Wall = 1,
179
- Swamp = 2,
180
- }
181
- /**
182
- * A wrapper around the `LocalCostMatrix` type from the Screeps API.
183
- * Instances can be passed between WASM and JS as a pointer, using the
184
- * methods to get and set values, rather than copying the entire matrix.
185
- */
186
- export class ClockworkCostMatrix {
187
- free(): void;
188
- /**
189
- * Creates a new cost matrix within the WASM module. Optionally, a default value
190
- * can be provided to initialize all cells in the matrix to that value.
191
- */
192
- constructor(_default?: number | null);
193
- /**
194
- * Gets the cost of a given position in the cost matrix.
195
- */
196
- get(x: number, y: number): number;
197
- /**
198
- * Sets the cost of a given position in the cost matrix.
199
- */
200
- set(x: number, y: number, value: number): void;
201
- }
202
- /**
203
- * Maps a distance value onto individual room tile positions.
291
+ * Translates `FIND_*` constants for interal API calls
292
+ *
293
+ * Unless you're storing the type of find constant to be used for a call, you
294
+ * likely want the constants which implement the `FindConstant` trait to make
295
+ * calls to find methods.
296
+ *
297
+ * This is hidden from the documentation to avoid confusion due to its narrow
298
+ * use case, but wasm_bindgen requires it remain public.
299
+ * @enum {1 | 3 | 5 | 7 | 10 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 10011 | 10012 | 10021 | 10022 | 10051}
204
300
  */
205
- export class DistanceMap {
206
- private constructor();
207
- free(): void;
208
- /**
209
- * Gets the distance value at a given position.
210
- */
211
- get(x: number, y: number): number;
212
- /**
213
- * Sets the distance value at a given position.
214
- */
215
- set(x: number, y: number, value: number): void;
216
- /**
217
- * Converts the distance map into a flat array of distances.
218
- */
219
- toArray(): Uint32Array;
220
- }
301
+ export const Find: Readonly<{
302
+ /**
303
+ * Find all exit positions at the top of the room
304
+ */
305
+ ExitTop: 1;
306
+ "1": "ExitTop";
307
+ ExitRight: 3;
308
+ "3": "ExitRight";
309
+ ExitBottom: 5;
310
+ "5": "ExitBottom";
311
+ ExitLeft: 7;
312
+ "7": "ExitLeft";
313
+ Exit: 10;
314
+ "10": "Exit";
315
+ Creeps: 101;
316
+ "101": "Creeps";
317
+ MyCreeps: 102;
318
+ "102": "MyCreeps";
319
+ HostileCreeps: 103;
320
+ "103": "HostileCreeps";
321
+ SourcesActive: 104;
322
+ "104": "SourcesActive";
323
+ Sources: 105;
324
+ "105": "Sources";
325
+ DroppedResources: 106;
326
+ "106": "DroppedResources";
327
+ Structures: 107;
328
+ "107": "Structures";
329
+ MyStructures: 108;
330
+ "108": "MyStructures";
331
+ HostileStructures: 109;
332
+ "109": "HostileStructures";
333
+ Flags: 110;
334
+ "110": "Flags";
335
+ ConstructionSites: 111;
336
+ "111": "ConstructionSites";
337
+ MySpawns: 112;
338
+ "112": "MySpawns";
339
+ HostileSpawns: 113;
340
+ "113": "HostileSpawns";
341
+ MyConstructionSites: 114;
342
+ "114": "MyConstructionSites";
343
+ HostileConstructionSites: 115;
344
+ "115": "HostileConstructionSites";
345
+ Minerals: 116;
346
+ "116": "Minerals";
347
+ Nukes: 117;
348
+ "117": "Nukes";
349
+ Tombstones: 118;
350
+ "118": "Tombstones";
351
+ PowerCreeps: 119;
352
+ "119": "PowerCreeps";
353
+ MyPowerCreeps: 120;
354
+ "120": "MyPowerCreeps";
355
+ HostilePowerCreeps: 121;
356
+ "121": "HostilePowerCreeps";
357
+ Deposits: 122;
358
+ "122": "Deposits";
359
+ Ruins: 123;
360
+ "123": "Ruins";
361
+ ScoreContainers: 10011;
362
+ "10011": "ScoreContainers";
363
+ ScoreCollectors: 10012;
364
+ "10012": "ScoreCollectors";
365
+ SymbolContainers: 10021;
366
+ "10021": "SymbolContainers";
367
+ SymbolDecoders: 10022;
368
+ "10022": "SymbolDecoders";
369
+ Reactors: 10051;
370
+ "10051": "Reactors";
371
+ }>;
221
372
  /**
222
373
  * A flow field is a 50x50 grid (representing a room), representing viable directions
223
374
  * to travel to reach a particular target (or targets). A given tile may have multiple
@@ -225,28 +376,45 @@ export class DistanceMap {
225
376
  * 8-bit unsigned integer represents a direction that is either viable or not).
226
377
  */
227
378
  export class FlowField {
228
- private constructor();
229
- free(): void;
230
- /**
231
- * Add a direction to the list of valid directions for a given coordinate.
232
- */
233
- addDirection(x: number, y: number, direction: Direction): void;
234
- /**
235
- * Get the list of valid directions for a given coordinate.
236
- */
237
- getDirections(x: number, y: number): any[];
238
- /**
239
- * Set the list of valid directions for a given coordinate.
240
- */
241
- setDirections(x: number, y: number, directions: any[]): void;
242
- /**
243
- * Get the internal value for a given coordinate.
244
- */
245
- get(x: number, y: number): number;
246
- /**
247
- * Set the internal value for a given coordinate.
248
- */
249
- set(x: number, y: number, value: number): void;
379
+ static __wrap(ptr: any): any;
380
+ __destroy_into_raw(): number | undefined;
381
+ __wbg_ptr: number | undefined;
382
+ free(): void;
383
+ /**
384
+ * Add a direction to the list of valid directions for a given coordinate.
385
+ * @param {number} x
386
+ * @param {number} y
387
+ * @param {Direction} direction
388
+ */
389
+ addDirection(x: number, y: number, direction: Direction): void;
390
+ /**
391
+ * Get the internal value for a given coordinate.
392
+ * @param {number} x
393
+ * @param {number} y
394
+ * @returns {number}
395
+ */
396
+ get(x: number, y: number): number;
397
+ /**
398
+ * Get the list of valid directions for a given coordinate.
399
+ * @param {number} x
400
+ * @param {number} y
401
+ * @returns {any[]}
402
+ */
403
+ getDirections(x: number, y: number): any[];
404
+ /**
405
+ * Set the internal value for a given coordinate.
406
+ * @param {number} x
407
+ * @param {number} y
408
+ * @param {number} value
409
+ */
410
+ set(x: number, y: number, value: number): void;
411
+ /**
412
+ * Set the list of valid directions for a given coordinate.
413
+ * @param {number} x
414
+ * @param {number} y
415
+ * @param {any[]} directions
416
+ */
417
+ setDirections(x: number, y: number, directions: any[]): void;
250
418
  }
251
419
  /**
252
420
  * A flow field is a 50x50 grid (representing a room), representing viable directions
@@ -255,156 +423,288 @@ export class FlowField {
255
423
  * integer (0 for no direction, 1 for TOP, etc.).
256
424
  */
257
425
  export class MonoFlowField {
258
- private constructor();
259
- free(): void;
260
- /**
261
- * Get the direction for a given coordinate.
262
- */
263
- get(x: number, y: number): Direction | undefined;
264
- /**
265
- * Set the direction for a given coordinate.
266
- */
267
- set(x: number, y: number, value?: Direction | null): void;
426
+ static __wrap(ptr: any): any;
427
+ __destroy_into_raw(): number | undefined;
428
+ __wbg_ptr: number | undefined;
429
+ free(): void;
430
+ /**
431
+ * Get the direction for a given coordinate.
432
+ * @param {number} x
433
+ * @param {number} y
434
+ * @returns {Direction | undefined}
435
+ */
436
+ get(x: number, y: number): Direction | undefined;
437
+ /**
438
+ * Set the direction for a given coordinate.
439
+ * @param {number} x
440
+ * @param {number} y
441
+ * @param {Direction | null} [value]
442
+ */
443
+ set(x: number, y: number, value?: Direction | null): void;
268
444
  }
269
445
  /**
270
446
  * Maps distance values across multiple rooms, storing a DistanceMap for each room
271
447
  */
272
448
  export class MultiroomDistanceMap {
273
- free(): void;
274
- /**
275
- * Gets the DistanceMap for a given room
276
- */
277
- get_room(room_name: number): DistanceMap | undefined;
278
- /**
279
- * Gets the list of rooms in the map
280
- */
281
- get_rooms(): Uint16Array;
282
- /**
283
- * Gets the distance value at a given position
284
- */
285
- get(packed_pos: number): number;
286
- /**
287
- * Creates a new empty multiroom distance map (JavaScript constructor)
288
- */
289
- constructor();
290
- /**
291
- * Sets the distance value at a given position
292
- */
293
- set(packed_pos: number, value: number): void;
449
+ static __wrap(ptr: any): any;
450
+ __destroy_into_raw(): any;
451
+ __wbg_ptr: any;
452
+ free(): void;
453
+ /**
454
+ * Gets the distance value at a given position
455
+ * @param {number} packed_pos
456
+ * @returns {number}
457
+ */
458
+ get(packed_pos: number): number;
459
+ /**
460
+ * Gets the DistanceMap for a given room
461
+ * @param {number} room_name
462
+ * @returns {DistanceMap | undefined}
463
+ */
464
+ get_room(room_name: number): DistanceMap | undefined;
465
+ /**
466
+ * Gets the list of rooms in the map
467
+ * @returns {Uint16Array}
468
+ */
469
+ get_rooms(): Uint16Array;
470
+ /**
471
+ * Sets the distance value at a given position
472
+ * @param {number} packed_pos
473
+ * @param {number} value
474
+ */
475
+ set(packed_pos: number, value: number): void;
294
476
  }
295
477
  /**
296
478
  * Maps flow field values across multiple rooms, storing a FlowField for each room
297
479
  */
298
480
  export class MultiroomFlowField {
299
- free(): void;
300
- /**
301
- * Gets the FlowField for a given room
302
- */
303
- getRoom(room_name: number): FlowField | undefined;
304
- /**
305
- * Gets the list of rooms in the flow field
306
- */
307
- getRooms(): Uint16Array;
308
- /**
309
- * Adds a direction to the list of valid directions at a given position (JavaScript)
310
- */
311
- addDirection(packed_pos: number, direction: Direction): void;
312
- /**
313
- * Gets the list of valid directions at a given position (JavaScript)
314
- */
315
- getDirections(packed_pos: number): any[];
316
- /**
317
- * Sets the list of valid directions at a given position (JavaScript)
318
- */
319
- setDirections(packed_pos: number, directions: any[]): void;
320
- /**
321
- * Gets the flow field value at a given position
322
- */
323
- get(packed_pos: number): number;
324
- /**
325
- * Creates a new empty multiroom flow field (JavaScript constructor)
326
- */
327
- constructor();
328
- /**
329
- * Sets the flow field value at a given position
330
- */
331
- set(packed_pos: number, value: number): void;
481
+ static __wrap(ptr: any): any;
482
+ __destroy_into_raw(): any;
483
+ __wbg_ptr: any;
484
+ free(): void;
485
+ /**
486
+ * Adds a direction to the list of valid directions at a given position (JavaScript)
487
+ * @param {number} packed_pos
488
+ * @param {Direction} direction
489
+ */
490
+ addDirection(packed_pos: number, direction: Direction): void;
491
+ /**
492
+ * Gets the flow field value at a given position
493
+ * @param {number} packed_pos
494
+ * @returns {number}
495
+ */
496
+ get(packed_pos: number): number;
497
+ /**
498
+ * Gets the list of valid directions at a given position (JavaScript)
499
+ * @param {number} packed_pos
500
+ * @returns {any[]}
501
+ */
502
+ getDirections(packed_pos: number): any[];
503
+ /**
504
+ * Gets the FlowField for a given room
505
+ * @param {number} room_name
506
+ * @returns {FlowField | undefined}
507
+ */
508
+ getRoom(room_name: number): FlowField | undefined;
509
+ /**
510
+ * Gets the list of rooms in the flow field
511
+ * @returns {Uint16Array}
512
+ */
513
+ getRooms(): Uint16Array;
514
+ /**
515
+ * Sets the flow field value at a given position
516
+ * @param {number} packed_pos
517
+ * @param {number} value
518
+ */
519
+ set(packed_pos: number, value: number): void;
520
+ /**
521
+ * Sets the list of valid directions at a given position (JavaScript)
522
+ * @param {number} packed_pos
523
+ * @param {any[]} directions
524
+ */
525
+ setDirections(packed_pos: number, directions: any[]): void;
332
526
  }
333
527
  /**
334
528
  * Maps monodirectional flow field values across multiple rooms, storing a MonoFlowField for each room
335
529
  */
336
530
  export class MultiroomMonoFlowField {
337
- free(): void;
338
- /**
339
- * Gets the MonoFlowField for a given room
340
- */
341
- getRoom(room_name: number): MonoFlowField | undefined;
342
- /**
343
- * Gets the list of rooms in the flow field
344
- */
345
- getRooms(): Uint16Array;
346
- /**
347
- * Gets the direction at a given position
348
- */
349
- get(packed_pos: number): Direction | undefined;
350
- /**
351
- * Creates a new empty multiroom monodirectional flow field (JavaScript constructor)
352
- */
353
- constructor();
354
- /**
355
- * Sets the direction at a given position
356
- */
357
- set(packed_pos: number, direction?: Direction | null): void;
531
+ static __wrap(ptr: any): any;
532
+ __destroy_into_raw(): any;
533
+ __wbg_ptr: any;
534
+ free(): void;
535
+ /**
536
+ * Gets the direction at a given position
537
+ * @param {number} packed_pos
538
+ * @returns {Direction | undefined}
539
+ */
540
+ get(packed_pos: number): Direction | undefined;
541
+ /**
542
+ * Gets the MonoFlowField for a given room
543
+ * @param {number} room_name
544
+ * @returns {MonoFlowField | undefined}
545
+ */
546
+ getRoom(room_name: number): MonoFlowField | undefined;
547
+ /**
548
+ * Gets the list of rooms in the flow field
549
+ * @returns {Uint16Array}
550
+ */
551
+ getRooms(): Uint16Array;
552
+ /**
553
+ * Sets the direction at a given position
554
+ * @param {number} packed_pos
555
+ * @param {Direction | null} [direction]
556
+ */
557
+ set(packed_pos: number, direction?: Direction | null): void;
358
558
  }
559
+ /**
560
+ * Translates the `EFFECT_*` constants, which are natural effect types
561
+ */
562
+ export type NaturalEffectType = 1001 | 1002;
563
+ /**
564
+ * Translates the `EFFECT_*` constants, which are natural effect types
565
+ * @enum {1001 | 1002}
566
+ */
567
+ export const NaturalEffectType: Readonly<{
568
+ Invulnerability: 1001;
569
+ "1001": "Invulnerability";
570
+ CollapseTimer: 1002;
571
+ "1002": "CollapseTimer";
572
+ }>;
359
573
  /**
360
574
  * A list of positions representing a path.
361
575
  */
362
576
  export class Path {
363
- private constructor();
364
- free(): void;
365
- to_array(): Uint32Array;
366
- /**
367
- * Given a position, find the index of the next adjacent position
368
- * in the path. If the position is not in the path, the target is
369
- * the next adjacent position closest to the end of the path. If
370
- * the position is neither on nor adjacent to the path, return None.
371
- */
372
- find_next_index(packed_position: number): number | undefined;
373
- to_array_reversed(): Uint32Array;
374
- add(packed_position: number): void;
375
- get(index: number): number | undefined;
376
- len(): number;
577
+ static __wrap(ptr: any): any;
578
+ __destroy_into_raw(): number | undefined;
579
+ __wbg_ptr: number | undefined;
580
+ free(): void;
581
+ /**
582
+ * @param {number} packed_position
583
+ */
584
+ add(packed_position: number): void;
585
+ /**
586
+ * Given a position, find the index of the next adjacent position
587
+ * in the path. If the position is not in the path, the target is
588
+ * the next adjacent position closest to the end of the path. If
589
+ * the position is neither on nor adjacent to the path, return None.
590
+ * @param {number} packed_position
591
+ * @returns {number | undefined}
592
+ */
593
+ find_next_index(packed_position: number): number | undefined;
594
+ /**
595
+ * @param {number} index
596
+ * @returns {number | undefined}
597
+ */
598
+ get(index: number): number | undefined;
599
+ /**
600
+ * @returns {number}
601
+ */
602
+ len(): number;
603
+ /**
604
+ * @returns {Uint32Array}
605
+ */
606
+ to_array(): Uint32Array;
607
+ /**
608
+ * @returns {Uint32Array}
609
+ */
610
+ to_array_reversed(): Uint32Array;
377
611
  }
378
612
  /**
379
613
  * Tracks fatigue cost for each position in a path. Used to calculate move time
380
614
  * for a given creep build.
381
615
  */
382
616
  export class PathFatigue {
383
- free(): void;
384
- len(): number;
385
- constructor(path: Path);
386
- /**
387
- * Refreshes fatigue cost for each position in the path. If the PathFatigue
388
- * has not been initialized yet, every position's fatigue cost will be set,
389
- * even if there is no vision in the room, based on terrain costs. If the
390
- * list *has* been initialized, only positions with vision will be updated.
391
- *
392
- * When there is vision, this also accounts for roads at the position.
393
- */
394
- refresh(path: Path): void;
395
- /**
396
- * Calculates the total move time for the path, given a fatigue ratio.
397
- *
398
- * For unboosted creeps, the ratio is `Math.floor(moveParts * 2 / fatigueParts)`
399
- * where `fatigue_parts` are any part except MOVE and empty CARRY parts.
400
- */
401
- moveTime(fatigue_ratio: number): number;
617
+ /**
618
+ * @param {Path} path
619
+ */
620
+ constructor(path: Path);
621
+ __destroy_into_raw(): any;
622
+ __wbg_ptr: any;
623
+ free(): void;
624
+ /**
625
+ * @returns {number}
626
+ */
627
+ len(): number;
628
+ /**
629
+ * Calculates the total move time for the path, given a fatigue ratio.
630
+ *
631
+ * For unboosted creeps, the ratio is `Math.floor(moveParts * 2 / fatigueParts)`
632
+ * where `fatigue_parts` are any part except MOVE and empty CARRY parts.
633
+ * @param {number} fatigue_ratio
634
+ * @returns {number}
635
+ */
636
+ moveTime(fatigue_ratio: number): number;
637
+ /**
638
+ * Refreshes fatigue cost for each position in the path. If the PathFatigue
639
+ * has not been initialized yet, every position's fatigue cost will be set,
640
+ * even if there is no vision in the room, based on terrain costs. If the
641
+ * list *has* been initialized, only positions with vision will be updated.
642
+ *
643
+ * When there is vision, this also accounts for roads at the position.
644
+ * @param {Path} path
645
+ */
646
+ refresh(path: Path): void;
402
647
  }
648
+ /**
649
+ * Translates the `PWR_*` constants, which are types of powers used by power
650
+ * creeps
651
+ */
652
+ export type PowerType = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19;
653
+ /**
654
+ * Translates the `PWR_*` constants, which are types of powers used by power
655
+ * creeps
656
+ * @enum {1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19}
657
+ */
658
+ export const PowerType: Readonly<{
659
+ GenerateOps: 1;
660
+ "1": "GenerateOps";
661
+ OperateSpawn: 2;
662
+ "2": "OperateSpawn";
663
+ OperateTower: 3;
664
+ "3": "OperateTower";
665
+ OperateStorage: 4;
666
+ "4": "OperateStorage";
667
+ OperateLab: 5;
668
+ "5": "OperateLab";
669
+ OperateExtension: 6;
670
+ "6": "OperateExtension";
671
+ OperateObserver: 7;
672
+ "7": "OperateObserver";
673
+ OperateTerminal: 8;
674
+ "8": "OperateTerminal";
675
+ DisruptSpawn: 9;
676
+ "9": "DisruptSpawn";
677
+ DisruptTower: 10;
678
+ "10": "DisruptTower";
679
+ Shield: 12;
680
+ "12": "Shield";
681
+ RegenSource: 13;
682
+ "13": "RegenSource";
683
+ RegenMineral: 14;
684
+ "14": "RegenMineral";
685
+ DisruptTerminal: 15;
686
+ "15": "DisruptTerminal";
687
+ OperatePower: 16;
688
+ "16": "OperatePower";
689
+ Fortify: 17;
690
+ "17": "Fortify";
691
+ OperateController: 18;
692
+ "18": "OperateController";
693
+ OperateFactory: 19;
694
+ "19": "OperateFactory";
695
+ }>;
403
696
  export class SearchGoal {
404
- private constructor();
405
- free(): void;
406
- readonly pos: any;
407
- readonly range: number;
697
+ __destroy_into_raw(): number | undefined;
698
+ __wbg_ptr: number | undefined;
699
+ free(): void;
700
+ /**
701
+ * @returns {any}
702
+ */
703
+ get pos(): any;
704
+ /**
705
+ * @returns {number}
706
+ */
707
+ get range(): number;
408
708
  }
409
709
  /**
410
710
  * A distance map search returns both the distance map (filled out
@@ -416,109 +716,39 @@ export class SearchGoal {
416
716
  * ones that are in range of the found target(s).
417
717
  */
418
718
  export class SearchResult {
419
- private constructor();
420
- free(): void;
421
- readonly distance_map: MultiroomDistanceMap;
422
- readonly found_targets: Uint32Array;
423
- readonly ops: number;
719
+ static __wrap(ptr: any): any;
720
+ __destroy_into_raw(): number | undefined;
721
+ __wbg_ptr: number | undefined;
722
+ free(): void;
723
+ /**
724
+ * @returns {MultiroomDistanceMap}
725
+ */
726
+ get distance_map(): MultiroomDistanceMap;
727
+ /**
728
+ * @returns {Uint32Array}
729
+ */
730
+ get found_targets(): Uint32Array;
731
+ /**
732
+ * @returns {number}
733
+ */
734
+ get ops(): number;
424
735
  }
425
-
426
- export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
427
-
428
- export interface InitOutput {
429
- readonly memory: WebAssembly.Memory;
430
- readonly get_range: (a: number, b: number) => number;
431
- readonly js_bfs_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
432
- readonly js_dijkstra_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
433
- readonly js_path_to_multiroom_mono_flow_field_origin: (a: number, b: number) => number;
434
- readonly version: (a: number) => void;
435
- readonly __wbg_distancemap_free: (a: number, b: number) => void;
436
- readonly __wbg_flowfield_free: (a: number, b: number) => void;
437
- readonly distancemap_get: (a: number, b: number, c: number) => number;
438
- readonly distancemap_set: (a: number, b: number, c: number, d: number) => void;
439
- readonly distancemap_toArray: (a: number, b: number) => void;
440
- readonly flowfield_addDirection: (a: number, b: number, c: number, d: number) => void;
441
- readonly flowfield_get: (a: number, b: number, c: number) => number;
442
- readonly flowfield_getDirections: (a: number, b: number, c: number, d: number) => void;
443
- readonly flowfield_set: (a: number, b: number, c: number, d: number) => void;
444
- readonly flowfield_setDirections: (a: number, b: number, c: number, d: number, e: number) => void;
445
- readonly multiroomMonoFlowField: (a: number) => number;
446
- readonly __wbg_clockworkcostmatrix_free: (a: number, b: number) => void;
447
- readonly clockworkcostmatrix_get: (a: number, b: number, c: number) => number;
448
- readonly clockworkcostmatrix_new: (a: number) => number;
449
- readonly clockworkcostmatrix_set: (a: number, b: number, c: number, d: number) => void;
450
- readonly __wbg_monoflowfield_free: (a: number, b: number) => void;
451
- readonly __wbg_multiroommonoflowfield_free: (a: number, b: number) => void;
452
- readonly get_terrain_cost_matrix: (a: number, b: number, c: number, d: number) => number;
453
- readonly monoflowfield_get: (a: number, b: number, c: number) => number;
454
- readonly monoflowfield_set: (a: number, b: number, c: number, d: number) => void;
455
- readonly multiroomFlowField: (a: number) => number;
456
- readonly multiroommonoflowfield_get: (a: number, b: number) => number;
457
- readonly multiroommonoflowfield_getRoom: (a: number, b: number) => number;
458
- readonly multiroommonoflowfield_getRooms: (a: number, b: number) => void;
459
- readonly multiroommonoflowfield_js_new: () => number;
460
- readonly multiroommonoflowfield_set: (a: number, b: number, c: number) => void;
461
- readonly __wbg_multiroomdistancemap_free: (a: number, b: number) => void;
462
- readonly __wbg_multiroomflowfield_free: (a: number, b: number) => void;
463
- readonly __wbg_searchresult_free: (a: number, b: number) => void;
464
- readonly js_path_to_multiroom_distance_map_origin: (a: number, b: number) => number;
465
- readonly js_path_to_multiroom_flow_field_origin: (a: number, b: number) => number;
466
- readonly multiroomdistancemap_get: (a: number, b: number) => number;
467
- readonly multiroomdistancemap_get_room: (a: number, b: number) => number;
468
- readonly multiroomdistancemap_get_rooms: (a: number, b: number) => void;
469
- readonly multiroomdistancemap_js_new: () => number;
470
- readonly multiroomdistancemap_set: (a: number, b: number, c: number) => void;
471
- readonly multiroomflowfield_addDirection: (a: number, b: number, c: number) => void;
472
- readonly multiroomflowfield_get: (a: number, b: number) => number;
473
- readonly multiroomflowfield_getDirections: (a: number, b: number, c: number) => void;
474
- readonly multiroomflowfield_getRoom: (a: number, b: number) => number;
475
- readonly multiroomflowfield_getRooms: (a: number, b: number) => void;
476
- readonly multiroomflowfield_set: (a: number, b: number, c: number) => void;
477
- readonly multiroomflowfield_setDirections: (a: number, b: number, c: number, d: number) => void;
478
- readonly searchresult_distance_map: (a: number) => number;
479
- readonly searchresult_found_targets: (a: number, b: number) => void;
480
- readonly searchresult_ops: (a: number) => number;
481
- readonly multiroomflowfield_js_new: () => number;
482
- readonly js_astar_multiroom_distance_map: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
483
- readonly __wbg_path_free: (a: number, b: number) => void;
484
- readonly __wbg_pathfatigue_free: (a: number, b: number) => void;
485
- readonly path_add: (a: number, b: number) => void;
486
- readonly path_find_next_index: (a: number, b: number) => number;
487
- readonly path_get: (a: number, b: number) => number;
488
- readonly path_len: (a: number) => number;
489
- readonly path_to_array: (a: number, b: number) => void;
490
- readonly path_to_array_reversed: (a: number, b: number) => void;
491
- readonly pathfatigue_len: (a: number) => number;
492
- readonly pathfatigue_moveTime: (a: number, b: number) => number;
493
- readonly pathfatigue_new: (a: number) => number;
494
- readonly pathfatigue_refresh: (a: number, b: number) => void;
495
- readonly __wbg_searchgoal_free: (a: number, b: number) => void;
496
- readonly searchgoal_pos: (a: number) => number;
497
- readonly searchgoal_range: (a: number) => number;
498
- readonly __wbindgen_exn_store: (a: number) => void;
499
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
500
- readonly __wbindgen_malloc: (a: number, b: number) => number;
501
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
502
- readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
503
- }
504
-
505
- export type SyncInitInput = BufferSource | WebAssembly.Module;
506
- /**
507
- * Instantiates the given `module`, which can either be bytes or
508
- * a precompiled `WebAssembly.Module`.
509
- *
510
- * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
511
- *
512
- * @returns {InitOutput}
513
- */
514
- export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
515
-
516
- /**
517
- * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
518
- * for everything else, calls `WebAssembly.instantiate` directly.
519
- *
520
- * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
521
- *
522
- * @returns {Promise<InitOutput>}
523
- */
524
- export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
736
+ /**
737
+ * Translates `TERRAIN_*` constants.
738
+ */
739
+ export type Terrain = 0 | 1 | 2;
740
+ /**
741
+ * Translates `TERRAIN_*` constants.
742
+ * @enum {0 | 1 | 2}
743
+ */
744
+ export const Terrain: Readonly<{
745
+ Plain: 0;
746
+ "0": "Plain";
747
+ Wall: 1;
748
+ "1": "Wall";
749
+ Swamp: 2;
750
+ "2": "Swamp";
751
+ }>;
752
+ export function initSync(module: any): any;
753
+ declare function __wbg_init(module_or_path: any): Promise<any>;
754
+ export { __wbg_init as default };