screeps-clockwork 0.7.1 → 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/dist/index.js +286 -284
- package/dist/index.js.map +1 -1
- package/dist/screeps_clockwork.wasm +0 -0
- package/dist/src/wasm/screeps_clockwork.d.ts +109 -109
- package/package.json +3 -3
- 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
235
|
* @param {Uint32Array | null} [any_of_destinations]
|
|
192
236
|
* @param {Uint32Array | null} [all_of_destinations]
|
|
193
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,16 +244,36 @@ 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.
|
|
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);
|
|
204
248
|
return SearchResult.__wrap(ret);
|
|
205
249
|
} finally {
|
|
206
250
|
heap[stack_pointer++] = undefined;
|
|
207
251
|
}
|
|
208
252
|
}
|
|
209
253
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
254
|
+
/**
|
|
255
|
+
* @param {Uint32Array} start_packed
|
|
256
|
+
* @param {Function} get_cost_matrix
|
|
257
|
+
* @param {number} max_ops
|
|
258
|
+
* @param {number} max_rooms
|
|
259
|
+
* @param {number} max_path_cost
|
|
260
|
+
* @param {Uint32Array | null} [any_of_destinations]
|
|
261
|
+
* @param {Uint32Array | null} [all_of_destinations]
|
|
262
|
+
* @returns {SearchResult}
|
|
263
|
+
*/
|
|
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) {
|
|
265
|
+
try {
|
|
266
|
+
const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
|
|
267
|
+
const len0 = WASM_VECTOR_LEN;
|
|
268
|
+
var ptr1 = isLikeNone(any_of_destinations) ? 0 : passArray32ToWasm0(any_of_destinations, wasm.__wbindgen_malloc);
|
|
269
|
+
var len1 = WASM_VECTOR_LEN;
|
|
270
|
+
var ptr2 = isLikeNone(all_of_destinations) ? 0 : passArray32ToWasm0(all_of_destinations, wasm.__wbindgen_malloc);
|
|
271
|
+
var len2 = WASM_VECTOR_LEN;
|
|
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);
|
|
273
|
+
return SearchResult.__wrap(ret);
|
|
274
|
+
} finally {
|
|
275
|
+
heap[stack_pointer++] = undefined;
|
|
276
|
+
}
|
|
213
277
|
}
|
|
214
278
|
|
|
215
279
|
function _assertClass(instance, klass) {
|
|
@@ -228,28 +292,16 @@ function js_path_to_multiroom_mono_flow_field_origin(start, flow_field) {
|
|
|
228
292
|
return Path.__wrap(ret);
|
|
229
293
|
}
|
|
230
294
|
|
|
231
|
-
let cachedUint16ArrayMemory0 = null;
|
|
232
|
-
|
|
233
|
-
function getUint16ArrayMemory0() {
|
|
234
|
-
if (cachedUint16ArrayMemory0 === null || cachedUint16ArrayMemory0.byteLength === 0) {
|
|
235
|
-
cachedUint16ArrayMemory0 = new Uint16Array(wasm.memory.buffer);
|
|
236
|
-
}
|
|
237
|
-
return cachedUint16ArrayMemory0;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function getArrayU16FromWasm0(ptr, len) {
|
|
241
|
-
ptr = ptr >>> 0;
|
|
242
|
-
return getUint16ArrayMemory0().subarray(ptr / 2, ptr / 2 + len);
|
|
243
|
-
}
|
|
244
295
|
/**
|
|
245
|
-
*
|
|
246
|
-
* @param {
|
|
247
|
-
* @returns {
|
|
296
|
+
* Creates a monodirectional flow field for the given distance map.
|
|
297
|
+
* @param {MultiroomDistanceMap} distance_map
|
|
298
|
+
* @returns {MultiroomMonoFlowField}
|
|
248
299
|
*/
|
|
249
|
-
function
|
|
250
|
-
_assertClass(
|
|
251
|
-
|
|
252
|
-
|
|
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);
|
|
253
305
|
}
|
|
254
306
|
|
|
255
307
|
function getArrayJsValueFromWasm0(ptr, len) {
|
|
@@ -271,6 +323,11 @@ function passArrayJsValueToWasm0(array, malloc) {
|
|
|
271
323
|
WASM_VECTOR_LEN = array.length;
|
|
272
324
|
return ptr;
|
|
273
325
|
}
|
|
326
|
+
|
|
327
|
+
function getArrayU32FromWasm0(ptr, len) {
|
|
328
|
+
ptr = ptr >>> 0;
|
|
329
|
+
return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
|
|
330
|
+
}
|
|
274
331
|
/**
|
|
275
332
|
* @param {number} room_name
|
|
276
333
|
* @param {number | null} [plain_cost]
|
|
@@ -295,56 +352,52 @@ function multiroomFlowField(distance_map) {
|
|
|
295
352
|
return MultiroomFlowField.__wrap(ret);
|
|
296
353
|
}
|
|
297
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
|
+
}
|
|
298
368
|
/**
|
|
299
|
-
* @param {
|
|
300
|
-
* @param {
|
|
301
|
-
* @
|
|
302
|
-
* @param {number} max_rooms
|
|
303
|
-
* @param {number} max_path_cost
|
|
304
|
-
* @param {Uint32Array | null} [any_of_destinations]
|
|
305
|
-
* @param {Uint32Array | null} [all_of_destinations]
|
|
306
|
-
* @returns {SearchResult}
|
|
369
|
+
* @param {number} start
|
|
370
|
+
* @param {MultiroomFlowField} flow_field
|
|
371
|
+
* @returns {Path}
|
|
307
372
|
*/
|
|
308
|
-
function
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
373
|
+
function js_path_to_multiroom_flow_field_origin(start, flow_field) {
|
|
374
|
+
_assertClass(flow_field, MultiroomFlowField);
|
|
375
|
+
const ret = wasm.js_path_to_multiroom_flow_field_origin(start, flow_field.__wbg_ptr);
|
|
376
|
+
return Path.__wrap(ret);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* @param {number} start
|
|
381
|
+
* @param {MultiroomDistanceMap} distance_map
|
|
382
|
+
* @returns {Path}
|
|
383
|
+
*/
|
|
384
|
+
function js_path_to_multiroom_distance_map_origin(start, distance_map) {
|
|
385
|
+
_assertClass(distance_map, MultiroomDistanceMap);
|
|
386
|
+
const ret = wasm.js_path_to_multiroom_distance_map_origin(start, distance_map.__wbg_ptr);
|
|
387
|
+
return Path.__wrap(ret);
|
|
321
388
|
}
|
|
322
389
|
|
|
323
390
|
/**
|
|
324
|
-
* WASM wrapper for the BFS multiroom distance map function.
|
|
325
|
-
*
|
|
326
|
-
* # Arguments
|
|
327
|
-
* * `start_packed` - Array of packed position integers representing start positions
|
|
328
|
-
* * `get_cost_matrix` - JavaScript function that returns cost matrices for rooms
|
|
329
|
-
* * `max_ops` - Maximum number of tiles to explore
|
|
330
|
-
* * `max_rooms` - Maximum number of rooms to explore
|
|
331
|
-
* * `max_room_distance` - Maximum Manhattan distance in rooms to explore
|
|
332
|
-
* * `max_path_cost` - Maximum distance in tiles to explore
|
|
333
|
-
* * `any_of_destinations` - Array of packed positions to trigger early exit when any are reached
|
|
334
|
-
* * `all_of_destinations` - Array of packed positions to trigger early exit when all are reached
|
|
335
|
-
*
|
|
336
|
-
* # Returns
|
|
337
|
-
* A `MultiroomDistanceMap` containing the distances from the start positions
|
|
338
391
|
* @param {Uint32Array} start_packed
|
|
339
392
|
* @param {Function} get_cost_matrix
|
|
340
|
-
* @param {number} max_ops
|
|
341
393
|
* @param {number} max_rooms
|
|
394
|
+
* @param {number} max_ops
|
|
342
395
|
* @param {number} max_path_cost
|
|
343
396
|
* @param {Uint32Array | null} [any_of_destinations]
|
|
344
397
|
* @param {Uint32Array | null} [all_of_destinations]
|
|
345
398
|
* @returns {SearchResult}
|
|
346
399
|
*/
|
|
347
|
-
function
|
|
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) {
|
|
348
401
|
try {
|
|
349
402
|
const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
|
|
350
403
|
const len0 = WASM_VECTOR_LEN;
|
|
@@ -352,67 +405,13 @@ function js_bfs_multiroom_distance_map(start_packed, get_cost_matrix, max_ops, m
|
|
|
352
405
|
var len1 = WASM_VECTOR_LEN;
|
|
353
406
|
var ptr2 = isLikeNone(all_of_destinations) ? 0 : passArray32ToWasm0(all_of_destinations, wasm.__wbindgen_malloc);
|
|
354
407
|
var len2 = WASM_VECTOR_LEN;
|
|
355
|
-
const ret = wasm.
|
|
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);
|
|
356
409
|
return SearchResult.__wrap(ret);
|
|
357
410
|
} finally {
|
|
358
411
|
heap[stack_pointer++] = undefined;
|
|
359
412
|
}
|
|
360
413
|
}
|
|
361
414
|
|
|
362
|
-
/**
|
|
363
|
-
* @returns {string}
|
|
364
|
-
*/
|
|
365
|
-
function version() {
|
|
366
|
-
let deferred1_0;
|
|
367
|
-
let deferred1_1;
|
|
368
|
-
try {
|
|
369
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
370
|
-
wasm.version(retptr);
|
|
371
|
-
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
372
|
-
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
373
|
-
deferred1_0 = r0;
|
|
374
|
-
deferred1_1 = r1;
|
|
375
|
-
return getStringFromWasm0(r0, r1);
|
|
376
|
-
} finally {
|
|
377
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
378
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Exports the global range calculation between two positions.
|
|
384
|
-
* @param {number} packed_pos_1
|
|
385
|
-
* @param {number} packed_pos_2
|
|
386
|
-
* @returns {number}
|
|
387
|
-
*/
|
|
388
|
-
function get_range(packed_pos_1, packed_pos_2) {
|
|
389
|
-
const ret = wasm.get_range(packed_pos_1, packed_pos_2);
|
|
390
|
-
return ret >>> 0;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* Creates a monodirectional flow field for the given distance map.
|
|
395
|
-
* @param {MultiroomDistanceMap} distance_map
|
|
396
|
-
* @returns {MultiroomMonoFlowField}
|
|
397
|
-
*/
|
|
398
|
-
function multiroomMonoFlowField(distance_map) {
|
|
399
|
-
_assertClass(distance_map, MultiroomDistanceMap);
|
|
400
|
-
var ptr0 = distance_map.__destroy_into_raw();
|
|
401
|
-
const ret = wasm.multiroomMonoFlowField(ptr0);
|
|
402
|
-
return MultiroomMonoFlowField.__wrap(ret);
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* @param {number} start
|
|
407
|
-
* @param {MultiroomDistanceMap} distance_map
|
|
408
|
-
* @returns {Path}
|
|
409
|
-
*/
|
|
410
|
-
function js_path_to_multiroom_distance_map_origin(start, distance_map) {
|
|
411
|
-
_assertClass(distance_map, MultiroomDistanceMap);
|
|
412
|
-
const ret = wasm.js_path_to_multiroom_distance_map_origin(start, distance_map.__wbg_ptr);
|
|
413
|
-
return Path.__wrap(ret);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
415
|
/**
|
|
417
416
|
* Translates `COLOR_*` and `COLORS_ALL` constants.
|
|
418
417
|
* @enum {1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10}
|
|
@@ -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,10 +674,27 @@ class DistanceMap {
|
|
|
692
674
|
set(x, y, value) {
|
|
693
675
|
wasm.distancemap_set(this.__wbg_ptr, x, y, value);
|
|
694
676
|
}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
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
|
+
}
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
const FlowFieldFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
697
|
+
? { register: () => {}, unregister: () => {} }
|
|
699
698
|
: new FinalizationRegistry(ptr => wasm.__wbg_flowfield_free(ptr >>> 0, 1));
|
|
700
699
|
/**
|
|
701
700
|
* A flow field is a 50x50 grid (representing a room), representing viable directions
|
|
@@ -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
|
|
|
@@ -863,30 +862,13 @@ class MultiroomDistanceMap {
|
|
|
863
862
|
wasm.__wbg_multiroomdistancemap_free(ptr, 0);
|
|
864
863
|
}
|
|
865
864
|
/**
|
|
866
|
-
*
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
const ret = wasm.multiroomdistancemap_js_new();
|
|
870
|
-
this.__wbg_ptr = ret >>> 0;
|
|
871
|
-
MultiroomDistanceMapFinalization.register(this, this.__wbg_ptr, this);
|
|
872
|
-
return this;
|
|
873
|
-
}
|
|
874
|
-
/**
|
|
875
|
-
* Gets the distance value at a given position
|
|
876
|
-
* @param {number} packed_pos
|
|
877
|
-
* @returns {number}
|
|
878
|
-
*/
|
|
879
|
-
get(packed_pos) {
|
|
880
|
-
const ret = wasm.multiroomdistancemap_get(this.__wbg_ptr, packed_pos);
|
|
881
|
-
return ret >>> 0;
|
|
882
|
-
}
|
|
883
|
-
/**
|
|
884
|
-
* Sets the distance value at a given position
|
|
885
|
-
* @param {number} packed_pos
|
|
886
|
-
* @param {number} value
|
|
865
|
+
* Gets the DistanceMap for a given room
|
|
866
|
+
* @param {number} room_name
|
|
867
|
+
* @returns {DistanceMap | undefined}
|
|
887
868
|
*/
|
|
888
|
-
|
|
889
|
-
wasm.
|
|
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);
|
|
890
872
|
}
|
|
891
873
|
/**
|
|
892
874
|
* Gets the list of rooms in the map
|
|
@@ -906,13 +888,30 @@ class MultiroomDistanceMap {
|
|
|
906
888
|
}
|
|
907
889
|
}
|
|
908
890
|
/**
|
|
909
|
-
* Gets the
|
|
910
|
-
* @param {number}
|
|
911
|
-
* @returns {
|
|
891
|
+
* Gets the distance value at a given position
|
|
892
|
+
* @param {number} packed_pos
|
|
893
|
+
* @returns {number}
|
|
912
894
|
*/
|
|
913
|
-
|
|
914
|
-
const ret = wasm.
|
|
915
|
-
return ret
|
|
895
|
+
get(packed_pos) {
|
|
896
|
+
const ret = wasm.multiroomdistancemap_get(this.__wbg_ptr, packed_pos);
|
|
897
|
+
return ret >>> 0;
|
|
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
|
+
}
|
|
908
|
+
/**
|
|
909
|
+
* Sets the distance value at a given position
|
|
910
|
+
* @param {number} packed_pos
|
|
911
|
+
* @param {number} value
|
|
912
|
+
*/
|
|
913
|
+
set(packed_pos, value) {
|
|
914
|
+
wasm.multiroomdistancemap_set(this.__wbg_ptr, packed_pos, value);
|
|
916
915
|
}
|
|
917
916
|
}
|
|
918
917
|
|
|
@@ -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 | null} [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
|
|
|
@@ -1141,39 +1140,6 @@ class Path {
|
|
|
1141
1140
|
const ptr = this.__destroy_into_raw();
|
|
1142
1141
|
wasm.__wbg_path_free(ptr, 0);
|
|
1143
1142
|
}
|
|
1144
|
-
/**
|
|
1145
|
-
* @param {number} packed_position
|
|
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}
|
|
1160
|
-
*/
|
|
1161
|
-
len() {
|
|
1162
|
-
const ret = wasm.path_len(this.__wbg_ptr);
|
|
1163
|
-
return ret >>> 0;
|
|
1164
|
-
}
|
|
1165
|
-
/**
|
|
1166
|
-
* Given a position, find the index of the next adjacent position
|
|
1167
|
-
* in the path. If the position is not in the path, the target is
|
|
1168
|
-
* the next adjacent position closest to the end of the path. If
|
|
1169
|
-
* the position is neither on nor adjacent to the path, return None.
|
|
1170
|
-
* @param {number} packed_position
|
|
1171
|
-
* @returns {number | undefined}
|
|
1172
|
-
*/
|
|
1173
|
-
find_next_index(packed_position) {
|
|
1174
|
-
const ret = wasm.path_find_next_index(this.__wbg_ptr, packed_position);
|
|
1175
|
-
return ret === 0x100000001 ? undefined : ret;
|
|
1176
|
-
}
|
|
1177
1143
|
/**
|
|
1178
1144
|
* @returns {Uint32Array}
|
|
1179
1145
|
*/
|
|
@@ -1190,6 +1156,18 @@ class Path {
|
|
|
1190
1156
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1191
1157
|
}
|
|
1192
1158
|
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Given a position, find the index of the next adjacent position
|
|
1161
|
+
* in the path. If the position is not in the path, the target is
|
|
1162
|
+
* the next adjacent position closest to the end of the path. If
|
|
1163
|
+
* the position is neither on nor adjacent to the path, return None.
|
|
1164
|
+
* @param {number} packed_position
|
|
1165
|
+
* @returns {number | undefined}
|
|
1166
|
+
*/
|
|
1167
|
+
find_next_index(packed_position) {
|
|
1168
|
+
const ret = wasm.path_find_next_index(this.__wbg_ptr, packed_position);
|
|
1169
|
+
return ret === 0x100000001 ? undefined : ret;
|
|
1170
|
+
}
|
|
1193
1171
|
/**
|
|
1194
1172
|
* @returns {Uint32Array}
|
|
1195
1173
|
*/
|
|
@@ -1206,6 +1184,27 @@ class Path {
|
|
|
1206
1184
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
1207
1185
|
}
|
|
1208
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
|
+
}
|
|
1209
1208
|
}
|
|
1210
1209
|
|
|
1211
1210
|
(typeof FinalizationRegistry === 'undefined')
|
|
@@ -1296,7 +1295,7 @@ function __wbg_get_imports() {
|
|
|
1296
1295
|
const ret = Math.ceil(arg0);
|
|
1297
1296
|
return ret;
|
|
1298
1297
|
};
|
|
1299
|
-
imports.wbg.
|
|
1298
|
+
imports.wbg.__wbg_clockworkcostmatrixgetpointer_ee2b0a46684eb38c = function(arg0) {
|
|
1300
1299
|
const ret = clockworkcostmatrix_get_pointer(takeObject(arg0));
|
|
1301
1300
|
return ret;
|
|
1302
1301
|
};
|
|
@@ -1339,7 +1338,7 @@ function __wbg_get_imports() {
|
|
|
1339
1338
|
const ret = getObject(arg0).length;
|
|
1340
1339
|
return ret;
|
|
1341
1340
|
};
|
|
1342
|
-
imports.wbg.
|
|
1341
|
+
imports.wbg.__wbg_log_4a86514c61094407 = function(arg0, arg1) {
|
|
1343
1342
|
console.log(getStringFromWasm0(arg0, arg1));
|
|
1344
1343
|
};
|
|
1345
1344
|
imports.wbg.__wbg_lookFor_04c5885fea38e9b2 = function() { return handleError(function (arg0, arg1) {
|
|
@@ -1504,7 +1503,10 @@ const MAX_USIZE = 0xffffffff;
|
|
|
1504
1503
|
|
|
1505
1504
|
function fromPacked(packedPos) {
|
|
1506
1505
|
const pos = Object.create(RoomPosition.prototype);
|
|
1507
|
-
|
|
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;
|
|
1508
1510
|
return pos;
|
|
1509
1511
|
}
|
|
1510
1512
|
function fromPackedRoomName(packedRoomName) {
|