screeps-clockwork 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -46,15 +46,6 @@ function takeObject(idx) {
46
46
  return ret;
47
47
  }
48
48
 
49
- function addHeapObject(obj) {
50
- if (heap_next === heap.length) heap.push(heap.length + 1);
51
- const idx = heap_next;
52
- heap_next = heap[idx];
53
-
54
- heap[idx] = obj;
55
- return idx;
56
- }
57
-
58
49
  function isLikeNone(x) {
59
50
  return x === undefined || x === null;
60
51
  }
@@ -68,6 +59,15 @@ function getDataViewMemory0() {
68
59
  return cachedDataViewMemory0;
69
60
  }
70
61
 
62
+ function addHeapObject(obj) {
63
+ if (heap_next === heap.length) heap.push(heap.length + 1);
64
+ const idx = heap_next;
65
+ heap_next = heap[idx];
66
+
67
+ heap[idx] = obj;
68
+ return idx;
69
+ }
70
+
71
71
  const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
72
72
 
73
73
  if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
@@ -84,36 +84,6 @@ function getStringFromWasm0(ptr, len) {
84
84
  ptr = ptr >>> 0;
85
85
  return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
86
86
  }
87
- /**
88
- * @returns {string}
89
- */
90
- function version() {
91
- let deferred1_0;
92
- let deferred1_1;
93
- try {
94
- const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
95
- wasm.version(retptr);
96
- var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
97
- var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
98
- deferred1_0 = r0;
99
- deferred1_1 = r1;
100
- return getStringFromWasm0(r0, r1);
101
- } finally {
102
- wasm.__wbindgen_add_to_stack_pointer(16);
103
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
104
- }
105
- }
106
-
107
- /**
108
- * Exports the global range calculation between two positions.
109
- * @param {number} packed_pos_1
110
- * @param {number} packed_pos_2
111
- * @returns {number}
112
- */
113
- function get_range(packed_pos_1, packed_pos_2) {
114
- const ret = wasm.get_range(packed_pos_1, packed_pos_2);
115
- return ret >>> 0;
116
- }
117
87
 
118
88
  let cachedUint32ArrayMemory0 = null;
119
89
 
@@ -124,13 +94,9 @@ function getUint32ArrayMemory0() {
124
94
  return cachedUint32ArrayMemory0;
125
95
  }
126
96
 
