Skip to content

Commit

Permalink
Update for 11.297
Browse files Browse the repository at this point in the history
  • Loading branch information
dev7355608 committed May 14, 2023
1 parent aa33e0b commit 9b78add
Show file tree
Hide file tree
Showing 21 changed files with 68 additions and 69 deletions.
10 changes: 5 additions & 5 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"email": "dev7355608@gmail.com"
}
],
"version": "1.1.0",
"version": "1.1.1",
"compatibility": {
"minimum": "11",
"verified": "11"
"minimum": "11.297",
"verified": "11.297"
},
"scripts": [
"scripts/patches.js"
Expand Down Expand Up @@ -41,8 +41,8 @@
},
"url": "https://github.com/dev7355608/vision-5e",
"manifest": "https://github.com/dev7355608/vision-5e/releases/latest/download/module.json",
"download": "https://github.com/dev7355608/vision-5e/releases/download/v1.1.0/module.zip",
"changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v1.1.0",
"download": "https://github.com/dev7355608/vision-5e/releases/download/v1.1.1/module.zip",
"changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v1.1.1",
"bugs": "https://github.com/dev7355608/vision-5e/issues",
"readme": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/README.md",
"license": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/LICENSE"
Expand Down
12 changes: 2 additions & 10 deletions scripts/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,6 @@ Hooks.once("i18nInit", () => {
sort(CONFIG.Canvas.visionModes);
});

// TODO
Hooks.once("init", () => {
CONFIG.Token.objectClass = class Token5e extends CONFIG.Token.objectClass {
/** @override */
_onApplyStatusEffect(statusId, active) {
super._onApplyStatusEffect(statusId, active);

specialStatusEffectsHooks.get(statusId)?.(statusId, active);
}
};
Hooks.on("applyTokenStatusEffect", (token, statusId, active) => {
specialStatusEffectsHooks.get(statusId)?.(token, statusId, active);
});
11 changes: 3 additions & 8 deletions scripts/detection-modes/blindsight.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
export class DetectionModeBlindsight extends DetectionMode {
priority = 500;

/**
* @type {boolean}
* @protected
*/
_ingoreVisionAngle = true;

/**
* @type {PointSourcePolygon.WALL_DIRECTION_MODES}
* @protected
Expand All @@ -21,7 +15,8 @@ export class DetectionModeBlindsight extends DetectionMode {
id: "blindsight",
label: "DND5E.SenseBlindsight",
type: DetectionMode.DETECTION_TYPES.OTHER,
walls: true
walls: true,
angle: false
}, data), options);
}

Expand All @@ -42,7 +37,7 @@ export class DetectionModeBlindsight extends DetectionMode {

/** @override */
_testLOS(visionSource, mode, target, test) {
if (!this._ingoreVisionAngle && !this.#testAngle(visionSource, test.point)) return false;
if (this.angle && !this.#testAngle(visionSource, test.point)) return false;
return !CONFIG.Canvas.polygonBackends.sight.testCollision(
{ x: visionSource.x, y: visionSource.y },
test.point,
Expand Down
3 changes: 2 additions & 1 deletion scripts/detection-modes/darkvision.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export class DetectionModeDarkvision extends DetectionModeBasicSight {
id: DetectionMode.BASIC_MODE_ID,
label: "DND5E.SenseDarkvision",
type: DetectionMode.DETECTION_TYPES.SIGHT,
walls: true
walls: true,
angle: true
}, data), options);
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/detection-modes/detect-evil-and-good.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class DetectionModeDetectEvilAndGood extends DetectionMode {
id: "detectEvilAndGood",
label: "VISION5E.DetectEvilAndGood",
type: DetectionMode.DETECTION_TYPES.OTHER,
walls: false
walls: false,
angle: false
});
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/detection-modes/detect-magic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class DetectionModeDetectMagic extends DetectionMode {
id: "detectMagic",
label: "VISION5E.DetectMagic",
type: DetectionMode.DETECTION_TYPES.OTHER,
walls: false
walls: false,
angle: false
});
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/detection-modes/detect-poison-and-disease.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class DetectionModeDetectPoisonAndDisease extends DetectionMode {
id: "detectPoisonAndDisease",
label: "VISION5E.DetectPoisonAndDisease",
type: DetectionMode.DETECTION_TYPES.OTHER,
walls: false
walls: false,
angle: false
});
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/detection-modes/detect-thoughts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class DetectionModeDetectThoughts extends DetectionMode {
id: "detectThoughts",
label: "VISION5E.DetectThoughts",
type: DetectionMode.DETECTION_TYPES.OTHER,
walls: false
walls: false,
angle: false
});
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/detection-modes/devils-sight.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export class DetectionModeDevilsSight extends DetectionMode {
id: "devilsSight",
label: "VISION5E.DevilsSight",
type: DetectionMode.DETECTION_TYPES.SIGHT,
walls: true
walls: true,
angle: false
});
}

