All user data for FoundryVTT. Includes worlds, systems, modules, and any asset in the "foundryuserdata" directory. Does NOT include the FoundryVTT installation itself.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
1.2 KiB

1 year ago
  1. export class LightHandler{
  2. static isLightVisibleWrapper(wrapped, ...args){
  3. const result = wrapped(...args);
  4. if(!CONFIG.Levels.handlers.UIHandler.emitsLightUI(this)) return false;
  5. if(game.Levels3DPreview?._active) return result;
  6. const rangeBottom = this instanceof Token ? this.document.elevation : this.document.flags.levels?.rangeBottom ?? -Infinity;
  7. const rangeTop = this instanceof Token ? this.losHeight : this.document.flags.levels?.rangeTop ?? Infinity;
  8. const currentElevation = CONFIG.Levels.currentToken?.losHeight
  9. if(currentElevation === undefined) return result;
  10. const underBackground = currentElevation >= canvas.primary.background.elevation && rangeTop < canvas.primary.background.elevation;
  11. if(underBackground) return false;
  12. let isLightVisible = false;
  13. if ((canvas.scene.flags.levels?.lightMasking ?? true)) {
  14. if (this instanceof Token) isLightVisible = this.visible || rangeBottom <= currentElevation;
  15. else isLightVisible = rangeBottom <= currentElevation;
  16. }else{
  17. isLightVisible = rangeBottom <= currentElevation && currentElevation <= rangeTop;
  18. }
  19. return result && isLightVisible;
  20. }
  21. }