Completed functionality

This commit is contained in:
WBHarry 2026-04-18 00:20:44 +02:00
parent 5e608dea99
commit f6aa3dc750
8 changed files with 68 additions and 14 deletions

View file

@ -0,0 +1,28 @@
export default class DhRegionBehavior extends RegionBehavior {
/**@inheritDoc */
async _handleRegionEvent(event) {
if (!(this.system instanceof foundry.data.regionBehaviors.RegionBehaviorType)) return;
// Optionally prevent event if not applicable
// Currently only caring about statically registered events
if (event.name in this.system.constructor.events) {
if (this.isEventApplicable(event) === false) return;
super._handleRegionEvent(event);
}
}
isEventApplicable(event) {
switch(this.type) {
case 'applyActiveEffect':
/* If reworked to an area, we'll probably still have to override the onEnter/onExit methods to filter which effects apply */
const effects = this.system.effects.map(effect => foundry.utils.fromUuidSync(effect)).filter(x => x);
const applicableDispositions = effects.first().system.area?.targetDispositions??[];
if(!applicableDispositions.size) return true;
return event.data.token.disposition === CONST.TOKEN_DISPOSITIONS.SECRET ||
applicableDispositions.has(event.data.token.disposition);
default:
return true;
}
}
}