screeps-clockwork 0.2.1 → 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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Usage
6
6
 
7
- This guide will assume you're using Rollup along the lines of the Screeps Typescript starter kit.
7
+ This guide will assume you're using Rollup along the lines of the [Screeps Typescript starter kit](https://github.com/screepers/screeps-typescript-starter).
8
8
 
9
9
  Set up dependencies:
10
10
 
@@ -44,6 +44,16 @@ export default {
44
44
 
45
45
  `rollup-plugin-screeps` will automatically push the wasm file out when it deploys.
46
46
 
47
+ Then, in your main loop, call the `initialize` function before running anything else:
48
+
49
+ ```js
50
+ import { initialize } from 'screeps-clockwork';
51
+ export const loop = () => {
52
+ initialize();
53
+ // ...
54
+ };
55
+ ```
56
+
47
57
  ## Dev Setup
48
58
 
49
59
  Dependencies to build and run the project:
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,6 +105,15 @@ 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
118
  * WASM wrapper for the Dijkstra flow field function.
144
119
  * @param {Uint32Array} start_packed
@@ -153,71 +128,106 @@ function js_dijkstra_flow_field(start_packed, cost_matrix) {
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
+ }
156
150
  /**
157
- * WASM wrapper for the Dijkstra mono flow field function.
158
- * @param {Uint32Array} start_packed
159
- * @param {ClockworkCostMatrix} cost_matrix
160
- * @returns {MonoFlowField}
151
+ * @param {number} start
152
+ * @param {MonoFlowField} flow_field
153
+ * @returns {Path}
161
154
  */
162
- function js_dijkstra_mono_flow_field(start_packed, cost_matrix) {
163
- const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
164
- const len0 = WASM_VECTOR_LEN;
165
- _assertClass(cost_matrix, ClockworkCostMatrix);
166
- const ret = wasm.js_dijkstra_mono_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
167
- return MonoFlowField.__wrap(ret);
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);
168
159
  }
169
160
 
170
161
  /**
171
- * WASM wrapper for the BFS flow field function.
162
+ * WASM wrapper for the Dijkstra distance map function.
172
163
  * @param {Uint32Array} start_packed
173
164
  * @param {ClockworkCostMatrix} cost_matrix
174
- * @returns {FlowField}
165
+ * @returns {DistanceMap}
175
166
  */
176
- function js_bfs_flow_field(start_packed, cost_matrix) {
167
+ function js_dijkstra_distance_map(start_packed, cost_matrix) {
177
168
  const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
178
169
  const len0 = WASM_VECTOR_LEN;
179
170
  _assertClass(cost_matrix, ClockworkCostMatrix);
180
- const ret = wasm.js_bfs_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
181
- return FlowField.__wrap(ret);
171
+ const ret = wasm.js_dijkstra_distance_map(ptr0, len0, cost_matrix.__wbg_ptr);
172
+ return DistanceMap.__wrap(ret);
182
173
  }
183
174
 
184
- function getArrayU32FromWasm0(ptr, len) {
185
- ptr = ptr >>> 0;
186
- return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
187
- }
188
175
  /**
189
- * WASM wrapper for the Dijkstra distance map function.
176
+ * WASM wrapper for the BFS mono flow field function.
190
177
  * @param {Uint32Array} start_packed
191
178
  * @param {ClockworkCostMatrix} cost_matrix
192
- * @returns {DistanceMap}
179
+ * @returns {MonoFlowField}
193
180
  */
194
- function js_dijkstra_distance_map(start_packed, cost_matrix) {
181
+ function js_bfs_mono_flow_field(start_packed, cost_matrix) {
195
182
  const ptr0 = passArray32ToWasm0(start_packed, wasm.__wbindgen_malloc);
196
183
  const len0 = WASM_VECTOR_LEN;
197
184
  _assertClass(cost_matrix, ClockworkCostMatrix);
198
- const ret = wasm.js_dijkstra_distance_map(ptr0, len0, cost_matrix.__wbg_ptr);
199
- return DistanceMap.__wrap(ret);
185
+ const ret = wasm.js_bfs_mono_flow_field(ptr0, len0, cost_matrix.__wbg_ptr);
186
+ return MonoFlowField.__wrap(ret);
200
187
  }
201
188
 
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)));
208
- }
209
- return result;
189
+ /**
190
+ * @param {number} start
191
+ * @param {DistanceMap} distance_map
192
+ * @returns {Path}
193
+ */
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);
210
198
  }
211
199
 
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);
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);
217
217
  }
218
- WASM_VECTOR_LEN = array.length;
219
- return ptr;
220
218
  }
219
+
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;
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
  };
@@ -780,6 +985,90 @@ function getRange(pos1, pos2) {
780
985
  return get_range(pos1.__packedPos, pos2.__packedPos);
781
986
  }
782
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
+
783
1072
  let wasm_bytes;
784
1073
  let wasm_module;
785
1074
  let wasm_instance;
@@ -814,6 +1103,7 @@ exports.ClockworkCostMatrix = ClockworkCostMatrix;
814
1103
  exports.DistanceMap = DistanceMap;
815
1104
  exports.FlowField = FlowField;
816
1105
  exports.MonoFlowField = MonoFlowField;
1106
+ exports.Path = Path;
817
1107
  exports.bfsDistanceMap = bfsDistanceMap;
818
1108
  exports.bfsFlowField = bfsFlowField;
819
1109
  exports.bfsMonoFlowField = bfsMonoFlowField;
@@ -822,4 +1112,7 @@ exports.dijkstraFlowField = dijkstraFlowField;
822
1112
  exports.dijkstraMonoFlowField = dijkstraMonoFlowField;
823
1113
  exports.getRange = getRange;
824
1114
  exports.initialize = initialize;
1115
+ exports.pathToDistanceMapOrigin = pathToDistanceMapOrigin;
1116
+ exports.pathToFlowFieldOrigin = pathToFlowFieldOrigin;
1117
+ exports.pathToMonoFlowFieldOrigin = pathToMonoFlowFieldOrigin;
825
1118
  //# sourceMappingURL=index.js.map