2022-02-12 04:01:38 +01:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2022-11-04 21:47:18 +01:00
|
|
|
import { getGame } from "../utils/utils";
|
2022-02-16 13:32:04 +01:00
|
|
|
import { DS4ActorProxy } from "./actor/proxy";
|
2022-02-12 04:01:38 +01:00
|
|
|
|
2022-11-17 00:12:29 +01:00
|
|
|
/** @type {object | undefined} */
|
|
|
|
let fallbackData = undefined;
|
2022-02-12 04:01:38 +01:00
|
|
|
|
|
|
|
function getFallbackData() {
|
|
|
|
if (!fallbackData) {
|
2022-11-17 00:12:29 +01:00
|
|
|
fallbackData = {};
|
2022-02-12 04:01:38 +01:00
|
|
|
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);
|
2022-02-12 04:01:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return fallbackData;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DS4TokenDocument extends TokenDocument {
|
2022-11-17 00:12:29 +01:00
|
|
|
static getTrackedAttributes(data, _path = []) {
|
2022-02-12 04:01:38 +01:00
|
|
|
if (!data) {
|
|
|
|
data = getFallbackData();
|
|
|
|
}
|
|
|
|
return super.getTrackedAttributes(data, _path);
|
|
|
|
}
|
|
|
|
}
|