alpathfinder 0.5.1 → 0.6.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
@@ -38,10 +38,19 @@ ALPathfinder.prepare(parent.G, ignoreMaps);
38
38
 
39
39
  ```js
40
40
  ALPathfinder.canWalkPath(character.map, character.x, character.y, 123, 456)
41
- const path = ALPathfinder.getPath(character.map, character.x, character.y, "spookytown", 0, 0, character.speed);
41
+ const path = ALPathfinder.getPath(character.map, character.x, character.y, "spookytown", 0, 0, { speed: character.speed });
42
42
  pathfinder.isWalkable("main", 200, 20)
43
43
  ```
44
44
 
45
+ `getPath` also accepts optional options such as `avoidMaps` (maps that the path may not enter, pass through, or end on):
46
+
47
+ ```js
48
+ const path = ALPathfinder.getPath(character.map, character.x, character.y, "spookytown", 0, 0, {
49
+ speed: character.speed,
50
+ avoidMaps: ["bank_b", "bank_u"],
51
+ });
52
+ ```
53
+
45
54
  ## Development
46
55
 
47
56
  ### Build
package/alpathfinder.d.ts CHANGED
@@ -34,6 +34,13 @@ x_to: number,
34
34
  y_to: number,
35
35
  ): boolean;
36
36
 
37
+ export interface PathOptions {
38
+ /** How fast your character can walk. Setting this to a very high number can also reduce the number of town warps. */
39
+ speed?: number;
40
+ /** Maps that this path may not enter, pass through, or end on. */
41
+ avoidMaps?: MapKey[];
42
+ }
43
+
37
44
  export function getPath(
38
45
  map_from: MapKey,
39
46
  x_from: number,
@@ -41,8 +48,7 @@ y_from: number,
41
48
  map_to: MapKey,
42
49
  x_to: number,
43
50
  y_to: number,
44
- /** How fast your character can walk. Setting this to a very high number can also reduce the number of town warps. */
45
- speed?: number,
51
+ options?: PathOptions,
46
52
  ): PathNode[] | null;
47
53
 
48
54
  export function getSafeWalkTo(
package/alpathfinder.js CHANGED
@@ -42,15 +42,15 @@ exports.clear = clear;
42
42
  * @param {string} map_to_name
43
43
  * @param {number} x_to
44
44
  * @param {number} y_to
45
- * @param {number | null} [speed]
45
+ * @param {any | null} [options]
46
46
  * @returns {any}
47
47
  */
48
- function getPath(map_from_name, x_from, y_from, map_to_name, x_to, y_to, speed) {
48
+ function getPath(map_from_name, x_from, y_from, map_to_name, x_to, y_to, options) {
49
49
  const ptr0 = passStringToWasm0(map_from_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
50
50
  const len0 = WASM_VECTOR_LEN;
51
51
  const ptr1 = passStringToWasm0(map_to_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
52
52
  const len1 = WASM_VECTOR_LEN;
53
- const ret = wasm.getPath(ptr0, len0, x_from, y_from, ptr1, len1, x_to, y_to, isLikeNone(speed) ? Number.MAX_SAFE_INTEGER : Math.fround(speed));
53
+ const ret = wasm.getPath(ptr0, len0, x_from, y_from, ptr1, len1, x_to, y_to, isLikeNone(options) ? 0 : addHeapObject(options));
54
54
  return takeObject(ret);
55
55
  }
56
56
  exports.getPath = getPath;
@@ -134,6 +134,10 @@ function __wbg_get_imports() {
134
134
  const ret = typeof(getObject(arg0)) === 'function';
135
135
  return ret;
136
136
  },
137
+ __wbg___wbindgen_is_null_ea9085d691f535d3: function(arg0) {
138
+ const ret = getObject(arg0) === null;
139
+ return ret;
140
+ },
137
141
  __wbg___wbindgen_is_object_a27215656b807791: function(arg0) {
138
142
  const val = getObject(arg0);
139
143
  const ret = typeof(val) === 'object' && val !== null;
Binary file
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "collaborators": [
4
4
  "Kent Rasmussen <hyprkookeez@gmail.com>"
5
5
  ],
6
- "version": "0.5.1",
6
+ "version": "0.6.0",
7
7
  "files": [
8
8
  "alpathfinder_bg.wasm",
9
9
  "alpathfinder.js",