File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,19 @@ const layer = pathfinding.createLayer(
6060```
6161* ` grid ` - _ Grid with walkable tiles_
6262
63+ ### ⚡️ Get list of created layers
64+ ``` ts
65+ pathfinding .getLayers ()
66+ ```
67+
68+ ### ⚡️ Get layer by id
69+ ``` ts
70+ pathfinding .getLayer (
71+ id : string
72+ )
73+ ```
74+ * ` id ` - _ Layer id_
75+
6376### ⚡️ Remove exist layer of grid
6477``` ts
6578layer .remove ()
Original file line number Diff line number Diff line change @@ -24,11 +24,15 @@ export declare class Pathfinding {
2424 */
2525 createLayer ( grid : PathfindingGrid ) : PathfindingLayer ;
2626 /**
27- * Check for layer presence.
27+ * Get list of created layers.
28+ */
29+ getLayers ( ) : PathfindingLayer [ ] ;
30+ /**
31+ * Get layer by id.
2832 *
2933 * @param id - Layer id
3034 */
31- hasLayer ( id : string ) : boolean ;
35+ getLayer ( id : string ) : PathfindingLayer | null ;
3236 /**
3337 * Remove layer of grid.
3438 *
Original file line number Diff line number Diff line change 11{
22 "name" : " pathfinding-worker" ,
33 "description" : " Fast node.js pathfinding on workers for grid-based games" ,
4- "version" : " 2.3 .0" ,
4+ "version" : " 2.4 .0" ,
55 "keywords" : [
66 " astar" ,
77 " dijkstra" ,
Original file line number Diff line number Diff line change @@ -86,12 +86,19 @@ export class Pathfinding {
8686 }
8787
8888 /**
89- * Check for layer presence.
89+ * Get list of created layers.
90+ */
91+ public getLayers ( ) : PathfindingLayer [ ] {
92+ return Array . from ( this . layers . values ( ) ) ;
93+ }
94+
95+ /**
96+ * Get layer by id.
9097 *
9198 * @param id - Layer id
9299 */
93- public hasLayer ( id : string ) : boolean {
94- return this . layers . has ( id ) ;
100+ public getLayer ( id : string ) : PathfindingLayer | null {
101+ return this . layers . get ( id ) ?? null ;
95102 }
96103
97104 /**
@@ -100,7 +107,7 @@ export class Pathfinding {
100107 * @param id - Layer id
101108 */
102109 public removeLayer ( id : string ) : void {
103- if ( ! this . hasLayer ( id ) ) {
110+ if ( ! this . getLayer ( id ) ) {
104111 throw Error ( `Layer with id '${ id } ' is not found` ) ;
105112 }
106113
You can’t perform that action at this time.
0 commit comments