Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b0018ddf4 | |||
| e5b5c336d6 | |||
| da5872042e | |||
| dc5d328cd9 | |||
| 360d724240 | |||
| 948a7eb06d |
2
CHANGELOG.md
Normal file
2
CHANGELOG.md
Normal file
@@ -0,0 +1,2 @@
|
||||
## v1.0.1 (in development)
|
||||
- When adding a door to a synchronization group adjust it's state to bring it in sync with the other doors
|
||||
42
main.js
42
main.js
@@ -73,22 +73,25 @@ function hookWallConfigUpdate() {
|
||||
|
||||
// Store our custom data from the WallConfig dialog
|
||||
async function onWallConfigUpdate(event, formData) {
|
||||
// TODO Bring newly merged doors in sync
|
||||
const updateData = {flags: {smartdoors: {synchronizationGroup: formData.synchronizationGroup}}}
|
||||
let ids = this.options.editTargets;
|
||||
if (ids.length == 0) {
|
||||
ids = [this.object.data._id];
|
||||
}
|
||||
|
||||
const ids = this.options.editTargets;
|
||||
if (ids.length > 0) {
|
||||
// Multiple walls are edited at once. Update all of them
|
||||
const updateDataset = ids.reduce((dataset, id) => {
|
||||
dataset.push({_id: id, ...updateData})
|
||||
return dataset
|
||||
}, [])
|
||||
return canvas.scene.updateEmbeddedEntity("Wall", updateDataset)
|
||||
}
|
||||
else {
|
||||
// Only one wall is being edited
|
||||
return this.object.update(updateData);
|
||||
// If a synchronization group is set, get the state of existing doors and assume their state
|
||||
if (formData.synchronizationGroup) {
|
||||
const doorInGroup = findInAllWalls(wall => wall.door && wall.flags.smartdoors?.synchronizationGroup == formData.synchronizationGroup && !ids.includes(wall._id));
|
||||
if (doorInGroup)
|
||||
updateData.ds = doorInGroup.ds;
|
||||
}
|
||||
|
||||
// Update all the edited walls
|
||||
const updateDataset = ids.reduce((dataset, id) => {
|
||||
dataset.push({_id: id, ...updateData})
|
||||
return dataset
|
||||
}, [])
|
||||
return canvas.scene.updateEmbeddedEntity("Wall", updateDataset)
|
||||
}
|
||||
|
||||
// Hook mouse events on DoorControls to perform our logic.
|
||||
@@ -117,7 +120,18 @@ function hookDoorEvents() {
|
||||
|
||||
// Searches through all scenes for walls and returns those that match the given filter criteria.
|
||||
function filterAllWalls(filterFn) {
|
||||
return game.scenes.map((scene) => {return {scene: scene, walls: scene.data.walls.filter(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
|
||||
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]
|
||||
}
|
||||
|
||||
// Our custom handler for mousedown events on doors
|
||||
|
||||
BIN
media/door_control_outline.webp
Normal file
BIN
media/door_control_outline.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
media/door_control_size.webp
Normal file
BIN
media/door_control_size.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
BIN
media/locked_door_alert.webp
Normal file
BIN
media/locked_door_alert.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 MiB |
BIN
media/secret_door_toggle.webp
Normal file
BIN
media/secret_door_toggle.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
BIN
media/synchronized_doors.webp
Normal file
BIN
media/synchronized_doors.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 MiB |
BIN
media/tint_secret_doors.webp
Normal file
BIN
media/tint_secret_doors.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
@@ -20,5 +20,6 @@
|
||||
"manifest": "https://raw.githubusercontent.com/manuelVo/foundryvtt-smart-doors/master/module.json",
|
||||
"download": "https://github.com/manuelVo/foundryvtt-smart-doors/archive/v1.0.0.zip",
|
||||
"readme": "https://github.com/manuelVo/foundryvtt-smart-doors/blob/master/README.md",
|
||||
"changelog": "https://github.com/manuelVo/foundryvtt-smart-doors/blob/master/CHANGELOG.md",
|
||||
"bugs": "https://github.com/manuelVo/foundryvtt-smart-doors/issues"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user