2022-02-12 04:01:38 +01:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
2022-02-16 13:32:04 +01:00
|
|
|
import { DS4ActorProxy } from "./actor/proxy";
|
2022-02-12 04:01:38 +01:00
|
|
|
import { getGame } from "./helpers";
|
|
|
|
|
|
|
|
let fallbackData: foundry.data.ActorData["data"] | undefined = undefined;
|
|
|
|
|
|
|
|
function getFallbackData() {
|
|
|
|
if (!fallbackData) {
|
|
|
|
fallbackData = {} as foundry.data.ActorData["data"];
|
|
|
|
for (const type of getGame().system.template.Actor?.types ?? []) {
|
|
|
|
foundry.utils.mergeObject(
|
|
|
|
fallbackData,
|
2022-02-16 13:32:04 +01:00
|
|
|
new DS4ActorProxy({ type: type as foundry.data.ActorData["type"], name: "temporary" }).data.data,
|
2022-02-12 04:01:38 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fallbackData;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class DS4TokenDocument extends TokenDocument {
|
|
|
|
static getTrackedAttributes(data?: foundry.data.ActorData["data"], _path: string[] = []) {
|
|
|
|
if (!data) {
|
|
|
|
data = getFallbackData();
|
|
|
|
}
|
|
|
|
return super.getTrackedAttributes(data, _path);
|
|
|
|
}
|
|
|
|
}
|