[V14] 1605 - Template Migration (#1621)

* Fixed so that our templates make use of SceneRegions instead

* Fixed visibility
This commit is contained in:
WBHarry 2026-02-01 17:21:56 +01:00 committed by GitHub
parent 57e51ee841
commit 578b090f08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 70 additions and 115 deletions

View file

@ -58,7 +58,7 @@ export const renderMeasuredTemplate = async event => {
const usedType = type === 'inFront' ? 'cone' : type === 'emanation' ? 'circle' : type;
const usedAngle =
type === CONST.MEASURED_TEMPLATE_TYPES.CONE
type === CONFIG.DH.GENERAL.templateTypes.CONE
? (angle ?? CONFIG.MeasuredTemplate.defaults.angle)
: type === CONFIG.DH.GENERAL.templateTypes.INFRONT
? '180'
@ -71,17 +71,32 @@ export const renderMeasuredTemplate = async event => {
];
}
const distance = type === CONFIG.DH.GENERAL.templateTypes.EMANATION ? baseDistance + 2.5 : baseDistance;
const radius = (distance / game.scenes.active.grid.distance) * game.scenes.active.grid.size;
const { width, height } = game.canvas.scene.dimensions;
const data = {
const shapeData = {
x: width / 2,
y: height / 2,
t: usedType,
distance: distance,
width: type === CONST.MEASURED_TEMPLATE_TYPES.RAY ? 5 : undefined,
width: type === CONFIG.DH.GENERAL.templateTypes.RAY ? 5 : undefined,
angle: usedAngle,
direction: direction
radius: radius,
direction: direction,
type: usedType
};
CONFIG.ux.TemplateManager.createPreview(data);
await canvas.regions.placeRegion(
{
name: usedType.capitalize(),
shapes: [shapeData],
restriction: { enabled: false, type: 'move', priority: 0 },
behaviors: [],
displayMeasurements: true,
locked: false,
ownership: { default: CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE },
visibility: CONST.REGION_VISIBILITY.ALWAYS
},
{ create: true }
);
};