mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Added size to Beastform tokenData
This commit is contained in:
parent
0f52eb0492
commit
989a6e3a2a
5 changed files with 79 additions and 28 deletions
|
|
@ -65,20 +65,30 @@ export default class BeastformEffect extends BaseEffect {
|
|||
}
|
||||
};
|
||||
|
||||
const updateToken = token => ({
|
||||
...baseUpdate,
|
||||
'texture': {
|
||||
enabled: this.characterTokenData.usesDynamicToken,
|
||||
src: token.flags.daggerheart?.beastformTokenImg ?? this.characterTokenData.tokenImg
|
||||
},
|
||||
'ring': {
|
||||
subject: {
|
||||
texture:
|
||||
token.flags.daggerheart?.beastformSubjectTexture ?? this.characterTokenData.tokenRingImg
|
||||
}
|
||||
},
|
||||
'flags.daggerheart': { '-=beastformTokenImg': null, '-=beastformSubjectTexture': null }
|
||||
});
|
||||
const updateToken = token => {
|
||||
const { x, y } = game.system.api.documents.DhToken.getSnappedPositionInSquareGrid(
|
||||
token.object.scene.grid,
|
||||
{ x: token.x, y: token.y, elevation: token.elevation },
|
||||
baseUpdate.width,
|
||||
baseUpdate.height
|
||||
);
|
||||
return {
|
||||
...baseUpdate,
|
||||
x,
|
||||
y,
|
||||
'texture': {
|
||||
enabled: this.characterTokenData.usesDynamicToken,
|
||||
src: token.flags.daggerheart?.beastformTokenImg ?? this.characterTokenData.tokenImg
|
||||
},
|
||||
'ring': {
|
||||
subject: {
|
||||
texture:
|
||||
token.flags.daggerheart?.beastformSubjectTexture ?? this.characterTokenData.tokenRingImg
|
||||
}
|
||||
},
|
||||
'flags.daggerheart': { '-=beastformTokenImg': null, '-=beastformSubjectTexture': null }
|
||||
};
|
||||
};
|
||||
|
||||
await updateActorTokens(this.parent.parent, update, updateToken);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@ export default class DHBeastform extends BaseDataItem {
|
|||
base64: false
|
||||
}),
|
||||
tokenSize: new fields.SchemaField({
|
||||
size: new fields.StringField({
|
||||
required: true,
|
||||
nullable: false,
|
||||
choices: CONFIG.DH.ACTOR.tokenSize,
|
||||
initial: CONFIG.DH.ACTOR.tokenSize.custom.id
|
||||
}),
|
||||
height: new fields.NumberField({ integer: true, min: 1, initial: null, nullable: true }),
|
||||
width: new fields.NumberField({ integer: true, min: 1, initial: null, nullable: true })
|
||||
}),
|
||||
|
|
@ -190,9 +196,18 @@ export default class DHBeastform extends BaseDataItem {
|
|||
|
||||
await this.parent.parent.createEmbeddedDocuments('ActiveEffect', [beastformEffect.toObject()]);
|
||||
|
||||
let width = this.tokenSize.width;
|
||||
let height = this.tokenSize.height;
|
||||
if (this.tokenSize.size !== 'custom') {
|
||||
const tokenSizes = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Homebrew).tokenSizes;
|
||||
const tokenSize = tokenSizes[this.tokenSize.size];
|
||||
width = tokenSize;
|
||||
height = tokenSize;
|
||||
}
|
||||
|
||||
const prototypeTokenUpdate = {
|
||||
height: this.tokenSize.height,
|
||||
width: this.tokenSize.width,
|
||||
height,
|
||||
width,
|
||||
texture: {
|
||||
src: this.tokenImg
|
||||
},
|
||||
|
|
@ -202,16 +217,25 @@ export default class DHBeastform extends BaseDataItem {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
const tokenUpdate = token => ({
|
||||
...prototypeTokenUpdate,
|
||||
flags: {
|
||||
daggerheart: {
|
||||
beastformTokenImg: token.texture.src,
|
||||
beastformSubjectTexture: token.ring.subject.texture
|
||||
const tokenUpdate = token => {
|
||||
const { x, y } = game.system.api.documents.DhToken.getSnappedPositionInSquareGrid(
|
||||
token.object.scene.grid,
|
||||
{ x: token.x, y: token.y, elevation: token.elevation },
|
||||
width,
|
||||
height
|
||||
);
|
||||
return {
|
||||
...prototypeTokenUpdate,
|
||||
x,
|
||||
y,
|
||||
flags: {
|
||||
daggerheart: {
|
||||
beastformTokenImg: token.texture.src,
|
||||
beastformSubjectTexture: token.ring.subject.texture
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
await updateActorTokens(this.parent.parent, prototypeTokenUpdate, tokenUpdate);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue