From 56527ccf75abf41be6120a1a29ab43304ea7e1f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Fri, 30 Apr 2021 00:01:41 +0200 Subject: [PATCH] Add a hook that's called when the movement history is updated to the API --- src/socket.js | 5 ++++- src/speed_provider.js | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/socket.js b/src/socket.js index cfef48e..addbc06 100644 --- a/src/socket.js +++ b/src/socket.js @@ -1,3 +1,5 @@ +import {currentSpeedProvider} from "./api.js"; + let socket; Hooks.once("socketlib.ready", () => { @@ -7,7 +9,8 @@ Hooks.once("socketlib.ready", () => { export function updateCombatantDragRulerFlags(combat, updates) { const combatId = combat.id; - return socket.executeAsGM(_socketUpdateCombatantDragRulerFlags, combatId, updates); + return socket.executeAsGM(_socketUpdateCombatantDragRulerFlags, combatId, updates) + .then(() => currentSpeedProvider.onMovementHistoryUpdate(updates.map(update => combat.getCombatant(update._id).token))); } async function _socketUpdateCombatantDragRulerFlags(combatId, updates) { diff --git a/src/speed_provider.js b/src/speed_provider.js index 6ffcb47..29bebf7 100644 --- a/src/speed_provider.js +++ b/src/speed_provider.js @@ -84,6 +84,12 @@ export class SpeedProvider { return true } + /** + * This hook is being called after Drag Ruler has updated the movement history for one or more tokens. + * It'll receive an array of tokens that have been updated + */ + async onMovementHistoryUpdate(tokens) {} + /** * Returns the value that is currently set for the setting registered with the provided settingId. *