Skip to content

Commit

Permalink
Added option to show / hide auras based on token visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyEdmonds committed Jan 19, 2025
1 parent 3798cf2 commit 0b3656d
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 19 deletions.
1 change: 1 addition & 0 deletions AuraRingApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class AuraRingApi
* @property {number} id The unique numeric identifier of the Aura Ring
* @property {string} name The display name of the Aura Ring
* @property {number} radius The radius of the Aura Ring, from 0
* @property {boolean} respect_fog Whether to hide the Aura Ring when the eminating token cannot be seen
* @property {boolean} stroke_close Whether to stroke the complete outline of the Aura Ring
* @property {string} stroke_colour The stroke colour in hex
* @property {number} stroke_opacity The stroke opacity as a fraction between 0 and 1
Expand Down
23 changes: 9 additions & 14 deletions AuraRingCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,7 @@ export class AuraRingCanvas
AuraRingCanvas.getCanvas(token)?.drawCanvas();
}
}

static async handleSightRefresh()
{
for (const tokenDocument of game.scenes.current.tokens) {
AuraRingCanvas.getCanvas(tokenDocument.object)?.refreshSight();
}
}


static async handleUpdateToken(tokenDocument)
{
if (AuraRingCanvas.isClass(tokenDocument, TokenDocument) === true) {
Expand Down Expand Up @@ -111,12 +104,7 @@ export class AuraRingCanvas
this.renderAuraRings();
}
}

refreshSight()
{
this.pixiGraphics.alpha = this.token.isVisible === true ? 1 : 0;
}


// PIXI Auras Container
static findPixiAurasContainer()
{
Expand Down Expand Up @@ -281,6 +269,13 @@ export class AuraRingCanvas
) {
return false;
}

if (
auraRing.respect_fog === true
&& this.token.isVisible === false
) {
return false;
}

return true;
}
Expand Down
16 changes: 16 additions & 0 deletions AuraRingDataModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class AuraRingDataModel extends foundry.abstract.DataModel
'visibility',
'use_grid_shapes',
'hide',
'respect_fog',
'hover_only',
'owner_only',
],
Expand Down Expand Up @@ -44,6 +45,7 @@ export class AuraRingDataModel extends foundry.abstract.DataModel
name: AuraRingDataModel.nameField(defaults.name),
owner_only: AuraRingDataModel.ownerOnlyField(defaults.owner_only),
radius: AuraRingDataModel.radiusField(defaults.radius),
respect_fog: AuraRingDataModel.respectFogField(defaults.respect_fog),
stroke_close: AuraRingDataModel.strokeCloseField(defaults.stroke_close),
stroke_colour: AuraRingDataModel.strokeColourField(defaults.stroke_colour),
stroke_opacity: AuraRingDataModel.strokeOpacityField(defaults.stroke_opacity),
Expand All @@ -66,6 +68,7 @@ export class AuraRingDataModel extends foundry.abstract.DataModel
name: 'Aura',
owner_only: false,
radius: 20,
respect_fog: true,
stroke_close: false,
stroke_colour: '#ff0000',
stroke_opacity: 0.75,
Expand Down Expand Up @@ -320,6 +323,19 @@ export class AuraRingDataModel extends foundry.abstract.DataModel
);
}

static respectFogField(initial)
{
return AuraRingField.booleanField(
AuraRingField.dataFieldOptions(
'Respect fog of war?',
initial,
),
AuraRingField.dataFieldContext(
'respect_fog',
),
);
}

static strokeCloseField(initial)
{
return AuraRingField.booleanField(
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Aura rings are calculated as an emanation, based on the [Pathfinder 2nd Edition

Creatures larger than 1 tile will have flattened sides to correctly represent their aura range.

Visibility of aura rings are obscured by fog-of-war, and hidden entirely when the viewing player is unable to see the token from which the aura rings are being emitted.
Visibility of aura rings can be obscured by fog-of-war, and hidden entirely when the viewing player is unable to see the token from which the aura rings are being emitted.

Hidden tokens will only show their aura rings to the game master.

Expand Down Expand Up @@ -72,6 +72,8 @@ Enabling the "Only show on hover?" option will cause the Aura Ring to only show

Enabling the "Only show to owner?" option will cause the Aura Ring to only show for the token owner and observer, which includes the Game Master.

Disabling "Respect fog of war?" will cause the Aura Ring to be visible even when the player cannot see the eminating token.

### Angled aura rings

You can adjust the "Direction" and "Angle" settings to create arcs instead of circles.
Expand Down
2 changes: 1 addition & 1 deletion aura-ring.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Hooks.on('initializeVisionSources', function () {
Hooks.on('refreshToken', AuraRingCanvas.handleRefreshToken);

// Fired on: deleted, moved, selected, updated
Hooks.on('sightRefresh', AuraRingCanvas.handleSightRefresh);
// Hooks.on('sightRefresh', AuraRingCanvas.handleSightRefresh);

// Fired on: updated (for client)
Hooks.on('updateToken', AuraRingCanvas.handleUpdateToken);
Expand Down
Binary file modified images/config.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
"title": "Token Aura Ring",
"description": "A simple module for Foundry VTT which adds an outlined ring aura to a token.",
"url": "https://github.com/AnthonyEdmonds/token-aura-ring",
"manifest": "https://raw.githubusercontent.com/AnthonyEdmonds/token-aura-ring/2.5.1/module.json",
"download": "https://github.com/AnthonyEdmonds/token-aura-ring/archive/refs/tags/2.5.1.zip",
"manifest": "https://raw.githubusercontent.com/AnthonyEdmonds/token-aura-ring/2.6.0/module.json",
"download": "https://github.com/AnthonyEdmonds/token-aura-ring/archive/refs/tags/2.6.0.zip",
"authors": [
{
"name": "Anthony Edmonds",
"url": "https://github.com/AnthonyEdmonds",
"flags": {}
}
],
"version": "2.5.1",
"version": "2.6.0",
"compatibility": {
"minimum": "12",
"verified": "12"
Expand Down

0 comments on commit 0b3656d

Please sign in to comment.