Split the module up into multiple files

This commit is contained in:
2020-12-10 00:30:00 +01:00
parent 01df3b9dba
commit 38204c7651
11 changed files with 504 additions and 476 deletions

15
src/util.js Normal file
View File

@@ -0,0 +1,15 @@
// Searches through all scenes for walls and returns those that match the given filter criteria.
export function filterAllWalls(filterFn) {
// Find all walls that match the filter criteria
const scenes = game.scenes.map((scene) => {return {scene: scene, walls: scene.data.walls.filter(filterFn)}})
// Drop all scenes that don't contain any results
return scenes.filter(scene => scene.walls.length > 0)
}
// Searches through all scenes for a wall that matches the given filter criteria
export function findInAllWalls(filterFn) {
// TODO The performance of this could be increased by stopping the search on the first hit
const scenes = filterAllWalls(filterFn)
// If results were found take the first wall from the first scene.
return scenes[0]?.walls[0]
}