Skip to content

Commit ba6bccf

Browse files
authored
Update EffectSource types for V13 (#19180)
1 parent 0cd87b7 commit ba6bccf

21 files changed

+323
-212
lines changed

types/foundry/client/_types.d.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { AVSettingsData } from "./av/settings.mjs";
88
import { CanvasAnimationData, CanvasAnimationEasingFunction } from "./canvas/animation/_types.mjs";
99
import { Ray } from "./canvas/geometry/_module.mjs";
1010
import { PingData } from "./canvas/interaction/_types.mjs";
11+
import AmbientLight from "./canvas/placeables/light.mjs";
1112
import Token, { TokenShape } from "./canvas/placeables/token.mjs";
1213
import PointVisionSource from "./canvas/sources/point-vision-source.mjs";
1314
import Roll from "./dice/roll.mjs";
@@ -1077,7 +1078,7 @@ export interface CanvasViewPosition {
10771078

10781079
export interface CanvasVisibilityTest {
10791080
point: ElevatedPoint;
1080-
los: Map<PointVisionSource, boolean>;
1081+
los: Map<PointVisionSource<Token | AmbientLight>, boolean>;
10811082
}
10821083

10831084
export interface CanvasVisibilityTestConfiguration {

types/foundry/client/canvas/groups/effects.d.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default class EffectsCanvasGroup extends CanvasGroupMixin(PIXI.Container)
5353
initializeLightSources(): void;
5454

5555
/** Update the global light source which provide global illumination to the Scene. */
56-
protected _updateGlobalLightSource(): PointLightSource<null>;
56+
protected _updateGlobalLightSource(): GlobalLightSource;
5757

5858
/** Refresh the state and uniforms of all LightSource objects. */
5959
refreshLightSources(): void;

types/foundry/client/canvas/groups/visibility.d.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { PointVisionSource } from "@client/canvas/sources/_module.mjs";
22
import { Point } from "@common/_types.mjs";
33
import { CanvasVisibilityTestConfiguration, CanvasVisibilityTextureConfiguration } from "../../_types.mjs";
44
import { CanvasVisionContainer } from "../layers/_types.mjs";
5+
import { AmbientLight, Token } from "../placeables/_module.mjs";
56
import CanvasGroupMixin from "./canvas-group-mixin.mjs";
67

78
/**
@@ -36,7 +37,7 @@ export default class CanvasVisibility extends CanvasGroupMixin(PIXI.Container) {
3637
/**
3738
* The active vision source data object
3839
*/
39-
visionModeData: { source: PointVisionSource | null; activeLightingOptions: object };
40+
visionModeData: { source: PointVisionSource<AmbientLight | Token> | null; activeLightingOptions: object };
4041

4142
/**
4243
* Define whether each lighting layer is enabled, required, or disabled by this vision mode.

types/foundry/client/canvas/layers/_types.d.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface AmbientSoundPlaybackConfig {
1010
/** The Sound node which should be controlled for playback */
1111
sound: Sound;
1212
/** The SoundSource which defines the area of effect for the sound */
13-
source: PointSoundSource;
13+
source: PointSoundSource<AmbientSound>;
1414
/** An AmbientSound object responsible for the sound, or undefined */
1515
object?: AmbientSound;
1616
/** The coordinates of the closest listener or undefined if there is none */

types/foundry/client/canvas/layers/sounds.d.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default class SoundsLayer<TObject extends AmbientSound = AmbientSound> ex
2525
livePreview: boolean;
2626

2727
/** A mapping of ambient audio sources which are active within the rendered Scene */
28-
sources: Collection<string, PointSoundSource>;
28+
sources: Collection<string, PointSoundSource<TObject>>;
2929

3030
static override get layerOptions(): PlaceablesLayerOptions;
3131

types/foundry/client/canvas/perception/detection-mode.d.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default class DetectionMode extends foundry.abstract.DataModel<null, Dete
104104
* @returns Is the point within the vision angle?
105105
*/
106106
protected _testAngle(
107-
visionSource: PointVisionSource,
107+
visionSource: PointVisionSource<Token>,
108108
mode: TokenDetectionMode,
109109
target: PlaceableObject,
110110
test: CanvasVisibilityTest,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PlaceableObject } from "../../placeables/_module.mjs";
1+
import { PlaceableObject, Token } from "../../placeables/_module.mjs";
22
import PointVisionSource from "../../sources/point-vision-source.mjs";
33
import DetectionMode from "../detection-mode.mjs";
44

@@ -7,5 +7,5 @@ import DetectionMode from "../detection-mode.mjs";
77
* This mode is the default case which is tested first when evaluating visibility of objects.
88
*/
99
export default class DetectionModeDarkvision extends DetectionMode {
10-
protected override _canDetect(visionSource: PointVisionSource, target: PlaceableObject): boolean;
10+
protected override _canDetect(visionSource: PointVisionSource<Token>, target: PlaceableObject): boolean;
1111
}

types/foundry/client/canvas/perception/vision-mode.d.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ export default class VisionMode extends DataModel<null, VisionModeSchema> {
5656
* Special activation handling that could be implemented by VisionMode subclasses
5757
* @param source Activate this VisionMode for a specific source
5858
*/
59-
_activate(source: PointVisionSource): void;
59+
_activate(source: PointVisionSource<Token>): void;
6060

6161
/**
6262
* Special deactivation handling that could be implemented by VisionMode subclasses
6363
* @param source Deactivate this VisionMode for a specific source
6464
*/
65-
protected _deactivate(source: PointVisionSource): void;
65+
protected _deactivate(source: PointVisionSource<Token>): void;
6666

6767
/**
6868
* Special handling which is needed when this Vision Mode is activated for a VisionSource.

types/foundry/client/canvas/placeables/light.d.mts

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,64 +4,91 @@ import {
44
DatabaseDeleteCallbackOptions,
55
DatabaseUpdateCallbackOptions,
66
} from "@common/abstract/_types.mjs";
7+
import { LightData } from "@common/data/_module.mjs";
78
import { ControlIcon } from "../containers/_module.mjs";
9+
import { RenderFlag } from "../interaction/_types.mjs";
810
import { LightingLayer } from "../layers/_module.mjs";
911
import { PointDarknessSource, PointLightSource } from "../sources/_module.mjs";
12+
import { LightSourceData } from "../sources/base-light-source.mjs";
1013
import PlaceableObject from "./placeable-object.mjs";
1114

1215
export default class AmbientLight<
1316
TDocument extends AmbientLightDocument<Scene | null> = AmbientLightDocument<Scene | null>,
1417
> extends PlaceableObject<TDocument> {
15-
constructor(document: TDocument);
18+
static override embeddedName: "AmbientLight";
19+
20+
static override RENDER_FLAGS: Record<string, Partial<RenderFlag>>;
1621

17-
/** The area that is affected by this light */
22+
/**
23+
* The area that is affected by this light
24+
*/
1825
field: PIXI.Graphics;
1926

2027
/**
2128
* A reference to the PointSource object which defines this light or darkness area of effect.
2229
* This is undefined if the AmbientLight does not provide an active source of light.
2330
*/
24-
lightSource?: PointDarknessSource<this> | PointLightSource<this>;
25-
26-
/** A reference to the ControlIcon used to configure this light */
27-
controlIcon: ControlIcon;
28-
29-
static override embeddedName: "AmbientLight";
31+
lightSource: PointDarknessSource<this> | PointLightSource<this> | undefined;
3032

3133
override get bounds(): PIXI.Rectangle;
3234

33-
/** A convenience accessor to the LightData configuration object */
34-
get config(): TDocument["config"];
35+
/**
36+
* A convenience accessor to the LightData configuration object
37+
*/
38+
get config(): LightData<TDocument>;
3539

36-
/** Test whether a specific AmbientLight source provides global illumination */
40+
/**
41+
* Test whether a specific AmbientLight source provides global illumination
42+
*/
3743
get global(): boolean;
3844

39-
/** The maximum radius in pixels of the light field */
45+
/**
46+
* The maximum radius in pixels of the light field
47+
*/
4048
get radius(): number;
4149

42-
/** Get the pixel radius of dim light emitted by this light source */
50+
/**
51+
* Get the pixel radius of dim light emitted by this light source
52+
*/
4353
get dimRadius(): number;
4454

45-
/** Get the pixel radius of bright light emitted by this light source */
55+
/**
56+
* Get the pixel radius of bright light emitted by this light source
57+
*/
4658
get brightRadius(): number;
4759

48-
/** Is this ambient light is currently visible based on its hidden state and the darkness level of the Scene? */
60+
/**
61+
* Is this Ambient Light currently visible? By default, true only if the source actively emits light or darkness.
62+
*/
4963
get isVisible(): boolean;
5064

51-
/** Check if the point source is a LightSource instance */
65+
/**
66+
* Check if the point source is a LightSource instance
67+
*/
5268
get isLightSource(): boolean;
5369

54-
/** Check if the point source is a DarknessSource instance */
70+
/**
71+
* Check if the point source is a DarknessSource instance
72+
*/
5573
get isDarknessSource(): boolean;
5674

57-
/** Does this Ambient Light actively emit darkness light given its properties and the current darkness level of the Scene? */
75+
/**
76+
* Does this Ambient Light actively emit darkness light given
77+
* its properties and the current darkness level of the Scene?
78+
*/
5879
get emitsDarkness(): boolean;
5980

6081
/**
61-
* Does this Ambient Light actively emit light given its properties and the current darkness level of the Scene?
82+
* Does this Ambient Light actively emit positive light given
83+
* its properties and the current darkness level of the Scene?
6284
*/
6385
get emitsLight(): boolean;
6486

87+
/**
88+
* Is the source of this Ambient Light disabled?
89+
*/
90+
protected _isLightSourceDisabled(): boolean;
91+
6592
/* -------------------------------------------- */
6693
/* Rendering */
6794
/* -------------------------------------------- */

types/foundry/client/canvas/placeables/placeable-object.d.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default abstract class PlaceableObject<
3333
document: TDocument;
3434

3535
/** A control icon for interacting with the object */
36-
controlIcon: ControlIcon;
36+
controlIcon: ControlIcon | null;
3737

3838
/** A mouse interaction manager instance which handles mouse workflows related to this object. */
3939
mouseInteractionManager: MouseInteractionManager;

0 commit comments

Comments
 (0)