Use the correct token shape

This commit is contained in:
Manuel Vögele
2022-03-03 22:08:51 +01:00
parent d1db57451a
commit a0aa51df78
2 changed files with 42 additions and 15 deletions
+25
View File
@@ -157,6 +157,31 @@ export function getAreaFromPositionAndShape(position, shape) {
});
}
export function getTokenShapeId(token) {
if (token.scene.data.gridType === CONST.GRID_TYPES.GRIDLESS) {
return "1";
}
else if (token.scene.data.gridType === CONST.GRID_TYPES.SQUARE) {
return `${token.data.width}x${token.data.height}`;
}
else {
// Hex grids
if (game.modules.get("hex-size-support")?.active && CONFIG.hexSizeSupport.getAltSnappingFlag(token)) {
const borderSize = token.data.flags["hex-size-support"].borderSize;
let inversionFlag = "";
if (Boolean(CONFIG.hexSizeSupport.getAltOrientationFlag(token)) !== canvas.grid.grid.options.columns)
inversionFlag = "i";
return `${borderSize}${inversionFlag}`;
}
else {
return "1";
}
}
}
export function getTokenShape(token) {
if (token.scene.data.gridType === CONST.GRID_TYPES.GRIDLESS) {
return [{x: 0, y: 0}]