Expand Down
7 changes: 2 additions & 5 deletions scripts/detection-modes/echolocation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import { DetectionModeBlindsight } from "./blindsight.mjs";
export class DetectionModeEcholocation extends DetectionModeBlindsight {
priority = 499;

// Echolocation is directional and therefore limited by the vision angle.
_ingoreVisionAngle = false;
_wallDirectionMode = PointSourcePolygon.WALL_DIRECTION_MODES.BOTH;

constructor() {
super({
id: "echolocation",
label: "VISION5E.Echolocation",
type: DetectionMode.DETECTION_TYPES.SOUND
type: DetectionMode.DETECTION_TYPES.SOUND,
angle: true
});
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/detection-modes/hearing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class DetectionModeHearing extends DetectionMode {
id: "hearing",
label: "VISION5E.Hearing",
type: DetectionMode.DETECTION_TYPES.SOUND,
walls: true
walls: true,
angle: false
});
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/detection-modes/see-invisibility.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export class DetectionModeSeeInvisibility extends DetectionMode {
id: "seeInvisibility",
label: "DETECTION.SeeInvisibility",
type: DetectionMode.DETECTION_TYPES.SIGHT,
walls: false
walls: false,
angle: false
});
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/detection-modes/tremorsense.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export class DetectionModeTremorsense extends DetectionMode {
id: "feelTremor",
label: "DND5E.SenseTremorsense",
type: DetectionMode.DETECTION_TYPES.MOVE,
walls: false
walls: false,
angle: false
});
}

Expand Down
3 changes: 2 additions & 1 deletion scripts/detection-modes/truesight.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export class DetectionModeTruesight extends DetectionMode {
id: "seeAll",
label: "DND5E.SenseTruesight",
type: DetectionMode.DETECTION_TYPES.SIGHT,
walls: true
walls: true,
angle: true
});
}

