screeps-clockwork 0.6.0 → 0.7.2
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 +1 -0
- package/dist/index.js +425 -313
- package/dist/index.js.map +1 -1
- package/dist/screeps_clockwork.wasm +0 -0
- package/dist/src/wasm/screeps_clockwork.d.ts +123 -103
- package/dist/src/wrappers/astarDistanceMap.d.ts +13 -4
- package/dist/src/wrappers/bfsDistanceMap.d.ts +13 -4
- package/dist/src/wrappers/dijkstraDistanceMap.d.ts +13 -4
- package/dist/src/wrappers/searchResult.d.ts +7 -0
- package/package.json +4 -4
- package/dist/src/wrappers/distanceMap.d.ts +0 -24
package/dist/index.js
CHANGED
|
@@ -158,6 +158,36 @@ function getDataViewMemory0() {
|
|
|
158
158
|
}
|
|
159
159
|
return cachedDataViewMemory0;
|
|
160
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* @returns {string}
|
|
163
|
+
*/
|
|
164
|
+
function version() {
|
|
165
|
+
let deferred1_0;
|
|
166
|
+
let deferred1_1;
|
|
167
|
+
try {
|
|
168
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
169
|
+
wasm.version(retptr);
|
|
170
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
171
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
172
|
+
deferred1_0 = r0;
|
|
173
|
+
deferred1_1 = r1;
|
|
174
|
+
return getStringFromWasm0(r0, r1);
|
|
175
|
+
} finally {
|
|
176
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
177
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Exports the global range calculation between two positions.
|
|
183
|
+
* @param {number} packed_pos_1
|
|
184
|
+
* @param {number} packed_pos_2
|
|
185
|
+
* @returns {number}
|
|
186
|
+
*/
|
|
187
|
+
function get_range(packed_pos_1, packed_pos_2) {
|
|
188
|
+
const ret = wasm.get_range(packed_pos_1, packed_pos_2);
|
|
189
|
+
return ret >>> 0;
|
|
190
|
+
}
|
|
161
191
|
|
|
162
192
|
let cachedUint32ArrayMemory0 = null;
|
|
163
193
|
|
|
@@ -183,16 +213,30 @@ function addBorrowedObject(obj) {
|
|
|
183
213
|
return stack_pointer;
|
|
184
214
|
}
|
|
185
215
|
/**
|
|
216
|
+
* WASM wrapper for the BFS multiroom distance map function.
|
|
217
|
+
*
|
|
218
|
+
* # Arguments
|
|
219
|
+
* * `start_packed` - Array of packed position integers representing start positions
|
|
220
|
+
* * `get_cost_matrix` - JavaScript function that returns cost matrices for rooms
|
|
221
|
+
* * `max_ops` - Maximum number of tiles to explore
|
|
222
|
+
* * `max_rooms` - Maximum number of rooms to explore
|
|
223
|
+
* * `max_room_distance` - Maximum Manhattan distance in rooms to explore
|
|
224
|
+
* * `max_path_cost` - Maximum distance in tiles to explore
|
|
225
|
+
* * `any_of_destinations` - Array of packed positions to trigger early exit when any are reached
|
|
226
|
+
* * `all_of_destinations` - Array of packed positions to trigger early exit when all are reached
|
|
227
|
+
*
|
|
228
|
+
* # Returns
|
|
229
|
+
* A `MultiroomDistanceMap` containing the distances from the start positions
|
|
186
230
|
* @param {Uint32Array} start_packed
|
|
187
231
|
* @param {Function} get_cost_matrix
|
|
188
|
-
* @param {number} max_rooms
|
|
189
232
|
* @param {number} max_ops
|
|
233
|
+
* @param {number} max_rooms
|
|
190
234
|
* @param {number} max_path_cost
|
|
191
|
-
* @param {Uint32Array |
|
|
192
|
-
* @param {Uint32Array |
|
|
193
|
-
* @returns {
|
|
235
|
+
* @param {Uint32Array | null} [any_of_destinations]
|
|
236
|
+
* @param {Uint32Array | null} [all_of_destinations]
|
|
237
|
+
* @returns {SearchResult}
|
|
194
238
|
*/
|
|
195
|
-
function
|
|
239
|
+
function js_bfs_multiroom_distance_map(start_packed, get_cost_matrix, max_ops, max_rooms, max_path_cost, any_of_destinations, all_of_destinations) {
|
|
196
240
|
try {
|
|
197
241
|
const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
|
|
198
242
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -200,51 +244,22 @@ function js_astar_multiroom_distance_map(start_packed, get_cost_matrix, max_room
|
|
|
200
244
|
var len1 = WASM_VECTOR_LEN;
|
|
201
245
|
var ptr2 = isLikeNone(all_of_destinations) ? 0 : passArray32ToWasm0(all_of_destinations, wasm.__wbindgen_malloc);
|
|
202
246
|
var len2 = WASM_VECTOR_LEN;
|
|
203
|
-
const ret = wasm.
|
|
204
|
-
return
|
|
247
|
+
const ret = wasm.js_bfs_multiroom_distance_map(ptr0, len0, addBorrowedObject(get_cost_matrix), max_ops, max_rooms, max_path_cost, ptr1, len1, ptr2, len2);
|
|
248
|
+
return SearchResult.__wrap(ret);
|
|
205
249
|
} finally {
|
|
206
250
|
heap[stack_pointer++] = undefined;
|
|
207
251
|
}
|
|
208
252
|
}
|
|
209
253
|
|
|
210
|
-
function _assertClass(instance, klass) {
|
|
211
|
-
if (!(instance instanceof klass)) {
|
|
212
|
-
throw new Error(`expected instance of ${klass.name}`);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* @param {number} start
|
|
217
|
-
* @param {MultiroomMonoFlowField} flow_field
|
|
218
|
-
* @returns {Path}
|
|
219
|
-
*/
|
|
220
|
-
function js_path_to_multiroom_mono_flow_field_origin(start, flow_field) {
|
|
221
|
-
_assertClass(flow_field, MultiroomMonoFlowField);
|
|
222
|
-
const ret = wasm.js_path_to_multiroom_mono_flow_field_origin(start, flow_field.__wbg_ptr);
|
|
223
|
-
return Path.__wrap(ret);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
let cachedUint16ArrayMemory0 = null;
|
|
227
|
-
|
|
228
|
-
function getUint16ArrayMemory0() {
|
|
229
|
-
if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
|
|
230
|
-
cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
|
|
231
|
-
}
|
|
232
|
-
return cachedUint16ArrayMemory0;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
function getArrayU16FromWasm0(ptr, len) {
|
|
236
|
-
ptr = ptr >>> 0;
|
|
237
|
-
return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
238
|
-
}
|
|
239
254
|
/**
|
|
240
255
|
* @param {Uint32Array} start_packed
|
|
241
256
|
* @param {Function} get_cost_matrix
|
|
242
257
|
* @param {number} max_ops
|
|
243
258
|
* @param {number} max_rooms
|
|
244
259
|
* @param {number} max_path_cost
|
|
245
|
-
* @param {Uint32Array |
|
|
246
|
-
* @param {Uint32Array |
|
|
247
|
-
* @returns {
|
|
260
|
+
* @param {Uint32Array | null} [any_of_destinations]
|
|
261
|
+
* @param {Uint32Array | null} [all_of_destinations]
|
|
262
|
+
* @returns {SearchResult}
|
|
248
263
|
*/
|
|
249
264
|
function js_dijkstra_multiroom_distance_map(start_packed, get_cost_matrix, max_ops, max_rooms, max_path_cost, any_of_destinations, all_of_destinations) {
|
|
250
265
|
try {
|
|
@@ -255,15 +270,38 @@ function js_dijkstra_multiroom_distance_map(start_packed, get_cost_matrix, max_o
|
|
|
255
270
|
var ptr2 = isLikeNone(all_of_destinations) ? 0 : passArray32ToWasm0(all_of_destinations, wasm.__wbindgen_malloc);
|
|
256
271
|
var len2 = WASM_VECTOR_LEN;
|
|
257
272
|
const ret = wasm.js_dijkstra_multiroom_distance_map(ptr0, len0, addBorrowedObject(get_cost_matrix), max_ops, max_rooms, max_path_cost, ptr1, len1, ptr2, len2);
|
|
258
|
-
return
|
|
273
|
+
return SearchResult.__wrap(ret);
|
|
259
274
|
} finally {
|
|
260
275
|
heap[stack_pointer++] = undefined;
|
|
261
276
|
}
|
|
262
277
|
}
|
|
263
278
|
|
|
264
|
-
function
|
|
265
|
-
|
|
266
|
-
|
|
279
|
+
function _assertClass(instance, klass) {
|
|
280
|
+
if (!(instance instanceof klass)) {
|
|
281
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* @param {number} start
|
|
286
|
+
* @param {MultiroomMonoFlowField} flow_field
|
|
287
|
+
* @returns {Path}
|
|
288
|
+
*/
|
|
289
|
+
function js_path_to_multiroom_mono_flow_field_origin(start, flow_field) {
|
|
290
|
+
_assertClass(flow_field, MultiroomMonoFlowField);
|
|
291
|
+
const ret = wasm.js_path_to_multiroom_mono_flow_field_origin(start, flow_field.__wbg_ptr);
|
|
292
|
+
return Path.__wrap(ret);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Creates a monodirectional flow field for the given distance map.
|
|
297
|
+
* @param {MultiroomDistanceMap} distance_map
|
|
298
|
+
* @returns {MultiroomMonoFlowField}
|
|
299
|
+
*/
|
|
300
|
+
function multiroomMonoFlowField(distance_map) {
|
|
301
|
+
_assertClass(distance_map, MultiroomDistanceMap);
|
|
302
|
+
var ptr0 = distance_map.__destroy_into_raw();
|
|
303
|
+
const ret = wasm.multiroomMonoFlowField(ptr0);
|
|
304
|
+
return MultiroomMonoFlowField.__wrap(ret);
|
|
267
305
|
}
|
|
268
306
|
|
|
269
307
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
@@ -285,61 +323,16 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
|
285
323
|
WASM_VECTOR_LEN = array.length;
|
|
286
324
|
return ptr;
|
|
287
325
|
}
|
|
288
|
-
/**
|
|
289
|
-
* WASM wrapper for the BFS multiroom distance map function.
|
|
290
|
-
*
|
|
291
|
-
* # Arguments
|
|
292
|
-
* * `start_packed` - Array of packed position integers representing start positions
|
|
293
|
-
* * `get_cost_matrix` - JavaScript function that returns cost matrices for rooms
|
|
294
|
-
* * `max_ops` - Maximum number of tiles to explore
|
|
295
|
-
* * `max_rooms` - Maximum number of rooms to explore
|
|
296
|
-
* * `max_room_distance` - Maximum Manhattan distance in rooms to explore
|
|
297
|
-
* * `max_path_cost` - Maximum distance in tiles to explore
|
|
298
|
-
* * `any_of_destinations` - Array of packed positions to trigger early exit when any are reached
|
|
299
|
-
* * `all_of_destinations` - Array of packed positions to trigger early exit when all are reached
|
|
300
|
-
*
|
|
301
|
-
* # Returns
|
|
302
|
-
* A `MultiroomDistanceMap` containing the distances from the start positions
|
|
303
|
-
* @param {Uint32Array} start_packed
|
|
304
|
-
* @param {Function} get_cost_matrix
|
|
305
|
-
* @param {number} max_ops
|
|
306
|
-
* @param {number} max_rooms
|
|
307
|
-
* @param {number} max_path_cost
|
|
308
|
-
* @param {Uint32Array | undefined} [any_of_destinations]
|
|
309
|
-
* @param {Uint32Array | undefined} [all_of_destinations]
|
|
310
|
-
* @returns {MultiroomDistanceMap}
|
|
311
|
-
*/
|
|
312
|
-
function js_bfs_multiroom_distance_map(start_packed, get_cost_matrix, max_ops, max_rooms, max_path_cost, any_of_destinations, all_of_destinations) {
|
|
313
|
-
try {
|
|
314
|
-
const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
|
|
315
|
-
const len0 = WASM_VECTOR_LEN;
|
|
316
|
-
var ptr1 = isLikeNone(any_of_destinations) ? 0 : passArray32ToWasm0(any_of_destinations, wasm.__wbindgen_malloc);
|
|
317
|
-
var len1 = WASM_VECTOR_LEN;
|
|
318
|
-
var ptr2 = isLikeNone(all_of_destinations) ? 0 : passArray32ToWasm0(all_of_destinations, wasm.__wbindgen_malloc);
|
|
319
|
-
var len2 = WASM_VECTOR_LEN;
|
|
320
|
-
const ret = wasm.js_bfs_multiroom_distance_map(ptr0, len0, addBorrowedObject(get_cost_matrix), max_ops, max_rooms, max_path_cost, ptr1, len1, ptr2, len2);
|
|
321
|
-
return MultiroomDistanceMap.__wrap(ret);
|
|
322
|
-
} finally {
|
|
323
|
-
heap[stack_pointer++] = undefined;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
326
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
* @returns {Path}
|
|
331
|
-
*/
|
|
332
|
-
function js_path_to_multiroom_distance_map_origin(start, distance_map) {
|
|
333
|
-
_assertClass(distance_map, MultiroomDistanceMap);
|
|
334
|
-
const ret = wasm.js_path_to_multiroom_distance_map_origin(start, distance_map.__wbg_ptr);
|
|
335
|
-
return Path.__wrap(ret);
|
|
327
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
328
|
+
ptr = ptr >>> 0;
|
|
329
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
336
330
|
}
|
|
337
|
-
|
|
338
331
|
/**
|
|
339
332
|
* @param {number} room_name
|
|
340
|
-
* @param {number |
|
|
341
|
-
* @param {number |
|
|
342
|
-
* @param {number |
|
|
333
|
+
* @param {number | null} [plain_cost]
|
|
334
|
+
* @param {number | null} [swamp_cost]
|
|
335
|
+
* @param {number | null} [wall_cost]
|
|
343
336
|
* @returns {ClockworkCostMatrix}
|
|
344
337
|
*/
|
|
345
338
|
function get_terrain_cost_matrix(room_name, plain_cost, swamp_cost, wall_cost) {
|
|
@@ -348,48 +341,30 @@ function get_terrain_cost_matrix(room_name, plain_cost, swamp_cost, wall_cost) {
|
|
|
348
341
|
}
|
|
349
342
|
|
|
350
343
|
/**
|
|
351
|
-
*
|
|
352
|
-
*/
|
|
353
|
-
function version() {
|
|
354
|
-
let deferred1_0;
|
|
355
|
-
let deferred1_1;
|
|
356
|
-
try {
|
|
357
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
358
|
-
wasm.version(retptr);
|
|
359
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
360
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
361
|
-
deferred1_0 = r0;
|
|
362
|
-
deferred1_1 = r1;
|
|
363
|
-
return getStringFromWasm0(r0, r1);
|
|
364
|
-
} finally {
|
|
365
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
366
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Exports the global range calculation between two positions.
|
|
372
|
-
* @param {number} packed_pos_1
|
|
373
|
-
* @param {number} packed_pos_2
|
|
374
|
-
* @returns {number}
|
|
375
|
-
*/
|
|
376
|
-
function get_range(packed_pos_1, packed_pos_2) {
|
|
377
|
-
const ret = wasm.get_range(packed_pos_1, packed_pos_2);
|
|
378
|
-
return ret >>> 0;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
/**
|
|
382
|
-
* Creates a monodirectional flow field for the given distance map.
|
|
344
|
+
* Creates a flow field for the given distance map.
|
|
383
345
|
* @param {MultiroomDistanceMap} distance_map
|
|
384
|
-
* @returns {
|
|
346
|
+
* @returns {MultiroomFlowField}
|
|
385
347
|
*/
|
|
386
|
-
function
|
|
348
|
+
function multiroomFlowField(distance_map) {
|
|
387
349
|
_assertClass(distance_map, MultiroomDistanceMap);
|
|
388
350
|
var ptr0 = distance_map.__destroy_into_raw();
|
|
389
|
-
const ret = wasm.
|
|
390
|
-
return
|
|
351
|
+
const ret = wasm.multiroomFlowField(ptr0);
|
|
352
|
+
return MultiroomFlowField.__wrap(ret);
|
|
391
353
|
}
|
|
392
354
|
|
|
355
|
+
let cachedUint16ArrayMemory0 = null;
|
|
356
|
+
|
|
357
|
+
function getUint16ArrayMemory0() {
|
|
358
|
+
if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
|
|
359
|
+
cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
|
|
360
|
+
}
|
|
361
|
+
return cachedUint16ArrayMemory0;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function getArrayU16FromWasm0(ptr, len) {
|
|
365
|
+
ptr = ptr >>> 0;
|
|
366
|
+
return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
367
|
+
}
|
|
393
368
|
/**
|
|
394
369
|
* @param {number} start
|
|
395
370
|
* @param {MultiroomFlowField} flow_field
|
|
@@ -402,15 +377,39 @@ function js_path_to_multiroom_flow_field_origin(start, flow_field) {
|
|
|
402
377
|
}
|
|
403
378
|
|
|
404
379
|
/**
|
|
405
|
-
*
|
|
380
|
+
* @param {number} start
|
|
406
381
|
* @param {MultiroomDistanceMap} distance_map
|
|
407
|
-
* @returns {
|
|
382
|
+
* @returns {Path}
|
|
408
383
|
*/
|
|
409
|
-
function
|
|
384
|
+
function js_path_to_multiroom_distance_map_origin(start, distance_map) {
|
|
410
385
|
_assertClass(distance_map, MultiroomDistanceMap);
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
386
|
+
const ret = wasm.js_path_to_multiroom_distance_map_origin(start, distance_map.__wbg_ptr);
|
|
387
|
+
return Path.__wrap(ret);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* @param {Uint32Array} start_packed
|
|
392
|
+
* @param {Function} get_cost_matrix
|
|
393
|
+
* @param {number} max_rooms
|
|
394
|
+
* @param {number} max_ops
|
|
395
|
+
* @param {number} max_path_cost
|
|
396
|
+
* @param {Uint32Array | null} [any_of_destinations]
|
|
397
|
+
* @param {Uint32Array | null} [all_of_destinations]
|
|
398
|
+
* @returns {SearchResult}
|
|
399
|
+
*/
|
|
400
|
+
function js_astar_multiroom_distance_map(start_packed, get_cost_matrix, max_rooms, max_ops, max_path_cost, any_of_destinations, all_of_destinations) {
|
|
401
|
+
try {
|
|
402
|
+
const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
|
|
403
|
+
const len0 = WASM_VECTOR_LEN;
|
|
404
|
+
var ptr1 = isLikeNone(any_of_destinations) ? 0 : passArray32ToWasm0(any_of_destinations, wasm.__wbindgen_malloc);
|
|
405
|
+
var len1 = WASM_VECTOR_LEN;
|
|
406
|
+
var ptr2 = isLikeNone(all_of_destinations) ? 0 : passArray32ToWasm0(all_of_destinations, wasm.__wbindgen_malloc);
|
|
407
|
+
var len2 = WASM_VECTOR_LEN;
|
|
408
|
+
const ret = wasm.js_astar_multiroom_distance_map(ptr0, len0, addBorrowedObject(get_cost_matrix), max_rooms, max_ops, max_path_cost, ptr1, len1, ptr2, len2);
|
|
409
|
+
return SearchResult.__wrap(ret);
|
|
410
|
+
} finally {
|
|
411
|
+
heap[stack_pointer++] = undefined;
|
|
412
|
+
}
|
|
414
413
|
}
|
|
415
414
|
|
|
416
415
|
/**
|
|
@@ -600,7 +599,7 @@ class ClockworkCostMatrix {
|
|
|
600
599
|
/**
|
|
601
600
|
* Creates a new cost matrix within the WASM module. Optionally, a default value
|
|
602
601
|
* can be provided to initialize all cells in the matrix to that value.
|
|
603
|
-
* @param {number |
|
|
602
|
+
* @param {number | null} [_default]
|
|
604
603
|
*/
|
|
605
604
|
constructor(_default) {
|
|
606
605
|
const ret = wasm.clockworkcostmatrix_new(isLikeNone(_default) ? 0xFFFFFF : _default);
|
|
@@ -656,23 +655,6 @@ class DistanceMap {
|
|
|
656
655
|
const ptr = this.__destroy_into_raw();
|
|
657
656
|
wasm.__wbg_distancemap_free(ptr, 0);
|
|
658
657
|
}
|
|
659
|
-
/**
|
|
660
|
-
* Converts the distance map into a flat array of distances.
|
|
661
|
-
* @returns {Uint32Array}
|
|
662
|
-
*/
|
|
663
|
-
toArray() {
|
|
664
|
-
try {
|
|
665
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
666
|
-
wasm.distancemap_toArray(retptr, this.__wbg_ptr);
|
|
667
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
668
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
669
|
-
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
670
|
-
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
671
|
-
return v1;
|
|
672
|
-
} finally {
|
|
673
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
658
|
/**
|
|
677
659
|
* Gets the distance value at a given position.
|
|
678
660
|
* @param {number} x
|
|
@@ -692,6 +674,23 @@ class DistanceMap {
|
|
|
692
674
|
set(x, y, value) {
|
|
693
675
|
wasm.distancemap_set(this.__wbg_ptr, x, y, value);
|
|
694
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* Converts the distance map into a flat array of distances.
|
|
679
|
+
* @returns {Uint32Array}
|
|
680
|
+
*/
|
|
681
|
+
toArray() {
|
|
682
|
+
try {
|
|
683
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
684
|
+
wasm.distancemap_toArray(retptr, this.__wbg_ptr);
|
|
685
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
686
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
687
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
688
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
689
|
+
return v1;
|
|
690
|
+
} finally {
|
|
691
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
695
694
|
}
|
|
696
695
|
|
|
697
696
|
const FlowFieldFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -725,23 +724,13 @@ class FlowField {
|
|
|
725
724
|
wasm.__wbg_flowfield_free(ptr, 0);
|
|
726
725
|
}
|
|
727
726
|
/**
|
|
728
|
-
*
|
|
729
|
-
* @param {number} x
|
|
730
|
-
* @param {number} y
|
|
731
|
-
* @returns {number}
|
|
732
|
-
*/
|
|
733
|
-
get(x, y) {
|
|
734
|
-
const ret = wasm.flowfield_get(this.__wbg_ptr, x, y);
|
|
735
|
-
return ret;
|
|
736
|
-
}
|
|
737
|
-
/**
|
|
738
|
-
* Set the internal value for a given coordinate.
|
|
727
|
+
* Add a direction to the list of valid directions for a given coordinate.
|
|
739
728
|
* @param {number} x
|
|
740
729
|
* @param {number} y
|
|
741
|
-
* @param {
|
|
730
|
+
* @param {Direction} direction
|
|
742
731
|
*/
|
|
743
|
-
|
|
744
|
-
wasm.
|
|
732
|
+
addDirection(x, y, direction) {
|
|
733
|
+
wasm.flowfield_addDirection(this.__wbg_ptr, x, y, direction);
|
|
745
734
|
}
|
|
746
735
|
/**
|
|
747
736
|
* Get the list of valid directions for a given coordinate.
|
|
@@ -774,13 +763,23 @@ class FlowField {
|
|
|
774
763
|
wasm.flowfield_setDirections(this.__wbg_ptr, x, y, ptr0, len0);
|
|
775
764
|
}
|
|
776
765
|
/**
|
|
777
|
-
*
|
|
766
|
+
* Get the internal value for a given coordinate.
|
|
778
767
|
* @param {number} x
|
|
779
768
|
* @param {number} y
|
|
780
|
-
* @
|
|
769
|
+
* @returns {number}
|
|
781
770
|
*/
|
|
782
|
-
|
|
783
|
-
wasm.
|
|
771
|
+
get(x, y) {
|
|
772
|
+
const ret = wasm.flowfield_get(this.__wbg_ptr, x, y);
|
|
773
|
+
return ret;
|
|
774
|
+
}
|
|
775
|
+
/**
|
|
776
|
+
* Set the internal value for a given coordinate.
|
|
777
|
+
* @param {number} x
|
|
778
|
+
* @param {number} y
|
|
779
|
+
* @param {number} value
|
|
780
|
+
*/
|
|
781
|
+
set(x, y, value) {
|
|
782
|
+
wasm.flowfield_set(this.__wbg_ptr, x, y, value);
|
|
784
783
|
}
|
|
785
784
|
}
|
|
786
785
|
|
|
@@ -828,7 +827,7 @@ class MonoFlowField {
|
|
|
828
827
|
* Set the direction for a given coordinate.
|
|
829
828
|
* @param {number} x
|
|
830
829
|
* @param {number} y
|
|
831
|
-
* @param {Direction |
|
|
830
|
+
* @param {Direction | null} [value]
|
|
832
831
|
*/
|
|
833
832
|
set(x, y, value) {
|
|
834
833
|
wasm.monoflowfield_set(this.__wbg_ptr, x, y, isLikeNone(value) ? 0 : value);
|
|
@@ -863,13 +862,30 @@ class MultiroomDistanceMap {
|
|
|
863
862
|
wasm.__wbg_multiroomdistancemap_free(ptr, 0);
|
|
864
863
|
}
|
|
865
864
|
/**
|
|
866
|
-
*
|
|
865
|
+
* Gets the DistanceMap for a given room
|
|
866
|
+
* @param {number} room_name
|
|
867
|
+
* @returns {DistanceMap | undefined}
|
|
867
868
|
*/
|
|
868
|
-
|
|
869
|
-
const ret = wasm.
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
869
|
+
get_room(room_name) {
|
|
870
|
+
const ret = wasm.multiroomdistancemap_get_room(this.__wbg_ptr, room_name);
|
|
871
|
+
return ret === 0 ? undefined : DistanceMap.__wrap(ret);
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Gets the list of rooms in the map
|
|
875
|
+
* @returns {Uint16Array}
|
|
876
|
+
*/
|
|
877
|
+
get_rooms() {
|
|
878
|
+
try {
|
|
879
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
880
|
+
wasm.multiroomdistancemap_get_rooms(retptr, this.__wbg_ptr);
|
|
881
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
882
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
883
|
+
var v1 = getArrayU16FromWasm0(r0, r1).slice();
|
|
884
|
+
wasm.__wbindgen_free(r0, r1 * 2, 2);
|
|
885
|
+
return v1;
|
|
886
|
+
} finally {
|
|
887
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
888
|
+
}
|
|
873
889
|
}
|
|
874
890
|
/**
|
|
875
891
|
* Gets the distance value at a given position
|
|
@@ -880,6 +896,15 @@ class MultiroomDistanceMap {
|
|
|
880
896
|
const ret = wasm.multiroomdistancemap_get(this.__wbg_ptr, packed_pos);
|
|
881
897
|
return ret >>> 0;
|
|
882
898
|
}
|
|
899
|
+
/**
|
|
900
|
+
* Creates a new empty multiroom distance map (JavaScript constructor)
|
|
901
|
+
*/
|
|
902
|
+
constructor() {
|
|
903
|
+
const ret = wasm.multiroomdistancemap_js_new();
|
|
904
|
+
this.__wbg_ptr = ret >>> 0;
|
|
905
|
+
MultiroomDistanceMapFinalization.register(this, this.__wbg_ptr, this);
|
|
906
|
+
return this;
|
|
907
|
+
}
|
|
883
908
|
/**
|
|
884
909
|
* Sets the distance value at a given position
|
|
885
910
|
* @param {number} packed_pos
|
|
@@ -888,32 +913,6 @@ class MultiroomDistanceMap {
|
|
|
888
913
|
set(packed_pos, value) {
|
|
889
914
|
wasm.multiroomdistancemap_set(this.__wbg_ptr, packed_pos, value);
|
|
890
915
|
}
|
|
891
|
-
/**
|
|
892
|
-
* Gets the list of rooms in the map
|
|
893
|
-
* @returns {Uint16Array}
|
|
894
|
-
*/
|
|
895
|
-
get_rooms() {
|
|
896
|
-
try {
|
|
897
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
898
|
-
wasm.multiroomdistancemap_get_rooms(retptr, this.__wbg_ptr);
|
|
899
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
900
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
901
|
-
var v1 = getArrayU16FromWasm0(r0, r1).slice();
|
|
902
|
-
wasm.__wbindgen_free(r0, r1 * 2, 2);
|
|
903
|
-
return v1;
|
|
904
|
-
} finally {
|
|
905
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
/**
|
|
909
|
-
* Gets the DistanceMap for a given room
|
|
910
|
-
* @param {number} room_name
|
|
911
|
-
* @returns {DistanceMap | undefined}
|
|
912
|
-
*/
|
|
913
|
-
get_room(room_name) {
|
|
914
|
-
const ret = wasm.multiroomdistancemap_get_room(this.__wbg_ptr, room_name);
|
|
915
|
-
return ret === 0 ? undefined : DistanceMap.__wrap(ret);
|
|
916
|
-
}
|
|
917
916
|
}
|
|
918
917
|
|
|
919
918
|
const MultiroomFlowFieldFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -944,30 +943,13 @@ class MultiroomFlowField {
|
|
|
944
943
|
wasm.__wbg_multiroomflowfield_free(ptr, 0);
|
|
945
944
|
}
|
|
946
945
|
/**
|
|
947
|
-
*
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
const ret = wasm.multiroomflowfield_js_new();
|
|
951
|
-
this.__wbg_ptr = ret >>> 0;
|
|
952
|
-
MultiroomFlowFieldFinalization.register(this, this.__wbg_ptr, this);
|
|
953
|
-
return this;
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Gets the flow field value at a given position
|
|
957
|
-
* @param {number} packed_pos
|
|
958
|
-
* @returns {number}
|
|
959
|
-
*/
|
|
960
|
-
get(packed_pos) {
|
|
961
|
-
const ret = wasm.multiroomflowfield_get(this.__wbg_ptr, packed_pos);
|
|
962
|
-
return ret;
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* Sets the flow field value at a given position
|
|
966
|
-
* @param {number} packed_pos
|
|
967
|
-
* @param {number} value
|
|
946
|
+
* Gets the FlowField for a given room
|
|
947
|
+
* @param {number} room_name
|
|
948
|
+
* @returns {FlowField | undefined}
|
|
968
949
|
*/
|
|
969
|
-
|
|
970
|
-
wasm.
|
|
950
|
+
getRoom(room_name) {
|
|
951
|
+
const ret = wasm.multiroomflowfield_getRoom(this.__wbg_ptr, room_name);
|
|
952
|
+
return ret === 0 ? undefined : FlowField.__wrap(ret);
|
|
971
953
|
}
|
|
972
954
|
/**
|
|
973
955
|
* Gets the list of rooms in the flow field
|
|
@@ -987,13 +969,12 @@ class MultiroomFlowField {
|
|
|
987
969
|
}
|
|
988
970
|
}
|
|
989
971
|
/**
|
|
990
|
-
*
|
|
991
|
-
* @param {number}
|
|
992
|
-
* @
|
|
972
|
+
* Adds a direction to the list of valid directions at a given position (JavaScript)
|
|
973
|
+
* @param {number} packed_pos
|
|
974
|
+
* @param {Direction} direction
|
|
993
975
|
*/
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
return ret === 0 ? undefined : FlowField.__wrap(ret);
|
|
976
|
+
addDirection(packed_pos, direction) {
|
|
977
|
+
wasm.multiroomflowfield_addDirection(this.__wbg_ptr, packed_pos, direction);
|
|
997
978
|
}
|
|
998
979
|
/**
|
|
999
980
|
* Gets the list of valid directions at a given position (JavaScript)
|
|
@@ -1024,12 +1005,30 @@ class MultiroomFlowField {
|
|
|
1024
1005
|
wasm.multiroomflowfield_setDirections(this.__wbg_ptr, packed_pos, ptr0, len0);
|
|
1025
1006
|
}
|
|
1026
1007
|
/**
|
|
1027
|
-
*
|
|
1008
|
+
* Gets the flow field value at a given position
|
|
1028
1009
|
* @param {number} packed_pos
|
|
1029
|
-
* @
|
|
1010
|
+
* @returns {number}
|
|
1030
1011
|
*/
|
|
1031
|
-
|
|
1032
|
-
wasm.
|
|
1012
|
+
get(packed_pos) {
|
|
1013
|
+
const ret = wasm.multiroomflowfield_get(this.__wbg_ptr, packed_pos);
|
|
1014
|
+
return ret;
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Creates a new empty multiroom flow field (JavaScript constructor)
|
|
1018
|
+
*/
|
|
1019
|
+
constructor() {
|
|
1020
|
+
const ret = wasm.multiroomdistancemap_js_new();
|
|
1021
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1022
|
+
MultiroomFlowFieldFinalization.register(this, this.__wbg_ptr, this);
|
|
1023
|
+
return this;
|
|
1024
|
+
}
|
|
1025
|
+
/**
|
|
1026
|
+
* Sets the flow field value at a given position
|
|
1027
|
+
* @param {number} packed_pos
|
|
1028
|
+
* @param {number} value
|
|
1029
|
+
*/
|
|
1030
|
+
set(packed_pos, value) {
|
|
1031
|
+
wasm.multiroomflowfield_set(this.__wbg_ptr, packed_pos, value);
|
|
1033
1032
|
}
|
|
1034
1033
|
}
|
|
1035
1034
|
|
|
@@ -1061,30 +1060,13 @@ class MultiroomMonoFlowField {
|
|
|
1061
1060
|
wasm.__wbg_multiroommonoflowfield_free(ptr, 0);
|
|
1062
1061
|
}
|
|
1063
1062
|
/**
|
|
1064
|
-
*
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
const ret = wasm.multiroommonoflowfield_js_new();
|
|
1068
|
-
this.__wbg_ptr = ret >>> 0;
|
|
1069
|
-
MultiroomMonoFlowFieldFinalization.register(this, this.__wbg_ptr, this);
|
|
1070
|
-
return this;
|
|
1071
|
-
}
|
|
1072
|
-
/**
|
|
1073
|
-
* Gets the direction at a given position
|
|
1074
|
-
* @param {number} packed_pos
|
|
1075
|
-
* @returns {Direction | undefined}
|
|
1076
|
-
*/
|
|
1077
|
-
get(packed_pos) {
|
|
1078
|
-
const ret = wasm.multiroommonoflowfield_get(this.__wbg_ptr, packed_pos);
|
|
1079
|
-
return ret === 0 ? undefined : ret;
|
|
1080
|
-
}
|
|
1081
|
-
/**
|
|
1082
|
-
* Sets the direction at a given position
|
|
1083
|
-
* @param {number} packed_pos
|
|
1084
|
-
* @param {Direction | undefined} [direction]
|
|
1063
|
+
* Gets the MonoFlowField for a given room
|
|
1064
|
+
* @param {number} room_name
|
|
1065
|
+
* @returns {MonoFlowField | undefined}
|
|
1085
1066
|
*/
|
|
1086
|
-
|
|
1087
|
-
wasm.
|
|
1067
|
+
getRoom(room_name) {
|
|
1068
|
+
const ret = wasm.multiroommonoflowfield_getRoom(this.__wbg_ptr, room_name);
|
|
1069
|
+
return ret === 0 ? undefined : MonoFlowField.__wrap(ret);
|
|
1088
1070
|
}
|
|
1089
1071
|
/**
|
|
1090
1072
|
* Gets the list of rooms in the flow field
|
|
@@ -1104,13 +1086,30 @@ class MultiroomMonoFlowField {
|
|
|
1104
1086
|
}
|
|
1105
1087
|
}
|
|
1106
1088
|
/**
|
|
1107
|
-
* Gets the
|
|
1108
|
-
* @param {number}
|
|
1109
|
-
* @returns {
|
|
1089
|
+
* Gets the direction at a given position
|
|
1090
|
+
* @param {number} packed_pos
|
|
1091
|
+
* @returns {Direction | undefined}
|
|
1110
1092
|
*/
|
|
1111
|
-
|
|
1112
|
-
const ret = wasm.
|
|
1113
|
-
return ret === 0 ? undefined :
|
|
1093
|
+
get(packed_pos) {
|
|
1094
|
+
const ret = wasm.multiroommonoflowfield_get(this.__wbg_ptr, packed_pos);
|
|
1095
|
+
return ret === 0 ? undefined : ret;
|
|
1096
|
+
}
|
|
1097
|
+
/**
|
|
1098
|
+
* Creates a new empty multiroom monodirectional flow field (JavaScript constructor)
|
|
1099
|
+
*/
|
|
1100
|
+
constructor() {
|
|
1101
|
+
const ret = wasm.multiroommonoflowfield_js_new();
|
|
1102
|
+
this.__wbg_ptr = ret >>> 0;
|
|
1103
|
+
MultiroomMonoFlowFieldFinalization.register(this, this.__wbg_ptr, this);
|
|
1104
|
+
return this;
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Sets the direction at a given position
|
|
1108
|
+
* @param {number} packed_pos
|
|
1109
|
+
* @param {Direction | null} [direction]
|
|
1110
|
+
*/
|
|
1111
|
+
set(packed_pos, direction) {
|
|
1112
|
+
wasm.multiroommonoflowfield_set(this.__wbg_ptr, packed_pos, isLikeNone(direction) ? 0 : direction);
|
|
1114
1113
|
}
|
|
1115
1114
|
}
|
|
1116
1115
|
|
|
@@ -1142,25 +1141,20 @@ class Path {
|
|
|
1142
1141
|
wasm.__wbg_path_free(ptr, 0);
|
|
1143
1142
|
}
|
|
1144
1143
|
/**
|
|
1145
|
-
* @
|
|
1146
|
-
*/
|
|
1147
|
-
add(packed_position) {
|
|
1148
|
-
wasm.path_add(this.__wbg_ptr, packed_position);
|
|
1149
|
-
}
|
|
1150
|
-
/**
|
|
1151
|
-
* @param {number} index
|
|
1152
|
-
* @returns {number | undefined}
|
|
1153
|
-
*/
|
|
1154
|
-
get(index) {
|
|
1155
|
-
const ret = wasm.path_get(this.__wbg_ptr, index);
|
|
1156
|
-
return ret === 0x100000001 ? undefined : ret;
|
|
1157
|
-
}
|
|
1158
|
-
/**
|
|
1159
|
-
* @returns {number}
|
|
1144
|
+
* @returns {Uint32Array}
|
|
1160
1145
|
*/
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1146
|
+
to_array() {
|
|
1147
|
+
try {
|
|
1148
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1149
|
+
wasm.path_to_array(retptr, this.__wbg_ptr);
|
|
1150
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1151
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1152
|
+
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
1153
|
+
wasm.__wbindgen_free(r0, r1 * 4, 4);
|
|
1154
|
+
return v1;
|
|
1155
|
+
} finally {
|
|
1156
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1157
|
+
}
|
|
1164
1158
|
}
|
|
1165
1159
|
/**
|
|
1166
1160
|
* Given a position, find the index of the next adjacent position
|
|
@@ -1177,10 +1171,10 @@ class Path {
|
|
|
1177
1171
|
/**
|
|
1178
1172
|
* @returns {Uint32Array}
|
|
1179
1173
|
*/
|
|
1180
|
-
|
|
1174
|
+
to_array_reversed() {
|
|
1181
1175
|
try {
|
|
1182
1176
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1183
|
-
wasm.
|
|
1177
|
+
wasm.path_to_array_reversed(retptr, this.__wbg_ptr);
|
|
1184
1178
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1185
1179
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1186
1180
|
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
@@ -1190,13 +1184,84 @@ class Path {
|
|
|
1190
1184
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1191
1185
|
}
|
|
1192
1186
|
}
|
|
1187
|
+
/**
|
|
1188
|
+
* @param {number} packed_position
|
|
1189
|
+
*/
|
|
1190
|
+
add(packed_position) {
|
|
1191
|
+
wasm.path_add(this.__wbg_ptr, packed_position);
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* @param {number} index
|
|
1195
|
+
* @returns {number | undefined}
|
|
1196
|
+
*/
|
|
1197
|
+
get(index) {
|
|
1198
|
+
const ret = wasm.path_get(this.__wbg_ptr, index);
|
|
1199
|
+
return ret === 0x100000001 ? undefined : ret;
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* @returns {number}
|
|
1203
|
+
*/
|
|
1204
|
+
len() {
|
|
1205
|
+
const ret = wasm.path_len(this.__wbg_ptr);
|
|
1206
|
+
return ret >>> 0;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
(typeof FinalizationRegistry === 'undefined')
|
|
1211
|
+
? { register: () => {}, unregister: () => {} }
|
|
1212
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_pathfatigue_free(ptr >>> 0, 1));
|
|
1213
|
+
|
|
1214
|
+
(typeof FinalizationRegistry === 'undefined')
|
|
1215
|
+
? { register: () => {}, unregister: () => {} }
|
|
1216
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_searchgoal_free(ptr >>> 0, 1));
|
|
1217
|
+
|
|
1218
|
+
const SearchResultFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1219
|
+
? { register: () => {}, unregister: () => {} }
|
|
1220
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_searchresult_free(ptr >>> 0, 1));
|
|
1221
|
+
/**
|
|
1222
|
+
* A distance map search returns both the distance map (filled out
|
|
1223
|
+
* with all tiles explored) and the targets found. These aren't necessarily
|
|
1224
|
+
* the same positions specified as targets - if the target range is 5, then
|
|
1225
|
+
* this is the first position in range 5 of the target. If multiple targets
|
|
1226
|
+
* are specified, and you care about matching the found target with one of
|
|
1227
|
+
* the original targets, you can iterate through your list and figure out the
|
|
1228
|
+
* ones that are in range of the found target(s).
|
|
1229
|
+
*/
|
|
1230
|
+
class SearchResult {
|
|
1231
|
+
|
|
1232
|
+
static __wrap(ptr) {
|
|
1233
|
+
ptr = ptr >>> 0;
|
|
1234
|
+
const obj = Object.create(SearchResult.prototype);
|
|
1235
|
+
obj.__wbg_ptr = ptr;
|
|
1236
|
+
SearchResultFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
1237
|
+
return obj;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
__destroy_into_raw() {
|
|
1241
|
+
const ptr = this.__wbg_ptr;
|
|
1242
|
+
this.__wbg_ptr = 0;
|
|
1243
|
+
SearchResultFinalization.unregister(this);
|
|
1244
|
+
return ptr;
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
free() {
|
|
1248
|
+
const ptr = this.__destroy_into_raw();
|
|
1249
|
+
wasm.__wbg_searchresult_free(ptr, 0);
|
|
1250
|
+
}
|
|
1251
|
+
/**
|
|
1252
|
+
* @returns {MultiroomDistanceMap}
|
|
1253
|
+
*/
|
|
1254
|
+
get distance_map() {
|
|
1255
|
+
const ret = wasm.searchresult_distance_map(this.__wbg_ptr);
|
|
1256
|
+
return MultiroomDistanceMap.__wrap(ret);
|
|
1257
|
+
}
|
|
1193
1258
|
/**
|
|
1194
1259
|
* @returns {Uint32Array}
|
|
1195
1260
|
*/
|
|
1196
|
-
|
|
1261
|
+
get found_targets() {
|
|
1197
1262
|
try {
|
|
1198
1263
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
1199
|
-
wasm.
|
|
1264
|
+
wasm.searchresult_found_targets(retptr, this.__wbg_ptr);
|
|
1200
1265
|
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
1201
1266
|
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
1202
1267
|
var v1 = getArrayU32FromWasm0(r0, r1).slice();
|
|
@@ -1206,36 +1271,35 @@ class Path {
|
|
|
1206
1271
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1207
1272
|
}
|
|
1208
1273
|
}
|
|
1274
|
+
/**
|
|
1275
|
+
* @returns {number}
|
|
1276
|
+
*/
|
|
1277
|
+
get ops() {
|
|
1278
|
+
const ret = wasm.searchresult_ops(this.__wbg_ptr);
|
|
1279
|
+
return ret >>> 0;
|
|
1280
|
+
}
|
|
1209
1281
|
}
|
|
1210
1282
|
|
|
1211
|
-
(typeof FinalizationRegistry === 'undefined')
|
|
1212
|
-
? { register: () => {}, unregister: () => {} }
|
|
1213
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_pathfatigue_free(ptr >>> 0, 1));
|
|
1214
|
-
|
|
1215
|
-
(typeof FinalizationRegistry === 'undefined')
|
|
1216
|
-
? { register: () => {}, unregister: () => {} }
|
|
1217
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_searchgoal_free(ptr >>> 0, 1));
|
|
1218
|
-
|
|
1219
1283
|
function __wbg_get_imports() {
|
|
1220
1284
|
const imports = {};
|
|
1221
1285
|
imports.wbg = {};
|
|
1222
|
-
imports.wbg.
|
|
1286
|
+
imports.wbg.__wbg_buffer_609cc3eee51ed158 = function(arg0) {
|
|
1223
1287
|
const ret = getObject(arg0).buffer;
|
|
1224
1288
|
return addHeapObject(ret);
|
|
1225
1289
|
};
|
|
1226
|
-
imports.wbg.
|
|
1290
|
+
imports.wbg.__wbg_call_7cccdd69e0791ae2 = function() { return handleError(function (arg0, arg1, arg2) {
|
|
1227
1291
|
const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
|
|
1228
1292
|
return addHeapObject(ret);
|
|
1229
1293
|
}, arguments) };
|
|
1230
|
-
imports.wbg.
|
|
1294
|
+
imports.wbg.__wbg_ceil_2a411b0e70cc0baf = function(arg0) {
|
|
1231
1295
|
const ret = Math.ceil(arg0);
|
|
1232
1296
|
return ret;
|
|
1233
1297
|
};
|
|
1234
|
-
imports.wbg.
|
|
1298
|
+
imports.wbg.__wbg_clockworkcostmatrixgetpointer_ee2b0a46684eb38c = function(arg0) {
|
|
1235
1299
|
const ret = clockworkcostmatrix_get_pointer(takeObject(arg0));
|
|
1236
1300
|
return ret;
|
|
1237
1301
|
};
|
|
1238
|
-
imports.wbg.
|
|
1302
|
+
imports.wbg.__wbg_create_cfe43ccc88c64e0a = function(arg0) {
|
|
1239
1303
|
const ret = Object.create(getObject(arg0));
|
|
1240
1304
|
return addHeapObject(ret);
|
|
1241
1305
|
};
|
|
@@ -1262,7 +1326,7 @@ function __wbg_get_imports() {
|
|
|
1262
1326
|
const ret = getObject(arg0).get(arg1, arg2);
|
|
1263
1327
|
return ret;
|
|
1264
1328
|
};
|
|
1265
|
-
imports.wbg.
|
|
1329
|
+
imports.wbg.__wbg_get_b9b93047fe3cf45b = function(arg0, arg1) {
|
|
1266
1330
|
const ret = getObject(arg0)[arg1 >>> 0];
|
|
1267
1331
|
return addHeapObject(ret);
|
|
1268
1332
|
};
|
|
@@ -1270,11 +1334,11 @@ function __wbg_get_imports() {
|
|
|
1270
1334
|
const ret = getObject(arg0)[getObject(arg1)];
|
|
1271
1335
|
return addHeapObject(ret);
|
|
1272
1336
|
};
|
|
1273
|
-
imports.wbg.
|
|
1337
|
+
imports.wbg.__wbg_length_e2d2a49132c1b256 = function(arg0) {
|
|
1274
1338
|
const ret = getObject(arg0).length;
|
|
1275
1339
|
return ret;
|
|
1276
1340
|
};
|
|
1277
|
-
imports.wbg.
|
|
1341
|
+
imports.wbg.__wbg_log_4a86514c61094407 = function(arg0, arg1) {
|
|
1278
1342
|
console.log(getStringFromWasm0(arg0, arg1));
|
|
1279
1343
|
};
|
|
1280
1344
|
imports.wbg.__wbg_lookFor_04c5885fea38e9b2 = function() { return handleError(function (arg0, arg1) {
|
|
@@ -1289,7 +1353,7 @@ function __wbg_get_imports() {
|
|
|
1289
1353
|
const ret = new Room.Terrain(getObject(arg0));
|
|
1290
1354
|
return addHeapObject(ret);
|
|
1291
1355
|
}, arguments) };
|
|
1292
|
-
imports.wbg.
|
|
1356
|
+
imports.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(arg0, arg1, arg2) {
|
|
1293
1357
|
const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
|
|
1294
1358
|
return addHeapObject(ret);
|
|
1295
1359
|
};
|
|
@@ -1439,7 +1503,10 @@ const MAX_USIZE = 0xffffffff;
|
|
|
1439
1503
|
|
|
1440
1504
|
function fromPacked(packedPos) {
|
|
1441
1505
|
const pos = Object.create(RoomPosition.prototype);
|
|
1442
|
-
|
|
1506
|
+
// Screeps stores __packedPos as a signed int32, while Clockwork receives
|
|
1507
|
+
// packed positions from WASM as u32. Re-sign the same bits so Map lookups and
|
|
1508
|
+
// direct comparisons against native RoomPosition.__packedPos values work.
|
|
1509
|
+
pos.__packedPos = packedPos | 0;
|
|
1443
1510
|
return pos;
|
|
1444
1511
|
}
|
|
1445
1512
|
function fromPackedRoomName(packedRoomName) {
|
|
@@ -1827,6 +1894,21 @@ class ClockworkMultiroomDistanceMap {
|
|
|
1827
1894
|
}
|
|
1828
1895
|
}
|
|
1829
1896
|
|
|
1897
|
+
function fromPackedSearchResult(result) {
|
|
1898
|
+
const foundTargets = result.found_targets.reduce((acc, pos) => {
|
|
1899
|
+
acc.push(fromPacked(pos));
|
|
1900
|
+
return acc;
|
|
1901
|
+
}, []);
|
|
1902
|
+
const distanceMap = new ClockworkMultiroomDistanceMap(result.distance_map);
|
|
1903
|
+
const ops = result.ops;
|
|
1904
|
+
result.free();
|
|
1905
|
+
return {
|
|
1906
|
+
distanceMap,
|
|
1907
|
+
foundTargets,
|
|
1908
|
+
ops
|
|
1909
|
+
};
|
|
1910
|
+
}
|
|
1911
|
+
|
|
1830
1912
|
/**
|
|
1831
1913
|
* Create a distance map for the given start positions, using a breadth-first search.
|
|
1832
1914
|
* This does not factor in terrain costs (treating anything less than 255 in the cost
|
|
@@ -1848,8 +1930,18 @@ function astarMultiroomDistanceMap(start, { costMatrixCallback, maxRooms = MAX_U
|
|
|
1848
1930
|
throw new Error('At least one of maxRooms, maxOps, maxPathCost, anyOfDestinations, or allOfDestinations must be set');
|
|
1849
1931
|
}
|
|
1850
1932
|
const startPacked = new Uint32Array(start.map(pos => pos.__packedPos));
|
|
1851
|
-
const result = js_astar_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxRooms, maxOps, maxPathCost, anyOfDestinations
|
|
1852
|
-
|
|
1933
|
+
const result = js_astar_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxRooms, maxOps, maxPathCost, anyOfDestinations
|
|
1934
|
+
? new Uint32Array(anyOfDestinations.reduce((acc, { pos, range }) => {
|
|
1935
|
+
acc.push(pos.__packedPos, range);
|
|
1936
|
+
return acc;
|
|
1937
|
+
}, []))
|
|
1938
|
+
: undefined, allOfDestinations
|
|
1939
|
+
? new Uint32Array(allOfDestinations.reduce((acc, { pos, range }) => {
|
|
1940
|
+
acc.push(pos.__packedPos, range);
|
|
1941
|
+
return acc;
|
|
1942
|
+
}, []))
|
|
1943
|
+
: undefined);
|
|
1944
|
+
return fromPackedSearchResult(result);
|
|
1853
1945
|
}
|
|
1854
1946
|
|
|
1855
1947
|
/**
|
|
@@ -1873,8 +1965,18 @@ function bfsMultiroomDistanceMap(start, { costMatrixCallback, maxOps = MAX_USIZE
|
|
|
1873
1965
|
throw new Error('At least one of maxOps, maxRooms, maxRoomDistance, maxPathCost, anyOfDestinations, or allOfDestinations must be set');
|
|
1874
1966
|
}
|
|
1875
1967
|
const startPacked = new Uint32Array(start.map(pos => pos.__packedPos));
|
|
1876
|
-
const result = js_bfs_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxOps, maxRooms, maxPathCost, anyOfDestinations
|
|
1877
|
-
|
|
1968
|
+
const result = js_bfs_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxOps, maxRooms, maxPathCost, anyOfDestinations
|
|
1969
|
+
? new Uint32Array(anyOfDestinations.reduce((acc, { pos, range }) => {
|
|
1970
|
+
acc.push(pos.__packedPos, range);
|
|
1971
|
+
return acc;
|
|
1972
|
+
}, []))
|
|
1973
|
+
: undefined, allOfDestinations
|
|
1974
|
+
? new Uint32Array(allOfDestinations.reduce((acc, { pos, range }) => {
|
|
1975
|
+
acc.push(pos.__packedPos, range);
|
|
1976
|
+
return acc;
|
|
1977
|
+
}, []))
|
|
1978
|
+
: undefined);
|
|
1979
|
+
return fromPackedSearchResult(result);
|
|
1878
1980
|
}
|
|
1879
1981
|
|
|
1880
1982
|
/**
|
|
@@ -1897,8 +1999,18 @@ function dijkstraMultiroomDistanceMap(start, { costMatrixCallback, maxOps = MAX_
|
|
|
1897
1999
|
throw new Error('At least one of maxOps, maxRooms, maxPathCost, anyOfDestinations, or allOfDestinations must be set');
|
|
1898
2000
|
}
|
|
1899
2001
|
const startPacked = new Uint32Array(start.map(pos => pos.__packedPos));
|
|
1900
|
-
const result = js_dijkstra_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxOps, maxRooms, maxPathCost, anyOfDestinations
|
|
1901
|
-
|
|
2002
|
+
const result = js_dijkstra_multiroom_distance_map(startPacked, (room) => costMatrixCallback(fromPackedRoomName(room)), maxOps, maxRooms, maxPathCost, anyOfDestinations
|
|
2003
|
+
? new Uint32Array(anyOfDestinations.reduce((acc, { pos, range }) => {
|
|
2004
|
+
acc.push(pos.__packedPos, range);
|
|
2005
|
+
return acc;
|
|
2006
|
+
}, []))
|
|
2007
|
+
: undefined, allOfDestinations
|
|
2008
|
+
? new Uint32Array(allOfDestinations.reduce((acc, { pos, range }) => {
|
|
2009
|
+
acc.push(pos.__packedPos, range);
|
|
2010
|
+
return acc;
|
|
2011
|
+
}, []))
|
|
2012
|
+
: undefined);
|
|
2013
|
+
return fromPackedSearchResult(result);
|
|
1902
2014
|
}
|
|
1903
2015
|
|
|
1904
2016
|
/**
|