ds4/src/documents/token-document.js

29 lines
785 B
JavaScript
Raw Normal View History

// SPDX-FileCopyrightText: 2021 Johannes Loher
//
// SPDX-License-Identifier: MIT
2022-11-04 21:47:18 +01:00
import { getGame } from "../utils/utils";
import { DS4ActorProxy } from "./actor/proxy";
/** @type {object | undefined} */
let fallbackData = undefined;
function getFallbackData() {
if (!fallbackData) {
fallbackData = {};
for (const type of getGame().system.template.Actor?.types ?? []) {
2022-11-21 03:00:46 +01:00
foundry.utils.mergeObject(fallbackData, new DS4ActorProxy({ type, name: "temporary" }).system);
}
}
return fallbackData;
}
export class DS4TokenDocument extends TokenDocument {
static getTrackedAttributes(data, _path = []) {
if (!data) {
data = getFallbackData();
}
return super.getTrackedAttributes(data, _path);
}
}