Expand Down
17 changes: 13 additions & 4 deletions scripts/hud.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Hooks.on("renderTokenHUD", (hud, html) => {
visionModes.push(visionMode);
}

if (visionModes.length === 0) {
return;
if (!visionModes.find((m) => m.id === "darkvision")) {
visionModes.push(CONFIG.Canvas.visionModes.basic);
}

visionModes.sort((a, b) => game.i18n.localize(a.label).localeCompare(game.i18n.localize(b.label), game.i18n.lang));
Expand All @@ -64,7 +64,7 @@ Hooks.on("renderTokenHUD", (hud, html) => {
<div class="vision-5e vision-modes">
${visionModes.map(mode => `
<div class="vision-5e vision-mode ${mode.id === token.document.sight.visionMode ? "active" : ""} flexrow" data-vision-mode="${mode.id}">
<span class="vision-5e vision-mode-label">${game.i18n.localize(mode.label)}</span>
<span class="vision-5e vision-mode-label">${game.i18n.localize(mode.id !== "basic" ? mode.label : CONFIG.Canvas.visionModes.darkvision.label)}</span>
</div>`).join("")}
</div>
`);
Expand All @@ -82,7 +82,16 @@ Hooks.on("renderTokenHUD", (hud, html) => {
element => element.addEventListener("click", (event) => {
event.preventDefault();

token.document.updateVisionMode(event.currentTarget.dataset.visionMode);
const visionMode = event.currentTarget.dataset.visionMode;
const update = { sight: { visionMode } };

foundry.utils.mergeObject(update.sight, CONFIG.Canvas.visionModes[visionMode].vision.defaults);

if (visionMode === "basic") {
foundry.utils.mergeObject(update.sight, CONFIG.Canvas.visionModes.darkvision.vision.defaults);
}

token.document.update(update);
hud.clear();
})
);
Expand Down
15 changes: 13 additions & 2 deletions scripts/patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,24 @@ VisionSource.prototype._createRestrictedPolygon = function () {
const radius = this.data.radius > 0 ? this.data.radius : this.data.externalRadius;
const density = PIXI.Circle.approximateVertexDensity(radius);
if (!this.detectionMode.walls) {
return CONFIG.Canvas.polygonBackends[this.constructor.sourceType].create(origin, {
const config = {
...this._getPolygonConfiguration(),
type: "universal",
radius,
density,
useThreshold: false
});
};
if (!this.detectionMode.angle) config.angle = 360;
return CONFIG.Canvas.polygonBackends[this.constructor.sourceType].create(origin, config);
}
if (!this.detectionMode.angle && this.data.angle !== 360) {
const config = {
...this._getPolygonConfiguration(),
radius,
density,
angle: 360
};
return CONFIG.Canvas.polygonBackends[this.constructor.sourceType].create(origin, config);
}
const circle = new PIXI.Circle(origin.x, origin.y, radius);
return this.los.applyConstraint(circle, { density, scalingFactor: 100 });
Expand Down
7 changes: 2 additions & 5 deletions scripts/vision-modes/detect-evil-and-good.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ export class VisionModeDetectEvilAndGood extends VisionMode {
background: { shader: VoidBackgroundVisionShader },
illumination: { shader: VoidIlluminationVisionShader },
coloration: {
// TODO
shader: class DetectEvilAndGoodColorationVisionShader extends DetectColorationVisionShader {
/** @override */
static defaultUniforms = { ...super.defaultUniforms, colorDetection: [1, 1, 0] };
}
shader: DetectColorationVisionShader,
uniforms: { colorDetection: [1, 1, 0] }
}
}
}, { animated: true });
Expand Down
7 changes: 2 additions & 5 deletions scripts/vision-modes/detect-magic.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ export class VisionModeDetectMagic extends VisionMode {
background: { shader: VoidBackgroundVisionShader },
illumination: { shader: VoidIlluminationVisionShader },
coloration: {
// TODO
shader: class DetectMagicColorationVisionShader extends DetectColorationVisionShader {
/** @override */
static defaultUniforms = { ...super.defaultUniforms, colorDetection: [1, 0, 1] };
}
shader: DetectColorationVisionShader,
uniforms: { colorDetection: [1, 0, 1] }
}
}
}, { animated: true });
Expand Down
7 changes: 2 additions & 5 deletions scripts/vision-modes/detect-poison-and-disease.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ export class VisionModeDetectPoisonAndDisease extends VisionMode {
background: { shader: VoidBackgroundVisionShader },
illumination: { shader: VoidIlluminationVisionShader },
coloration: {
// TODO
shader: class DetectPoisonAndDiseaseColorationVisionShader extends DetectColorationVisionShader {
/** @override */
static defaultUniforms = { ...super.defaultUniforms, colorDetection: [0, 1, 0] };
}
shader: DetectColorationVisionShader,
uniforms: { colorDetection: [0, 1, 0] }
}
}
}, { animated: true });
Expand Down
7 changes: 2 additions & 5 deletions scripts/vision-modes/detect-thoughts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ export class VisionModeDetectThoughts extends VisionMode {
background: { shader: VoidBackgroundVisionShader },
illumination: { shader: VoidIlluminationVisionShader },
coloration: {
// TODO
shader: class DetectThoughtsColorationVisionShader extends DetectColorationVisionShader {
/** @override */
static defaultUniforms = { ...super.defaultUniforms, colorDetection: [0, 1, 1] };
}
shader: DetectColorationVisionShader,
uniforms: { colorDetection: [0, 1, 1] }
}
}
}, { animated: true });
Expand Down
7 changes: 2 additions & 5 deletions scripts/vision-modes/tremorsense.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ export class VisionModeTremorsense extends VisionMode {
background: { shader: VoidBackgroundVisionShader },
illumination: { shader: VoidIlluminationVisionShader },
coloration: {
// TODO
shader: class TremorsenseColorationVisionShader extends TremorColorationVisionShader {
/** @override */
static defaultUniforms = { ...super.defaultUniforms, colorDetection: [1, 0, 1] };
}
shader: DetectColorationVisionShader,
uniforms: { colorDetection: [1, 0, 1] }
}
}
}, { animated: true });
Expand Down

0 comments on commit 9b78add

Please sign in to comment.