Added Soft remove and a character asset parenting system

This commit is contained in:
Thaum
2015-03-18 08:59:02 +00:00
parent 06b0ad7eba
commit 3656a0b66f
24 changed files with 215 additions and 121 deletions

View File

@@ -22,20 +22,8 @@ Features.helpers({
}
});
//Delete effects where this the removed feature is source
Features.before.remove(function (userId, feature) {
Effects.find({sourceId: feature._id, type: "feature"}).forEach(function(effect){
Effects.remove(effect._id);
});
});
//keep the effects up to date with enabled state
Features.after.update(function (userId, feature, fieldNames, modifier, options) {
var enabled = feature.enabled !== "disabled";
Effects.find({sourceId: feature._id, type: "feature"}).forEach(function(effect){
Effects.update(effect._id, { $set: {charId: feature.charId, enabled: enabled, name: feature.name} });
});
}, {fetchPrevious: false});
Features.attachBehaviour('softRemovable');
makeParent(Features); //parents of effects and attacks
Features.allow(CHARACTER_SUBSCHEMA_ALLOW);
Features.deny(CHARACTER_SUBSCHEMA_DENY);