127
- let WASM_VECTOR_LEN = 0;
128
-
129
- function passArray32ToWasm0(arg, malloc) {
130
- const ptr = malloc(arg.length * 4, 4) >>> 0;
131
- getUint32ArrayMemory0().set(arg, ptr / 4);
132
- WASM_VECTOR_LEN = arg.length;
133
- return ptr;
97
+ function getArrayU32FromWasm0(ptr, len) {
98
+ ptr = ptr >>> 0;
99
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
134
100
  }
135
101
 
136
102
  function _assertClass(instance, klass) {
@@ -139,85 +105,129 @@ function _assertClass(instance, klass) {
139
105
  }
140
106
  return instance.ptr;
141
107
  }
108
+
109
+ let WASM_VECTOR_LEN = 0;
110
+
111
+ function passArray32ToWasm0(arg, malloc) {
112
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
113
+ getUint32ArrayMemory0().set(arg, ptr / 4);
114
+ WASM_VECTOR_LEN = arg.length;
115
+ return ptr;
116
+ }
142
117
  /**
143
- * WASM wrapper for the BFS flow field function.
118
+ * WASM wrapper for the Dijkstra flow field function.
144
119
  * @param {Uint32Array} start_packed
145
120
  * @param {ClockworkCostMatrix} cost_matrix
146
121
  * @returns {FlowField}
147
122
  */
148
- function js_bfs_flow_field(start_packed, cost_matrix) {
123
+ function js_dijkstra_flow_field(start_packed, cost_matrix) {
149
124
  const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
150
125
  const len0 = WASM_VECTOR_LEN;
151
126
  _assertClass(cost_matrix, ClockworkCostMatrix);
152
- const ret = wasm.js_bfs_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
127
+ const ret = wasm.js_dijkstra_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
153
128
  return FlowField.__wrap(ret);
154
129
  }
155
130
 
131
+ function getArrayJsValueFromWasm0(ptr, len) {
132
+ ptr = ptr >>> 0;
133
+ const mem = getDataViewMemory0();
134
+ const result = [];
135
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
136
+ result.push(takeObject(mem.getUint32(i, true)));
137
+ }
138
+ return result;
139
+ }
140
+
141
+ function passArrayJsValueToWasm0(array, malloc) {
142
+ const ptr = malloc(array.length * 4, 4) >>> 0;
143
+ const mem = getDataViewMemory0();
144
+ for (let i = 0; i < array.length; i++) {
145
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
146
+ }
147
+ WASM_VECTOR_LEN = array.length;
148
+ return ptr;
149
+ }
150
+ /**
151
+ * @param {number} start
152
+ * @param {MonoFlowField} flow_field
153
+ * @returns {Path}
154
+ */
155
+ function js_path_to_mono_flow_field_origin(start, flow_field) {
156
+ _assertClass(flow_field, MonoFlowField);
157
+ const ret = wasm.js_path_to_mono_flow_field_origin(start, flow_field.__wbg_ptr);
158
+ return Path$1.__wrap(ret);
159
+ }
160
+
156
161
  /**
157
- * WASM wrapper for the Dijkstra mono flow field function.
162
+ * WASM wrapper for the Dijkstra distance map function.
158
163
  * @param {Uint32Array} start_packed
159
164
  * @param {ClockworkCostMatrix} cost_matrix
160
- * @returns {MonoFlowField}
165
+ * @returns {DistanceMap}
161
166
  */
162
- function js_dijkstra_mono_flow_field(start_packed, cost_matrix) {
167
+ function js_dijkstra_distance_map(start_packed, cost_matrix) {
163
168
  const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
164
169
  const len0 = WASM_VECTOR_LEN;
165
170
  _assertClass(cost_matrix, ClockworkCostMatrix);
166
- const ret = wasm.js_dijkstra_mono_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
167
- return MonoFlowField.__wrap(ret);
171
+ const ret = wasm.js_dijkstra_distance_map(ptr0, len0, cost_matrix.__wbg_ptr);
172
+ return DistanceMap.__wrap(ret);
168
173
  }
169
174
 
170
175
  /**
171
- * WASM wrapper for the Dijkstra flow field function.
176
+ * WASM wrapper for the BFS mono flow field function.
172
177
  * @param {Uint32Array} start_packed
173
178
  * @param {ClockworkCostMatrix} cost_matrix
174
- * @returns {FlowField}
179
+ * @returns {MonoFlowField}
175
180
  */
176
- function js_dijkstra_flow_field(start_packed, cost_matrix) {
181
+ function js_bfs_mono_flow_field(start_packed, cost_matrix) {
177
182
  const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
178
183
  const len0 = WASM_VECTOR_LEN;
179
184
  _assertClass(cost_matrix, ClockworkCostMatrix);
180
- const ret = wasm.js_dijkstra_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
181
- return FlowField.__wrap(ret);
185
+ const ret = wasm.js_bfs_mono_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
186
+ return MonoFlowField.__wrap(ret);
182
187
  }
183
188
 
184
- function getArrayU32FromWasm0(ptr, len) {
185
- ptr = ptr >>> 0;
186
- return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
187
- }
188
189
  /**
189
- * WASM wrapper for the Dijkstra distance map function.
190
- * @param {Uint32Array} start_packed
191
- * @param {ClockworkCostMatrix} cost_matrix
192
- * @returns {DistanceMap}
190
+ * @param {number} start
191
+ * @param {DistanceMap} distance_map
192
+ * @returns {Path}
193
193
  */
194
- function js_dijkstra_distance_map(start_packed, cost_matrix) {
195
- const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
196
- const len0 = WASM_VECTOR_LEN;
197
- _assertClass(cost_matrix, ClockworkCostMatrix);
198
- const ret = wasm.js_dijkstra_distance_map(ptr0, len0, cost_matrix.__wbg_ptr);
199
- return DistanceMap.__wrap(ret);
194
+ function js_path_to_distance_map_origin(start, distance_map) {
195
+ _assertClass(distance_map, DistanceMap);
196
+ const ret = wasm.js_path_to_distance_map_origin(start, distance_map.__wbg_ptr);
197
+ return Path$1.__wrap(ret);
200
198
  }
201
199
 
202
- function getArrayJsValueFromWasm0(ptr, len) {
203
- ptr = ptr >>> 0;
204
- const mem = getDataViewMemory0();
205
- const result = [];
206
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
207
- result.push(takeObject(mem.getUint32(i, true)));
200
+ /**
201
+ * @returns {string}
202
+ */
203
+ function version() {
204
+ let deferred1_0;
205
+ let deferred1_1;
206
+ try {
207
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
208
+ wasm.version(retptr);
209
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
210
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
211
+ deferred1_0 = r0;
212
+ deferred1_1 = r1;
213
+ return getStringFromWasm0(r0, r1);
214
+ } finally {
215
+ wasm.__wbindgen_add_to_stack_pointer(16);
216
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
208
217
  }
209
- return result;
210
218
  }
211
219
 
212
- function passArrayJsValueToWasm0(array, malloc) {
213
- const ptr = malloc(array.length * 4, 4) >>> 0;
214
- const mem = getDataViewMemory0();
215
- for (let i = 0; i < array.length; i++) {
216
- mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
217
- }
218
- WASM_VECTOR_LEN = array.length;
219
- return ptr;
220
+ /**
221
+ * Exports the global range calculation between two positions.
222
+ * @param {number} packed_pos_1
223
+ * @param {number} packed_pos_2
224
+ * @returns {number}
225
+ */
226
+ function get_range(packed_pos_1, packed_pos_2) {
227
+ const ret = wasm.get_range(packed_pos_1, packed_pos_2);
228
+ return ret >>> 0;
220
229
  }
230
+
221
231
  /**
222
232
  * WASM wrapper for the BFS distance map function.
223
233
  * @param {Uint32Array} start_packed
@@ -233,19 +243,53 @@ function js_bfs_distance_map(start_packed, cost_matrix) {
233
243
  }
234
244
 
235
245
  /**
236
- * WASM wrapper for the BFS mono flow field function.
246
+ * WASM wrapper for the BFS flow field function.
247
+ * @param {Uint32Array} start_packed
248
+ * @param {ClockworkCostMatrix} cost_matrix
249
+ * @returns {FlowField}
250
+ */
251
+ function js_bfs_flow_field(start_packed, cost_matrix) {
252
+ const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
253
+ const len0 = WASM_VECTOR_LEN;
254
+ _assertClass(cost_matrix, ClockworkCostMatrix);
255
+ const ret = wasm.js_bfs_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
256
+ return FlowField.__wrap(ret);
257
+ }
258
+
259
+ /**
260
+ * WASM wrapper for the Dijkstra mono flow field function.
237
261
  * @param {Uint32Array} start_packed
238
262
  * @param {ClockworkCostMatrix} cost_matrix
239
263
  * @returns {MonoFlowField}
240
264
  */
241
- function js_bfs_mono_flow_field(start_packed, cost_matrix) {
265
+ function js_dijkstra_mono_flow_field(start_packed, cost_matrix) {
242
266
  const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
243
267
  const len0 = WASM_VECTOR_LEN;
244
268
  _assertClass(cost_matrix, ClockworkCostMatrix);
245
- const ret = wasm.js_bfs_mono_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
269
+ const ret = wasm.js_dijkstra_mono_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
246
270
  return MonoFlowField.__wrap(ret);
247
271
  }
248
272
 
273
+ /**
274
+ * @param {number} start
275
+ * @param {FlowField} flow_field
276
+ * @returns {Path}
277
+ */
278
+ function js_path_to_flow_field_origin(start, flow_field) {
279
+ _assertClass(flow_field, FlowField);
280
+ const ret = wasm.js_path_to_flow_field_origin(start, flow_field.__wbg_ptr);
281
+ return Path$1.__wrap(ret);
282
+ }
283
+
284
+ function handleError(f, args) {
285
+ try {
286
+ return f.apply(this, args);
287
+ } catch (e) {
288
+ wasm.__wbindgen_exn_store(addHeapObject(e));
289
+ }
290
+ }
291
+
292
+ function notDefined(what) { return () => { throw new Error(`${what} is not defined`); }; }
249
293
  /**
250
294
  * Translates `COLOR_*` and `COLORS_ALL` constants.
251
295
  */
@@ -300,6 +344,10 @@ Object.freeze({ GenerateOps:1,"1":"GenerateOps",OperateSpawn:2,"2":"OperateSpawn
300
344
  */
301
345
  Object.freeze({ Plain:0,"0":"Plain",Wall:1,"1":"Wall",Swamp:2,"2":"Swamp", });
302
346
 
347
+ const __wbindgen_enum_Look = ["creep", "energy", "resource", "source", "mineral", "structure", "flag", "constructionSite", "nuke", "terrain", "tombstone", "powerCreep", "deposit", "ruin", "scoreContainer", "scoreCollector", "symbolContainer", "symbolDecoder", "reactor"];
348
+
349
+ const __wbindgen_enum_StructureType = ["spawn", "extension", "road", "constructedWall", "rampart", "keeperLair", "portal", "controller", "link", "storage", "tower", "observer", "powerBank", "powerSpawn", "extractor", "lab", "terminal", "container", "nuker", "factory", "invaderCore"];
350
+
303
351
  const ClockworkCostMatrixFinalization = (typeof FinalizationRegistry === 'undefined')
304
352
  ? { register: () => {}, unregister: () => {} }
305
353
  : new FinalizationRegistry(ptr => wasm.__wbg_clockworkcostmatrix_free(ptr >>> 0, 1));
@@ -559,6 +607,118 @@ class MonoFlowField {
559
607
  }
560
608
  }
561
609
 
610
+ const PathFinalization = (typeof FinalizationRegistry === 'undefined')
611
+ ? { register: () => {}, unregister: () => {} }
612
+ : new FinalizationRegistry(ptr => wasm.__wbg_path_free(ptr >>> 0, 1));
613
+ /**
614
+ * A list of positions representing a path.
615
+ */
616
+ class Path$1 {
617
+
618
+ static __wrap(ptr) {
619
+ ptr = ptr >>> 0;
620
+ const obj = Object.create(Path$1.prototype);
621
+ obj.__wbg_ptr = ptr;
622
+ PathFinalization.register(obj, obj.__wbg_ptr, obj);
623
+ return obj;
624
+ }
625
+
626
+ __destroy_into_raw() {
627
+ const ptr = this.__wbg_ptr;
628
+ this.__wbg_ptr = 0;
629
+ PathFinalization.unregister(this);
630
+ return ptr;
631
+ }
632
+
633
+ free() {
634
+ const ptr = this.__destroy_into_raw();
635
+ wasm.__wbg_path_free(ptr, 0);
636
+ }
637
+ /**
638
+ * @param {number} packed_position
639
+ */
640
+ add(packed_position) {
641
+ wasm.path_add(this.__wbg_ptr, packed_position);
642
+ }
643
+ /**
644
+ * @param {number} index
645
+ * @returns {number | undefined}
646
+ */
647
+ get(index) {
648
+ try {
649
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
650
+ wasm.path_get(retptr, this.__wbg_ptr, index);
651
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
652
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
653
+ return r0 === 0 ? undefined : r1 >>> 0;
654
+ } finally {
655
+ wasm.__wbindgen_add_to_stack_pointer(16);
656
+ }
657
+ }
658
+ /**
659
+ * @returns {number}
660
+ */
661
+ len() {
662
+ const ret = wasm.path_len(this.__wbg_ptr);
663
+ return ret >>> 0;
664
+ }
665
+ /**
666
+ * Given a position, find the index of the next adjacent position
667
+ * in the path. If the position is not in the path, the target is
668
+ * the next adjacent position closest to the end of the path. If
669
+ * the position is neither on nor adjacent to the path, return None.
670
+ * @param {number} packed_position
671
+ * @returns {number | undefined}
672
+ */
673
+ find_next_index(packed_position) {
674
+ try {
675
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
676
+ wasm.path_find_next_index(retptr, this.__wbg_ptr, packed_position);
677
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
678
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
679
+ return r0 === 0 ? undefined : r1 >>> 0;
680
+ } finally {
681
+ wasm.__wbindgen_add_to_stack_pointer(16);
682
+ }
683
+ }
684
+ /**
685
+ * @returns {Uint32Array}
686
+ */
687
+ to_array() {
688
+ try {
689
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
690
+ wasm.path_to_array(retptr, this.__wbg_ptr);
691
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
692
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
693
+ var v1 = getArrayU32FromWasm0(r0, r1).slice();
694
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
695
+ return v1;
696
+ } finally {
697
+ wasm.__wbindgen_add_to_stack_pointer(16);
698
+ }
699
+ }
700
+ /**
701
+ * @returns {Uint32Array}
702
+ */
703
+ to_array_reversed() {
704
+ try {
705
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
706
+ wasm.path_to_array_reversed(retptr, this.__wbg_ptr);
707
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
708
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
709
+ var v1 = getArrayU32FromWasm0(r0, r1).slice();
710
+ wasm.__wbindgen_free(r0, r1 * 4, 4);
711
+ return v1;
712
+ } finally {
713
+ wasm.__wbindgen_add_to_stack_pointer(16);
714
+ }
715
+ }
716
+ }
717
+
718
+ (typeof FinalizationRegistry === 'undefined')
719
+ ? { register: () => {}, unregister: () => {} }
720
+ : new FinalizationRegistry(ptr => wasm.__wbg_pathfatigue_free(ptr >>> 0, 1));
721
+
562
722
  (typeof FinalizationRegistry === 'undefined')
563
723
  ? { register: () => {}, unregister: () => {} }
564
724
  : new FinalizationRegistry(ptr => wasm.__wbg_searchgoal_free(ptr >>> 0, 1));
@@ -569,9 +729,13 @@ function __wbg_get_imports() {
569
729
  imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
570
730
  takeObject(arg0);
571
731
  };
572
- imports.wbg.__wbindgen_number_new = function(arg0) {
573
- const ret = arg0;
574
- return addHeapObject(ret);
732
+ imports.wbg.__wbindgen_is_null = function(arg0) {
733
+ const ret = getObject(arg0) === null;
734
+ return ret;
735
+ };
736
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
737
+ const ret = getObject(arg0) === undefined;
738
+ return ret;
575
739
  };
576
740
  imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
577
741
  const obj = getObject(arg1);
@@ -579,23 +743,64 @@ function __wbg_get_imports() {
579
743
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
580
744
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
581
745
  };
746
+ imports.wbg.__wbindgen_number_new = function(arg0) {
747
+ const ret = arg0;
748
+ return addHeapObject(ret);
749
+ };
582
750
  imports.wbg.__wbindgen_try_into_number = function(arg0) {
583
751
  let result;
584
752
  try { result = +getObject(arg0); } catch (e) { result = e; }
585
753
  const ret = result;
586
754
  return addHeapObject(ret);
587
755
  };
588
- imports.wbg.__wbg_static_accessor_ROOM_POSITION_PROTOTYPE_359d8a1531b99b4c = function() {
589
- const ret = RoomPosition.prototype;
756
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
757
+ const ret = getStringFromWasm0(arg0, arg1);
590
758
  return addHeapObject(ret);
591
759
  };
592
760
  imports.wbg.__wbg_setpacked_e36387710a3ff5bb = function(arg0, arg1) {
593
761
  getObject(arg0).__packedPos = arg1 >>> 0;
594
762
  };
763
+ imports.wbg.__wbg_getvalue_b80bdd3552834f00 = function(arg0, arg1) {
764
+ const ret = getObject(arg0)[getObject(arg1)];
765
+ return addHeapObject(ret);
766
+ };
767
+ imports.wbg.__wbg_getRoomTerrain_de7e854c5bcae92b = function() { return handleError(function (arg0) {
768
+ const ret = Game.map.getRoomTerrain(getObject(arg0));
769
+ return addHeapObject(ret);
770
+ }, arguments) };
771
+ imports.wbg.__wbg_lookFor_649f089b6bfdb0c7 = function() { return handleError(function (arg0, arg1) {
772
+ const ret = getObject(arg0).lookFor(__wbindgen_enum_Look[arg1]);
773
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
774
+ }, arguments) };
775
+ imports.wbg.__wbg_rooms_8265844828084f14 = function() {
776
+ const ret = Game.rooms;
777
+ return addHeapObject(ret);
778
+ };
779
+ imports.wbg.__wbg_static_accessor_ROOM_POSITION_PROTOTYPE_359d8a1531b99b4c = function() {
780
+ const ret = RoomPosition.prototype;
781
+ return addHeapObject(ret);
782
+ };
783
+ imports.wbg.__wbg_structuretype_f649797e27122f54 = function(arg0) {
784
+ const ret = getObject(arg0).structureType;
785
+ return (__wbindgen_enum_StructureType.indexOf(ret) + 1 || 22) - 1;
786
+ };
787
+ imports.wbg.__wbg_get_ac6072ecac1ab4ec = function(arg0, arg1, arg2) {
788
+ const ret = getObject(arg0).get(arg1, arg2);
789
+ return ret;
790
+ };
791
+ imports.wbg.__wbg_get_5419cf6b954aa11d = function(arg0, arg1) {
792
+ const ret = getObject(arg0)[arg1 >>> 0];
793
+ return addHeapObject(ret);
794
+ };
795
+ imports.wbg.__wbg_length_f217bbbf7e8e4df4 = function(arg0) {
796
+ const ret = getObject(arg0).length;
797
+ return ret;
798
+ };
595
799
  imports.wbg.__wbg_create_70ef5302cb22a5c4 = function(arg0) {
596
800
  const ret = Object.create(getObject(arg0));
597
801
  return addHeapObject(ret);
598
802
  };
803
+ imports.wbg.__wbg_ceil_f6b5b24722eb28de = typeof Math.ceil == 'function' ? Math.ceil : notDefined('Math.ceil');
599
804
  imports.wbg.__wbindgen_throw = function(arg0, arg1) {
600
805
  throw new Error(getStringFromWasm0(arg0, arg1));
601
806
  };
@@ -648,6 +853,9 @@ function initSync(module) {
648
853
  * This might be useful for creeps with only MOVE parts and/or empty
649
854
  * CARRY parts, which don't generate fatigue.
650
855
  *
856
+ * Note that the `roomName` on start positions is ignored - all positions
857
+ * are assumed to be in the same room as the cost matrix.
858
+ *
651
859
  * @param start - The starting positions.
652
860
  * @param costMatrix - The cost matrix to use for the flow field.
653
861
  * @returns The flow field.
@@ -689,6 +897,9 @@ function bfsFlowField(start, costMatrix) {
689
897
  * This might be useful for creeps with only MOVE parts and/or empty
690
898
  * CARRY parts, which don't generate fatigue.
691
899
  *
900
+ * Note that the `roomName` on start positions is ignored - all positions
901
+ * are assumed to be in the same room as the cost matrix.
902
+ *
692
903
  * @param start - The starting positions.
693
904
  * @param costMatrix - The cost matrix to use for the flow field.
694
905
  * @returns The flow field.
@@ -708,6 +919,9 @@ function bfsMonoFlowField(start, costMatrix) {
708
919
  * Note that values of 0 in the cost matrix may have unexpected behavior. You probably want
709
920
  * a cost matrix with a default value of at least 1.
710
921
  *
922
+ * Note that the `roomName` on start positions is ignored - all positions
923
+ * are assumed to be in the same room as the cost matrix.
924
+ *
711
925
  * @param start - The starting positions.
712
926
  * @param costMatrix - The cost matrix to use for the flow field.
713
927
  * @returns The flow field.
@@ -745,6 +959,9 @@ function dijkstraFlowField(start, costMatrix) {
745
959
  * Note that values of 0 in the cost matrix may have unexpected behavior. You probably want
746
960
  * a cost matrix with a default value of at least 1.
747
961
  *
962
+ * Note that the `roomName` on start positions is ignored - all positions
963
+ * are assumed to be in the same room as the cost matrix.
964
+ *
748
965
  * @param start - The starting positions.
749
966
  * @param costMatrix - The cost matrix to use for the flow field.
750
967
  * @returns The flow field.
@@ -768,6 +985,90 @@ function getRange(pos1, pos2) {
768
985
  return get_range(pos1.__packedPos, pos2.__packedPos);
769
986
  }
770
987
 
988
+ function fromPacked(packedPos) {
989
+ const pos = Object.create(RoomPosition.prototype);
990
+ pos.__packedPos = packedPos;
991
+ return pos;
992
+ }
993
+
994
+ class Path {
995
+ constructor(path) {
996
+ this.path = path;
997
+ }
998
+ [Symbol.iterator]() {
999
+ let index = 0;
1000
+ const length = this.length;
1001
+ return {
1002
+ next: () => {
1003
+ if (index < length - 1) {
1004
+ return { value: this.get(index++), done: false };
1005
+ }
1006
+ else {
1007
+ return { value: this.get(index++), done: true };
1008
+ }
1009
+ }
1010
+ };
1011
+ }
1012
+ /**
1013
+ * Iterate over the path in reverse order
1014
+ */
1015
+ *reversed() {
1016
+ let index = this.length - 1;
1017
+ return {
1018
+ next: () => {
1019
+ if (index > 0) {
1020
+ return { value: this.get(index--), done: false };
1021
+ }
1022
+ else {
1023
+ return { value: this.get(index--), done: true };
1024
+ }
1025
+ }
1026
+ };
1027
+ }
1028
+ get(index) {
1029
+ const packedPos = this.path.get(index);
1030
+ if (packedPos === undefined) {
1031
+ throw new Error('Index out of bounds');
1032
+ }
1033
+ return fromPacked(packedPos);
1034
+ }
1035
+ get length() {
1036
+ return this.path.len();
1037
+ }
1038
+ findNextIndex(index) {
1039
+ return this.path.find_next_index(index);
1040
+ }
1041
+ toArray() {
1042
+ const result = [];
1043
+ for (const packedPos of this.path.to_array()) {
1044
+ result.push(fromPacked(packedPos));
1045
+ }
1046
+ return result;
1047
+ }
1048
+ toArrayReversed() {
1049
+ const result = [];
1050
+ for (const packedPos of this.path.to_array_reversed()) {
1051
+ result.push(fromPacked(packedPos));
1052
+ }
1053
+ return result;
1054
+ }
1055
+ free() {
1056
+ this.path.free();
1057
+ }
1058
+ }
1059
+
1060
+ function pathToDistanceMapOrigin(start, distanceMap) {
1061
+ return new Path(js_path_to_distance_map_origin(start.__packedPos, distanceMap));
1062
+ }
1063
+
1064
+ function pathToFlowFieldOrigin(start, flowField) {
1065
+ return new Path(js_path_to_flow_field_origin(start.__packedPos, flowField));
1066
+ }
1067
+
1068
+ function pathToMonoFlowFieldOrigin(start, flowField) {
1069
+ return new Path(js_path_to_mono_flow_field_origin(start.__packedPos, flowField));
1070
+ }
1071
+
771
1072
  let wasm_bytes;
772
1073
  let wasm_module;
773
1074
  let wasm_instance;
@@ -802,6 +1103,7 @@ exports.ClockworkCostMatrix = ClockworkCostMatrix;
802
1103
  exports.DistanceMap = DistanceMap;
803
1104
  exports.FlowField = FlowField;
804
1105
  exports.MonoFlowField = MonoFlowField;
1106
+ exports.Path = Path;
805
1107
  exports.bfsDistanceMap = bfsDistanceMap;
806
1108
  exports.bfsFlowField = bfsFlowField;
807
1109
  exports.bfsMonoFlowField = bfsMonoFlowField;
@@ -810,4 +1112,7 @@ exports.dijkstraFlowField = dijkstraFlowField;
810
1112
  exports.dijkstraMonoFlowField = dijkstraMonoFlowField;
811
1113
  exports.getRange = getRange;
812
1114
  exports.initialize = initialize;
1115
+ exports.pathToDistanceMapOrigin = pathToDistanceMapOrigin;
1116
+ exports.pathToFlowFieldOrigin = pathToFlowFieldOrigin;
1117
+ exports.pathToMonoFlowFieldOrigin = pathToMonoFlowFieldOrigin;
813
1118
  //# sourceMappingURL=index.js.map