Added compute triggers to store trigger ids on their
targeted props. Needs testing
This commit is contained in:
@@ -7,6 +7,7 @@ import propertySlot from './computeByType/computeSlot.js';
|
||||
import container from './computeByType/computeContainer.js';
|
||||
import spellList from './computeByType/computeSpellList.js';
|
||||
import toggle from './computeByType/computeToggle.js';
|
||||
import trigger from './computeByType/computeTrigger.js'
|
||||
import _calculation from './computeByType/computeCalculation.js';
|
||||
|
||||
export default Object.freeze({
|
||||
@@ -21,4 +22,5 @@ export default Object.freeze({
|
||||
spell: action,
|
||||
spellList,
|
||||
toggle,
|
||||
trigger,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { get, set } from 'lodash';
|
||||
import { getEffectTagTargets } from '/imports/api/engine/computation/buildComputation/linkTypeDependencies';
|
||||
|
||||
export default function computeTrigger(computation, node) {
|
||||
const prop = node.data;
|
||||
|
||||
// Triggers that aren't active aren't linked to properties
|
||||
if (prop.inactive) return;
|
||||
|
||||
// Link triggers to all the properties that would fire them when applied
|
||||
if (prop.event === 'doActionProperty') {
|
||||
getEffectTagTargets(prop, computation).forEach(targetId => {
|
||||
const targetProp = computation.propsById[targetId];
|
||||
// Only apply if the trigger matches this property type
|
||||
if (targetProp.type !== prop.actionPropertyType) return;
|
||||
let triggerIdArray = get(targetProp, `triggerIds.${prop.timing}`);
|
||||
if (!triggerIdArray) {
|
||||
triggerIdArray = [];
|
||||
set(targetProp, `triggerIds.${prop.timing}`, triggerIdArray);
|
||||
}
|
||||
triggerIdArray.push(prop._id);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user