mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
[Feature] ActiveEffect Auras (#2049)
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
Some checks are pending
Project CI / build (24.x) (push) Waiting to run
* Added Attached type to action areas * Added functionality to Elemental Aura
This commit is contained in:
parent
d36c141d36
commit
cdf6e7fdd0
9 changed files with 213 additions and 114 deletions
|
|
@ -96,7 +96,7 @@ export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer {
|
|||
return inBounds.length === 1 ? inBounds[0] : null;
|
||||
}
|
||||
|
||||
static getTemplateShape({ type, angle, range, direction } = {}) {
|
||||
static getTemplateShape({ shapeType, angle, range, direction, hasHole } = {}) {
|
||||
const { line, rectangle, inFront, cone, circle, emanation } = CONFIG.DH.GENERAL.templateTypes;
|
||||
|
||||
/* Length calculation */
|
||||
|
|
@ -112,11 +112,11 @@ export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer {
|
|||
|
||||
const shapeData = {
|
||||
...canvas.mousePosition,
|
||||
type: type,
|
||||
type: shapeType,
|
||||
direction: direction ?? 0
|
||||
};
|
||||
|
||||
switch (type) {
|
||||
switch (shapeType) {
|
||||
case rectangle.id:
|
||||
shapeData.width = length;
|
||||
shapeData.height = length;
|
||||
|
|
@ -145,7 +145,8 @@ export default class DhRegionLayer extends foundry.canvas.layers.RegionLayer {
|
|||
y: 0,
|
||||
width: 1,
|
||||
height: 1,
|
||||
shape: game.canvas.grid.isHexagonal ? CONST.TOKEN_SHAPES.ELLIPSE_1 : CONST.TOKEN_SHAPES.RECTANGLE_1
|
||||
shape: game.canvas.grid.isHexagonal ? CONST.TOKEN_SHAPES.ELLIPSE_1 : CONST.TOKEN_SHAPES.RECTANGLE_1,
|
||||
hole: hasHole
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,6 +119,10 @@ export const advantageState = {
|
|||
export const areaTypes = {
|
||||
placed: {
|
||||
id: 'placed',
|
||||
label: 'Placed Area'
|
||||
label: 'DAGGERHEART.CONFIG.AreaTypes.placed.label'
|
||||
},
|
||||
attached: {
|
||||
id: 'attached',
|
||||
label: 'DAGGERHEART.CONFIG.AreaTypes.attached.label'
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,6 +33,10 @@ export default class AreasField extends fields.ArrayField {
|
|||
initial: CONFIG.DH.GENERAL.range.veryClose.id,
|
||||
label: 'DAGGERHEART.ACTIONS.Config.area.size'
|
||||
}),
|
||||
hasHole: new fields.BooleanField({
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.ACTIONS.Config.area.hasHole'
|
||||
}),
|
||||
effects: new fields.ArrayField(new fields.DocumentIdField())
|
||||
});
|
||||
super(element, options, context);
|
||||
|
|
|
|||
|
|
@ -276,8 +276,12 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
async onCreateAreas(event) {
|
||||
const createArea = async selectedArea => {
|
||||
const effects = selectedArea.effects.map(effect => this.system.action.item.effects.get(effect).uuid);
|
||||
const { shape: type, size: range } = selectedArea;
|
||||
const shapeData = CONFIG.Canvas.layers.regions.layerClass.getTemplateShape({ type, range });
|
||||
const { shape: shapeType, size: range, hasHole } = selectedArea;
|
||||
const shapeData = CONFIG.Canvas.layers.regions.layerClass.getTemplateShape({
|
||||
shapeType,
|
||||
range,
|
||||
hasHole
|
||||
});
|
||||
|
||||
const scene = game.scenes.get(game.user.viewedScene);
|
||||
const level = scene.levels.find(x => x.isView);
|
||||
|
|
@ -305,7 +309,10 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
|
|||
visibility: CONST.REGION_VISIBILITY.ALWAYS
|
||||
};
|
||||
const placeRegion = data => {
|
||||
canvas.regions.placeRegion(data, { create: true });
|
||||
canvas.regions.placeRegion(data, {
|
||||
create: true,
|
||||
attachToToken: selectedArea.type === CONFIG.DH.ACTIONS.areaTypes.attached.id
|
||||
});
|
||||
};
|
||||
|
||||
// Regions with effects must be placed by the GM
|
||||
|
|
|
|||
|
|
@ -58,10 +58,11 @@ export const renderMeasuredTemplate = async event => {
|
|||
if (!type || !range || !game.canvas.scene) return;
|
||||
|
||||
const shapeData = CONFIG.Canvas.layers.regions.layerClass.getTemplateShape({
|
||||
type,
|
||||
shapetype: type,
|
||||
angle,
|
||||
range,
|
||||
direction
|
||||
direction,
|
||||
hasHole: false
|
||||
});
|
||||
|
||||
await canvas.regions.placeRegion(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue