Sur creation de personnage, force le lien du token

This commit is contained in:
LeRatierBretonnien 2023-11-04 17:48:59 +01:00
parent e6592f8333
commit 728c5f2f8e

View File

@ -51,7 +51,7 @@ export class RdDBaseActor extends Actor {
static onRemoteActorCall(callData, userId) {
if (userId == game.user.id) {
let actor = game.actors.get(callData?.actorId);
if ( callData.tokenId) {
if (callData.tokenId) {
let token = canvas.tokens.placeables.find(t => t.id == callData.tokenId)
if (token) {
actor = token.actor
@ -111,6 +111,19 @@ export class RdDBaseActor extends Actor {
super(docData, context);
}
/* -------------------------------------------- */
async _preCreate(data, options, user) {
await super._preCreate(data, options, user);
// Configure prototype token settings
const prototypeToken = {};
if (this.type === "personnage") Object.assign(prototypeToken, {
sight: { enabled: true }, actorLink: true, disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY
});
this.updateSource({ prototypeToken });
}
/* -------------------------------------------- */
isCreatureEntite() { return this.type == 'creature' || this.type == 'entite'; }
isCreature() { return this.type == 'creature'; }
isEntite() { return this.type == 'entite'; }